Skip to content

Commit

Permalink
Enforce rawType to be a Class in ParameterizedTypeImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
panic08 committed Oct 12, 2024
1 parent 7e98ebd commit f03717f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gson/src/main/java/com/google/gson/internal/$Gson$Types.java
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,12 @@ private static final class ParameterizedTypeImpl implements ParameterizedType, S
private final Type[] typeArguments;

public ParameterizedTypeImpl(Type ownerType, Type rawType, Type... typeArguments) {
// TODO: Should this enforce that rawType is a Class? See JDK implementation of
// the ParameterizedType interface and https://bugs.openjdk.org/browse/JDK-8250659
requireNonNull(rawType);

if (!(rawType instanceof Class)) {
throw new IllegalArgumentException("rawType must be a Class type");
}

if (ownerType == null && requiresOwnerType(rawType)) {
throw new IllegalArgumentException("Must specify owner type for " + rawType);
}
Expand Down

0 comments on commit f03717f

Please sign in to comment.