test/tools/javac/jvm/T8020689.java

Sun, 28 Jul 2013 10:17:45 +0200

author
jlahoda
date
Sun, 28 Jul 2013 10:17:45 +0200
changeset 1923
8c4b2987edac
parent 0
959103a6100f
permissions
-rw-r--r--

8020689: Missing LineNumberTable entries in compiled class files
Reviewed-by: ksrini, mcimadamore

     1 /*
     2  * @test  /nodynamiccopyright/
     3  * @bug 8020689
     4  * @summary Making sure the LineNumberTable entry is correctly generated for the leading method invocation in the else section
     5  * @compile T8020689.java
     6  * @run main T8020689
     7  */
     9 public class T8020689 {
    11     public static void main(String... args) {
    12         if (args.length > 0) {
    13             a();
    14         } else {
    15             b();
    16         }
    17     }
    19     static void a() {
    20     }
    22     static void b() {
    23         assertLine(15);
    24     }
    26     public static void assertLine(int expectedline) {
    27         Exception e = new Exception("expected line#: " + expectedline);
    28         int myline = e.getStackTrace()[2].getLineNumber();
    29         if( myline != expectedline) {
    30             throw new RuntimeException("Incorrect line number " +
    31                     "expected: " + expectedline +
    32                     ", got: " + myline, e);
    33         }
    34         System.out.format("Got expected line number %d correct %n", myline);
    35     }
    36 }

mercurial