@@ -10,31 +10,25 @@ private JavaScript() {
1010 }
1111
1212 public static void compileOrThrow (final String function ) {
13- try {
14- final Context context = Context .enter ();
15- context .setOptimizationLevel (-1 );
13+ try (Context context = Context .enter ()) {
14+ context .setInterpretedMode (true );
1615
1716 // If it doesn't compile it throws an exception here
1817 context .compileString (function , null , 1 , null );
19- } finally {
20- Context .exit ();
2118 }
2219 }
2320
2421 public static String run (final String function ,
2522 final String functionName ,
2623 final String ... parameters ) {
27- try {
28- final Context context = Context .enter ();
29- context .setOptimizationLevel (-1 );
24+ try (Context context = Context .enter ()) {
25+ context .setInterpretedMode (true );
3026 final ScriptableObject scope = context .initSafeStandardObjects ();
3127
3228 context .evaluateString (scope , function , functionName , 1 , null );
3329 final Function jsFunction = (Function ) scope .get (functionName , scope );
3430 final Object result = jsFunction .call (context , scope , scope , parameters );
3531 return result .toString ();
36- } finally {
37- Context .exit ();
3832 }
3933 }
4034
0 commit comments