Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 530058

Summary: [9] Also add --add-opens when launching with earlier JUnit versions
Product: [Eclipse Project] JDT Reporter: Till Brychcy <register.eclipse>
Component: UIAssignee: Till Brychcy <register.eclipse>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: noopur_gupta
Version: 4.8   
Target Milestone: 4.7.3   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/115729
https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=ac9a1d5b0d38e7aae5209273ced22d6c841743b6
https://git.eclipse.org/r/115753
https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=d1fa9146155aab7489cf8a16541e2fc304e0005d
Whiteboard:
Bug Depends on: 525948    
Bug Blocks:    

Description Till Brychcy CLA 2018-01-19 15:30:48 EST
When testing Bug 520713, I noted that launching works, if I use JUnit 5, but but fails, because the required --add-opens is not added, if JUnit 4 is used. 

Also, if JUnit is on the class path, a warning is displayed in the console, 
because a module for JUnit is mentioned in the --add-opens argument, but cannot be found.

PATCH:
1) Support earlier JUnit Versions
2) Check if JUnit is on the classpath or module path and use appropriate target for --add-opens.
Comment 1 Eclipse Genie CLA 2018-01-19 15:33:07 EST
New Gerrit change created: https://git.eclipse.org/r/115729
Comment 2 Till Brychcy CLA 2018-01-19 15:51:26 EST
Note: For testing with JUnit on the module path (and mentioned in module-info.java as "requires junit;", you cannot use the JUnit4 Container, because the bundled hamcrest library has a name that leads to an invalid automatic module name.

Instead it can be done e.g. with http://central.maven.org/maven2/junit/junit/4.8.2/junit-4.8.2.jar, which has the required hamcrest classes included.
Comment 4 Till Brychcy CLA 2018-01-19 16:49:10 EST
(In reply to Eclipse Genie from comment #3)
> Gerrit change https://git.eclipse.org/r/115729 was merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/
> ?id=ac9a1d5b0d38e7aae5209273ced22d6c841743b6

Released for 4.8M5
Comment 5 Noopur Gupta CLA 2018-01-20 05:47:50 EST
Thanks for the fix, Till. 

Could you please backport it to 4.7.3 also?
Comment 6 Eclipse Genie CLA 2018-01-20 14:05:16 EST
New Gerrit change created: https://git.eclipse.org/r/115753
Comment 7 Eclipse Genie CLA 2018-01-20 15:01:33 EST
Gerrit change https://git.eclipse.org/r/115753 was merged to [R4_7_maintenance].
Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=d1fa9146155aab7489cf8a16541e2fc304e0005d
Comment 8 Till Brychcy CLA 2018-01-20 15:04:51 EST
(In reply to Noopur Gupta from comment #5)
> Thanks for the fix, Till. 
> 
> Could you please backport it to 4.7.3 also?

OK

(In reply to Eclipse Genie from comment #7)
> Gerrit change https://git.eclipse.org/r/115753 was merged to
> [R4_7_maintenance].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/
> ?id=d1fa9146155aab7489cf8a16541e2fc304e0005d

Released for 4.7.3
Comment 9 Noopur Gupta CLA 2018-01-22 01:53:28 EST
Thanks, Till.
Comment 10 Noopur Gupta CLA 2018-02-08 07:29:31 EST
Verified for 4.7.3 in M20180207-1700.