From 429627ad923c4ad26031679827c0cfc8f49c0801 Mon Sep 17 00:00:00 2001 From: Jeroen Frijters Date: Fri, 21 Apr 2006 09:41:44 +0000 Subject: 2006-04-21 Jeroen Frijters * java/lang/reflect/AccessibleObject.java: Implemented AnnotatedElement. (getAnnotation, getAnnotations, getDeclaredAnnotations, isAnnotationPresent): New methods. --- ChangeLog | 7 +++++++ java/lang/reflect/AccessibleObject.java | 27 +++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a9a7310af..a7adb0379 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-04-21 Jeroen Frijters + + * java/lang/reflect/AccessibleObject.java: + Implemented AnnotatedElement. + (getAnnotation, getAnnotations, getDeclaredAnnotations, + isAnnotationPresent): New methods. + 2006-04-17 Andrew John Hughes * java/lang/Enum.java: Documented. diff --git a/java/lang/reflect/AccessibleObject.java b/java/lang/reflect/AccessibleObject.java index 24418c971..fd46a53dc 100644 --- a/java/lang/reflect/AccessibleObject.java +++ b/java/lang/reflect/AccessibleObject.java @@ -1,5 +1,5 @@ /* java.lang.reflect.AccessibleObject - Copyright (C) 2001, 2005 Free Software Foundation, Inc. + Copyright (C) 2001, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,6 +38,8 @@ exception statement from your version. */ package java.lang.reflect; +import java.lang.annotation.Annotation; + /** * This class is the superclass of various reflection classes, and * allows sufficiently trusted code to bypass normal restrictions to @@ -53,9 +55,10 @@ package java.lang.reflect; * @see Method * @see ReflectPermission * @since 1.2 - * @status updated to 1.4 + * @status updated to 1.5 */ public class AccessibleObject + implements AnnotatedElement { /** * True if this object is marked accessible, which means the reflected @@ -156,4 +159,24 @@ public class AccessibleObject throw new SecurityException("Cannot make object accessible: " + this); this.flag = flag; } + + public T getAnnotation(Class annotationClass) + { + throw new AssertionError("Subclass must override this method"); + } + + public Annotation[] getAnnotations() + { + return getDeclaredAnnotations(); + } + + public Annotation[] getDeclaredAnnotations() + { + throw new AssertionError("Subclass must override this method"); + } + + public boolean isAnnotationPresent(Class annotationClass) + { + return getAnnotation(annotationClass) != null; + } } -- cgit v1.2.1