コード例 #1
0
        internal static TypeWrapper GetTypeWrapperFromObject(object o)
        {
            TypeWrapper ghostType = GhostTag.GetTag(o);

            if (ghostType != null)
            {
                return(ghostType);
            }
            Type t = o.GetType();

            if (t.IsPrimitive || (ClassLoaderWrapper.IsRemappedType(t) && !t.IsSealed))
            {
                return(DotNetTypeWrapper.GetWrapperFromDotNetType(t));
            }
            for (; ;)
            {
                TypeWrapper tw = ClassLoaderWrapper.GetWrapperFromType(t);
                // if GetWrapperFromType returns null (or if tw.IsAbstract), that
                // must mean that the Type of the object is an implementation helper class
                // (e.g. an AtomicReferenceFieldUpdater or ThreadLocal instrinsic subclass)
                if (tw != null && (!tw.IsAbstract || tw.IsArray))
                {
                    return(tw);
                }
                t = t.BaseType;
            }
        }
コード例 #2
0
    private static int ProcessAssembly(Assembly assembly, bool continueOnError)
    {
        int rc = 0;

        foreach (Type t in assembly.GetTypes())
        {
            if (t.IsPublic &&
                !t.IsGenericTypeDefinition &&
                !AttributeHelper.IsHideFromJava(t) &&
                (!t.IsGenericType || !AttributeHelper.IsJavaModule(t.Module)))
            {
                TypeWrapper c;
                if (ClassLoaderWrapper.IsRemappedType(t) || t.IsPrimitive || t == Types.Void)
                {
                    c = DotNetTypeWrapper.GetWrapperFromDotNetType(t);
                }
                else
                {
                    c = ClassLoaderWrapper.GetWrapperFromType(t);
                }
                if (c != null)
                {
                    AddToExportList(c);
                }
            }
        }
        bool keepGoing;

        do
        {
            keepGoing = false;
            foreach (TypeWrapper c in new List <TypeWrapper>(todo.Values))
            {
                if (!done.ContainsKey(c.Name))
                {
                    keepGoing = true;
                    done.Add(c.Name, null);

                    try
                    {
                        ProcessClass(c);
                    }
                    catch (Exception x)
                    {
                        if (continueOnError)
                        {
                            rc = 1;
                            Console.WriteLine(x);
                        }
                        else
                        {
                            throw;
                        }
                    }
                    WriteClass(c);
                }
            }
        } while(keepGoing);
        return(rc);
    }
コード例 #3
0
        public static jlClass getClassFromTypeHandle(RuntimeTypeHandle handle, int rank)
        {
            Type t = Type.GetTypeFromHandle(handle);

            if (t.IsPrimitive || ClassLoaderWrapper.IsRemappedType(t) || t == typeof(void))
            {
                return(DotNetTypeWrapper.GetWrapperFromDotNetType(t).MakeArrayType(rank).ClassObject);
            }
            if (!IsVisibleAsClass(t))
            {
                return(null);
            }
            TypeWrapper tw = ClassLoaderWrapper.GetWrapperFromType(t);

            if (tw != null)
            {
                return(tw.MakeArrayType(rank).ClassObject);
            }
            return(null);
        }