Class TypeUtils

java.lang.Object
com.offbynull.coroutines.instrumenter.asm.TypeUtils

public final class TypeUtils extends Object
Utility class to provide common functionality for types.
Author:
Kasra Faghihi
  • 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 to Class.isAssignableFrom(java.lang.Class) (with some caveats, explained in next paragraph), but uses a ClassInformationRepository 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 and Class.isAssignableFrom(java.lang.Class) is that SimpleVerifier will treat any interface instance as if it were an Object instance. That means that, for example, an Object is assignable to a Comparable (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 details
      t - type being assigned from
      u - type being assigned to
      Returns:
      true if u is assignable to t (t = u), false otherwise