Package com.strobel.assembler.metadata
Class MetadataHelper
java.lang.Object
com.strobel.assembler.metadata.MetadataHelper
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
static class
(package private) static final class
(package private) static class
(package private) static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ThreadLocal
<HashSet<Pair<TypeReference, TypeReference>>> private static final TypeMapper
<TypeReference> private static final TypeMapper
<TypeReference> private static final ThreadLocal
<HashSet<Pair<TypeReference, TypeReference>>> private static final TypeRelation
private static final DefaultTypeVisitor
<Boolean, TypeReference> private static final DefaultTypeVisitor
<Void, List<TypeReference>> private static final DefaultTypeVisitor
<Void, Boolean> private static final TypeRelation
private static final TypeMapper
<Void> private static final MetadataHelper.SameTypeVisitor
private static final MetadataHelper.SameTypeVisitor
private static final TypeMapper
<Void> private static final TypeMapper
<Void> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Map
<TypeReference, TypeReference> adapt
(TypeReference source, TypeReference target) private static Map
<TypeReference, TypeReference> static boolean
static boolean
areSameTypes
(List<? extends TypeReference> t, List<? extends TypeReference> s) static boolean
areSameTypes
(List<? extends TypeReference> t, List<? extends TypeReference> s, boolean strict) private static TypeReference
static FieldReference
asMemberOf
(FieldReference field, TypeReference baseType) static MethodReference
asMemberOf
(MethodReference method, TypeReference baseType) static TypeReference
asMemberOf
(TypeReference innerType, TypeReference baseType) static TypeReference
asSubType
(TypeReference type, TypeReference baseType) static TypeReference
asSuper
(TypeReference type, TypeReference subType) static boolean
canReferenceTypeVariablesOf
(TypeReference declaringType, TypeReference referenceSite) private static TypeReference
capture
(TypeReference type) (package private) static List
<TypeReference> checkTypeArguments
(IGenericParameterProvider owner, List<TypeReference> typeArguments) private static TypeReference
static boolean
Check ift
containss
.private static boolean
containsType
(List<? extends TypeReference> t, List<? extends TypeReference> s) private static boolean
private static boolean
containsTypeEquivalent
(List<? extends TypeReference> t, List<? extends TypeReference> s) private static boolean
private static ConversionType
conversionType0
(TypeReference target, TypeReference source, boolean processCompoundTypes) (package private) static List
<ParameterDefinition> copyParameters
(List<ParameterDefinition> parameters) private static TypeReference
doNumericPromotion
(TypeReference leftType, TypeReference rightType) private static MethodReference
ensureReturnType
(MethodReference originalMethod, MethodReference method, TypeReference returnType, TypeReference declaringType) static MethodReference
erase
(MethodReference method) static TypeReference
erase
(TypeReference type) static TypeReference
erase
(TypeReference type, boolean recurse) private static boolean
eraseNotNeeded
(TypeReference type) static TypeReference
eraseRecursive
(TypeReference type) static List
<TypeReference> eraseRecursive
(List<TypeReference> types) static TypeReference
findCommonSuperType
(TypeReference type1, TypeReference type2) private static TypeReference
findCommonSuperTypeCore
(TypeReference type1, TypeReference type2) static List
<MethodReference> findMethods
(TypeReference type) static List
<MethodReference> findMethods
(TypeReference type, Predicate<? super MethodReference> filter) static List
<MethodReference> findMethods
(TypeReference type, Predicate<? super MethodReference> filter, boolean includeBridgeMethods) static List
<MethodReference> findMethods
(TypeReference type, Predicate<? super MethodReference> filter, boolean includeBridgeMethods, boolean includeOverriddenMethods) static int
static TypeReference
getBaseType
(TypeReference type) static TypeReference
static ConversionType
getConversionType
(ICompoundType targetType, TypeReference source) static ConversionType
getConversionType
(TypeReference targetType, ICompoundType source) static ConversionType
getConversionType
(TypeReference target, TypeReference source) static TypeReference
getDeclaredType
(TypeReference type) static TypeReference
static Map
<TypeReference, TypeReference> getGenericSubTypeMappings
(TypeReference type, TypeReference baseType) static List
<TypeReference> getInterfaces
(TypeReference type) static TypeReference
static ConversionType
getNumericConversionType
(TypeReference target, TypeReference source) static TypeDefinition
getOutermostEnclosingType
(TypeReference innerType) static TypeReference
private static List
<? extends TypeReference> static int
static TypeReference
static TypeReference
static boolean
hasImplicitNumericConversion
(TypeReference target, TypeReference source) static boolean
isAssignableFrom
(TypeReference target, TypeReference source) static boolean
isAssignableFrom
(TypeReference target, TypeReference source, boolean allowUnchecked) static boolean
isBytecodeCastAssignable
(TypeReference target, TypeReference castType) private static boolean
static boolean
isConvertible
(TypeReference source, TypeReference target) static boolean
isConvertible
(TypeReference source, TypeReference target, boolean allowUnchecked) static boolean
isEnclosedBy
(TypeReference innerType, TypeReference outerType) private static boolean
static boolean
static boolean
static boolean
isOverride
(MethodDefinition method, MethodReference ancestorMethod) static boolean
static boolean
static boolean
static boolean
isSameType
(TypeReference t, TypeReference s, boolean strict) private static boolean
static boolean
isSubType
(TypeReference type, TypeReference baseType) static boolean
isSubType
(TypeReference type, TypeReference baseType, boolean capture) static boolean
isSubTypeNoCapture
(TypeReference type, TypeReference baseType) private static boolean
private static boolean
private static TypeReference
private static MethodReference
specializeIfNecessary
(MethodReference originalMethod, MethodReference asMember, TypeReference baseType) static TypeReference
substituteGenericArguments
(TypeReference inputType, MethodReference substitutionsProvider) static TypeReference
substituteGenericArguments
(TypeReference inputType, TypeReference substitutionsProvider) static TypeReference
substituteGenericArguments
(TypeReference inputType, Map<TypeReference, TypeReference> substitutionsProvider)
-
Field Details
-
CONTAINS_TYPE_CACHE
-
ADAPT_CACHE
-
UPPER_BOUND_VISITOR
-
LOWER_BOUND_VISITOR
-
IS_SUBTYPE_VISITOR
-
CONTAINS_TYPE_VISITOR
-
AS_SUPER_VISITOR
-
SUPER_VISITOR
-
SAME_TYPE_VISITOR_LOOSE
-
SAME_TYPE_VISITOR_STRICT
-
INTERFACES_VISITOR
-
AS_SUBTYPE_VISITOR
-
ERASE_VISITOR
-
IS_DECLARED_TYPE
-
-
Constructor Details
-
MetadataHelper
public MetadataHelper()
-
-
Method Details
-
areGenericsSupported
-
getArrayRank
-
getOutermostEnclosingType
-
isEnclosedBy
-
canReferenceTypeVariablesOf
public static boolean canReferenceTypeVariablesOf(TypeReference declaringType, TypeReference referenceSite) -
findCommonSuperType
-
doNumericPromotion
-
findCommonSuperTypeCore
-
getConversionType
-
getConversionType
-
getConversionType
-
conversionType0
private static ConversionType conversionType0(TypeReference target, TypeReference source, boolean processCompoundTypes) -
getNumericConversionType
@NotNull public static ConversionType getNumericConversionType(TypeReference target, TypeReference source) -
hasImplicitNumericConversion
-
isConvertible
-
isConvertible
public static boolean isConvertible(TypeReference source, TypeReference target, boolean allowUnchecked) -
isSubTypeUnchecked
-
isSubtypeUncheckedInternal
-
isAssignableFrom
-
isAssignableFrom
public static boolean isAssignableFrom(TypeReference target, TypeReference source, boolean allowUnchecked) -
isSubType
-
isBytecodeCastAssignable
-
isPrimitiveBoxType
-
getBoxedTypeOrSelf
-
getUnderlyingPrimitiveTypeOrSelf
-
getDeclaredType
-
getBaseType
-
getInterfaces
-
asSubType
-
asSuper
-
getGenericSubTypeMappings
public static Map<TypeReference,TypeReference> getGenericSubTypeMappings(TypeReference type, TypeReference baseType) -
asMemberOf
-
specializeIfNecessary
private static MethodReference specializeIfNecessary(MethodReference originalMethod, MethodReference asMember, TypeReference baseType) -
ensureReturnType
private static MethodReference ensureReturnType(MethodReference originalMethod, MethodReference method, TypeReference returnType, TypeReference declaringType) -
checkTypeArguments
@NotNull static List<TypeReference> checkTypeArguments(@Nullable IGenericParameterProvider owner, @NotNull List<TypeReference> typeArguments) -
asMemberOf
-
asMemberOf
-
substituteGenericArguments
public static TypeReference substituteGenericArguments(TypeReference inputType, TypeReference substitutionsProvider) -
substituteGenericArguments
public static TypeReference substituteGenericArguments(TypeReference inputType, MethodReference substitutionsProvider) -
substituteGenericArguments
public static TypeReference substituteGenericArguments(TypeReference inputType, Map<TypeReference, TypeReference> substitutionsProvider) -
isGenericSubstitutionNeeded
-
findMethods
-
findMethods
public static List<MethodReference> findMethods(TypeReference type, Predicate<? super MethodReference> filter) -
findMethods
public static List<MethodReference> findMethods(TypeReference type, Predicate<? super MethodReference> filter, boolean includeBridgeMethods) -
findMethods
public static List<MethodReference> findMethods(TypeReference type, Predicate<? super MethodReference> filter, boolean includeBridgeMethods, boolean includeOverriddenMethods) -
isOverloadCheckingRequired
-
isInterface
-
getLowerBound
-
getUpperBound
-
getElementType
-
getSuperType
-
isSubTypeNoCapture
-
isSubType
-
capture
-
adapt
-
adaptSelf
-
rewriteSupers
-
containsType
Check ift
containss
.T
containsS
if:L(T) <: L(S) && U(S) <: U(T)
This relation is only used by isSubType(), that is:
C<S> <: C<T> if T contains S.
Because of F-bounds, this relation can lead to infinite recursion. Thus, we must somehow break that recursion. Notice that containsType() is only called from isSubType(). Since the arguments have already been checked against their bounds, we know:
U(S) <: U(T) if T is "super" bound (U(T) *is* the bound)
L(T) <: L(S) if T is "extends" bound (L(T) is bottom)
- Parameters:
t
- a types
- a type
-
isSameType
-
isSameType
-
areSameTypes
public static boolean areSameTypes(List<? extends TypeReference> t, List<? extends TypeReference> s) -
areSameTypes
public static boolean areSameTypes(List<? extends TypeReference> t, List<? extends TypeReference> s, boolean strict) -
isCaptureOf
-
isSameWildcard
-
getTypeArguments
-
containsType
private static boolean containsType(List<? extends TypeReference> t, List<? extends TypeReference> s) -
containsTypeEquivalent
-
containsTypeEquivalent
private static boolean containsTypeEquivalent(List<? extends TypeReference> t, List<? extends TypeReference> s) -
containsTypeRecursive
-
arraySuperType
-
isRawType
-
getUnboundGenericParameterCount
-
eraseRecursive
-
eraseRecursive
-
eraseNotNeeded
-
erase
-
erase
-
erase
-
classBound
-
isOverride
-
copyParameters
-