public static bool isMethodDeprecated(object method) { MethodWrapper mw = MethodWrapper.FromMethodOrConstructor(method); MethodBase mb = mw.GetMethod(); return(mb != null && mb.IsDefined(typeof(ObsoleteAttribute), false)); }
public static void init(MemberName self, object r) { #if !FIRST_PASS if (r is java.lang.reflect.Method || r is java.lang.reflect.Constructor) { MethodWrapper mw = MethodWrapper.FromMethodOrConstructor(r); int index = Array.IndexOf(mw.DeclaringType.GetMethods(), mw); if (index != -1) { // TODO self.setVMIndex(index); typeof(MemberName).GetField("vmindex", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(self, index); typeof(MemberName).GetField("vmtarget", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(self, mw.DeclaringType); int flags = (int)mw.Modifiers; if (r is java.lang.reflect.Method) { flags |= MemberName.IS_METHOD; } else { flags |= MemberName.IS_CONSTRUCTOR; } typeof(MemberName).GetField("flags", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(self, flags); } } else if (r is java.lang.reflect.Field) { FieldWrapper fw = FieldWrapper.FromField(r); int index = Array.IndexOf(fw.DeclaringType.GetFields(), fw); if (index != -1) { // TODO self.setVMIndex(index); typeof(MemberName).GetField("vmindex", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(self, index); typeof(MemberName).GetField("flags", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(self, (int)fw.Modifiers | MemberName.IS_FIELD); } } else { throw new InvalidOperationException(); } #endif }
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 }
public static object getDeclaredAnnotationsImpl(object methodOrConstructor) { MethodWrapper mw = MethodWrapper.FromMethodOrConstructor(methodOrConstructor); return(Java_java_lang_Class.AnnotationsToMap(mw.DeclaringType.GetClassLoader(), mw.DeclaringType.GetMethodAnnotations(mw))); }