How can i add code to a construtor of a javascript class. The code in Java is very simple:
public class MyObject extends SomeAbstractObject {
public MyObject() {
super();
System.out.println("hello");
}
}
I know that its possible to extend java class like this (let's assume i did some bindings):
var myJSClass= Java.extend(SomeAbstractObject.static
{methods i want to override}
})
But how can i replicate my java example in javascript and nashorn?
No, Nashorn generates constructors for the subclass - these can not be "customized". While you can override non-final methods by script functions, you can't "extend" constructors.