getSuperclass() private method

private getSuperclass ( ) : global::java.lang.Class
return global::java.lang.Class
Exemplo n.º 1
0
        internal static GType RegisterClass(Class clazz, TypeRegistration registration)
        {
            if (knownClasses.ContainsKey(clazz))
            {
                GType known = knownClasses[clazz];
                if (registration != null)
                {
                    known.Registration = registration;
                }
                return known;
            }
            var res = new GType();
            if (clazz.isArray())
            {
                res.ArrayElement = RegisterClass(clazz.getComponentType(), null);
                res.IsArray = true;
                string array = "[]";
                Class comp = clazz.getComponentType();
                while (comp.isArray())
                {
                    array += "[]";
                    comp = comp.getComponentType();
                }
                res.LowerName = ((string) comp.getName()).ToLowerInvariant() + array;
            }
            else
            {
                res.LowerName = ((string) clazz.getName()).ToLowerInvariant();
            }

            res.Attributes = 0;
            var classModifiers = (ModifierFlags) clazz.getModifiers();
            if ((classModifiers & ModifierFlags.Abstract) != 0)
            {
                res.IsAbstract = true;
                res.Attributes |= TypeAttributes.Abstract;
            }
            if ((classModifiers & ModifierFlags.Final) != 0)
            {
                res.IsFinal = true;
            }
            if ((classModifiers & ModifierFlags.Public) != 0)
            {
                res.Attributes |= TypeAttributes.Public;
            }
            else if ((classModifiers & ModifierFlags.Private) != 0)
            {
                res.Attributes |= TypeAttributes.NotPublic;
            }
            //TODO internal ?
            if (knownNames.ContainsKey(res.LowerName))
            {
                res = knownNames[res.LowerName];
            }
            if (res.Registration == null && registration != null)
            {
                res.Registration = registration;
            }
            res.JVMType = clazz;
            res.JVMFullName = clazz.getName();
            if (res.IsArray)
            {
                string array = "[]";
                Class comp = clazz.getComponentType();
                while (comp.isArray())
                {
                    array += "[]";
                    comp = comp.getComponentType();
                }
                res.JVMFullName = comp.getName() + array;
            }
            else
            {
                res.JVMFullName = clazz.getName();
            }
            res.IsJVMType = true;
            res.IsPrimitive = clazz.isPrimitive();
            res.IsException = Throwable._class.isAssignableFrom(clazz);
            res.IsInterface = clazz.isInterface();
            res.IsCLRProxy = clrProxyClass != null && clrProxyClass.isAssignableFrom(clazz);
            if (!res.IsCLRProxy)
            {
                res.IsJVMRealType = true;
            }
            Class superclass = clazz.getSuperclass();
            var isBaseClassPublic = superclass == null || ((ModifierFlags)superclass.getModifiers() & ModifierFlags.Public) != 0;
            if (superclass != null && res.Base == null
                && clazz != Object._class
                && clazz != Throwable._class
                && res.JVMFullName != "system.Object"
                && res.JVMFullName != "system.Exception"
                && isBaseClassPublic)
            {
                res.Base = RegisterClass(superclass);
            }
            List<Class> interfaces = new List<Class>(clazz.getInterfaces());
            if (!isBaseClassPublic)
            {
                interfaces.AddRange(superclass.getInterfaces());
                res.Base = RegisterClass(superclass.getSuperclass());
            }
            foreach (Class ifc in interfaces)
            {
                GType gifc = RegisterClass(ifc);
                if (!res.Interfaces.Contains(gifc))
                {
                    if (res.IsInterface && res.Base == null)
                    {
                        res.Base = gifc;
                    }
                    res.Interfaces.Add(gifc);
                    res.AllInterfaces.Add(gifc);
                }
            }
            Register(res);
            return res;
        }
Exemplo n.º 2
0
        private static RegistryRecord ResolveNew(Class clazz)
        {
            var fill = new List<Class> {clazz};
            Class current = clazz.getSuperclass();
            RegistryRecord res;
            while (!knownJVM.TryGetValue(current, out res))
            {
                fill.Add(current);
                current = current.getSuperclass();
            }

            if (current == Object._class)
            {
                RegistryRecord resi = null;
                // any interface is better than system.Object
                current = clazz;
                while (current != Object._class)
                {
                    foreach (Class ifc in current.getInterfaces())
                    {
                        if (knownJVM.TryGetValue(ifc, out resi))
                        {
                            res = resi;
                            fill = new List<Class> {clazz};
                            if (current != clazz)
                            {
                                fill.Add(current);
                            }
                            break;
                        }
                        foreach (Class ifcin in ifc.getInterfaces())
                        {
                            if (knownJVM.TryGetValue(ifcin, out resi))
                            {
                                res = resi;
                                fill = new List<Class> {clazz};
                                fill.Add(ifc);
                                if (current != clazz)
                                {
                                    fill.Add(current);
                                }
                                break;
                            }
                        }
                        if (resi != null)
                        {
                            break;
                        }
                    }
                    if (resi != null)
                    {
                        break;
                    }
                    current = current.getSuperclass();
                }
            }

            foreach (Class newType in fill)
            {
                knownJVM.Add(newType, res);
            }
            return res;
        }
Exemplo n.º 3
0
 private static bool testVirtual(GType type, Class clazz, Method method, bool create, bool isBaseClassPublic)
 {
     var modifiers = (ModifierFlags) method.getModifiers();
     bool isStatic = (modifiers & ModifierFlags.Static) != ModifierFlags.None;
     bool isVirtual = (modifiers & ModifierFlags.Final) == ModifierFlags.None;
     if (!clazz.isInterface())
     {
         if (create && !isStatic && isVirtual && !type.IsRootType)
         {
             Method smethod = clazz.getSuperclass().GetMethodNoThrow(method.getName(), method.GetSignature(), false);
             if (smethod != null && isBaseClassPublic)
             {
                 create = false;
             }
         }
     }
     return create;
 }