I am currently facing a challenge in my JavaScript project using ES4X/Graal, where I need to extend a Java class. This Java class has methods with overloaded parameters that I must override. While I understand how to call a specific Java method by specifying the type in square brackets, it seems that there is no clear way to specify parameter types when overriding based on the Graal/Oracle/Nashorn documentation. For example:
package com.mycomp;
class A {
public void method(String parameter) {...}
public void method(int parameter) {...}
}
In JavaScript, calling these methods can be done as follows:
var a = Java.type("com.mycomp.A");
a["method(String)"]("Some string parameter")
a["method(int)"](42)
a.method(stringOrIntParam)
However, during extension, the options are limited:
var ClassAFromJava = Java.type("com.mycom.A");
var MyJavaScriptClassA = Java.extend(ClassAFromJava, {
method: function(stringOrIntParam) {...}
}
I desire the ability to extend only one of the "method(...)" methods. Additionally, how would this work for overloaded methods with distinct return types?
Thank you!