-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
===
1 abstract class T {
2 class I {
3 boolean x;
4 }
5
6 static boolean id(boolean x) {
7 return x;
8 }
9
10 public static void main(String[] args) {
11 I i = null;
12 System.err.println(true
13 && id(i.x));
14 }
15 }
===
The null pointer exception in the following program occurs on line 13 with the evaluation of `i.x` (`i` is null), but the stack track reports it as having occurred on 12.
It looks like the LNT doesn't have a record of the select expression `i.x`.
$ javac -fullversion
javac full version "12-ea+30"
$ javac T.java
$ javap -v -p T
...
public static void main(java.lang.String[]);
descriptor: ([Ljava/lang/String;)V
flags: (0x0009) ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=2, args_size=1
0: aconst_null
1: astore_1
2: getstatic #2 // Field java/lang/System.err:Ljava/io/PrintStream;
5: aload_1
6: getfield #3 // Field T$I.x:Z
9: invokestatic #4 // Method id:(Z)Z
12: invokevirtual #5 // Method java/io/PrintStream.println:(Z)V
15: return
LineNumberTable:
line 11: 0
line 12: 2
line 13: 9
line 12: 12
line 14: 15
$ java T
$ java T
Exception in thread "main" java.lang.NullPointerException
at T.main(T.java:12)
1 abstract class T {
2 class I {
3 boolean x;
4 }
5
6 static boolean id(boolean x) {
7 return x;
8 }
9
10 public static void main(String[] args) {
11 I i = null;
12 System.err.println(true
13 && id(i.x));
14 }
15 }
===
The null pointer exception in the following program occurs on line 13 with the evaluation of `i.x` (`i` is null), but the stack track reports it as having occurred on 12.
It looks like the LNT doesn't have a record of the select expression `i.x`.
$ javac -fullversion
javac full version "12-ea+30"
$ javac T.java
$ javap -v -p T
...
public static void main(java.lang.String[]);
descriptor: ([Ljava/lang/String;)V
flags: (0x0009) ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=2, args_size=1
0: aconst_null
1: astore_1
2: getstatic #2 // Field java/lang/System.err:Ljava/io/PrintStream;
5: aload_1
6: getfield #3 // Field T$I.x:Z
9: invokestatic #4 // Method id:(Z)Z
12: invokevirtual #5 // Method java/io/PrintStream.println:(Z)V
15: return
LineNumberTable:
line 11: 0
line 12: 2
line 13: 9
line 12: 12
line 14: 15
$ java T
$ java T
Exception in thread "main" java.lang.NullPointerException
at T.main(T.java:12)