Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

security issue

 
Mike Croteau
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the Reflection API, trying to obtain class information. Displaying in an applet, when using the .getDeclaredMethods or .getDeclaredFields, I come across a Security Exception error. How do I get around this? Thanks in advance!


Here is sample code which I think is throwing the Exception:

public String getPublicMethods(String a) throws ClassNotFoundException{

this.initializeVariable(a);
sb.append(PB + MTD);
sb.append(HEADER);
Method[] theMethods = clas.getDeclaredMethods();
for (int i = 0; i < theMethods.length; i++) {
mod = theMethods[i].getModifiers();
Modifier modifier = new Modifier();
if(modifier.isPublic(mod)) {
methodName = theMethods[i].getName();
returnType = theMethods[i].getReturnType().getName();
sb.append(" " + returnType + " " + methodName + " (");

Class[] parameterTypes = theMethods[i].getParameterTypes();
boolean first = true;
for (int k = 0; k < parameterTypes.length; k ++) {
if(first) {
sb.append(parameterTypes[k].getName());
first = false;
} else {
sb.append(", " +parameterTypes[k].getName());
}
}
sb.append(" )\n");
}
}
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For security reasons, applets aren't allowed to do a number of things, including use of the Reflection API. If you really need to do this, then the two principal ways around that -applet signing, and altering the local security policy- are described here.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic