changeset 318:0946c8a60f39

8015814: loadWithNewGlobal needs to wrap createGlobal in AccessController.doPrivileged Reviewed-by: sundar Contributed-by: james.laskey@oracle.com
author jlaskey
date Mon, 03 Jun 2013 12:57:53 -0300
parents 2df08f4c531d
children 78113cda23bf
files src/jdk/nashorn/internal/runtime/Context.java
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk/nashorn/internal/runtime/Context.java	Mon Jun 03 11:16:33 2013 -0300
+++ b/src/jdk/nashorn/internal/runtime/Context.java	Mon Jun 03 12:57:53 2013 -0300
@@ -500,9 +500,21 @@
      *
      * @throws IOException if source cannot be found or loaded
      */
-    public Object loadWithNewGlobal(final Object from) throws IOException {
+    public Object loadWithNewGlobal(final Object from) throws IOException, RuntimeException {
         final ScriptObject oldGlobal = getGlobalTrusted();
-        final ScriptObject newGlobal = createGlobal();
+        final ScriptObject newGlobal = AccessController.doPrivileged(new PrivilegedAction<ScriptObject>() {
+           @Override
+           public ScriptObject run() {
+               try {
+                   return createGlobal();
+               } catch (final RuntimeException e) {
+                   if (Context.DEBUG) {
+                       e.printStackTrace();
+                   }
+                   throw e;
+               }
+           }
+        });
         setGlobalTrusted(newGlobal);
 
         try {