Thu, 10 Oct 2013 14:58:04 +0200
8001931: The new build system whitespace cleanup
Reviewed-by: tbell, simonis, erikj
1 /*
2 * @test /nodynamiccopyright/
3 * @bug 7024096
4 * @summary Stack trace has invalid line numbers
5 * @author Bruce Chapman
6 * @compile T7024096.java
7 * @run main T7024096
8 */
10 public class T7024096 {
11 private static final int START = 14; // starting line number for the test
12 public static void main(String[] args) {
13 T7024096 m = new T7024096();
14 m.nest(START);
15 m.nest(START + 1, m.nest(START + 1), m.nest(START + 1),
16 m.nest(START + 2),
17 m.nest(START + 3, m.nest(START + 3)));
18 }
20 public T7024096 nest(int expectedline, T7024096... args) {
21 Exception e = new Exception("expected line#: " + expectedline);
22 int myline = e.getStackTrace()[1].getLineNumber();
23 if( myline != expectedline) {
24 throw new RuntimeException("Incorrect line number " +
25 "expected: " + expectedline +
26 ", got: " + myline, e);
27 }
28 System.out.format("Got expected line number %d correct %n", myline);
29 return null;
30 }
31 }