I used some code from another question to access the private field "classes" in the Java ClassLoader. This works fine, however when I move it to an applet it gets messed up with this exception: access denied (java.lang.RuntimePermission accessDeclaredMembers)
. I've done some searching and tried using PrivlegedExceptionAction to skip that, but it isn't working. So my question is this: is is possible to bypass this, and if not what is another way to get a list of classes?
Reflection Code:
final ClassLoader cLoader = getClass().getClassLoader();
final Field f = ClassLoader.class.getDeclaredField("classes");
AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws Exception {
f.setAccessible(true);
return null;}});
Vector<Class> classes = (Vector<Class>)f.get(cLoader);
cList.addAll(classes);