-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
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
Question about integration of GraalJSScriptEngine as default script engine in FXMLLoader #83
Comments
So after little playing I downloaded version of GraalVM 1.0.0-rc10 and then create small test application to test integration of GraalJSScriptEngine with JavaFX. Actually I could see that FXMLLoader really taking GraalJSScriptEngine as default javascript engine instead of Nashorn (see pic.1 ). Anway throw exception when I try to call function with the basic javascript code. Let me explain the example. I have fxml file where I have create dummy FXML view with javascript which should set up text to label after the button in clicked. The example of FXML can be seen below.
After trying to load fxml view by FXMLoader is everything fine but when I click on test button I got this kind of error. Its seems that GraalJSScriptEngine does not work properly as Nashorn.
Thank in advance for any hints from your side. |
Hi @jvaca92 thanks for your question. I am unfamiliar with FXML - can you provide the code you are using somewhere so we can replicate? On the concrete error message you get: Graal.js does not allow to arbitrarily exchange data between threads, as this can lead to all kinds of data races. That is what the message is telling you: a value (a function) is passed from one Context (one instance of the JS engine) to another, which we don't allow like that. I am sure there is a solution to that problem, but again, it would be helpful if we could inspect your code (for instance, we allow sharing of code between context so you don't have to re-evaluate them in each single one, see https://www.graalvm.org/docs/graalvm-as-a-platform/embed/#enable-source-caching). For a more in-depth discussion, see e.g. #59. We are also working on more documentation how safe multithreading can be achieved on Graal.js, it should be available mid-January. Best, |
Hi @wirthi, Thank you for your response. Sorry for little delay but anyway I have created the sample project where you can replicate the error. You can find it here Best regards, See |
Hello there, I would like inform you that after doing some research I have reached solution how can be achieved to implement GraalJS as script engine for FXML. The solution can be seen in my example. Actually I have reached by LoaderListener where I have picked up all nodes which has attribute fx:id and then stored them in map. Then I have used Graal context where I have configure javascript engine with attribute to -Dpolyglot.js.nashorn-compat=true and inject stored nodes as member and then evaluate the js script with inejcted members. The result works as expected. I have also created the enhancement issue on Oracle here where can be expected that the GraalJS will be implemented in FXMLLoader in future, but its question of time when would be done. Anyway if somebody would be interested about the solution, then can be found here see. |
I would have question if would be possible integration of GraalJSScriptEngine as default javascript engine instead of Nashorn into FXMLLoader. Nowadays there is not possibilities to change script engine in FXMLLoader related to javascript.
Thanks is advance.
The text was updated successfully, but these errors were encountered: