Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved annotation search performance #845

Merged
merged 1 commit into from
Jan 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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