Skip to content

Commit

Permalink
Merge pull request #845 from seppl831/fix-annotation-search-performance
Browse files Browse the repository at this point in the history
improved annotation search performance
  • Loading branch information
stleary authored Jan 1, 2024
2 parents d7819a4 + 23ac2e7 commit ac7806d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/org/json/JSONObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -1865,6 +1865,10 @@ private static <A extends Annotation> A getAnnotation(final Method m, final Clas
}
}

//If the superclass is Object, no annotations will be found any more
if (c.getSuperclass().equals(Object.class))
return null;

try {
return getAnnotation(
c.getSuperclass().getMethod(m.getName(), m.getParameterTypes()),
Expand Down Expand Up @@ -1919,6 +1923,10 @@ private static int getAnnotationDepth(final Method m, final Class<? extends Anno
}
}

//If the superclass is Object, no annotations will be found any more
if (c.getSuperclass().equals(Object.class))
return -1;

try {
int d = getAnnotationDepth(
c.getSuperclass().getMethod(m.getName(), m.getParameterTypes()),
Expand Down

0 comments on commit ac7806d

Please sign in to comment.