/*
* @test /nodynamiccopyright/
* @bug 4209652 4363318
* @summary Basic test for chained exceptions & Exception.getStackTrace().
* @author Josh Bloch
*/
public class ChainedExceptions {
try {
a();
} catch(HighLevelException e) {
throw new RuntimeException("Mid depth");
throw new RuntimeException("Low depth");
throw new RuntimeException("Low cause != null");
}
}
static void a() throws HighLevelException {
try {
b();
} catch(MidLevelException e) {
throw new HighLevelException(e);
}
}
static void b() throws MidLevelException {
c();
}
static void c() throws MidLevelException {
try {
d();
} catch(LowLevelException e) {
throw new MidLevelException(e);
}
}
static void d() throws LowLevelException {
e();
}
static void e() throws LowLevelException {
throw new LowLevelException();
}
throw new RuntimeException("Class: " + e, t);
throw new RuntimeException("Method name: " + e, t);
throw new RuntimeException("File name: " + e, t);
if (e.getLineNumber() != n)
throw new RuntimeException("Line number: " + e, t);
}
}
}
}
}