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

Bug 532490

Summary: cannot launch java project on JDK9 anymore
Product: [Eclipse Project] JDT Reporter: Martin Lippert <mlippert>
Component: DebugAssignee: Sarika Sinha <sarika.sinha>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: jarthana, sarika.sinha, stephan.herrmann
Version: 4.8   
Target Milestone: BETA J18.3   
Hardware: Macintosh   
OS: Mac OS X   
See Also: https://git.eclipse.org/r/119510
https://git.eclipse.org/c/jdt/eclipse.jdt.debug.git/commit/?id=c9a1f05d85f965a727e6ca01b023ff94985ef8c8
https://git.eclipse.org/r/119663
https://git.eclipse.org/c/jdt/eclipse.jdt.debug.git/commit/?id=9eaef85b313f20ed7cc67182a9c51f357d205924
https://bugs.eclipse.org/bugs/show_bug.cgi?id=542571
Whiteboard:

Description Martin Lippert CLA 2018-03-15 09:21:54 EDT
I have the simplest Java app around:

package javademo;

public class MyMain {
	
	public static void main(String[] args) {
		System.out.println("Hello World!");
	}

}


It is configured for JDK 1.8.

=> launching this on JDK 1.8 JRE/JDK works
=> launching this on JDK9 (9.0.4) fails with this message:

===

Error occurred during initialization of boot layer
java.lang.LayerInstantiationException: Package jdk.internal.jimage.decompressor in both module jrt.fs and module java.base

===

Switching the project to have JDK9 as the runtime JRE on the classpath (instead of the JDK1.8) fixes the issue.

This is a major regression compared to Oxygen.2 (tested that, too). Launching a JDK1.8-based project on a JDK 1.8 and a JDK 9 works both out-of-the-box.
Comment 1 Martin Lippert CLA 2018-03-15 09:27:21 EDT
Environment:

macOS High Sierra (10.13.3)

===

Eclipse IDE for Java Developers

Version: Photon Milestone 5 (4.8.0M5)
Build id: 20180314-2134

===

org.eclipse.jdt.launching bundle is from:
3.10.0.v20180303-2257

===

Eclipse itself running on a JDK 1.8.0_161
Comment 2 Stephan Herrmann CLA 2018-03-15 09:40:12 EDT
(In reply to Martin Lippert from comment #0)
> I have the simplest Java app around:
> 
> package javademo;
> 
> public class MyMain {
> 	
> 	public static void main(String[] args) {
> 		System.out.println("Hello World!");
> 	}
> 
> }
> 
> 
> It is configured for JDK 1.8.
> 
> => launching this on JDK 1.8 JRE/JDK works
> => launching this on JDK9 (9.0.4) fails with this message:
> 
> ===
> 
> Error occurred during initialization of boot layer
> java.lang.LayerInstantiationException: Package
> jdk.internal.jimage.decompressor in both module jrt.fs and module java.base
> 
> ===
> 
> Switching the project to have JDK9 as the runtime JRE on the classpath
> (instead of the JDK1.8) fixes the issue.

Now you got me confused: the error happens when you launch on JDK9 and it can be fixed by switching to JDK9??
Comment 3 Stephan Herrmann CLA 2018-03-15 09:51:33 EDT
(In reply to Stephan Herrmann from comment #2)
> (In reply to Martin Lippert from comment #0)
> > ===
> > 
> > Error occurred during initialization of boot layer
> > java.lang.LayerInstantiationException: Package
> > jdk.internal.jimage.decompressor in both module jrt.fs and module java.base
> > 
> > ===


Of course, this *is* bogus: jrt.fs is not a module contained in any JDK 9 image.

Perhaps you have a mix of both 1.8 and 9 System libraries on the runtime classpath?

Hint: after the (failed) launch: go to the Debug View, select the second node, its properties contain the full command line that was used for launching. What's it say?

@Sarika, maybe I can sell stick notes with this hint ;p
Comment 4 Martin Lippert CLA 2018-03-15 10:14:20 EDT
(In reply to Stephan Herrmann from comment #2)
> (In reply to Martin Lippert from comment #0)
> Now you got me confused: the error happens when you launch on JDK9 and it
> can be fixed by switching to JDK9??

Here is the matrix of what works and what doesn't:

- project configured with 1.8, launched on JDK 1.8: works
- project configured with 1.9, launched on JDK 9: works
- project configured with 1.8, launched on JDK 9: BOOOOOOM...

And it seems to be 100% reproduceable... :-)
Comment 5 Martin Lippert CLA 2018-03-15 10:17:12 EDT
(In reply to Stephan Herrmann from comment #3)
> (In reply to Stephan Herrmann from comment #2)
> > (In reply to Martin Lippert from comment #0)
> Hint: after the (failed) launch: go to the Debug View, select the second
> node, its properties contain the full command line that was used for
> launching. What's it say?

Command Line:
/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/bin/java -Dfile.encoding=UTF-8 -p /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/lib/jrt-fs.jar -classpath /Users/mlippert/Documents/eclipse-workspace-issue-launch-jdk9-jdk8/javademo/bin javademo.MyMain
Comment 6 Sarika Sinha CLA 2018-03-15 10:22:22 EDT
(In reply to Stephan Herrmann from comment #3)
> @Sarika, maybe I can sell stick notes with this hint ;p


What's the rate :)




Any way I checked it is getting patched
-p C:\Eclipse\Downloads\JDK\jdk-9\lib\jrt-fs.jar 

I see it happening on 4.7.3 also.
Comment 7 Eclipse Genie CLA 2018-03-15 13:09:33 EDT
New Gerrit change created: https://git.eclipse.org/r/119510
Comment 9 Stephan Herrmann CLA 2018-03-17 08:39:49 EDT
(In reply to Eclipse Genie from comment #8)
> Gerrit change https://git.eclipse.org/r/119510 was merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.debug.git/commit/
> ?id=c9a1f05d85f965a727e6ca01b023ff94985ef8c8

Does this fix still do the right thing when bug 490103 is merged (and jrt-fs.jar no longer shows up in classpath entries)?
Comment 10 Sarika Sinha CLA 2018-03-19 08:49:24 EDT
I don't think that will impact but adding Jay to this, so that he can test this if breaks and report here.
Comment 11 Eclipse Genie CLA 2018-03-19 08:51:11 EDT
New Gerrit change created: https://git.eclipse.org/r/119663
Comment 12 Jay Arthanareeswaran CLA 2018-03-19 10:16:40 EDT
(In reply to Stephan Herrmann from comment #9)
> Does this fix still do the right thing when bug 490103 is merged (and
> jrt-fs.jar no longer shows up in classpath entries)?

At the moment, that fix is not going anywhere :( 

But it will have an impact, but I already see what needs to be done. And without that fix, I don't think Sarika has a choice anyway.
Comment 13 Eclipse Genie CLA 2018-03-20 04:50:55 EDT
Gerrit change https://git.eclipse.org/r/119663 was merged to [BETA_JAVA_18_3].
Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.debug.git/commit/?id=9eaef85b313f20ed7cc67182a9c51f357d205924
Comment 14 Sarika Sinha CLA 2018-03-22 10:17:23 EDT
verified using
Eclipse SDK

Version: Photon (4.8)
Build id: I20180322-0645