mardi 27 juin 2023

Why upperBounds and lowerBounds of WildcardType are array in java?

Why upperBounds and lowerBounds of WildcardType are array in java?

// Only has a Number
? extends Number

T has two (Number and Serializable) but T is TypeVariable not WildcardType

? extends Number & Serializable

And in jdk implementation com.sun.beans.WildcardTypeImpl and sun.reflect.generics.reflectiveObjects.WildcardTypeImpl I see this code in toString():

for(int var3 = 0; var3 < var2.length; ++var3) {
            if (var3 > 0) {
                var1.append(" & ");
            }

            var1.append(var2[var3] instanceof Class ? ((Class)var2[var3]).getName() : var2[var3].toString());
        }

Why? Is this legal??? ? extends Number & Serializable

Same problem for rawType of ParameterizedType: Why return Type not Class?





Aucun commentaire:

Enregistrer un commentaire