Monday, 9 September 2013

Class.getClasses() not working with inherited classes from interface

Class.getClasses() not working with inherited classes from interface

Can someone explain why test() passes while testInheritance() not ?
public class IPanDeviceEnclosedClassesTest {
public static interface Root {
class Enclosed {}
}
public static interface Leaf extends Root {}
@Test
public void testInheritance() {
Class<?> enclosing = Leaf.class;
Class<?>[] enclosed = enclosing.getClasses();
assertNotEquals(0, enclosed.length);
}
@Test
public void test() {
Class<?> enclosing = Root.class;
Class<?>[] enclosed = enclosing.getClasses(); //
getDeclaredClasses() works as well
assertNotEquals(0, enclosed.length);
}
}

No comments:

Post a Comment