Extending Abstract Class With Constructor Parameters

98 views
Skip to first unread message

Brad Grier

unread,
Apr 17, 2018, 10:21:37 PM4/17/18
to mozilla-rhino
Is it possible to use JavaAdapter to extend a Java abstract class with a non-default constructor?

Thanks.

Brad Grier

unread,
Apr 18, 2018, 12:40:24 AM4/18/18
to mozilla-rhino
I found the answer by looking at the rhino source. Pass in the java class object, followed by a single implementation of all the abstract methods, followed by the constructor parameters: 

var myObject = new JavaAdapter(MyObject, {
        // override abstract methods
doSomething: function(){ ... }
}, param1, param2); // constructer params here
Reply all
Reply to author
Forward
0 new messages