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: a5ce3a7367da1d145e364f78551c16618495a3af
Describe the issue JVM prints:
while the corresponding native image prints:
Steps to reproduce the issue
Describe GraalVM and your environment:
More details Originally reported in https://github.com/quarkusio/quarkus/issues/43274