Skip to content
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

define a default js engine #275

Open
davidcoutadeur opened this issue Apr 12, 2024 · 2 comments · Fixed by #276
Open

define a default js engine #275

davidcoutadeur opened this issue Apr 12, 2024 · 2 comments · Fixed by #276

Comments

@davidcoutadeur
Copy link
Contributor

Currently, there are multiple ways to use javascript in dataset/pivot transformation/conditions.

In next version 2.2, we'll have the new graalvm engine.

See also:

Multiple issues here:

  1. it's not completely clear to me what js engine is used by default in LSC now (for example if no tag js: is present). I suppose it is graalvm. We should document this, and especially in https://lsc-project.org/documentation/latest/scripting.html

For example, in lsc.xml, we sometimes have dataset like these:

        <dataset>
                <name>favouriteDrink</name>
                <forceValues>
                  <string><![CDATA[js:
                    var value = srcBean.getDatasetFirstValueById("favouriteDrink");
                    value.replace('-src', '-dst');
                ]]></string>
                </forceValues>
        </dataset>

But even if js: is specified here, the graaljs engine seems used for evaluation (as shown in the logs below)

We should clarify in documentation:

  • what engine is really used,
  • if it is launched in a compatibility mode or other specific behaviors...
  • describe the migration steps if the users of version 2.1 should migrate the script engine of their configuration to use a specific engine in 2.2.
  • describe the limitation of the js engine they are using
  1. it seems that the engine behind js: is not supporting the java object anymore in java 17. This leads to errors like this one:
17:15:07.338 [ldap2ldapSamePivotConversionTestTask-38] DEBUG org.lsc.utils.JScriptEvaluator - javax.script.ScriptException: org.graalvm.polyglot.PolyglotException: ReferenceError: java is not defined
javax.script.ScriptException: org.graalvm.polyglot.PolyglotException: ReferenceError: java is not defined
        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.toScriptException(GraalJSScriptEngine.java:503)
        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:480)
        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:446)
        at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:231)
        at org.lsc.utils.JScriptEvaluator.instanceEval(JScriptEvaluator.java:310)
        at org.lsc.utils.JScriptEvaluator.evalToString(JScriptEvaluator.java:104)
        at org.lsc.utils.ScriptingEvaluator.evalToString(ScriptingEvaluator.java:152)
        at org.lsc.AbstractSynchronize.transform(AbstractSynchronize.java:449)
        at org.lsc.AbstractSynchronize.getBean(AbstractSynchronize.java:430)
        at org.lsc.runnable.SynchronizeEntryRunner.run(SynchronizeEntryRunner.java:87)
        at org.lsc.runnable.SynchronizeEntryRunner.run(SynchronizeEntryRunner.java:45)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: org.graalvm.polyglot.PolyglotException: ReferenceError: java is not defined
        at <js>.:program(<eval>:1)
        at org.graalvm.sdk/org.graalvm.polyglot.Context.eval(Context.java:399)
        at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:478)
        ... 12 common frames omitted
17:15:07.339 [ldap2ldapSamePivotConversionTestTask-38] ERROR org.lsc.AbstractSynchronize - Error while synchronizing ID {favouritedrink=0003-src}: org.lsc.exception.LscServiceException: javax.script.ScriptException: org.graalvm.polyglot.PolyglotException: ReferenceError: java is not defined
17:15:07.339 [ldap2ldapSamePivotConversionTestTask-36] ERROR org.lsc.utils.JScriptEvaluator - Fail to compute expression: 
                        value.replace('-src', '-dst');
                 on unknown id !

Removing js: before each script in the lsc.xml used for test solves the issue here. Using explicitely gj: also solves the issue.

I'll push a PR for fixing the tests.

@artlog: as you have worked on graaljs engine, if you have some infos, don't hesite to share here.

@vikinghawk
Copy link

@davidcoutadeur does the team have an idea when 2.2 would be released?

@davidcoutadeur
Copy link
Contributor Author

@davidcoutadeur does the team have an idea when 2.2 would be released?

The team is working on the last issues. As this is a community project, we can't promise to release at a well-defined date. Though, there are not much issues for finishing the release (66% of issues closed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants