-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed as not planned
Closed as not planned
Copy link
Labels
Description
Describe the issue
JVM prints:
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.length()" because "HelloWorld.name" is null
at HelloWorld.main(HelloWorld.java:6)
while the corresponding native image prints:
Exception in thread "main" java.lang.NullPointerException
at HelloWorld.main(HelloWorld.java:6)
Steps to reproduce the issue
cat > HelloWorld.java <<EOF
public class HelloWorld {
static final String name = null;
public static void main(String[] args) {
System.out.println("Hello world! " + name.length());
}
}
EOF
javac HelloWorld.java
java HelloWorld
native-image -cp ./ HelloWorld
./helloworld
Describe GraalVM and your environment:
- GraalVM version (latest snapshot builds can be found here), or commit id if built from source: a5ce3a7
- JDK major version: 24+3
- OS: Fedora 40
- Architecture: AMD64
More details
Originally reported in quarkusio/quarkus#43274
xtaixe and mkonecny-atlassian