apache / apache/maven-surefire

[SUREFIRE-1735] Using GraalVM toolchain causes NPE when default JAVA_HOME is not set to GraalVM JDK's home

Open
#2,009 0 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
461
Forks
588
Avg merge
1d 8h
Merged PRs (30d)
19

Description

**[Adam Czepil](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=kopper)** opened **[SUREFIRE-1735](https://issues.apache.org/jira/browse/SUREFIRE-1735?redirect=false)** and commented

When I use toolchains and configure GraalVM as the active toolchain AND my default JDK is NOT GraalVM (JAVA_HOME != GraalVM) I'm getting NPE from surefire plugin

**Caused by**: java.lang.NullPointerException

    **at** org.apache.maven.surefire.booter.SystemUtils.toJdkVersionFromReleaseFile (**SystemUtils.java:141**)

    **at** org.apache.maven.surefire.booter.SystemUtils.isJava9AtLeast (**SystemUtils.java:215**)

    **at** org.apache.maven.plugin.surefire.AbstractSurefireMojo.getEffectiveJvm (**AbstractSurefireMojo.java:2446**)

 

It works fine when I change JAVA_HOME to point to GraalVM home.

The reason is that https://github.com/apache/maven-surefire/blob/master/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemUtils.java try to read JAVA_VERSION from releases file and GraalVM doesn't have this variable there.

I'm not sure who is at fault, maybe GraalVM should export that var.

---

**Affects:** 3.0.0-M4

Contributor guide

Open the contributing guide

Research direction

Start in surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemUtils.java, especially toJdkVersionFromReleaseFile and isJava9AtLeast at the reported lines. Reproduce the toolchain setup with GraalVM selected while JAVA_HOME points elsewhere, then verify that Surefire no longer throws the reported NullPointerException and still determines the effective JVM correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.