Class TypeUtils
- java.lang.Object
-
- com.offbynull.coroutines.instrumenter.asm.TypeUtils
-
public final class TypeUtils extends java.lang.Object
Utility class to provide common functionality for types.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
TypeUtils()
-
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 void
flattenHierarchy(ClassInformationRepository repo, java.lang.String type, java.util.LinkedHashSet<java.lang.String> ret)
private static boolean
isArrayElementTypeAssignableFrom(ClassInformationRepository repo, org.objectweb.asm.Type t, org.objectweb.asm.Type u)
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.private static boolean
isObjectTypeAssignableFrom(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 aClassInformationRepository
object rather than requiring classes to be loaded up in to the JVM.Note that this code tries to mimic what ASM's original
SimpleVerifier
does 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 anObject
instance. That means that, for example, anObject
is 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:
true
if u is assignable to t (t = u
),false
otherwise
-
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)
-
-