Class TypeUtils
java.lang.Object
com.offbynull.coroutines.instrumenter.asm.TypeUtils
Utility class to provide common functionality for types.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static LinkedHashSet<String> flattenHierarchy(ClassInformationRepository repo, String type) private static voidflattenHierarchy(ClassInformationRepository repo, String type, LinkedHashSet<String> ret) private static booleanisArrayElementTypeAssignableFrom(ClassInformationRepository repo, org.objectweb.asm.Type t, org.objectweb.asm.Type u) static booleanisAssignableFrom(ClassInformationRepository repo, org.objectweb.asm.Type t, org.objectweb.asm.Type u) Checks to see if one type is assignable from another type.private static booleanisObjectTypeAssignableFrom(ClassInformationRepository repo, org.objectweb.asm.Type t, org.objectweb.asm.Type u)
-
Constructor Details
-
TypeUtils
private TypeUtils()
-
-
Method Details
-
isAssignableFrom
public static boolean isAssignableFrom(ClassInformationRepository repo, org.objectweb.asm.Type t, org.objectweb.asm.Type u) Checks to see if one type is assignable from another type. This method should be similar toClass.isAssignableFrom(java.lang.Class)(with some caveats, explained in next paragraph), but uses aClassInformationRepositoryobject rather than requiring classes to be loaded up in to the JVM.Note that this code tries to mimic what ASM's original
SimpleVerifierdoes to find out if two types are equal. The main difference between SimpleVerifier's code andClass.isAssignableFrom(java.lang.Class)is that SimpleVerifier will treat any interface instance as if it were anObjectinstance. That means that, for example, anObjectis assignable to aComparable(Comparable = Object) in the eyes of ASM's SimpleVerifier. Why this is the case has never been explained.- Parameters:
repo- repository to use for deriving class detailst- type being assigned fromu- type being assigned to- Returns:
trueif u is assignable to t (t = u),falseotherwise
-
isObjectTypeAssignableFrom
private static boolean isObjectTypeAssignableFrom(ClassInformationRepository repo, org.objectweb.asm.Type t, org.objectweb.asm.Type u) -
isArrayElementTypeAssignableFrom
private static boolean isArrayElementTypeAssignableFrom(ClassInformationRepository repo, org.objectweb.asm.Type t, org.objectweb.asm.Type u) -
flattenHierarchy
-
flattenHierarchy
private static void flattenHierarchy(ClassInformationRepository repo, String type, LinkedHashSet<String> ret)
-