public static Class < ? > toClass ( Type type , ClassLoader classLoader ) throws ClassNotFoundException { switch ( type . getSort ( ) ) { case Type . VOID : return void . class ; case Type . BOOLEAN : return boolean . class ; case Type . CHAR : return char . class ; case Type . BYTE : return byte . class ; case Type . SHORT : return short . class ; case Type . INT : return int . class ; case Type . FLOAT : return float . class ; case Type . LONG : return long . class ; case Type . DOUBLE : return double . class ; case Type . ARRAY : Class < ? > clazz = toClass ( type . getElementType ( ) , classLoader ) ; return Array . newInstance ( clazz , 0 ) . getClass ( ) ; default : // case OBJECT: return Class . forName ( type . getClassName ( ) , false , classLoader ) ; } }
Convert an asm Type into a corresponding Class object requires a reference to a ClassLoader to be able to convert classnames to class objects .