Class TypeUtils
- java.lang.Object
-
- com.offbynull.coroutines.instrumenter.asm.TypeUtils
-
public final class TypeUtils extends java.lang.ObjectUtility class to provide common functionality for types.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateTypeUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.util.LinkedHashSet<java.lang.String>flattenHierarchy(ClassInformationRepository repo, java.lang.String type)private static voidflattenHierarchy(ClassInformationRepository repo, java.lang.String type, java.util.LinkedHashSet<java.lang.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)
-
-
-
Method Detail
-
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
private static java.util.LinkedHashSet<java.lang.String> flattenHierarchy(ClassInformationRepository repo, java.lang.String type)
-
flattenHierarchy
private static void flattenHierarchy(ClassInformationRepository repo, java.lang.String type, java.util.LinkedHashSet<java.lang.String> ret)
-
-