eclipse-jdt / eclipse.jdt.core

Eclipse Public License 2.0
159 stars 129 forks source link

release 17 is not found in the system #191

Closed laeubi closed 2 years ago

laeubi commented 2 years ago

I see this in the error log:

org.eclipse.core.runtime.CoreException: release 17 is not found in the system
    at org.eclipse.jdt.internal.core.builder.ClasspathJrtWithReleaseOption.initialize(ClasspathJrtWithReleaseOption.java:120)
    at org.eclipse.jdt.internal.core.builder.ClasspathJrtWithReleaseOption.<init>(ClasspathJrtWithReleaseOption.java:82)
    at org.eclipse.jdt.internal.core.builder.ClasspathLocation.forJrtSystem(ClasspathLocation.java:157)
    at org.eclipse.jdt.internal.core.builder.NameEnvironment.computeClasspathLocations(NameEnvironment.java:333)
    at org.eclipse.jdt.internal.core.builder.NameEnvironment.<init>(NameEnvironment.java:63)
    at org.eclipse.jdt.internal.core.builder.JavaBuilder.initializeBuilder(JavaBuilder.java:644)
    at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:182)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:1024)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:254)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:311)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:400)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:403)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:514)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:462)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:544)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:161)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:255)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.lang.IllegalArgumentException: release 17 is not found in the system
    at org.eclipse.jdt.internal.core.builder.ClasspathJrtWithReleaseOption.initialize(ClasspathJrtWithReleaseOption.java:119)
    ... 19 more

A java 17 JDK is available and selected as the default JRE in my settings.

iloveeclipse commented 2 years ago

You have JRE, not JDK installed?

laeubi commented 2 years ago

JDT claims that it is a JDK and the path name also indicate its a JDK, but the preferences always name them as JREs (should it matter anyways?) Window> Preferences > Java > Installed JREs

iloveeclipse commented 2 years ago

Aua. You seem to configured project with --release 17 on Java 17?

laeubi commented 2 years ago

I don't do not configure anything specific here... might be automatically derived from maven settings or something... so whats wrong with --release 17 on Java 17, I think the tool generating this can't know if Java 17, 18, 19... is my default JVM, so maybe JDT can ignore this if it is useless?

iloveeclipse commented 2 years ago

so whats wrong with --release 17 on Java 17

JDT decides to look for Java 17 "compatibility layer API's" in lib/ct.sym file, but there is no such in 17 file. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=562764 and proposed patch https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/161966.

I've tried to run into your error, but I'm unable to construct such case. Now, that this is a user visible error, the patch makes more sense.

Please provide exact steps to reproduce (and platform/JDK used), ideally also concrete project settings used.

laeubi commented 2 years ago

According to the error log for example this project is affected:

https://github.com/eclipse-m2e/m2e-core/tree/master/org.eclipse.m2e.pde.connector

The project preferences are like this:

eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17

I suspect org.eclipse.jdt.core.compiler.release=enabled is the crucial part and I'm using a jdk-17.0.2 as default vm and another jdk-11.0.8, no other JDKs configured.

iloveeclipse commented 2 years ago

@laeubi : would be interesting if you could grab tomorrow' build and try again. If that should again report some error, please reopen this issue.