javascript - sun.org.mozilla Rhino and extending Java abstract classes -
in sun.org.mozilla version of rhino, javaadapter
takes interfaces first argument instead of other kind of class according error message:
javax.script.scriptexception: sun.org.mozilla.javascript.internal.evaluatorexcep tion: javaadapter: first arg should interface class (<unknown source>#11) in <unknown source> @ line number 11
is there way, no matter how hacky, extend abstract class (or normal class matter) via rhino?
here offending code:
var j = new javaadapter(foo.bar.abstractclass, { field : "test", method : function () { print("on enable"); } });
the other answer correct sun version of rhino. it's not entirely clear phrasing of question if switching original (mozilla) rhino option or not.
specifically, when sun added rhino java, "a few components have been excluded due footprint , security reasons", , 1 of them mozilla's javaadapter. sun wrote own "javaadapter" smaller , simpler mozilla one, , can used implement single java interface. mozilla's original javaadapter has no such restriction: use implement abstract classes time.
it has nothing vague philosophical difference "javascript isn't 'oo' in same way java". sun thought "the uses of javaadapter extend java class or implement multiple interfaces rare" (ibid) , decided remove feature.
if it's acceptable ship 850kb jar file code, grab mozilla rhino , implement abstract classes want!
Comments
Post a Comment