diff options
| author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-09 19:58:05 +0000 |
|---|---|---|
| committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-09 19:58:05 +0000 |
| commit | 65bf3316cf384588453604be6b4f0ed3751a8b0f (patch) | |
| tree | 996a5f57d4a68c53473382e45cb22f574cb3e4db /libjava/java/lang/reflect/Field.java | |
| parent | 8fc56618a84446beccd45b80381cdfe0e94050df (diff) | |
| download | gcc-65bf3316cf384588453604be6b4f0ed3751a8b0f.tar.gz | |
Merged gcj-eclipse branch to trunk.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120621 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/lang/reflect/Field.java')
| -rw-r--r-- | libjava/java/lang/reflect/Field.java | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/libjava/java/lang/reflect/Field.java b/libjava/java/lang/reflect/Field.java index 134ff132ecf..61db14df576 100644 --- a/libjava/java/lang/reflect/Field.java +++ b/libjava/java/lang/reflect/Field.java @@ -41,6 +41,7 @@ package java.lang.reflect; import gnu.java.lang.ClassHelper; import gnu.java.lang.reflect.FieldSignatureParser; +import java.lang.annotation.Annotation; /** * The Field class represents a member variable of a class. It also allows @@ -88,7 +89,7 @@ public final class Field // The Class (or primitive TYPE) of this field. private Class type; - private static final int FIELD_MODIFIERS + static final int FIELD_MODIFIERS = Modifier.FINAL | Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC | Modifier.STATIC | Modifier.TRANSIENT | Modifier.VOLATILE; @@ -104,7 +105,7 @@ public final class Field * is a non-inherited member. * @return the class that declared this member */ - public Class getDeclaringClass() + public Class<?> getDeclaringClass() { return declaringClass; } @@ -158,7 +159,7 @@ public final class Field * Gets the type of this field. * @return the type of this field */ - public native Class getType(); + public native Class<?> getType(); /** * Compare two objects to see if they are semantically equivalent. @@ -733,15 +734,30 @@ public final class Field return p.getFieldType(); } + public <T extends Annotation> T getAnnotation(Class<T> annoClass) + { + Annotation[] annos = getDeclaredAnnotations(); + for (int i = 0; i < annos.length; ++i) + if (annos[i].annotationType() == annoClass) + return (T) annos[i]; + return null; + } + + public Annotation[] getDeclaredAnnotations() + { + Annotation[] result = getDeclaredAnnotationsInternal(); + if (result == null) + result = new Annotation[0]; + return result; + } + + private native Annotation[] getDeclaredAnnotationsInternal(); + /** * Return the String in the Signature attribute for this field. If there * is no Signature attribute, return null. */ - private String getSignature() - { - // FIXME: libgcj doesn't record Signature attributes yet. - return null; - } + private native String getSignature(); native void setByte (Class caller, Object obj, byte b, boolean checkFinal) throws IllegalArgumentException, IllegalAccessException; |
