Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8175655 | 10 | Tobias Hartmann | P2 | Resolved | Fixed | b02 |
JDK-8183668 | 8u161 | Unassigned | P2 | Resolved | Fixed | b01 |
JDK-8176313 | 8u152 | Vladimir Kempik | P2 | Closed | Fixed | b03 |
JDK-8192231 | emb-8u161 | Unassigned | P2 | Resolved | Fixed | b01 |
If a field access that always throws NPE, e.g. ((Foo)null).f, is compiled by HotSpot then NPE is thrown regardless of whether Foo.f can be resolved or not.
This differs from the behavior of the interpreter which always performs resolution before the null-check.
Example:
=======================
public class TestGet version 52:0 {
public static Method main:"([Ljava/lang/String;)V" stack 5 locals 1 {
aconst_null;
getfield Field T.f:I; // T does not exist
return;
}
}
=======================
$ java -cp out/ TestGet
Exception in thread "main" java.lang.NoClassDefFoundError: T
at TestGet.main(TestGet.jasm)
Caused by: java.lang.ClassNotFoundException: T
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:532)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:186)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:473)
... 1 more
$ java -cp out/ -Xcomp TestGet
Exception in thread "main" java.lang.NullPointerException
at TestGet.main(TestGet.jasm)
This differs from the behavior of the interpreter which always performs resolution before the null-check.
Example:
=======================
public class TestGet version 52:0 {
public static Method main:"([Ljava/lang/String;)V" stack 5 locals 1 {
aconst_null;
getfield Field T.f:I; // T does not exist
return;
}
}
=======================
$ java -cp out/ TestGet
Exception in thread "main" java.lang.NoClassDefFoundError: T
at TestGet.main(TestGet.jasm)
Caused by: java.lang.ClassNotFoundException: T
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:532)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:186)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:473)
... 1 more
$ java -cp out/ -Xcomp TestGet
Exception in thread "main" java.lang.NullPointerException
at TestGet.main(TestGet.jasm)
- backported by
-
JDK-8175655 C1: NPE is thrown instead of LinkageError when accessing inaccessible field on NULL receiver
- Resolved
-
JDK-8183668 C1: NPE is thrown instead of LinkageError when accessing inaccessible field on NULL receiver
- Resolved
-
JDK-8192231 C1: NPE is thrown instead of LinkageError when accessing inaccessible field on NULL receiver
- Resolved
-
JDK-8176313 C1: NPE is thrown instead of LinkageError when accessing inaccessible field on NULL receiver
- Closed