public static String typedescToSignature ( final String desc , final MutableInteger from ) { int fromIndex = from . get ( ) ; from . value ++ ; // default usage for most cases switch ( desc . charAt ( fromIndex ) ) { case ' ' : return "byte" ; case ' ' : return "char" ; case ' ' : return "double" ; case ' ' : return "float" ; case ' ' : return "int" ; case ' ' : return "long" ; case ' ' : return "short" ; case ' ' : return "boolean" ; case ' ' : return "void" ; case ' ' : int index = desc . indexOf ( ' ' , fromIndex ) ; if ( index < 0 ) { throw new IllegalArgumentException ( INVALID_TYPE_DESCRIPTION + desc ) ; } from . set ( index + 1 ) ; String str = desc . substring ( fromIndex + 1 , index ) ; return str . replace ( ' ' , ' ' ) ; case ' ' : return desc . substring ( from . value ) ; case ' ' : StringBuilder brackets = new StringBuilder ( ) ; int n = fromIndex ; while ( desc . charAt ( n ) == ' ' ) { // count opening brackets brackets . append ( "[]" ) ; n ++ ; } from . value = n ; String type = typedescToSignature ( desc , from ) ; // the rest of the string denotes a `<field_type>' return type + brackets ; default : if ( from . value == 0 ) { throw new IllegalArgumentException ( INVALID_TYPE_DESCRIPTION + desc ) ; } // generics! return desc . substring ( from . value ) ; } }
Returns java - like signature of a bytecode - like description . Only first description is parsed .