langtools/test/tools/javac/jvm/T8020689.java
author jjg
Wed, 29 Oct 2014 17:25:23 -0700 (2014-10-30)
changeset 27319 030080f03e4f
parent 19131 519fa466d8ba
permissions -rw-r--r--
8062348: langtools tests should close file manager (group 1) Reviewed-by: darcy
/*
 * @test  /nodynamiccopyright/
 * @bug 8020689
 * @summary Making sure the LineNumberTable entry is correctly generated for the leading method invocation in the else section
 * @compile T8020689.java
 * @run main T8020689
 */

public class T8020689 {

    public static void main(String... args) {
        if (args.length > 0) {
            a();
        } else {
            b();
        }
    }

    static void a() {
    }

    static void b() {
        assertLine(15);
    }

    public static void assertLine(int expectedline) {
        Exception e = new Exception("expected line#: " + expectedline);
        int myline = e.getStackTrace()[2].getLineNumber();
        if( myline != expectedline) {
            throw new RuntimeException("Incorrect line number " +
                    "expected: " + expectedline +
                    ", got: " + myline, e);
        }
        System.out.format("Got expected line number %d correct %n", myline);
    }
}