eclipse-jdt / eclipse.jdt.debug

Eclipse Public License 2.0
16 stars 46 forks source link

ClassNotFoundException: SequencedMap #385

Open jukzi opened 6 months ago

jukzi commented 6 months ago

When having both JDK 17 and JDK 21 configured in the IDE (and jdk 21 as default JRE) and launching a test case for a BREEE 17 project (Run As..), then it it fails image image

WARNING: Using incubator modules: jdk.incubator.foreign, jdk.incubator.vector
java.lang.NoClassDefFoundError: java/util/SequencedMap
    at org.apache.felix.resolver.Candidates.<init>(Candidates.java:96)
    at org.apache.felix.resolver.ResolverImpl.getInitialCandidates(ResolverImpl.java:541)
    at org.apache.felix.resolver.ResolverImpl.doResolve(ResolverImpl.java:431)
    at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:420)
    at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:374)
    at org.eclipse.osgi.container.ModuleResolver$ResolveProcess.resolveRevisions(ModuleResolver.java:1084)
    at org.eclipse.osgi.container.ModuleResolver$ResolveProcess.resolveRevisionsInBatch(ModuleResolver.java:1035)
    at org.eclipse.osgi.container.ModuleResolver$ResolveProcess.resolve(ModuleResolver.java:951)
    at org.eclipse.osgi.container.ModuleResolver.resolveDelta(ModuleResolver.java:181)
    at org.eclipse.osgi.container.ModuleContainer.resolveAndApply(ModuleContainer.java:714)
    at org.eclipse.osgi.container.ModuleContainer.resolve(ModuleContainer.java:660)
    at org.eclipse.osgi.container.ModuleContainer.resolve(ModuleContainer.java:648)
    at org.eclipse.osgi.storage.Storage.checkSystemBundle(Storage.java:431)
    at org.eclipse.osgi.storage.Storage.createStorage(Storage.java:189)
    at org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(EquinoxContainer.java:108)
    at org.eclipse.osgi.launch.Equinox.<init>(Equinox.java:53)
    at org.eclipse.osgi.launch.Equinox.<init>(Equinox.java:46)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:342)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:267)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:651)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:588)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1459)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1432)
Caused by: java.lang.ClassNotFoundException: java.util.SequencedMap
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:592)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
    ... 27 more
An error has occurred. See the log file
null.

I understand it is compiled against JDK 21, but executed with JDK 17 by default image

workaround: open the Launch configuration "Main" tab -> JDK 21 is automaically(!) selected: image

There after "run" launches with 21 and test runs fine.

To my understanding the launchconfiguration should use JDK 21 even without using the configuration dialog

SarikaSinha commented 6 months ago

@jukzi Have you tried setting this in "Execution Environments" in the Java Preferences where the compatible JREs are listed?

jukzi commented 6 months ago

When i set JavaSE-17 Execution Environment to JDK21, the error is gone. But that feels only like a workaround. image image

SarikaSinha commented 6 months ago

That was the only purpose of allowing to set up the preferred JRE.

laeubi commented 5 months ago

I understand it is compiled against JDK 21, but executed with JDK 17 by default

Given your screenshot I think this is a bug. If the JDK to compile is higher than the JDK selected by the project it must use the --target option an not use any later constructs, this Bug is probably suffering from the same behavior: