1.1 --- a/src/jdk/nashorn/internal/runtime/Context.java Thu Jul 04 17:28:04 2013 +0200 1.2 +++ b/src/jdk/nashorn/internal/runtime/Context.java Fri Jul 05 14:38:04 2013 +0530 1.3 @@ -36,7 +36,6 @@ 1.4 import java.io.PrintWriter; 1.5 import java.lang.invoke.MethodHandle; 1.6 import java.lang.invoke.MethodHandles; 1.7 -import java.lang.reflect.Constructor; 1.8 import java.net.MalformedURLException; 1.9 import java.net.URL; 1.10 import java.security.AccessControlContext; 1.11 @@ -55,6 +54,7 @@ 1.12 import jdk.nashorn.internal.ir.FunctionNode; 1.13 import jdk.nashorn.internal.ir.debug.ASTWriter; 1.14 import jdk.nashorn.internal.ir.debug.PrintVisitor; 1.15 +import jdk.nashorn.internal.objects.Global; 1.16 import jdk.nashorn.internal.parser.Parser; 1.17 import jdk.nashorn.internal.runtime.options.Options; 1.18 1.19 @@ -123,8 +123,8 @@ 1.20 sm.checkPermission(new RuntimePermission("nashorn.setGlobal")); 1.21 } 1.22 1.23 - if (global != null && !(global instanceof GlobalObject)) { 1.24 - throw new IllegalArgumentException("global does not implement GlobalObject!"); 1.25 + if (global != null && !(global instanceof Global)) { 1.26 + throw new IllegalArgumentException("global is not an instance of Global!"); 1.27 } 1.28 1.29 setGlobalTrusted(global); 1.30 @@ -257,8 +257,7 @@ 1.31 new PrivilegedAction<ClassLoader>() { 1.32 @Override 1.33 public ClassLoader run() { 1.34 - final StructureLoader structureLoader = new StructureLoader(sharedLoader, Context.this); 1.35 - return new ScriptLoader(structureLoader, Context.this); 1.36 + return new ScriptLoader(sharedLoader, Context.this); 1.37 } 1.38 }); 1.39 this.errors = errors; 1.40 @@ -817,25 +816,12 @@ 1.41 new PrivilegedAction<ScriptLoader>() { 1.42 @Override 1.43 public ScriptLoader run() { 1.44 - // Generated code won't refer to any class generated by context 1.45 - // script loader and so parent loader can be the structure 1.46 - // loader -- which is parent of the context script loader. 1.47 - return new ScriptLoader((StructureLoader)scriptLoader.getParent(), Context.this); 1.48 + return new ScriptLoader(sharedLoader, Context.this); 1.49 } 1.50 }); 1.51 } 1.52 1.53 private ScriptObject newGlobalTrusted() { 1.54 - try { 1.55 - final Class<?> clazz = Class.forName("jdk.nashorn.internal.objects.Global", true, scriptLoader); 1.56 - final Constructor<?> cstr = clazz.getConstructor(Context.class); 1.57 - return (ScriptObject) cstr.newInstance(this); 1.58 - } catch (final Exception e) { 1.59 - printStackTrace(e); 1.60 - if (e instanceof RuntimeException) { 1.61 - throw (RuntimeException)e; 1.62 - } 1.63 - throw new RuntimeException(e); 1.64 - } 1.65 + return new Global(this); 1.66 } 1.67 }