{"action":"created","issue":{"url":"https://api.github.com/repos/junit-team/junit5/issues/474","repository_url":"https://api.github.com/repos/junit-team/junit5","labels_url":"https://api.github.com/repos/junit-team/junit5/issues/474/labels{/name}","comments_url":"https://api.github.com/repos/junit-team/junit5/issues/474/comments","events_url":"https://api.github.com/repos/junit-team/junit5/issues/474/events","html_url":"https://github.com/junit-team/junit5/issues/474","id":172328248,"number":474,"title":"Classpath scanning eagerly loads classes unnecessarily","user":{"login":"sbrannen","id":104798,"avatar_url":"https://avatars.githubusercontent.com/u/104798?v=3","gravatar_id":"","url":"https://api.github.com/users/sbrannen","html_url":"https://github.com/sbrannen","followers_url":"https://api.github.com/users/sbrannen/followers","following_url":"https://api.github.com/users/sbrannen/following{/other_user}","gists_url":"https://api.github.com/users/sbrannen/gists{/gist_id}","starred_url":"https://api.github.com/users/sbrannen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbrannen/subscriptions","organizations_url":"https://api.github.com/users/sbrannen/orgs","repos_url":"https://api.github.com/users/sbrannen/repos","events_url":"https://api.github.com/users/sbrannen/events{/privacy}","received_events_url":"https://api.github.com/users/sbrannen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/junit-team/junit5/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/junit-team/junit5/labels/Platform","name":"Platform","color":"11dd99"},{"url":"https://api.github.com/repos/junit-team/junit5/labels/team%20discussion","name":"team discussion","color":"207de5"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/junit-team/junit5/milestones/6","html_url":"https://github.com/junit-team/junit5/milestones/5.0%20M3","labels_url":"https://api.github.com/repos/junit-team/junit5/milestones/6/labels","id":1885703,"number":6,"title":"5.0 M3","description":"Themes: JUnit 4 interoperability, additional discovery selectors, documentation","creator":{"login":"sbrannen","id":104798,"avatar_url":"https://avatars.githubusercontent.com/u/104798?v=3","gravatar_id":"","url":"https://api.github.com/users/sbrannen","html_url":"https://github.com/sbrannen","followers_url":"https://api.github.com/users/sbrannen/followers","following_url":"https://api.github.com/users/sbrannen/following{/other_user}","gists_url":"https://api.github.com/users/sbrannen/gists{/gist_id}","starred_url":"https://api.github.com/users/sbrannen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbrannen/subscriptions","organizations_url":"https://api.github.com/users/sbrannen/orgs","repos_url":"https://api.github.com/users/sbrannen/repos","events_url":"https://api.github.com/users/sbrannen/events{/privacy}","received_events_url":"https://api.github.com/users/sbrannen/received_events","type":"User","site_admin":false},"open_issues":30,"closed_issues":33,"state":"open","created_at":"2016-07-15T14:13:22Z","updated_at":"2016-08-21T16:20:01Z","due_on":"2016-09-30T04:00:00Z","closed_at":null},"comments":2,"created_at":"2016-08-21T16:20:00Z","updated_at":"2016-08-21T19:38:46Z","closed_at":null,"body":"## Status Quo\r\n\r\n`ClasspathScanner.processClassFileSafely()` _eagerly_ loads candidate classes without applying any filtering (other than the recently adding filtering for `package-info`). Consequently, every single class in the classpath is loaded even if it will never be needed for the current test plan.\r\n\r\nAlthough `ClassFilter.includeClassNamePattern(String)` can be used to filter out scanned classes, this unfortunately occurs after classpath scanning has occurred, meaning that even unused test classes are unnecessarily eagerly loaded.\r\n\r\nThis leads to unnecessary loading of classes, and since classes may have `static` initialization blocks, this also potentially leads to unnecessary execution of code.\r\n\r\n## Worst Case Scenario\r\n\r\nAs soon as we add support for scanning JARs in the classpath, the `ClasspathScanner` will potentially *load every single class in the entire JVM* if the user selects the default package as the base package from which to begin scanning.\r\n\r\n## Deliverables\r\n\r\n- [ ] Apply filtering to classpath scanning candidates before loading the class (e.g., based merely on the class name).\r\n- [ ] Consider using class name patterns registered via `ClassFilter.includeClassNamePattern(String)` _during_ discovery instead of after classes have been scanned and loaded.\r\n"},"comment":{"url":"https://api.github.com/repos/junit-team/junit5/issues/comments/241277130","html_url":"https://github.com/junit-team/junit5/issues/474#issuecomment-241277130","issue_url":"https://api.github.com/repos/junit-team/junit5/issues/474","id":241277130,"user":{"login":"sbrannen","id":104798,"avatar_url":"https://avatars.githubusercontent.com/u/104798?v=3","gravatar_id":"","url":"https://api.github.com/users/sbrannen","html_url":"https://github.com/sbrannen","followers_url":"https://api.github.com/users/sbrannen/followers","following_url":"https://api.github.com/users/sbrannen/following{/other_user}","gists_url":"https://api.github.com/users/sbrannen/gists{/gist_id}","starred_url":"https://api.github.com/users/sbrannen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbrannen/subscriptions","organizations_url":"https://api.github.com/users/sbrannen/orgs","repos_url":"https://api.github.com/users/sbrannen/repos","events_url":"https://api.github.com/users/sbrannen/events{/privacy}","received_events_url":"https://api.github.com/users/sbrannen/received_events","type":"User","site_admin":false},"created_at":"2016-08-21T19:38:46Z","updated_at":"2016-08-21T19:38:46Z","body":"Added _Worst Case Scenario_ section to issue description."}}
{"actor":{"display_login":"sbrannen"}}