Open lcanet opened 3 years ago
Hello,
When injecting java.lang.String instances into sandbox, they do not seems to be evaluated as native javascript strings, as strict equality operator (===) not recognizing them. For instance the following snippet
java.lang.String
RhinoSandbox sandbox = RhinoSandboxes.create(); sandbox.inject("fromJava", "Hello"); System.out.println(sandbox.eval("source", "fromJava === 'Hello'")); System.out.println(sandbox.eval("source", "fromJava == 'Hello'"));
Outputs "false", "true". Expected: "true", "true"
Thank you for your question!
I think Rhino creates string objects that are 'almost' like JS strings. An easy way to make the 'Java' strings more JS like, maybe something like:
(fromJava+"")
Would that work for you?
Hello,
When injecting
java.lang.String
instances into sandbox, they do not seems to be evaluated as native javascript strings, as strict equality operator (===) not recognizing them. For instance the following snippetOutputs "false", "true". Expected: "true", "true"