aoqi@0: /* aoqi@0: * @test /nodynamiccopyright/ aoqi@0: * @bug 7024096 aoqi@0: * @summary Stack trace has invalid line numbers aoqi@0: * @author Bruce Chapman aoqi@0: * @compile T7024096.java aoqi@0: * @run main T7024096 aoqi@0: */ aoqi@0: aoqi@0: public class T7024096 { aoqi@0: private static final int START = 14; // starting line number for the test aoqi@0: public static void main(String[] args) { aoqi@0: T7024096 m = new T7024096(); aoqi@0: m.nest(START); aoqi@0: m.nest(START + 1, m.nest(START + 1), m.nest(START + 1), aoqi@0: m.nest(START + 2), aoqi@0: m.nest(START + 3, m.nest(START + 3))); aoqi@0: } aoqi@0: aoqi@0: public T7024096 nest(int expectedline, T7024096... args) { aoqi@0: Exception e = new Exception("expected line#: " + expectedline); aoqi@0: int myline = e.getStackTrace()[1].getLineNumber(); aoqi@0: if( myline != expectedline) { aoqi@0: throw new RuntimeException("Incorrect line number " + aoqi@0: "expected: " + expectedline + aoqi@0: ", got: " + myline, e); aoqi@0: } aoqi@0: System.out.format("Got expected line number %d correct %n", myline); aoqi@0: return null; aoqi@0: } aoqi@0: }