diff --git a/classpath/java/lang/Class.java b/classpath/java/lang/Class.java index ef38e6ec66..6e2708d39e 100644 --- a/classpath/java/lang/Class.java +++ b/classpath/java/lang/Class.java @@ -377,19 +377,18 @@ public final class Class implements Type, AnnotatedElement { } public Class[] getInterfaces() { - if (vmClass.interfaceTable != null) { - Classes.link(vmClass); - - int stride = (isInterface() ? 1 : 2); - Class[] array = new Class[vmClass.interfaceTable.length / stride]; - for (int i = 0; i < array.length; ++i) { - array[i] = SystemClassLoader.getClass - ((VMClass) vmClass.interfaceTable[i * stride]); + ClassAddendum addendum = vmClass.addendum; + if (addendum != null) { + Object[] table = addendum.interfaceTable; + if (table != null) { + Class[] array = new Class[table.length]; + for (int i = 0; i < table.length; ++i) { + array[i] = SystemClassLoader.getClass((VMClass) table[i]); + } + return array; } - return array; - } else { - return new Class[0]; } + return new Class[0]; } public native Class getEnclosingClass(); diff --git a/test/Reflection.java b/test/Reflection.java index 8a9f4de1cc..d20be272c4 100644 --- a/test/Reflection.java +++ b/test/Reflection.java @@ -269,6 +269,9 @@ public class Reflection { } catch (NoSuchMethodException e) { // cool } + + expect(C.class.getInterfaces().length == 1); + expect(C.class.getInterfaces()[0].equals(B.class)); } protected static class Baz { @@ -308,4 +311,8 @@ interface A { interface B extends A { } +class C implements B { + public void foo() { } +} + @interface Ann { }