Skip to content

Commit

Permalink
Cache hasUnresolvableGenerics result for repeated checks
Browse files Browse the repository at this point in the history
Closes gh-30713

(cherry picked from commit 93218a0)
  • Loading branch information
jhoeller committed Jun 21, 2023
1 parent c7bc40d commit 5375f62
Showing 1 changed file with 12 additions and 0 deletions.
Expand Up @@ -133,6 +133,9 @@ public class ResolvableType implements Serializable {
@Nullable
private volatile ResolvableType[] generics;

@Nullable
private volatile Boolean unresolvableGenerics;


/**
* Private constructor used to create a new {@link ResolvableType} for cache key purposes,
Expand Down Expand Up @@ -545,6 +548,15 @@ public boolean hasUnresolvableGenerics() {
if (this == NONE) {
return false;
}
Boolean unresolvableGenerics = this.unresolvableGenerics;
if (unresolvableGenerics == null) {
unresolvableGenerics = determineUnresolvableGenerics();
this.unresolvableGenerics = unresolvableGenerics;
}
return unresolvableGenerics;
}

private boolean determineUnresolvableGenerics() {
ResolvableType[] generics = getGenerics();
for (ResolvableType generic : generics) {
if (generic.isUnresolvableTypeVariable() || generic.isWildcardWithoutBounds()) {
Expand Down

0 comments on commit 5375f62

Please sign in to comment.