Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Java Reflection problem in applet under Sun plugin and Netscape.

0 views
Skip to first unread message

JP Deckers

unread,
Apr 25, 2002, 7:46:42 AM4/25/02
to
Hello,

I want to be able to call a showDocument using reflection, i.e.:
--
Object o = getAppletContext();
Method myMethod = o.getClass().getMethod("showDocument",
new Class[]{URL.class});
myMethod.invoke(o, new Object[]{new URL(myUrl)});
---

Under Internet Explorer w/ MS JVM, this works fine, however,
under Netscape, I'll get the following error:
java.lang.IllegalAccessException: netscape/applet/MozillaAppletContext

With the plugin, I'll get:
java.security.AccessControlException: access denied
(java.lang.RuntimePermission
accessClassInPackage.sun.plugin.viewer.context)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:270)
at java.security.AccessController.checkPermission(AccessController.java:401)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:542)
at java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:1513)
at sun.applet.AppletSecurity.checkPackageAccess(AppletSecurity.java:166)
at java.lang.Class.checkMemberAccess(Class.java:1408)
at java.lang.Class.getMethod(Class.java:950)

How can I make this work under the Sun plugin and Netscape (MS already
works fine), without having users change any setting etc (so run out
of the box).

Jon Skeet

unread,
Apr 25, 2002, 8:49:07 AM4/25/02
to
JP Deckers <pier...@hotmail.com> wrote:
> I want to be able to call a showDocument using reflection, i.e.:

> Object o = getAppletContext();

> Method myMethod = o.getClass().getMethod("showDocument",
new Class[]{URL.class});
> myMethod.invoke(o, new Object[]{new URL(myUrl)});

Out of interest, why do you want to do this? If you can get the applet
context anyway, why not just use it directly?

More to the point, if you *do* use it directly, do you still get the
same exception?


[Please don't use sig separators in the middle of your posts, btw - on
readers which automatically trim anything below the separator, it makes
the post harder to reply to.]

--
Jon Skeet - <sk...@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too

JP Deckers

unread,
Apr 26, 2002, 2:17:31 AM4/26/02
to
Jon Skeet <sk...@pobox.com> wrote:

> > I want to be able to call a showDocument using reflection, i.e.:
> > Object o = getAppletContext();
> > Method myMethod = o.getClass().getMethod("showDocument",
> new Class[]{URL.class});
> > myMethod.invoke(o, new Object[]{new URL(myUrl)});
> Out of interest, why do you want to do this? If you can get the applet
> context anyway, why not just use it directly?

It's an obfuscation step.

Strange thing is it works under IE and under Opera w/ plugin. Under
Netscape/Mozilla it doesn't, so I guess those security-managers don't
allow this.

But I'm left wondering what I'm violating on which point.

> More to the point, if you *do* use it directly, do you still get the
> same exception?

Nopes, without reflection everything works fine.

--
Jean-Pierre Deckers
http://www.gamegateway.com/?usenet

0 new messages