-
Notifications
You must be signed in to change notification settings - Fork 905
Closed
Description
Given an arrow function passed to a forEach the intepreter crashes with the message:
org.mozilla.javascript.EvaluatorException: Cannot convert function to interface java.util.function.Consumer since it contains methods with different names (<script name>#<line number>)
The point is that the InterfaceAdapter:27 expects an interface with at least one method, and if many all called the same. Which makes sense prior to default keyword for interfaces. But given that Consumer interface now has a andThen default method InterfaceAdapter:27 finds that there are two methods called differently.
Rhino version: 1.7.10
JS code interpreted:
tc.getValues().forEach(function (value) {
if (value.get('XX').get() === 'xx') {
if (value.get('YY') === undefined) {
value.set('YY', new Date());
}
}
});
Where tc.getValues() returns a NativeArray.
Stack trace:
rg.mozilla.javascript.EvaluatorException: Cannot convert function to interface java.util.function.Consumer since it contains methods with different names (<script_name>#<line number>)
at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:77) ~[rhino-1.7.10.jar:1.7.10]
at org.mozilla.javascript.Context.reportRuntimeError(Context.java:998) ~[rhino-1.7.10.jar:1.7.10]
at org.mozilla.javascript.Context.reportRuntimeError(Context.java:1053) ~[rhino-1.7.10.jar:1.7.10]
at org.mozilla.javascript.Context.reportRuntimeError1(Context.java:1016) ~[rhino-1.7.10.jar:1.7.10]
at org.mozilla.javascript.InterfaceAdapter.create(InterfaceAdapter.java:52) ~[rhino-1.7.10.jar:1.7.10]
at org.mozilla.javascript.NativeJavaObject.createInterfaceAdapter(NativeJavaObject.java:681) ~[rhino-1.7.10.jar:1.7.10]
at org.mozilla.javascript.NativeJavaObject.coerceTypeImpl(NativeJavaObject.java:657) ~[rhino-1.7.10.jar:1.7.10]
at org.mozilla.javascript.Context.jsToJava(Context.java:1874) ~[rhino-1.7.10.jar:1.7.10]
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:191) ~[rhino-1.7.10.jar:1.7.10]
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32) ~[rhino-1.7.10.jar:1.7.10]
at org.mozilla.javascript.gen.<script_name>._c_script_0(<script_name>:<line numbe>) ~[na:na]
at org.mozilla.javascript.gen.<script_name>.call(<script_name>) ~[na:na]
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:405) ~[rhino-1.7.10.jar:1.7.10]
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3508) ~[rhino-1.7.10.jar:1.7.10]
at org.mozilla.javascript.gen.<script_name>.call(<script_name>) ~[na:na]
at org.mozilla.javascript.gen.<script_name>.exec(<script_name>) ~[na:na]
at org.mozilla.javascript.Context.evaluateString(Context.java:1262) ~[rhino-1.7.10.jar:1.7.10]
Metadata
Metadata
Assignees
Labels
No labels