8139852: jjs interactive mode fails to work with security manager
authorsundar
Mon, 19 Oct 2015 15:49:21 +0530
changeset 33334 1c629852b339
parent 33333 0bad500ce4e0
child 33335 a46c85103868
8139852: jjs interactive mode fails to work with security manager Reviewed-by: attila, hannesw
nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/PackagesHelper.java
--- a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/PackagesHelper.java	Mon Oct 19 08:45:29 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/PackagesHelper.java	Mon Oct 19 15:49:21 2015 +0530
@@ -51,7 +51,11 @@
  */
 final class PackagesHelper {
     // JavaCompiler may be null on certain platforms (eg. JRE)
-    private static final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+    private static final JavaCompiler compiler;
+    static {
+        // Use javac only if security manager is not around!
+        compiler = System.getSecurityManager() == null? ToolProvider.getSystemJavaCompiler() : null;
+    }
 
     /**
      * Is Java package properties helper available?