diff --git a/classpath/java/lang/reflect/Field.java b/classpath/java/lang/reflect/Field.java index 91ad0f9670..5b686a0fa2 100644 --- a/classpath/java/lang/reflect/Field.java +++ b/classpath/java/lang/reflect/Field.java @@ -225,7 +225,7 @@ public class Field extends AccessibleObject { } public T getAnnotation(Class class_) { - if (vmField.addendum.annotationTable != null) { + if (vmField.addendum != null && vmField.addendum.annotationTable != null) { Object[] table = (Object[]) vmField.addendum.annotationTable; for (int i = 0; i < table.length; ++i) { Object[] a = (Object[]) table[i]; diff --git a/test/Reflection.java b/test/Reflection.java index 306b6959c2..8d889837b4 100644 --- a/test/Reflection.java +++ b/test/Reflection.java @@ -47,8 +47,16 @@ public class Reflection { expect(Hello.class == inner[0]); } + private int egads; + + private static void annotations() throws Exception { + Field egads = Reflection.class.getDeclaredField("egads"); + expect(egads.getAnnotation(Deprecated.class) == null); + } + public static void main(String[] args) throws Exception { innerClasses(); + annotations(); Class system = Class.forName("java.lang.System"); Field out = system.getDeclaredField("out");