8015814: loadWithNewGlobal needs to wrap createGlobal in AccessController.doPrivileged
Reviewed-by: sundar
Contributed-by: james.laskey@oracle.com
--- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java Mon Jun 03 11:16:33 2013 -0300
+++ b/nashorn/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 {