Beispiel #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
    }
Beispiel #2
0
    internal static java.lang.annotation.Annotation FreezeOrWrapAttribute(java.lang.annotation.Annotation ann)
    {
        [email protected] attr = ann as [email protected];
        if (attr != null)
        {
#if DONT_WRAP_ANNOTATION_ATTRIBUTES
            attr.freeze();
#else
            // freeze to make sure the defaults are set
            attr.freeze();
            ann = sun.reflect.annotation.AnnotationParser.annotationForMap(attr.annotationType(), attr.getValues());
#endif
        }
        return(ann);
    }
Beispiel #3
0
        internal static object NewAnnotation(java.lang.ClassLoader classLoader, object definition)
        {
#if !FIRST_PASS
            java.lang.annotation.Annotation ann = null;
            try
            {
                ann = (java.lang.annotation.Annotation)[email protected](classLoader, definition);
            }
            catch (java.lang.TypeNotPresentException) { }
            if (ann != null && sun.reflect.annotation.AnnotationType.getInstance(ann.annotationType()).retention() == java.lang.annotation.RetentionPolicy.RUNTIME)
            {
                return(ann);
            }
#endif
            return(null);
        }
Beispiel #4
0
    public static object[][] getParameterAnnotationsImpl(object methodOrConstructor)
    {
#if FIRST_PASS
        return(null);
#else
        MethodWrapper mw     = MethodWrapper.FromMethodOrConstructor(methodOrConstructor);
        object[][]    objAnn = mw.DeclaringType.GetParameterAnnotations(mw);
        if (objAnn == null)
        {
            return(null);
        }
        java.lang.annotation.Annotation[][] ann = new java.lang.annotation.Annotation[objAnn.Length][];
        for (int i = 0; i < ann.Length; i++)
        {
            List <java.lang.annotation.Annotation> list = new List <java.lang.annotation.Annotation>();
            foreach (object obj in objAnn[i])
            {
                java.lang.annotation.Annotation a = obj as java.lang.annotation.Annotation;
                if (a != null)
                {
                    list.Add(Java_java_lang_Class.FreezeOrWrapAttribute(a));
                }
                else if (obj is IKVM.Attributes.DynamicAnnotationAttribute)
                {
                    a = (java.lang.annotation.Annotation)JVM.NewAnnotation(mw.DeclaringType.GetClassLoader().GetJavaClassLoader(), ((IKVM.Attributes.DynamicAnnotationAttribute)obj).Definition);
                    if (a != null)
                    {
                        list.Add(a);
                    }
                }
            }
            ann[i] = list.ToArray();
        }
        return(ann);
#endif
    }
Beispiel #5
0
 public static object[][] getParameterAnnotationsImpl(object methodOrConstructor)
 {
     #if FIRST_PASS
     return null;
     #else
     MethodWrapper mw = MethodWrapper.FromMethodOrConstructor(methodOrConstructor);
     object[][] objAnn = mw.DeclaringType.GetParameterAnnotations(mw);
     if (objAnn == null)
     {
         return null;
     }
     java.lang.annotation.Annotation[][] ann = new java.lang.annotation.Annotation[objAnn.Length][];
     for (int i = 0; i < ann.Length; i++)
     {
         List<java.lang.annotation.Annotation> list = new List<java.lang.annotation.Annotation>();
         foreach (object obj in objAnn[i])
         {
             java.lang.annotation.Annotation a = obj as java.lang.annotation.Annotation;
             if (a != null)
             {
                 list.Add(Java_java_lang_Class.FreezeOrWrapAttribute(a));
             }
             else if (obj is IKVM.Attributes.DynamicAnnotationAttribute)
             {
                 a = (java.lang.annotation.Annotation)JVM.NewAnnotation(mw.DeclaringType.GetClassLoader().GetJavaClassLoader(), ((IKVM.Attributes.DynamicAnnotationAttribute)obj).Definition);
                 if (a != null)
                 {
                     list.Add(a);
                 }
             }
         }
         ann[i] = list.ToArray();
     }
     return ann;
     #endif
 }