You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Cameron McCormack <ca...@aka.mcc.id.au> on 2006/02/09 02:10:12 UTC
Allowing use of JavaAdapter in script
Hi Thomas, others.
I want to be able to use Rhino's JavaAdapter to implement some Java
interfaces from script. I have a Java interface that looks like this:
public interface QcFloatListener {
void valueChanged();
}
and my script looks like this:
var o = {
valueChanged: function() { System.err.println('changed'); }
};
var l = new QcFloatListener(o);
However, I get a SecurityException telling me "Script() objects are not
supported". I find that this exception is thrown from
BatikSecurityController.createClassLoader if the passed in security
domain object is not a RhinoClassLoader. createClassLoader is called
from Rhino's JavaAdapter.createAdapterClass with this bit of code at the
end of the method:
ClassLoader parentLoader = cx.getApplicationClassLoader();
GeneratedClassLoader loader;
SecurityController sc = cx.getSecurityController();
if (sc == null) {
loader = cx.createClassLoader(parentLoader);
} else {
Object securityDomain = sc.getDynamicSecurityDomain(null);
loader = sc.createClassLoader(parentLoader, securityDomain);
}
Calling BatikSecurityController.getDynamicSecurityDomain with null
results in AccessController.getContext() being returned, which isn't a
RhinoClassLoader, hence the problem.
So: why doesn't Rhino's JavaAdapter class take the security domain from
whatever script tried to construct it? Is there a valid way to change
BatikSecurityController.createClassLoader to allow JavaAdapter to be
used? I'm not very familiar with the security code.
Thanks,
Cameron
--
Cameron McCormack ICQ: 26955922
cam (at) mcc.id.au MSN: cam (at) mcc.id.au
http://mcc.id.au/ JBR: heycam (at) jabber.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org