I am attempting extend a Java class through JavaScript Nashorn and then call method from the super class. Normally this wouldn't be an issue, though I'm overriding a method, that's being called by the super class' constructor.
Below is my code:
const MyClass = Java.type("com.example.MyClass")
const myInstance = new (Java.extend(MyClass, {
    myMethod: () => {
        const _super = Java.super(myInstance)
        _super.doWhatever()
    }
}))()
I set the variable myInstance to a new instance of the extended class, which again is being referenced from within the method myMethod, which is being called by the constructor, which causes myInstance to be undefined by the time myMethod is called.
I'm having trouble figuring out a way to fix this issue, without having to extend it through Java, which would cause issues in the environment I work in.
EDIT:
I have no way of changing the Java code within MyClass
 
    