test/tools/javac/jvm/T7024096.java

changeset 0
959103a6100f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/jvm/T7024096.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,31 @@
     1.4 +/*
     1.5 + * @test  /nodynamiccopyright/
     1.6 + * @bug 7024096
     1.7 + * @summary Stack trace has invalid line numbers
     1.8 + * @author Bruce Chapman
     1.9 + * @compile T7024096.java
    1.10 + * @run main T7024096
    1.11 + */
    1.12 +
    1.13 +public class T7024096 {
    1.14 +    private static final int START = 14; // starting line number for the test
    1.15 +    public static void main(String[] args) {
    1.16 +        T7024096 m = new T7024096();
    1.17 +        m.nest(START);
    1.18 +        m.nest(START + 1, m.nest(START + 1), m.nest(START + 1),
    1.19 +            m.nest(START + 2),
    1.20 +            m.nest(START + 3, m.nest(START + 3)));
    1.21 +    }
    1.22 +
    1.23 +    public T7024096 nest(int expectedline, T7024096... args) {
    1.24 +        Exception e = new Exception("expected line#: " + expectedline);
    1.25 +        int myline = e.getStackTrace()[1].getLineNumber();
    1.26 +        if( myline != expectedline) {
    1.27 +            throw new RuntimeException("Incorrect line number " +
    1.28 +                    "expected: " + expectedline +
    1.29 +                    ", got: " + myline, e);
    1.30 +        }
    1.31 +        System.out.format("Got expected line number %d correct %n", myline);
    1.32 +        return null;
    1.33 +    }
    1.34 +}

mercurial