eclipse-jdt / eclipse-jdt/eclipse.jdt.debug

Potential NPE from ExecutionEnvironment.getCompatibleVMs

Open
#248 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
23
Forks
68
Avg merge
1d 4h
Merged PRs (30d)
13

Description

Some tests in m2e CI fail with the following stack
```
org.eclipse.core.runtime.AssertionFailedException: null argument:
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:88)
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:76)
at org.eclipse.jdt.internal.launching.CommandLineShortener.(CommandLineShortener.java:81)
at org.eclipse.jdt.internal.launching.CommandLineShortener.(CommandLineShortener.java:77)
at org.eclipse.jdt.internal.launching.StandardVMRunner.getCommandLine(StandardVMRunner.java:488)
at org.eclipse.jdt.internal.launching.StandardVMRunner.run(StandardVMRunner.java:516)
at org.eclipse.jdt.launching.AbstractVMInstall.evaluateSystemProperties(AbstractVMInstall.java:398)
at org.eclipse.jdt.internal.launching.environments.ExecutionEnvironmentAnalyzer.isFoundation1_0(ExecutionEnvironmentAnalyzer.java:210)
at org.eclipse.jdt.internal.launching.environments.ExecutionEnvironmentAnalyzer.analyze(ExecutionEnvironmentAnalyzer.java:124)
at org.eclipse.jdt.internal.launching.environments.Analyzer.analyze(Analyzer.java:44)
at org.eclipse.jdt.internal.launching.environments.EnvironmentsManager.analyze(EnvironmentsManager.java:409)
at org.eclipse.jdt.internal.launching.environments.EnvironmentsManager.initializeCompatibilities(EnvironmentsManager.java:316)
at org.eclipse.jdt.internal.launching.environments.ExecutionEnvironment.init(ExecutionEnvironment.java:185)
at org.eclipse.jdt.internal.launching.environments.ExecutionEnvironment.getCompatibleVMs(ExecutionEnvironment.java:209)
at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.getExecutionEnvironment(AbstractJavaProjectConfigurator.java:240)
....
```
The configured VMs are the one available in toolchains.xml (I can't tell whether they're all correct, but yet they were successfully created with this snippet
```java
getVMInstallation(toolchain)
.filter(f -> standardType.validateInstallLocation(f).isOK())
.ifPresent(candidate -> {
if (Arrays.stream(standardType.getVMInstalls()) //
.map(IVMInstall::getInstallLocation) //
.filter(Objects::nonNull)
.noneMatch(install -> isSameCanonicalFile(candidate, install))) {

VMStandin workingCopy = new VMStandin(standardType, candidate.getAbsolutePath());
workingCopy.setInstallLocation(candidate);
String name = candidate.getName();
int i = 1;
while (isDuplicateName(name)) {
name = candidate.getName() + '(' + i++ + ')';
}
workingCopy.setName(name);
workingCopy.convertToRealVM();
}
});
```
which seems to be proper usage of the API with the necessary checks for correct behavior.
The expectation here would be that if a VM is successfully created for a given directory with this API, then the errors get handled properly later on and not cause exceptions. Either the VM is not created/validated first, or it's created and it's fine to use.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.