Closed dhavkuma closed 2 months ago
See https://rhino.github.io/tutorials/scripting_java/#calling-overloaded-methods for how to select which one you want to call
Thanks. @p-bakker. The doc you shared talks about function overloading.
One question still open to me is how does the regex in resource.getPath().replace(/\W/g, '').replace(/+/g, '_')
converts to a replace( function, string)
.
Code resource.getPath().replace(/\W/g, '').replace(/+/g, '_')
ERROR
Caused by: org.mozilla.javascript.EvaluatorException: The choice of Java method java.lang.String.replace matching JavaScript argument types (function,string) is ambiguous; candidate methods are: _ class java.lang.String replace(java.lang.CharSequence,java.lang.CharSequence)_ class java.lang.String replace(char,char) (/libs/screens/core/components/content/video/video.js#169) at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:77) at org.mozilla.javascript.Context.reportRuntimeError(Context.java:954) at org.mozilla.javascript.Context.reportRuntimeError(Context.java:1010) at org.mozilla.javascript.Context.reportRuntimeError4(Context.java:997) at org.mozilla.javascript.NativeJavaMethod.findFunction(NativeJavaMethod.java:468) at org.mozilla.javascript.NativeJavaMethod.findCachedFunction(NativeJavaMethod.java:262) at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:139) at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:42) [org.apache.servicemix.bundles.rhino:1.7.7.1_1] at org.mozilla.javascript.gen._libs_screens_core_components_content_video_video_js_20._c_anonymous_1(/libs/screens/core/components/content/video/video.js:169)