示例#1
0
    internal static object AnnotationsToMap(ClassLoaderWrapper loader, object[] objAnn)
    {
#if FIRST_PASS
        return(null);
#else
        java.util.LinkedHashMap map = new java.util.LinkedHashMap();
        if (objAnn != null)
        {
            foreach (object obj in objAnn)
            {
                java.lang.annotation.Annotation a = obj as java.lang.annotation.Annotation;
                if (a != null)
                {
                    map.put(a.annotationType(), FreezeOrWrapAttribute(a));
                }
                else if (obj is IKVM.Attributes.DynamicAnnotationAttribute)
                {
                    a = (java.lang.annotation.Annotation)JVM.NewAnnotation(loader.GetJavaClassLoader(), ((IKVM.Attributes.DynamicAnnotationAttribute)obj).Definition);
                    if (a != null)
                    {
                        map.put(a.annotationType(), a);
                    }
                }
            }
        }
        return(map);
#endif
    }
示例#2
0
    public static java.lang.ClassLoader latestUserDefinedLoader()
    {
        // testing shows that it is cheaper the get the full stack trace and then look at a few frames than getting the frames individually
        StackTrace trace = new StackTrace(2, false);

        for (int i = 0; i < trace.FrameCount; i++)
        {
            StackFrame frame  = trace.GetFrame(i);
            MethodBase method = frame.GetMethod();
            if (method == null)
            {
                continue;
            }
            Type type = method.DeclaringType;
            if (type != null)
            {
                TypeWrapper tw = ClassLoaderWrapper.GetWrapperFromType(type);
                if (tw != null)
                {
                    ClassLoaderWrapper  classLoader = tw.GetClassLoader();
                    AssemblyClassLoader acl         = classLoader as AssemblyClassLoader;
                    if (acl == null || acl.GetAssembly(tw) != typeof(object).Assembly)
                    {
                        java.lang.ClassLoader javaClassLoader = classLoader.GetJavaClassLoader();
                        if (javaClassLoader != null)
                        {
                            return(javaClassLoader);
                        }
                    }
                }
            }
        }
        return(null);
    }
示例#3
0
 internal static object AnnotationsToMap(ClassLoaderWrapper loader, object[] objAnn)
 {
     #if FIRST_PASS
     return null;
     #else
     java.util.LinkedHashMap map = new java.util.LinkedHashMap();
     if (objAnn != null)
     {
         foreach (object obj in objAnn)
         {
             java.lang.annotation.Annotation a = obj as java.lang.annotation.Annotation;
             if (a != null)
             {
                 map.put(a.annotationType(), FreezeOrWrapAttribute(a));
             }
             else if (obj is IKVM.Attributes.DynamicAnnotationAttribute)
             {
                 a = (java.lang.annotation.Annotation)JVM.NewAnnotation(loader.GetJavaClassLoader(), ((IKVM.Attributes.DynamicAnnotationAttribute)obj).Definition);
                 if (a != null)
                 {
                     map.put(a.annotationType(), a);
                 }
             }
         }
     }
     return map;
     #endif
 }