You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unexpected "JRE container" entry derived from pom.xml for Java SE 13 #951
When opening a Maven project which uses maven.compiler.source/target 13, the derived .classpath file uses J2SE-1.5 as its JRE container, instead of the expected JavaSE-12.
In other words: if the value for the Maven compiler properties is unsupported/unrecognized, it should default to the highest currently-supported version. This is much more likely to be what the user wants/expects. For example, with the new JDK release cadence (the first JDK 14 build is already released), it's more common (for me at least) to try out early-access JDK builds.
Before the fix, the lookup was just an ID match with no viability check:
for (IExecutionEnvironment environment : manager.getExecutionEnvironments()) {
if (environment.getId().equals(environmentId)) {
return environment;
}
}
return null;
So m2e would happily select e.g. JavaSE-12 purely because the ID matched the Maven compiler target, even if there was no actual installed JDK bound to that environment — exactly fbricon's diagnosis: "we select the highest execution environment, but there might not be an actual jdk backing it."
The fix — commit aa212c49, Oct 11 2022, Konrad Windszus + Hannes Wellmann, closing m2e#842 ("Only select ExecutionEnvironments with at least one compatible VM installed"):
IExecutionEnvironment environment = manager.getEnvironment(environmentId);
if (environment != null && environment.getCompatibleVMs().length > 0) {
return environment;
}
log.error("Failed to find a compatible VM for environment id '{}', falling back to workspace default", environmentId);
return null;
Now, when the chosen EE has zero compatible VMs, it falls back to null — which addJREClasspathContainer() turns into JavaRuntime.newDefaultJREContainerPath() (the workspace default JRE) instead of silently emitting a classpath entry for an environment with nothing backing it.
Activity
fbricon commentedon Jul 16, 2019
upstream issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=549312
fbricon commentedon Jul 16, 2019
The fixed m2e version is now consumed by jdt.ls (eclipse-jdtls/eclipse.jdt.ls@c966395)
EricZhangzf commentedon Jul 18, 2019
Test this issue in my local machine, No matter what my local jdk version is(1.8, 11, 12), The .classpath file always:
fbricon commentedon Jul 18, 2019
Ok, I think I know what the issue is. We select the highest execution environment, but there might not be an actual jdk backing it.
robstryker commentedon Nov 2, 2026
Already fixed upstream!
Found it exactly where Fred's hunch pointed.
org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java, method getExecutionEnvironment(String environmentId).
Before the fix, the lookup was just an ID match with no viability check:
So m2e would happily select e.g. JavaSE-12 purely because the ID matched the Maven compiler target, even if there was no actual installed JDK bound to that environment — exactly fbricon's diagnosis: "we select the highest execution environment, but there might not be an actual jdk backing it."
The fix — commit aa212c49, Oct 11 2022, Konrad Windszus + Hannes Wellmann, closing m2e#842 ("Only select ExecutionEnvironments with at least one compatible VM installed"):
Now, when the chosen EE has zero compatible VMs, it falls back to null — which addJREClasspathContainer() turns into JavaRuntime.newDefaultJREContainerPath() (the workspace default JRE) instead of silently emitting a classpath entry for an environment with nothing backing it.
Closing as fixed upstream.