Inheritance: global::java.lang.Object
コード例 #1
0
ファイル: java.lang.cs プロジェクト: labsnap/ikvm-1
    public static java.lang.Class forName0(string name, bool initialize, java.lang.ClassLoader loader, java.lang.Class caller)
    {
#if FIRST_PASS
        return(null);
#else
        //Console.WriteLine("forName: " + name + ", loader = " + loader);
        TypeWrapper tw = null;
        if (name.IndexOf(',') > 0)
        {
            // we essentially require full trust before allowing arbitrary types to be loaded,
            // hence we do the "createClassLoader" permission check
            java.lang.SecurityManager sm = java.lang.System.getSecurityManager();
            if (sm != null)
            {
                sm.checkPermission(new java.lang.RuntimePermission("createClassLoader"));
            }
            Type type = Type.GetType(name);
            if (type != null)
            {
                tw = ClassLoaderWrapper.GetWrapperFromType(type);
            }
            if (tw == null)
            {
                java.lang.Throwable.suppressFillInStackTrace = true;
                throw new java.lang.ClassNotFoundException(name);
            }
        }
        else
        {
            try
            {
                ClassLoaderWrapper classLoaderWrapper = ClassLoaderWrapper.GetClassLoaderWrapper(loader);
                tw = classLoaderWrapper.LoadClassByDottedName(name);
            }
            catch (ClassNotFoundException x)
            {
                java.lang.Throwable.suppressFillInStackTrace = true;
                throw new java.lang.ClassNotFoundException(x.Message);
            }
            catch (ClassLoadingException x)
            {
                throw x.InnerException;
            }
            catch (RetargetableJavaException x)
            {
                throw x.ToJava();
            }
        }
        java.security.ProtectionDomain pd;
        if (loader != null && caller != null && (pd = getProtectionDomain0(caller)) != null)
        {
            loader.checkPackageAccess(tw.ClassObject, pd);
        }
        if (initialize && !tw.IsArray)
        {
            try
            {
                tw.Finish();
            }
            catch (RetargetableJavaException x)
            {
                throw x.ToJava();
            }
            tw.RunClassInit();
        }
        return(tw.ClassObject);
#endif
    }