Skip to content

Commit f2c0b30

Browse files
committed
Merge branch '6.0.x'
2 parents 601de66 + da37dee commit f2c0b30

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

spring-core/src/main/java/org/springframework/util/TypeUtils.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
*/
3737
public abstract class TypeUtils {
3838

39+
private static final Type[] IMPLICIT_LOWER_BOUNDS = { null };
40+
41+
private static final Type[] IMPLICIT_UPPER_BOUNDS = { Object.class };
42+
3943
/**
4044
* Check if the right-hand side type may be assigned to the left-hand side
4145
* type following the Java generics rules.
@@ -196,20 +200,14 @@ private static Type[] getLowerBounds(WildcardType wildcardType) {
196200
Type[] lowerBounds = wildcardType.getLowerBounds();
197201

198202
// supply the implicit lower bound if none are specified
199-
if (lowerBounds.length == 0) {
200-
lowerBounds = new Type[] { null };
201-
}
202-
return lowerBounds;
203+
return (lowerBounds.length == 0 ? IMPLICIT_LOWER_BOUNDS : lowerBounds);
203204
}
204205

205206
private static Type[] getUpperBounds(WildcardType wildcardType) {
206207
Type[] upperBounds = wildcardType.getUpperBounds();
207208

208209
// supply the implicit upper bound if none are specified
209-
if (upperBounds.length == 0) {
210-
upperBounds = new Type[] { Object.class };
211-
}
212-
return upperBounds;
210+
return (upperBounds.length == 0 ? IMPLICIT_UPPER_BOUNDS : upperBounds);
213211
}
214212

215213
public static boolean isAssignableBound(@Nullable Type lhsType, @Nullable Type rhsType) {

0 commit comments

Comments
 (0)