changeset 52183:9d5b5f07af5a

8202936: Improve script engine support Reviewed-by: jlaskey, ahgross, rhalade
author sundar
date Fri, 18 May 2018 13:34:42 +0530
parents 279174cb3a24
children 27135de165ac
files src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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) {