Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE in AbstractJavaProjectConfigurator #1735

Closed
snjeza opened this issue Apr 9, 2024 · 4 comments · Fixed by #1736
Closed

NPE in AbstractJavaProjectConfigurator #1735

snjeza opened this issue Apr 9, 2024 · 4 comments · Fixed by #1736

Comments

@snjeza
Copy link
Contributor

snjeza commented Apr 9, 2024

Steps to reproduce:

m2e throws NPE at AbstractJavaProjectConfigurator.java, line 128, and the project isn't configured correctly.
The issue is caused by eclipse-equinox/equinox#571

@rgrunber
Copy link
Contributor

rgrunber commented Apr 9, 2024

I'm also able to reproduce. Project import completely fails now.

image

Version: 2024-06 (4.32)
Build id: I20240406-1800

with m2e from https://download.eclipse.org/technology/m2e/releases/latest/

As @snjeza points out, at

var compliance = ee.getComplianceOptions().get(JavaCore.COMPILER_COMPLIANCE);
(static block) , getComplianceOptions() is called on the JRE-1.1 profile that is declared at https://github.com/eclipse-jdt/eclipse.jdt.debug/blob/7c57761f182f30e385b7c980f1f80390d75eadc2/org.eclipse.jdt.launching/plugin.xml#L281-L284 .

At https://github.com/eclipse-jdt/eclipse.jdt.debug/blob/master/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/environments/ExecutionEnvironment.java#L436 , since no path file is defined the code delegates to OSGI, and that profile is gone. It returns null and the NPE from the getComplianceOptions() chained call triggers an ExceptioninitializationError.

image

I've only seen this with m2e, but pretty much any client calling getComplianceOptions() on a JRE-1.1 EE provided by JDT Debug ( JavaRuntime.getExecutionEnvironmentsManager().getExecutionEnvironments() ) could run into this now.

Once jdt.debug removes the profile on their end, it might be nice to also guard against this failure in the static block.

@HannesWell
Copy link
Contributor

Thanks for this report. I also noticed this recently.

Once jdt.debug removes the profile on their end, it might be nice to also guard against this failure in the static block.

Shouldn't this error vanish completely automatically once eclipse-jdt/eclipse.jdt.debug#425 is available? Then JavaRuntime.getExecutionEnvironmentsManager().getExecutionEnvironments() simply shouldn't return a JRE-1.1 EE.
But then the JRE element can probably be removed from:

Set<String> supportedExecutionEnvironmentTypes = Set.of("JRE", "J2SE", "JavaSE");

@rgrunber
Copy link
Contributor

rgrunber commented Apr 9, 2024

Yes, the error will be completely fixed by the JDT Debug PR. I guess the only concern for m2e is that static blocks like

that do a fair amount of computation can be a real pain when they fail. After the ExceptionInitializationError, they'll just fail with ClassNotFoundException.

Update: Even simpler, getComplianceOptions().get(...) should be checked because getComplianceOptions() can be null.

@sratz
Copy link
Contributor

sratz commented Apr 10, 2024

I guess the only concern for m2e is that static blocks like

that do a fair amount of computation can be a real pain when they fail. After the ExceptionInitializationError, they'll just fail with ClassNotFoundException.

Indeed, I was hit by the same problem (just got a Project configurator "org.eclipse.m2e.jdt.javaConfigurator" required by plugin execution "org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (execution: default-compile, phase: compile)" is not available. To enable full functionality, install the project configurator and run Maven->Update Project Configuration. problem markerwith no log/stack whatsoever). Debugging pointed me to this very issue.

Update: Even simpler, getComplianceOptions().get(...) should be checked because getComplianceOptions() can be null.

#1736.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants