MCPcopy Create free account
hub / github.com/apache/shiro / ClassUtils

Class ClassUtils

lang/src/main/java/org/apache/shiro/lang/util/ClassUtils.java:41–417  ·  view source on GitHub ↗

Utility method library used to conveniently interact with Class es, such as acquiring them from the application ClassLoader s and instantiating Objects from them. @since 0.1

Source from the content-addressed store, hash-verified

39 * @since 0.1
40 */
41public final class ClassUtils {
42
43 /**
44 * Private internal log instance.
45 */
46 private static final Logger LOGGER = LoggerFactory.getLogger(ClassUtils.class);
47
48 private static final ThreadLocal<ClassLoader> ADDITIONAL_CLASS_LOADER = new ThreadLocal<>();
49
50 /**
51 * SHIRO-767: add a map to mapping primitive data type
52 */
53 private static final HashMap<String, Class<?>> PRIM_CLASSES
54 = new HashMap<>(8, 1.0F);
55
56 static {
57 PRIM_CLASSES.put("boolean", boolean.class);
58 PRIM_CLASSES.put("byte", byte.class);
59 PRIM_CLASSES.put("char", char.class);
60 PRIM_CLASSES.put("short", short.class);
61 PRIM_CLASSES.put("int", int.class);
62 PRIM_CLASSES.put("long", long.class);
63 PRIM_CLASSES.put("float", float.class);
64 PRIM_CLASSES.put("double", double.class);
65 PRIM_CLASSES.put("void", void.class);
66 }
67
68 /**
69 * @since 1.0
70 */
71 private static final ClassLoaderAccessor THREAD_CL_ACCESSOR = new ExceptionIgnoringAccessor() {
72 @Override
73 protected ClassLoader doGetClassLoader() throws Throwable {
74 return Thread.currentThread().getContextClassLoader();
75 }
76 };
77
78 /**
79 * @since 1.0
80 */
81 private static final ClassLoaderAccessor CLASS_LANG_CL_ACCESSOR = new ExceptionIgnoringAccessor() {
82 @Override
83 protected ClassLoader doGetClassLoader() throws Throwable {
84 return ClassUtils.class.getClassLoader();
85 }
86 };
87
88 /**
89 * @since 2.0.4
90 */
91 private static final ClassLoaderAccessor ADDITIONAL_CL_ACCESSOR = new ExceptionIgnoringAccessor() {
92 @Override
93 protected ClassLoader doGetClassLoader() throws Throwable {
94 ClassLoader cl = ADDITIONAL_CLASS_LOADER.get();
95 return cl != null ? cl : ClassUtils.class.getClassLoader();
96 }
97 };
98

Callers

nothing calls this directly

Calls 1

putMethod · 0.65

Tested by

no test coverage detected