java两次调用静态初始化程序 [英] java static initializer called twice
本文介绍了java两次调用静态初始化程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
static boolean isClassLoaded(String fullname) {
try {
Class.forName(fullname, false, Loader.instance().getModClassLoader());
return true;
} catch (Exception e) {
return false;
}
}
此方法是否有可能触发全名的静态初始值设定项? 我有两次调用静态初始化程序的问题. 当我尝试检查是否使用isClassLoaded加载的类并尝试使用该类时,由于构造函数调用了两次,因此出现错误. 任何人都知道Class.forName(fullname,false,Loader.instance().getModClassLoader())有什么问题; ?
does this method has potential to trigger fullname's static initializer ? i have problem with static initializer called twice. when i try to check if class loaded using isClassLoaded and try to use that class, i get error because of constructor called twice. anyone know what is problem with Class.forName(fullname, false, Loader.instance().getModClassLoader()); ?
推荐答案
第二个参数是一个名为"initialize"的标志.
The second parameter is a flag called "initialize".
查看全文