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

8238080: FXMLLoader: if script engines implement javax.script.Compilable compile scripts #192

Closed
Closed
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5c33d59
fix for <https://bugs.openjdk.java.net/browse/JDK-8234959> JDK-823495…
ronyfla Feb 22, 2020
e251996
test for <https://bugs.openjdk.java.net/browse/JDK-8234959> JDK-82349…
ronyfla Feb 22, 2020
6e4df77
Removed/replaced white space.
ronyfla Feb 22, 2020
3053959
Removed/replaced white space.
ronyfla Feb 22, 2020
8cf0a6e
Incorporating Kevin Rushfort's review comments to this WIP.
ronyfla Feb 27, 2020
2db3171
Incorporating Kevin Rushfort's review comments to this WIP.
ronyfla Feb 27, 2020
799a814
Merge branch 'scripttest' into script as requested by reviewer Kevin
ronyfla Feb 27, 2020
8821d25
Removed executable bit from gradlew as this causes an error when
ronyfla Feb 27, 2020
a42fed5
corrected wrong test string
ronyfla Feb 27, 2020
c4d7cb1
JDK-8238080 : FXMLLoader: if script engines implement javax.script.Co…
ronyfla Feb 28, 2020
119e61b
Merge master
ronyfla Mar 31, 2020
0667a8d
Merge master, correct ovesights.
ronyfla Mar 31, 2020
ea0a8f2
appease the jcheck script, such that that important trailing Whitespa…
ronyfla Mar 31, 2020
a33284a
Correct error constant.
ronyfla Apr 2, 2020
316580b
add compile process instruction to control compilation of compilable …
ronyfla Apr 17, 2020
8dd9b00
Compile by default, have fallback if compilation fails, adapt/add tes…
ronyfla Apr 18, 2020
ef93a8f
Make message more pregnant.
ronyfla Apr 20, 2020
7c3c241
Always supply the script's filename in the error message first to fur…
ronyfla Apr 20, 2020
a97e758
Correct ModuleLauncherTest (remove non-existing test), correct format…
ronyfla Apr 20, 2020
c2f5c29
Revert temporary rename of test method.
ronyfla Apr 20, 2020
59b66d3
Make sure we test the default behaviour to compile script by leaving …
ronyfla Apr 22, 2020
494b888
Correct typo, replace tabs, remove trailing blanks.
ronyfla May 12, 2020
a037496
Add missing language processing instruction.
ronyfla May 12, 2020
44b0f9f
Document the compile processing instruction for scripts.
ronyfla May 12, 2020
59a16c9
Reword the compile processing instructions (replace 'Hint' with 'Note…
ronyfla May 13, 2020
ca4b818
Merge remote-tracking branch 'upstream/master' into scriptCompilableP…
ronyfla Jun 3, 2020
7ef1bd6
Updates to meet Kevin's comment in PR 192 as of May 27th.
ronyfla Jun 4, 2020
f2ea3d0
Incorporating Kevin's review comments (final int, fix for loop test, …
ronyfla Jun 19, 2020
f7f9cac
Incorporating Kevin's review comments.
ronyfla Jun 26, 2020
52da8a3
Incorporating Kevin's review comments (overlooked some places).
ronyfla Jun 27, 2020
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -1111,4 +1111,3 @@ <h2><a id="deploy_as_module">Deploying an Application as a Module</a></h2>
</p>
</body>
</html>

@@ -1572,9 +1572,9 @@ public void processStartElement() throws IOException {
char[] charBuffer = new char[bufSize];
int n;
do {
n = scriptReader.read(charBuffer,0,bufSize);
if (n > 0) {
sb.append(new String(charBuffer,0,n));
n = scriptReader.read(charBuffer,0,bufSize);
if (n > 0) {
sb.append(new String(charBuffer,0,n));
}
} while (n > -1);
script = sb.toString();
@@ -1591,18 +1591,19 @@ public void processStartElement() throws IOException {
try {
compiledScript=((Compilable) engine).compile(script);
} catch (ScriptException compileExc) {
Logging.getJavaFXLogger().warning(filename+": compiling caused \""+compileExc+"\", falling back to evaluating script in uncompiled mode");
Logging.getJavaFXLogger().warning(filename + ": compiling caused \"" + compileExc +
"\", falling back to evaluating script in uncompiled mode");
}
if (compiledScript != null) {
compiledScript.eval();
compiledScript.eval();
} else { // fallback to uncompiled mode
engine.eval(script);
engine.eval(script);
}
} else {
engine.eval(script);
engine.eval(script);
}
} catch (ScriptException exception) {
System.err.println(filename+": caused ScriptException");
System.err.println(filename + ": caused ScriptException");
exception.printStackTrace();
}
}
@@ -1630,18 +1631,19 @@ public void processEndElement() throws IOException {
try {
compiledScript=((Compilable) scriptEngine).compile(script);
} catch (ScriptException compileExc) {
Logging.getJavaFXLogger().warning(filename+": compiling caused \""+compileExc+"\", falling back to evaluating script in uncompiled mode");
Logging.getJavaFXLogger().warning(filename + ": compiling caused \"" + compileExc +
"\", falling back to evaluating script in uncompiled mode");
}
if (compiledScript != null) {
compiledScript.eval();
compiledScript.eval();
} else { // fallback to uncompiled mode
scriptEngine.eval(script);
scriptEngine.eval(script);
}
} else {
scriptEngine.eval(script);
scriptEngine.eval(script);
}
} catch (ScriptException exception) {
System.err.println(filename+": caused ScriptException\n"+exception.getMessage());
System.err.println(filename + ": caused ScriptException\n" + exception.getMessage());
}
}
}
@@ -1741,14 +1743,15 @@ public ScriptEventHandler(String script, ScriptEngine scriptEngine, String filen
this.scriptEngine = scriptEngine;
this.filename = filename;
if (scriptEngine instanceof Compilable && compileScript) {
try {
// supply the filename to the scriptEngine engine scope Bindings in case it is needed for compilation
scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE).put(scriptEngine.FILENAME, filename);
this.compiledScript = ((Compilable) scriptEngine).compile(script);
this.isCompiled = true;
} catch (ScriptException compileExc){
Logging.getJavaFXLogger().warning(filename+": compiling caused \""+compileExc+"\", falling back to evaluating script in uncompiled mode");
}
try {
// supply the filename to the scriptEngine engine scope Bindings in case it is needed for compilation
scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE).put(scriptEngine.FILENAME, filename);
this.compiledScript = ((Compilable) scriptEngine).compile(script);
this.isCompiled = true;
} catch (ScriptException compileExc) {
Logging.getJavaFXLogger().warning(filename + ": compiling caused \"" + compileExc +
"\", falling back to evaluating script in uncompiled mode");
}
}
}

