Package com.strobel.assembler.metadata
Class MetadataHelper
- java.lang.Object
-
- com.strobel.assembler.metadata.MetadataHelper
-
public final class MetadataHelper extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
MetadataHelper.Adapter
static class
MetadataHelper.AdaptFailure
(package private) static class
MetadataHelper.LooseSameTypeVisitor
(package private) static class
MetadataHelper.SameTypeVisitor
(package private) static class
MetadataHelper.StrictSameTypeVisitor
-
Field Summary
-
Constructor Summary
Constructors Constructor Description MetadataHelper()
-
Method Summary
-
-
-
Field Detail
-
CONTAINS_TYPE_CACHE
private static final java.lang.ThreadLocal<java.util.HashSet<Pair<TypeReference,TypeReference>>> CONTAINS_TYPE_CACHE
-
ADAPT_CACHE
private static final java.lang.ThreadLocal<java.util.HashSet<Pair<TypeReference,TypeReference>>> ADAPT_CACHE
-
UPPER_BOUND_VISITOR
private static final TypeMapper<java.lang.Void> UPPER_BOUND_VISITOR
-
LOWER_BOUND_VISITOR
private static final TypeMapper<java.lang.Void> LOWER_BOUND_VISITOR
-
IS_SUBTYPE_VISITOR
private static final TypeRelation IS_SUBTYPE_VISITOR
-
CONTAINS_TYPE_VISITOR
private static final TypeRelation CONTAINS_TYPE_VISITOR
-
AS_SUPER_VISITOR
private static final TypeMapper<TypeReference> AS_SUPER_VISITOR
-
SUPER_VISITOR
private static final TypeMapper<java.lang.Void> SUPER_VISITOR
-
SAME_TYPE_VISITOR_LOOSE
private static final MetadataHelper.SameTypeVisitor SAME_TYPE_VISITOR_LOOSE
-
SAME_TYPE_VISITOR_STRICT
private static final MetadataHelper.SameTypeVisitor SAME_TYPE_VISITOR_STRICT
-
INTERFACES_VISITOR
private static final DefaultTypeVisitor<java.lang.Void,java.util.List<TypeReference>> INTERFACES_VISITOR
-
AS_SUBTYPE_VISITOR
private static final TypeMapper<TypeReference> AS_SUBTYPE_VISITOR
-
ERASE_VISITOR
private static final DefaultTypeVisitor<java.lang.Boolean,TypeReference> ERASE_VISITOR
-
IS_DECLARED_TYPE
private static final DefaultTypeVisitor<java.lang.Void,java.lang.Boolean> IS_DECLARED_TYPE
-
-
Method Detail
-
areGenericsSupported
public static boolean areGenericsSupported(TypeDefinition t)
-
getArrayRank
public static int getArrayRank(TypeReference t)
-
getOutermostEnclosingType
@Nullable public static TypeDefinition getOutermostEnclosingType(TypeReference innerType)
-
isEnclosedBy
public static boolean isEnclosedBy(TypeReference innerType, TypeReference outerType)
-
canReferenceTypeVariablesOf
public static boolean canReferenceTypeVariablesOf(TypeReference declaringType, TypeReference referenceSite)
-
findCommonSuperType
public static TypeReference findCommonSuperType(TypeReference type1, TypeReference type2)
-
doNumericPromotion
private static TypeReference doNumericPromotion(TypeReference leftType, TypeReference rightType)
-
findCommonSuperTypeCore
private static TypeReference findCommonSuperTypeCore(TypeReference type1, TypeReference type2)
-
getConversionType
public static ConversionType getConversionType(ICompoundType targetType, TypeReference source)
-
getConversionType
public static ConversionType getConversionType(TypeReference targetType, ICompoundType source)
-
getConversionType
public static ConversionType getConversionType(TypeReference target, TypeReference source)
-
conversionType0
private static ConversionType conversionType0(TypeReference target, TypeReference source, boolean processCompoundTypes)
-
getNumericConversionType
@NotNull public static ConversionType getNumericConversionType(TypeReference target, TypeReference source)
-
hasImplicitNumericConversion
public static boolean hasImplicitNumericConversion(TypeReference target, TypeReference source)
-
isConvertible
public static boolean isConvertible(TypeReference source, TypeReference target)
-
isConvertible
public static boolean isConvertible(TypeReference source, TypeReference target, boolean allowUnchecked)
-
isSubTypeUnchecked
private static boolean isSubTypeUnchecked(TypeReference t, TypeReference s)
-
isSubtypeUncheckedInternal
private static boolean isSubtypeUncheckedInternal(TypeReference t, TypeReference s)
-
isAssignableFrom
public static boolean isAssignableFrom(TypeReference target, TypeReference source)
-
isAssignableFrom
public static boolean isAssignableFrom(TypeReference target, TypeReference source, boolean allowUnchecked)
-
isSubType
public static boolean isSubType(TypeReference type, TypeReference baseType)
-
isBytecodeCastAssignable
public static boolean isBytecodeCastAssignable(TypeReference target, TypeReference castType)
-
isPrimitiveBoxType
public static boolean isPrimitiveBoxType(TypeReference type)
-
getBoxedTypeOrSelf
public static TypeReference getBoxedTypeOrSelf(TypeReference type)
-
getUnderlyingPrimitiveTypeOrSelf
@NotNull public static TypeReference getUnderlyingPrimitiveTypeOrSelf(@NotNull TypeReference type)
-
getDeclaredType
public static TypeReference getDeclaredType(TypeReference type)
-
getBaseType
public static TypeReference getBaseType(TypeReference type)
-
getInterfaces
public static java.util.List<TypeReference> getInterfaces(TypeReference type)
-
asSubType
public static TypeReference asSubType(TypeReference type, TypeReference baseType)
-
asSuper
public static TypeReference asSuper(TypeReference type, TypeReference subType)
-
getGenericSubTypeMappings
public static java.util.Map<TypeReference,TypeReference> getGenericSubTypeMappings(TypeReference type, TypeReference baseType)
-
asMemberOf
public static MethodReference asMemberOf(MethodReference method, TypeReference baseType)
-
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 java.util.List<TypeReference> checkTypeArguments(@Nullable IGenericParameterProvider owner, @NotNull java.util.List<TypeReference> typeArguments)
-
asMemberOf
public static FieldReference asMemberOf(FieldReference field, TypeReference baseType)
-
asMemberOf
public static TypeReference asMemberOf(TypeReference innerType, TypeReference baseType)
-
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, java.util.Map<TypeReference,TypeReference> substitutionsProvider)
-
isGenericSubstitutionNeeded
private static boolean isGenericSubstitutionNeeded(TypeReference type)
-
findMethods
public static java.util.List<MethodReference> findMethods(TypeReference type)
-
findMethods
public static java.util.List<MethodReference> findMethods(TypeReference type, Predicate<? super MethodReference> filter)
-
findMethods
public static java.util.List<MethodReference> findMethods(TypeReference type, Predicate<? super MethodReference> filter, boolean includeBridgeMethods)
-
findMethods
public static java.util.List<MethodReference> findMethods(TypeReference type, Predicate<? super MethodReference> filter, boolean includeBridgeMethods, boolean includeOverriddenMethods)
-
isOverloadCheckingRequired
public static boolean isOverloadCheckingRequired(MethodReference method)
-
isInterface
public static boolean isInterface(TypeReference t)
-
getLowerBound
public static TypeReference getLowerBound(TypeReference t)
-
getUpperBound
public static TypeReference getUpperBound(TypeReference t)
-
getElementType
public static TypeReference getElementType(TypeReference t)
-
getSuperType
public static TypeReference getSuperType(TypeReference t)
-
isSubTypeNoCapture
public static boolean isSubTypeNoCapture(TypeReference type, TypeReference baseType)
-
isSubType
public static boolean isSubType(TypeReference type, TypeReference baseType, boolean capture)
-
capture
private static TypeReference capture(TypeReference type)
-
adapt
public static java.util.Map<TypeReference,TypeReference> adapt(TypeReference source, TypeReference target)
-
adaptSelf
private static java.util.Map<TypeReference,TypeReference> adaptSelf(TypeReference t)
-
rewriteSupers
private static TypeReference rewriteSupers(TypeReference t)
-
containsType
public static boolean containsType(TypeReference t, TypeReference s)
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
public static boolean isSameType(TypeReference t, TypeReference s)
-
isSameType
public static boolean isSameType(TypeReference t, TypeReference s, boolean strict)
-
areSameTypes
public static boolean areSameTypes(java.util.List<? extends TypeReference> t, java.util.List<? extends TypeReference> s)
-
areSameTypes
public static boolean areSameTypes(java.util.List<? extends TypeReference> t, java.util.List<? extends TypeReference> s, boolean strict)
-
isCaptureOf
private static boolean isCaptureOf(TypeReference t, TypeReference s)
-
isSameWildcard
private static boolean isSameWildcard(TypeReference t, TypeReference s)
-
getTypeArguments
private static java.util.List<? extends TypeReference> getTypeArguments(TypeReference t)
-
containsType
private static boolean containsType(java.util.List<? extends TypeReference> t, java.util.List<? extends TypeReference> s)
-
containsTypeEquivalent
private static boolean containsTypeEquivalent(TypeReference t, TypeReference s)
-
containsTypeEquivalent
private static boolean containsTypeEquivalent(java.util.List<? extends TypeReference> t, java.util.List<? extends TypeReference> s)
-
containsTypeRecursive
private static boolean containsTypeRecursive(TypeReference t, TypeReference s)
-
arraySuperType
private static TypeReference arraySuperType(TypeReference t)
-
isRawType
public static boolean isRawType(TypeReference t)
-
getUnboundGenericParameterCount
public static int getUnboundGenericParameterCount(TypeReference t)
-
eraseRecursive
public static java.util.List<TypeReference> eraseRecursive(java.util.List<TypeReference> types)
-
eraseRecursive
public static TypeReference eraseRecursive(TypeReference type)
-
eraseNotNeeded
private static boolean eraseNotNeeded(TypeReference type)
-
erase
public static TypeReference erase(TypeReference type)
-
erase
public static TypeReference erase(TypeReference type, boolean recurse)
-
erase
public static MethodReference erase(MethodReference method)
-
classBound
private static TypeReference classBound(TypeReference t)
-
isOverride
public static boolean isOverride(MethodDefinition method, MethodReference ancestorMethod)
-
copyParameters
static java.util.List<ParameterDefinition> copyParameters(java.util.List<ParameterDefinition> parameters)
-
-