Sun.org.mozilla Rhino and Extending Java Abstract Classes

In the Rhino version for sun.org.mozilla, JavaAdapterit only accepts interfaces as its first argument instead of any other class according to this error message:

javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorExcep
tion: JavaAdapter: first arg should be interface Class (<Unknown source>#11) in
<Unknown source> at line number 11

Is there any way, no matter how hacked it is, to extend the abstract class (or the normal class for this) via Rhino?

Here is the violation code:

var j = new JavaAdapter(foo.bar.abstractClass, {
    field : "test",
    method : function () {
        print("on enable");
    }
});
+5
source share
1 answer

Another answer is correct for the Rhino version for Sun. This is not entirely clear from the wording of the question, if for you is the option of switching to the original (Mozilla) Rhino.

, Sun Rhino Java, " - , Mozilla JavaAdapter. Sun " JavaAdapter", , Mozilla, Java. Java- Mozilla : .

- , "JavaScript " OO " , Java". Sun , " JavaAdapter Java " (ibid) .

850 , Mozilla Rhino , !

+7

All Articles