Utils.java
1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.osgi.framework.Bundle
*/
package com.adobe.granite.jmx.internal;
import java.util.HashMap;
import java.util.Map;
import org.osgi.framework.Bundle;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public abstract class Utils {
private static final Map<String, Class<?>> PRIMITIVES = new HashMap();
public static Class<?> loadClass(String type, Bundle bundle) throws ClassNotFoundException {
if (PRIMITIVES.containsKey(type)) {
return PRIMITIVES.get(type);
}
return bundle.loadClass(type);
}
public static Class<?> loadClass(String type, ClassLoader loader) throws ClassNotFoundException {
if (PRIMITIVES.containsKey(type)) {
return PRIMITIVES.get(type);
}
return loader.loadClass(type);
}
public static Class<?> getArrayType(Class<?> clazz) {
return clazz.isArray() ? Utils.getArrayType(clazz.getComponentType()) : clazz;
}
public static int getArrayDim(Class<?> clazz) {
return clazz.isArray() ? 1 + Utils.getArrayDim(clazz.getComponentType()) : 0;
}
static {
PRIMITIVES.put("boolean", Boolean.TYPE);
PRIMITIVES.put("byte", Byte.TYPE);
PRIMITIVES.put("short", Short.TYPE);
PRIMITIVES.put("int", Integer.TYPE);
PRIMITIVES.put("long", Long.TYPE);
PRIMITIVES.put("float", Float.TYPE);
PRIMITIVES.put("double", Double.TYPE);
}
}