public static Class < ? > erase ( Type type ) { if ( type instanceof Class < ? > ) { return ( Class < ? > ) type ; } else if ( type instanceof ParameterizedType ) { return ( Class < ? > ) ( ( ParameterizedType ) type ) . getRawType ( ) ; } else if ( type instanceof TypeVariable < ? > ) { TypeVariable < ? > tv = ( TypeVariable < ? > ) type ; if ( tv . getBounds ( ) . length == 0 ) return Object . class ; else return erase ( tv . getBounds ( ) [ 0 ] ) ; } else if ( type instanceof GenericArrayType ) { GenericArrayType aType = ( GenericArrayType ) type ; return GenericArrayTypeImpl . createArrayType ( erase ( aType . getGenericComponentType ( ) ) ) ; } else { // TODO at least support CaptureType here throw new RuntimeException ( "not supported: " + type . getClass ( ) ) ; } }
Returns the erasure of the given type .