RFR: 8238080: FXMLLoader: if script engines implement javax.script.Compilable compile scripts
Rony G.Flatscher
github.com+60214806+ronyfla at openjdk.java.net
Tue May 12 16:55:16 UTC 2020
On Mon, 20 Apr 2020 12:45:30 GMT, Rony G. Flatscher <github.com+60214806+ronyfla at openjdk.org> wrote:
> This WIP adds the ability for a fallback in case compilation of scripts fails, in which case a warning gets issued
> about this fact and evaluation of the script will be done without compilation. Because of the fallback scripts get
> compiled with this version by default. It extends PR 187 <https://github.com/openjdk/jfx/pull/187>. To further ease
> spotting scripts that cause a ScriptException a message in the form of "filename: caused ScriptException" gets added to
> the exception handling in either of the three locations: an error message, a stack trace or a wrap-up into a
> RuntimeException (having three different kinds of reporting ScriptExceptions may be questioned, however none of these
> tear down the FXML GUI).
============================ test units for: compile PI+fallback
tests/system/src/testscriptapp2/java/mymod/myapp2/FXMLScriptDeployment2Compile_Off.java
... use compile PI to set off compilation of scripts; each script code starts with "demo_02_"
tests/system/src/testscriptapp2/resources/mymod/myapp2/demo_02_off.fxml
... set compilation for scripts off ("<?compile false?>"), therefore no script gets compiled
---
tests/system/src/testscriptapp2/java/mymod/myapp2/FXMLScriptDeployment2Compile_Off_On.java
... alternatively uses compile PI to turn compilation off and on; the script code starts alternatively with "demo_02_"
and "RgfPseudoCompiledScript.eval(", depending on the state set with the PI
tests/system/src/testscriptapp2/resources/mymod/myapp2/demo_02_off_on.fxml
... starts out explicitly with "<?compile false?>" switching the state after each element containing a script
---
tests/system/src/testscriptapp2/java/mymod/myapp2/FXMLScriptDeployment2Compile_On.java
... no compile PI given, hence compilation of scripts is on; each script code starts with
"RgfPseudoCompiledScript.eval("
tests/system/src/testscriptapp2/resources/mymod/myapp2/demo_02_on.fxml
... no compile PI given, starts out to compile scripts by default
---
tests/system/src/testscriptapp2/java/mymod/myapp2/FXMLScriptDeployment2Compile_On_Off.java
... alternatively uses compile PI to turn compilation on and off; the script code starts alternatively with
"RgfPseudoCompiledScript.eval(", and "demo_02_" depending on the state set with the PI
tests/system/src/testscriptapp2/resources/mymod/myapp2/demo_02_on_off.fxml
... starts out explicitly with "<?compile true?>" switching the state after each element containing a script (sometimes
using PI "<?compile?>" to test setting it to true)
---
tests/system/src/testscriptapp2/java/mymod/myapp2/FXMLScriptDeployment2Compile_Fail_Compilation.java
... although compile scripts is on, none of the scripts get compiled as they all contain the string "FAIL COMPILATION"
which causes RgfPseudoScriptEngineCompilable.compile(...) to throw a ScriptException causing the fallback to be used;
all scripts therefore start with "demo_03_"
tests/system/src/testscriptapp2/resources/mymod/myapp2/demo_03_fail_compile.fxml
... explicitly turns on compilation (which is on by default anyway), adds "FAIL COMPILATION" to all inline scripts and
to all external scripts with the filename that starts with "demo_03_"
-------------
PR: https://git.openjdk.java.net/jfx/pull/192
More information about the openjfx-dev
mailing list