mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +00:00
Class#getDeclaredClasses(): exclude inner classes of inner classes
Inner classes can have inner classes, but getDeclaredClasses() is supposed to list *only* the immediate inner classes. Example: if class Reflection contains a class Hello that contains a class World, Reflection.class.getDeclaredClasses() must not include World in its result. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
parent
b246804793
commit
0eb2d55da2
@ -415,7 +415,7 @@ public final class Class <T> implements Type, AnnotatedElement {
|
||||
byte[] inner = table[i].inner;
|
||||
if (inner != null && inner.length > 1) {
|
||||
String name = new String(inner, 0, inner.length - 1);
|
||||
if (name.startsWith(prefix)) {
|
||||
if (name.startsWith(prefix) && name.indexOf('$', prefix.length()) < 0) {
|
||||
Class innerClass = getClassLoader().loadClass(name);
|
||||
result[counter++] = innerClass;
|
||||
}
|
||||
|
@ -38,7 +38,9 @@ public class Reflection {
|
||||
if (! v) throw new RuntimeException();
|
||||
}
|
||||
|
||||
private static class Hello { }
|
||||
private static class Hello {
|
||||
private class World { }
|
||||
}
|
||||
|
||||
private static void innerClasses() throws Exception {
|
||||
Class c = Reflection.class;
|
||||
|
Loading…
Reference in New Issue
Block a user