8202936: Improve script engine support
authorsundar
Fri, 18 May 2018 13:34:42 +0530
changeset 52163 9d5b5f07af5a
parent 52162 279174cb3a24
child 52164 27135de165ac
8202936: Improve script engine support Reviewed-by: jlaskey, ahgross, rhalade
src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java	Mon May 14 09:05:20 2018 -0400
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java	Fri May 18 13:34:42 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1601,13 +1601,14 @@
             }
         }
 
-        switch (nameStr) {
-        case "context":
+        if ("context".equals(nameStr)) {
             return sctxt;
-        case "engine":
-            return global.engine;
-        default:
-            break;
+        } else if ("engine".equals(nameStr)) {
+            // expose "engine" variable only when there is no security manager
+            // or when no class filter is set.
+            if (System.getSecurityManager() == null || global.getClassFilter() == null) {
+                return global.engine;
+            }
         }
 
         if (self == UNDEFINED) {