javac could do a better job with line number reporting.
All the assertion compiler messages, and AssertionErrors generated at
runtime, refer to line 1 of the file, when it would be better to refer to
the line where the assert statement actually occurs; in this example, the
stack trace should refer to Foo.main(Foo.java:5).
$ cat Foo.java
class Foo { // 1
public static // 2
void main // 3
(String[] a) { // 4
assert false; // 5
} // 6
} // 7
$ javac -source 1.4 Foo.java
$ java -ea Foo
Exception in thread "main" java.lang.AssertionError
at Foo.main(Foo.java:1)
All the assertion compiler messages, and AssertionErrors generated at
runtime, refer to line 1 of the file, when it would be better to refer to
the line where the assert statement actually occurs; in this example, the
stack trace should refer to Foo.main(Foo.java:5).
$ cat Foo.java
class Foo { // 1
public static // 2
void main // 3
(String[] a) { // 4
assert false; // 5
} // 6
} // 7
$ javac -source 1.4 Foo.java
$ java -ea Foo
Exception in thread "main" java.lang.AssertionError
at Foo.main(Foo.java:1)
- duplicates
-
JDK-4471362 AssertException has wrong source line number
-
- Closed
-