I'm trying to implement scripting endpoint in our application, but I have a problem: Is it possible to instantiate an object that is instance of abstract class with implemented methods? In Java it will look like:
SimpleObject obj = new SimpleObject("contructor arg0") {
public void doCustomAction() {
System.out.println("Action");
}
}
SimpleObject is an abstract class with abstract method doCustomAction
How to do such thing via Java Scripting Engine? I'm trying to do in the following way:
obj1 = new SimpleObject("value1") {
doCustomAction : function() {
//Do smth.
}
}
But engine throws such exception:
javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException:
error instantiating (JavaAdapter: first arg should be interface Class (<Unknown source>#1)):
class SimpleObject is interface or abstract (<Unknown source>#1) in <Unknown source> at line number 1