We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When nested JS execution, ScriptRuntime.hasTopCall(cx) is true and the ConsString returned by the else branch is not converted to a Java String.
rhino/rhino/src/main/java/org/mozilla/javascript/InterpretedFunction.java
Lines 91 to 107 in 3e899f6
rhino/rhino/src/main/java/org/mozilla/javascript/ContextFactory.java
Lines 381 to 385 in 3e899f6
Reproduce code:
public class Main { public static void main(String[] args) { var obj = new MyObject(); obj.evalJS("myObj.method1()"); System.out.println(obj.evalJS("var a = 'a'; a + 'b'").getClass().getName()); } }
public class MyObject { public void method1() { System.out.println(evalJS("var a = 'a'; a + 'b'").getClass().getName()); } public Object evalJS(String jsStr) { try (var cx = Context.enter()) { cx.setOptimizationLevel(-1); var scope = cx.initStandardObjects(); scope.put("myObj", scope, Context.javaToJS(this, scope)); return cx.evaluateString(scope, jsStr, "unknown source", 0, null); } } }
The text was updated successfully, but these errors were encountered:
You should not expect calls from Java into JavaScript that return a JavaScript string to be a Java String.
Instead expect CharSequence
Sorry, something went wrong.
@gbrail @rbri agree this isn't a bug, but working as expected?
Also see #247
No branches or pull requests
When nested JS execution, ScriptRuntime.hasTopCall(cx) is true and the ConsString returned by the else branch is not converted to a Java String.
rhino/rhino/src/main/java/org/mozilla/javascript/InterpretedFunction.java
Lines 91 to 107 in 3e899f6
rhino/rhino/src/main/java/org/mozilla/javascript/ContextFactory.java
Lines 381 to 385 in 3e899f6
Reproduce code:
The text was updated successfully, but these errors were encountered: