Skip to content

Commit 23ac2e7

Browse files
author
Thomas Gress
committed
improved annotation search performance
1 parent d7819a4 commit 23ac2e7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main/java/org/json/JSONObject.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,6 +1865,10 @@ private static <A extends Annotation> A getAnnotation(final Method m, final Clas
18651865
}
18661866
}
18671867

1868+
//If the superclass is Object, no annotations will be found any more
1869+
if (c.getSuperclass().equals(Object.class))
1870+
return null;
1871+
18681872
try {
18691873
return getAnnotation(
18701874
c.getSuperclass().getMethod(m.getName(), m.getParameterTypes()),
@@ -1919,6 +1923,10 @@ private static int getAnnotationDepth(final Method m, final Class<? extends Anno
19191923
}
19201924
}
19211925

1926+
//If the superclass is Object, no annotations will be found any more
1927+
if (c.getSuperclass().equals(Object.class))
1928+
return -1;
1929+
19221930
try {
19231931
int d = getAnnotationDepth(
19241932
c.getSuperclass().getMethod(m.getName(), m.getParameterTypes()),

0 commit comments

Comments
 (0)