| Method from sun.reflect.misc.MethodUtil Detail: |
protected Class findClass(String name) throws ClassNotFoundException {
if (!name.startsWith(MISC_PKG)) {
throw new ClassNotFoundException(name);
}
String path = name.replace('.", '/").concat(".class");
URL res = getResource(path);
if (res != null) {
try {
return defineClass(name, res);
} catch (IOException e) {
throw new ClassNotFoundException(name, e);
}
} else {
throw new ClassNotFoundException(name);
}
}
|
public static Method getMethod(Class cls,
String name,
Class[] args) throws NoSuchMethodException {
ReflectUtil.checkPackageAccess(cls);
return cls.getMethod(name, args);
}
|
public static Method[] getMethods(Class cls) {
ReflectUtil.checkPackageAccess(cls);
return cls.getMethods();
}
|
protected PermissionCollection getPermissions(CodeSource codesource) {
PermissionCollection perms = super.getPermissions(codesource);
perms.add(new AllPermission());
return perms;
}
|
public static Method[] getPublicMethods(Class cls) {
// compatibility for update release
if (System.getSecurityManager() == null) {
return cls.getMethods();
}
Map< Signature, Method > sigs = new HashMap< Signature, Method >();
while (cls != null) {
boolean done = getInternalPublicMethods(cls, sigs);
if (done) {
break;
}
getInterfaceMethods(cls, sigs);
cls = cls.getSuperclass();
}
return sigs.values().toArray(new Method[sigs.size()]);
}
|
public static Object invoke(Method m,
Object obj,
Object[] params) throws InvocationTargetException, IllegalAccessException {
if (m.getDeclaringClass().equals(AccessController.class) ||
m.getDeclaringClass().equals(Method.class))
throw new InvocationTargetException(
new UnsupportedOperationException("invocation not supported"));
try {
return bounce.invoke(null, new Object[] {m, obj, params});
} catch (InvocationTargetException ie) {
Throwable t = ie.getCause();
if (t instanceof InvocationTargetException) {
throw (InvocationTargetException)t;
} else if (t instanceof IllegalAccessException) {
throw (IllegalAccessException)t;
} else if (t instanceof RuntimeException) {
throw (RuntimeException)t;
} else if (t instanceof Error) {
throw (Error)t;
} else {
throw new Error("Unexpected invocation error", t);
}
} catch (IllegalAccessException iae) {
// this can't happen
throw new Error("Unexpected invocation error", iae);
}
}
|
protected synchronized Class loadClass(String name,
boolean resolve) throws ClassNotFoundException {
// First, check if the class has already been loaded
ReflectUtil.checkPackageAccess(name);
Class c = findLoadedClass(name);
if (c == null) {
try {
c = findClass(name);
} catch (ClassNotFoundException e) {
// Fall through ...
}
if (c == null) {
c = getParent().loadClass(name);
}
}
if (resolve) {
resolveClass(c);
}
return c;
}
|