GetApplicationClassLoader() public method

public GetApplicationClassLoader ( ) : ClassLoader
return ClassLoader
Ejemplo n.º 1
0
		public static void Init(Context cx, Scriptable scope, bool @sealed)
		{
			ClassLoader loader = cx.GetApplicationClassLoader();
			Rhino.NativeJavaTopPackage top = new Rhino.NativeJavaTopPackage(loader);
			top.SetPrototype(GetObjectPrototype(scope));
			top.SetParentScope(scope);
			for (int i = 0; i != commonPackages.Length; i++)
			{
				NativeJavaPackage parent = top;
				for (int j = 0; j != commonPackages[i].Length; j++)
				{
					parent = parent.ForcePackage(commonPackages[i][j], scope);
				}
			}
			// getClass implementation
			IdFunctionObject getClass = new IdFunctionObject(top, FTAG, Id_getClass, "getClass", 1, scope);
			// We want to get a real alias, and not a distinct JavaPackage
			// with the same packageName, so that we share classes and top
			// that are underneath.
			string[] topNames = ScriptRuntime.GetTopPackageNames();
			NativeJavaPackage[] topPackages = new NativeJavaPackage[topNames.Length];
			for (int i_1 = 0; i_1 < topNames.Length; i_1++)
			{
				topPackages[i_1] = (NativeJavaPackage)top.Get(topNames[i_1], top);
			}
			// It's safe to downcast here since initStandardObjects takes
			// a ScriptableObject.
			ScriptableObject global = (ScriptableObject)scope;
			if (@sealed)
			{
				getClass.SealObject();
			}
			getClass.ExportAsScopeProperty();
			global.DefineProperty("Packages", top, ScriptableObject.DONTENUM);
			for (int i_2 = 0; i_2 < topNames.Length; i_2++)
			{
				global.DefineProperty(topNames[i_2], topPackages[i_2], ScriptableObject.DONTENUM);
			}
		}