提交 1a03eb16 authored 作者: Thomas Mueller's avatar Thomas Mueller

Get the caller using the "known good" method (not using getStackTrace()).

上级 f9cd5f7b
......@@ -1271,21 +1271,13 @@ public abstract class TestBase {
* @return the new test
*/
public static TestBase createCaller() {
return createCaller(new Exception().getStackTrace()[1].getClassName());
}
/**
* Create a new object of the given class.
*
* @param className the class name
* @return the new test
*/
public static TestBase createCaller(String className) {
org.h2.Driver.load();
try {
return (TestBase) Class.forName(className).newInstance();
return (TestBase) new SecurityManager() {
Class<?> clazz = getClassContext()[2];
}.clazz.newInstance();
} catch (Exception e) {
throw new RuntimeException("Can not create object " + className, e);
throw new RuntimeException(e);
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论