Avoid unnecessary Annotation array cloning in TypeDescriptor

Closes gh-32476

(cherry picked from commit 42a4f28962)
This commit is contained in:
Sam Brannen
2024-03-18 15:17:04 +01:00
parent d21100fea0
commit f6205d4207

View File

@@ -751,7 +751,7 @@ public class TypeDescriptor implements Serializable {
@Override
public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
for (Annotation annotation : getAnnotations()) {
for (Annotation annotation : this.annotations) {
if (annotation.annotationType() == annotationClass) {
return true;
}
@@ -763,7 +763,7 @@ public class TypeDescriptor implements Serializable {
@Nullable
@SuppressWarnings("unchecked")
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
for (Annotation annotation : getAnnotations()) {
for (Annotation annotation : this.annotations) {
if (annotation.annotationType() == annotationClass) {
return (T) annotation;
}