@@ -1768,8 +1771,8 @@ public void handle(Event event) {
} else {
scriptEngine.eval(script, localBindings);
}
} catch (ScriptException exception){
throw new RuntimeException(filename+": caused ScriptException", exception);
} catch (ScriptException exception) {
throw new RuntimeException(filename + ": caused ScriptException", exception);
}
}
}
@@ -3634,5 +3637,3 @@ private static int getAccess(final int fullModifiers) {
}
}
}


@@ -284,5 +284,3 @@ static void assertCorrectInvocations() {
}
}
}


@@ -75,4 +75,3 @@ public String toDebugFormat(String indentation) {
return sb.toString();
}
}

@@ -31,8 +31,7 @@
import javax.script.ScriptEngine;
import javax.script.ScriptException;

public class RgfPseudoCompiledScript extends CompiledScript
{
public class RgfPseudoCompiledScript extends CompiledScript {
String code = null;
ScriptEngine scriptEngine = null;

@@ -50,11 +49,10 @@ public Object eval(ScriptContext context) throws ScriptException {
}

public Object eval() throws ScriptException {
return scriptEngine.eval("RgfPseudoCompiledScript.eval(): " + code );
return scriptEngine.eval("RgfPseudoCompiledScript.eval(): " + code );
}

public ScriptEngine getEngine() {
return scriptEngine;
}
}

@@ -139,5 +139,3 @@ String readReader(Reader reader) {
return sb.toString();
}
}


ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.