P
porter
Hi,
Could someone help me with this: I'm trying to get 2 applets to talk to
one another via reflection: I have 2 jar archives - one is third party,
the other is mine. The third party archive contains a class derived
from Applet (DerivedApplet say) that contains a public method called
'execute' and a public field called 'viewer'. I can use reflection to
run the execute() method just fine, but trying to use reflection to
gain access to the public field fails
// This works fine
Method meth =
app.getClass().getMethod("execute",types);
meth.invoke(app,new String("set color green"));
// But this fails at the cast below
Field field = app.getClass().getField("viewer");
// This prints out "xxx.Viewer"
System.out.println(
field.get(app).getClass().getName() );
Object ob = field.get(app);
// This throws ClassCastException
xxx.Viewer viewer = (xxx.Viewer) ob;
Can anyone see anything wrong? TIA
Jason
Could someone help me with this: I'm trying to get 2 applets to talk to
one another via reflection: I have 2 jar archives - one is third party,
the other is mine. The third party archive contains a class derived
from Applet (DerivedApplet say) that contains a public method called
'execute' and a public field called 'viewer'. I can use reflection to
run the execute() method just fine, but trying to use reflection to
gain access to the public field fails
// This works fine
Method meth =
app.getClass().getMethod("execute",types);
meth.invoke(app,new String("set color green"));
// But this fails at the cast below
Field field = app.getClass().getField("viewer");
// This prints out "xxx.Viewer"
System.out.println(
field.get(app).getClass().getName() );
Object ob = field.get(app);
// This throws ClassCastException
xxx.Viewer viewer = (xxx.Viewer) ob;
Can anyone see anything wrong? TIA
Jason