Tag: 类的类

检查Java类path中是否存在类而不运行其静态初始化程序?

如果我使用 try { Class.forName("my.package.Foo"); // it exists on the classpath } catch(ClassNotFoundException e) { // it does not exist on the classpath } “Foo”的静态初始化块被启动。 有没有一种方法来确定一个类“my.package.Foo”是否在类path上,而不是踢开它的静态初始化器?