本文整理了Java中com.google.common.reflect.Reflection.initialize
方法的一些代码示例,展示了Reflection.initialize
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Reflection.initialize
方法的具体详情如下:
包路径:com.google.common.reflect.Reflection
类名称:Reflection
方法名:initialize
[英]Ensures that the given classes are initialized, as described in JLS Section 12.4.2.
WARNING: Normally it's a smell if a class needs to be explicitly initialized, because static state hurts system maintainability and testability. In cases when you have no choice while inter-operating with a legacy framework, this method helps to keep the code less ugly.
[中]确保初始化给定的类,如JLS Section 12.4.2中所述。
警告:通常情况下,如果一个类需要显式初始化,这是一种气味,因为静态会损害系统的可维护性和可测试性。当您在与遗留框架交互操作时别无选择时,此方法有助于降低代码的丑陋程度。
代码示例来源:origin: google/guava
public void testInitialize() {
assertEquals("This test can't be included twice in the same suite.", 0, classesInitialized);
Reflection.initialize(A.class);
assertEquals(1, classesInitialized);
Reflection.initialize(
A.class, // Already initialized (above)
B.class, C.class);
assertEquals(3, classesInitialized);
}
代码示例来源:origin: glowroot/glowroot
Reflection.initialize(Container.class);
代码示例来源:origin: RS485/LogisticsPipes
crawlerVersion++;
Class glClass = GL11.class.getClassLoader().loadClass(nextGL);
com.google.common.reflect.Reflection.initialize(glClass);
almostEnd = false;
代码示例来源:origin: com.google.guava/guava-tests
public void testInitialize() {
assertEquals("This test can't be included twice in the same suite.", 0, classesInitialized);
Reflection.initialize(A.class);
assertEquals(1, classesInitialized);
Reflection.initialize(
A.class, // Already initialized (above)
B.class,
C.class);
assertEquals(3, classesInitialized);
}
代码示例来源:origin: com.facebook.presto/presto-bytecode
try {
for (Class<?> clazz : classes.values()) {
Reflection.initialize(clazz);
代码示例来源:origin: io.airlift/bytecode
Reflection.initialize(clazz);
内容来源于网络,如有侵权,请联系作者删除!