{"action":"created","comment":{"url":"https://api.github.com/repos/wpilibsuite/allwpilib/pulls/comments/194926814","pull_request_review_id":128193689,"id":194926814,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NDkyNjgxNA==","diff_hunk":"@@ -221,44 +219,28 @@ public static void initializeHardwareConfiguration() {\n    */\n   @SuppressWarnings({\"PMD.AvoidInstantiatingObjectsInLoops\", \"PMD.AvoidCatchingThrowable\",\n                      \"PMD.CyclomaticComplexity\", \"PMD.NPathComplexity\"})\n-  public static void main(String... args) {\n+  public static <T extends RobotBase> void startRobot(Supplier<T> robotSupplier) {\n     if (!HAL.initialize(500, 0)) {\n       throw new IllegalStateException(\"Failed to initialize. Terminating\");\n     }\n \n     HAL.report(tResourceType.kResourceType_Language, tInstances.kLanguage_Java);\n \n-    String robotName = \"\";\n-    if (args.length > 0) {\n-      robotName = args[0];\n-    } else {\n-      Enumeration<URL> resources = null;\n-      try {\n-        resources = Thread.currentThread()\n-            .getContextClassLoader().getResources(\"META-INF/MANIFEST.MF\");\n-      } catch (IOException ex) {\n-        ex.printStackTrace();\n-      }\n-      while (resources != null && resources.hasMoreElements()) {\n-        try {\n-          Manifest manifest = new Manifest(resources.nextElement().openStream());\n-          robotName = manifest.getMainAttributes().getValue(\"Robot-Class\");\n-        } catch (IOException ex) {\n-          ex.printStackTrace();\n-        }\n-      }\n-    }\n-\n     System.out.println(\"********** Robot program starting **********\");\n \n-    RobotBase robot;\n+    T robot;\n     try {\n-      robot = (RobotBase) Class.forName(robotName).newInstance();\n+      robot = robotSupplier.get();\n     } catch (Throwable throwable) {\n       Throwable cause = throwable.getCause();\n       if (cause != null) {\n         throwable = cause;\n       }\n+      String robotName = \"Unknown\";\n+      StackTraceElement[] elements = throwable.getStackTrace();\n+      if (elements.length > 0) {\n+        robotName = throwable.getStackTrace()[0].getClassName();","path":"wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotBase.java","position":60,"original_position":60,"commit_id":"604e0e572b94b5e941a5b96932266e204a1423e5","original_commit_id":"604e0e572b94b5e941a5b96932266e204a1423e5","user":{"login":"ThadHouse","id":7727148,"node_id":"MDQ6VXNlcjc3MjcxNDg=","avatar_url":"https://avatars1.githubusercontent.com/u/7727148?v=4","gravatar_id":"","url":"https://api.github.com/users/ThadHouse","html_url":"https://github.com/ThadHouse","followers_url":"https://api.github.com/users/ThadHouse/followers","following_url":"https://api.github.com/users/ThadHouse/following{/other_user}","gists_url":"https://api.github.com/users/ThadHouse/gists{/gist_id}","starred_url":"https://api.github.com/users/ThadHouse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThadHouse/subscriptions","organizations_url":"https://api.github.com/users/ThadHouse/orgs","repos_url":"https://api.github.com/users/ThadHouse/repos","events_url":"https://api.github.com/users/ThadHouse/events{/privacy}","received_events_url":"https://api.github.com/users/ThadHouse/received_events","type":"User","site_admin":false},"body":"Its possible (Although highly unlikely) that that array is empty. And if it is, this would throw an index out of range. Just want to ensure that none of this can throw so the error gets printed.","created_at":"2018-06-13T00:28:55Z","updated_at":"2018-06-13T00:28:55Z","html_url":"https://github.com/wpilibsuite/allwpilib/pull/1148#discussion_r194926814","pull_request_url":"https://api.github.com/repos/wpilibsuite/allwpilib/pulls/1148","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/wpilibsuite/allwpilib/pulls/comments/194926814"},"html":{"href":"https://github.com/wpilibsuite/allwpilib/pull/1148#discussion_r194926814"},"pull_request":{"href":"https://api.github.com/repos/wpilibsuite/allwpilib/pulls/1148"}},"in_reply_to_id":194926322},"pull_request":{"url":"https://api.github.com/repos/wpilibsuite/allwpilib/pulls/1148","id":193755196,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkzNzU1MTk2","html_url":"https://github.com/wpilibsuite/allwpilib/pull/1148","diff_url":"https://github.com/wpilibsuite/allwpilib/pull/1148.diff","patch_url":"https://github.com/wpilibsuite/allwpilib/pull/1148.patch","issue_url":"https://api.github.com/repos/wpilibsuite/allwpilib/issues/1148","number":1148,"state":"open","locked":false,"title":"Moves Java main function from library to user code","user":{"login":"ThadHouse","id":7727148,"node_id":"MDQ6VXNlcjc3MjcxNDg=","avatar_url":"https://avatars1.githubusercontent.com/u/7727148?v=4","gravatar_id":"","url":"https://api.github.com/users/ThadHouse","html_url":"https://github.com/ThadHouse","followers_url":"https://api.github.com/users/ThadHouse/followers","following_url":"https://api.github.com/users/ThadHouse/following{/other_user}","gists_url":"https://api.github.com/users/ThadHouse/gists{/gist_id}","starred_url":"https://api.github.com/users/ThadHouse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThadHouse/subscriptions","organizations_url":"https://api.github.com/users/ThadHouse/orgs","repos_url":"https://api.github.com/users/ThadHouse/repos","events_url":"https://api.github.com/users/ThadHouse/events{/privacy}","received_events_url":"https://api.github.com/users/ThadHouse/received_events","type":"User","site_admin":false},"body":"With requiring an importer, we should be able to automate this in the importer. It is much more reliable, as it no longer depends on a magic string in a manifest file, and if the user changes their main class, or makes it not import from something RobotBase, it will fail to compile","created_at":"2018-06-09T02:58:36Z","updated_at":"2018-06-13T00:28:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6013011adc30fe3df4cc6d7eb3d53c8079c65f41","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/wpilibsuite/allwpilib/pulls/1148/commits","review_comments_url":"https://api.github.com/repos/wpilibsuite/allwpilib/pulls/1148/comments","review_comment_url":"https://api.github.com/repos/wpilibsuite/allwpilib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wpilibsuite/allwpilib/issues/1148/comments","statuses_url":"https://api.github.com/repos/wpilibsuite/allwpilib/statuses/604e0e572b94b5e941a5b96932266e204a1423e5","head":{"label":"ThadHouse:javainit","ref":"javainit","sha":"604e0e572b94b5e941a5b96932266e204a1423e5","user":{"login":"ThadHouse","id":7727148,"node_id":"MDQ6VXNlcjc3MjcxNDg=","avatar_url":"https://avatars1.githubusercontent.com/u/7727148?v=4","gravatar_id":"","url":"https://api.github.com/users/ThadHouse","html_url":"https://github.com/ThadHouse","followers_url":"https://api.github.com/users/ThadHouse/followers","following_url":"https://api.github.com/users/ThadHouse/following{/other_user}","gists_url":"https://api.github.com/users/ThadHouse/gists{/gist_id}","starred_url":"https://api.github.com/users/ThadHouse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThadHouse/subscriptions","organizations_url":"https://api.github.com/users/ThadHouse/orgs","repos_url":"https://api.github.com/users/ThadHouse/repos","events_url":"https://api.github.com/users/ThadHouse/events{/privacy}","received_events_url":"https://api.github.com/users/ThadHouse/received_events","type":"User","site_admin":false},"repo":{"id":44621879,"node_id":"MDEwOlJlcG9zaXRvcnk0NDYyMTg3OQ==","name":"allwpilib","full_name":"ThadHouse/allwpilib","owner":{"login":"ThadHouse","id":7727148,"node_id":"MDQ6VXNlcjc3MjcxNDg=","avatar_url":"https://avatars1.githubusercontent.com/u/7727148?v=4","gravatar_id":"","url":"https://api.github.com/users/ThadHouse","html_url":"https://github.com/ThadHouse","followers_url":"https://api.github.com/users/ThadHouse/followers","following_url":"https://api.github.com/users/ThadHouse/following{/other_user}","gists_url":"https://api.github.com/users/ThadHouse/gists{/gist_id}","starred_url":"https://api.github.com/users/ThadHouse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThadHouse/subscriptions","organizations_url":"https://api.github.com/users/ThadHouse/orgs","repos_url":"https://api.github.com/users/ThadHouse/repos","events_url":"https://api.github.com/users/ThadHouse/events{/privacy}","received_events_url":"https://api.github.com/users/ThadHouse/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ThadHouse/allwpilib","description":"Mirror of FIRST's WPILib repository for 2015+","fork":true,"url":"https://api.github.com/repos/ThadHouse/allwpilib","forks_url":"https://api.github.com/repos/ThadHouse/allwpilib/forks","keys_url":"https://api.github.com/repos/ThadHouse/allwpilib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ThadHouse/allwpilib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ThadHouse/allwpilib/teams","hooks_url":"https://api.github.com/repos/ThadHouse/allwpilib/hooks","issue_events_url":"https://api.github.com/repos/ThadHouse/allwpilib/issues/events{/number}","events_url":"https://api.github.com/repos/ThadHouse/allwpilib/events","assignees_url":"https://api.github.com/repos/ThadHouse/allwpilib/assignees{/user}","branches_url":"https://api.github.com/repos/ThadHouse/allwpilib/branches{/branch}","tags_url":"https://api.github.com/repos/ThadHouse/allwpilib/tags","blobs_url":"https://api.github.com/repos/ThadHouse/allwpilib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ThadHouse/allwpilib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ThadHouse/allwpilib/git/refs{/sha}","trees_url":"https://api.github.com/repos/ThadHouse/allwpilib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ThadHouse/allwpilib/statuses/{sha}","languages_url":"https://api.github.com/repos/ThadHouse/allwpilib/languages","stargazers_url":"https://api.github.com/repos/ThadHouse/allwpilib/stargazers","contributors_url":"https://api.github.com/repos/ThadHouse/allwpilib/contributors","subscribers_url":"https://api.github.com/repos/ThadHouse/allwpilib/subscribers","subscription_url":"https://api.github.com/repos/ThadHouse/allwpilib/subscription","commits_url":"https://api.github.com/repos/ThadHouse/allwpilib/commits{/sha}","git_commits_url":"https://api.github.com/repos/ThadHouse/allwpilib/git/commits{/sha}","comments_url":"https://api.github.com/repos/ThadHouse/allwpilib/comments{/number}","issue_comment_url":"https://api.github.com/repos/ThadHouse/allwpilib/issues/comments{/number}","contents_url":"https://api.github.com/repos/ThadHouse/allwpilib/contents/{+path}","compare_url":"https://api.github.com/repos/ThadHouse/allwpilib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ThadHouse/allwpilib/merges","archive_url":"https://api.github.com/repos/ThadHouse/allwpilib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ThadHouse/allwpilib/downloads","issues_url":"https://api.github.com/repos/ThadHouse/allwpilib/issues{/number}","pulls_url":"https://api.github.com/repos/ThadHouse/allwpilib/pulls{/number}","milestones_url":"https://api.github.com/repos/ThadHouse/allwpilib/milestones{/number}","notifications_url":"https://api.github.com/repos/ThadHouse/allwpilib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ThadHouse/allwpilib/labels{/name}","releases_url":"https://api.github.com/repos/ThadHouse/allwpilib/releases{/id}","deployments_url":"https://api.github.com/repos/ThadHouse/allwpilib/deployments","created_at":"2015-10-20T17:07:36Z","updated_at":"2018-06-08T23:27:37Z","pushed_at":"2018-06-12T19:47:13Z","git_url":"git://github.com/ThadHouse/allwpilib.git","ssh_url":"git@github.com:ThadHouse/allwpilib.git","clone_url":"https://github.com/ThadHouse/allwpilib.git","svn_url":"https://github.com/ThadHouse/allwpilib","homepage":"","size":87653,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"wpilibsuite:master","ref":"master","sha":"1ebb83e0f2414de7f264e217931facd0415998db","user":{"login":"wpilibsuite","id":19267233,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5MjY3MjMz","avatar_url":"https://avatars3.githubusercontent.com/u/19267233?v=4","gravatar_id":"","url":"https://api.github.com/users/wpilibsuite","html_url":"https://github.com/wpilibsuite","followers_url":"https://api.github.com/users/wpilibsuite/followers","following_url":"https://api.github.com/users/wpilibsuite/following{/other_user}","gists_url":"https://api.github.com/users/wpilibsuite/gists{/gist_id}","starred_url":"https://api.github.com/users/wpilibsuite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wpilibsuite/subscriptions","organizations_url":"https://api.github.com/users/wpilibsuite/orgs","repos_url":"https://api.github.com/users/wpilibsuite/repos","events_url":"https://api.github.com/users/wpilibsuite/events{/privacy}","received_events_url":"https://api.github.com/users/wpilibsuite/received_events","type":"Organization","site_admin":false},"repo":{"id":24655143,"node_id":"MDEwOlJlcG9zaXRvcnkyNDY1NTE0Mw==","name":"allwpilib","full_name":"wpilibsuite/allwpilib","owner":{"login":"wpilibsuite","id":19267233,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5MjY3MjMz","avatar_url":"https://avatars3.githubusercontent.com/u/19267233?v=4","gravatar_id":"","url":"https://api.github.com/users/wpilibsuite","html_url":"https://github.com/wpilibsuite","followers_url":"https://api.github.com/users/wpilibsuite/followers","following_url":"https://api.github.com/users/wpilibsuite/following{/other_user}","gists_url":"https://api.github.com/users/wpilibsuite/gists{/gist_id}","starred_url":"https://api.github.com/users/wpilibsuite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wpilibsuite/subscriptions","organizations_url":"https://api.github.com/users/wpilibsuite/orgs","repos_url":"https://api.github.com/users/wpilibsuite/repos","events_url":"https://api.github.com/users/wpilibsuite/events{/privacy}","received_events_url":"https://api.github.com/users/wpilibsuite/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wpilibsuite/allwpilib","description":"Official Repository of WPILibJ and WPILibC","fork":false,"url":"https://api.github.com/repos/wpilibsuite/allwpilib","forks_url":"https://api.github.com/repos/wpilibsuite/allwpilib/forks","keys_url":"https://api.github.com/repos/wpilibsuite/allwpilib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wpilibsuite/allwpilib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wpilibsuite/allwpilib/teams","hooks_url":"https://api.github.com/repos/wpilibsuite/allwpilib/hooks","issue_events_url":"https://api.github.com/repos/wpilibsuite/allwpilib/issues/events{/number}","events_url":"https://api.github.com/repos/wpilibsuite/allwpilib/events","assignees_url":"https://api.github.com/repos/wpilibsuite/allwpilib/assignees{/user}","branches_url":"https://api.github.com/repos/wpilibsuite/allwpilib/branches{/branch}","tags_url":"https://api.github.com/repos/wpilibsuite/allwpilib/tags","blobs_url":"https://api.github.com/repos/wpilibsuite/allwpilib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wpilibsuite/allwpilib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wpilibsuite/allwpilib/git/refs{/sha}","trees_url":"https://api.github.com/repos/wpilibsuite/allwpilib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wpilibsuite/allwpilib/statuses/{sha}","languages_url":"https://api.github.com/repos/wpilibsuite/allwpilib/languages","stargazers_url":"https://api.github.com/repos/wpilibsuite/allwpilib/stargazers","contributors_url":"https://api.github.com/repos/wpilibsuite/allwpilib/contributors","subscribers_url":"https://api.github.com/repos/wpilibsuite/allwpilib/subscribers","subscription_url":"https://api.github.com/repos/wpilibsuite/allwpilib/subscription","commits_url":"https://api.github.com/repos/wpilibsuite/allwpilib/commits{/sha}","git_commits_url":"https://api.github.com/repos/wpilibsuite/allwpilib/git/commits{/sha}","comments_url":"https://api.github.com/repos/wpilibsuite/allwpilib/comments{/number}","issue_comment_url":"https://api.github.com/repos/wpilibsuite/allwpilib/issues/comments{/number}","contents_url":"https://api.github.com/repos/wpilibsuite/allwpilib/contents/{+path}","compare_url":"https://api.github.com/repos/wpilibsuite/allwpilib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wpilibsuite/allwpilib/merges","archive_url":"https://api.github.com/repos/wpilibsuite/allwpilib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wpilibsuite/allwpilib/downloads","issues_url":"https://api.github.com/repos/wpilibsuite/allwpilib/issues{/number}","pulls_url":"https://api.github.com/repos/wpilibsuite/allwpilib/pulls{/number}","milestones_url":"https://api.github.com/repos/wpilibsuite/allwpilib/milestones{/number}","notifications_url":"https://api.github.com/repos/wpilibsuite/allwpilib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wpilibsuite/allwpilib/labels{/name}","releases_url":"https://api.github.com/repos/wpilibsuite/allwpilib/releases{/id}","deployments_url":"https://api.github.com/repos/wpilibsuite/allwpilib/deployments","created_at":"2014-09-30T20:51:33Z","updated_at":"2018-06-11T22:02:57Z","pushed_at":"2018-06-12T19:47:15Z","git_url":"git://github.com/wpilibsuite/allwpilib.git","ssh_url":"git@github.com:wpilibsuite/allwpilib.git","clone_url":"https://github.com/wpilibsuite/allwpilib.git","svn_url":"https://github.com/wpilibsuite/allwpilib","homepage":"","size":87044,"stargazers_count":204,"watchers_count":204,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":91,"mirror_url":null,"archived":false,"open_issues_count":121,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":91,"open_issues":121,"watchers":204,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wpilibsuite/allwpilib/pulls/1148"},"html":{"href":"https://github.com/wpilibsuite/allwpilib/pull/1148"},"issue":{"href":"https://api.github.com/repos/wpilibsuite/allwpilib/issues/1148"},"comments":{"href":"https://api.github.com/repos/wpilibsuite/allwpilib/issues/1148/comments"},"review_comments":{"href":"https://api.github.com/repos/wpilibsuite/allwpilib/pulls/1148/comments"},"review_comment":{"href":"https://api.github.com/repos/wpilibsuite/allwpilib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wpilibsuite/allwpilib/pulls/1148/commits"},"statuses":{"href":"https://api.github.com/repos/wpilibsuite/allwpilib/statuses/604e0e572b94b5e941a5b96932266e204a1423e5"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"ThadHouse"}}