test/tools/javac/jvm/T7024096.java

Wed, 27 Apr 2016 01:34:52 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:34:52 +0800
changeset 0
959103a6100f
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/langtools/
changeset: 2573:53ca196be1ae
tag: jdk8u25-b17

     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 }

mercurial