mirror of
https://github.com/corda/corda.git
synced 2025-01-08 14:03:06 +00:00
Merge pull request #345 from dicej/class-getinterfaces
fix Class.getInterfaces to return only declared interfaces
This commit is contained in:
commit
843a727ced
@ -377,19 +377,18 @@ public final class Class <T> implements Type, AnnotatedElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Class[] getInterfaces() {
|
public Class[] getInterfaces() {
|
||||||
if (vmClass.interfaceTable != null) {
|
ClassAddendum addendum = vmClass.addendum;
|
||||||
Classes.link(vmClass);
|
if (addendum != null) {
|
||||||
|
Object[] table = addendum.interfaceTable;
|
||||||
int stride = (isInterface() ? 1 : 2);
|
if (table != null) {
|
||||||
Class[] array = new Class[vmClass.interfaceTable.length / stride];
|
Class[] array = new Class[table.length];
|
||||||
for (int i = 0; i < array.length; ++i) {
|
for (int i = 0; i < table.length; ++i) {
|
||||||
array[i] = SystemClassLoader.getClass
|
array[i] = SystemClassLoader.getClass((VMClass) table[i]);
|
||||||
((VMClass) vmClass.interfaceTable[i * stride]);
|
}
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
return array;
|
|
||||||
} else {
|
|
||||||
return new Class[0];
|
|
||||||
}
|
}
|
||||||
|
return new Class[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public native Class getEnclosingClass();
|
public native Class getEnclosingClass();
|
||||||
|
@ -269,6 +269,9 @@ public class Reflection {
|
|||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
// cool
|
// cool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expect(C.class.getInterfaces().length == 1);
|
||||||
|
expect(C.class.getInterfaces()[0].equals(B.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static class Baz {
|
protected static class Baz {
|
||||||
@ -308,4 +311,8 @@ interface A {
|
|||||||
|
|
||||||
interface B extends A { }
|
interface B extends A { }
|
||||||
|
|
||||||
|
class C implements B {
|
||||||
|
public void foo() { }
|
||||||
|
}
|
||||||
|
|
||||||
@interface Ann { }
|
@interface Ann { }
|
||||||
|
Loading…
Reference in New Issue
Block a user