static int checkDesc(final String desc,final int start,final boolean canBeVoid){
  if (desc == null || start >= desc.length()) {
    throw new IllegalArgumentException("Invalid type descriptor (must not be null or empty)");
  }
  int index;
switch (desc.charAt(start)) {
case 'V':
    if (canBeVoid) {
      return start + 1;
    }
 else {
      throw new IllegalArgumentException("Invalid descriptor: " + desc);
    }
case 'Z':
case 'C':
case 'B':
case 'S':
case 'I':
case 'F':
case 'J':
case 'D':
  return start + 1;
case '[':
index=start + 1;
while (index < desc.length() && desc.charAt(index) == '[') {
++index;
}
if (index < desc.length()) {
return checkDesc(desc,index,false);
}
 else {
throw new IllegalArgumentException("Invalid descriptor: " + desc);
}
case 'L':
index=desc.indexOf(';',start);
if (index == -1 || index - start < 2) {
throw new IllegalArgumentException("Invalid descriptor: " + desc);
}
try {
checkInternalName(desc,start + 1,index,null);
}
 catch (IllegalArgumentException unused) {
throw new IllegalArgumentException("Invalid descriptor: " + desc);
}
return index + 1;
default :
throw new IllegalArgumentException("Invalid descriptor: " + desc);
}
}

static int checkDesc ( final String desc , final int start , final boolean canBeVoid ) { if ( desc == null || start >= desc . length ( ) ) { throw new IllegalArgumentException ( "Invalid type descriptor (must not be null or empty)" ) ; } int index ; switch ( desc . charAt ( start ) ) { case 'V' : if ( canBeVoid ) { return start + 1 ; } else { throw new IllegalArgumentException ( "Invalid descriptor: " + desc ) ; } case 'Z' : case 'C' : case 'B' : case 'S' : case 'I' : case 'F' : case 'J' : case 'D' : return start + 1 ; case '[' : index = start + 1 ; while ( index < desc . length ( ) && desc . charAt ( index ) == '[' ) { ++ index ; } if ( index < desc . length ( ) ) { return checkDesc ( desc , index , false ) ; } else { throw new IllegalArgumentException ( "Invalid descriptor: " + desc ) ; } case 'L' : index = desc . indexOf ( ';' , start ) ; if ( index == - 1 || index - start < 2 ) { throw new IllegalArgumentException ( "Invalid descriptor: " + desc ) ; } try { checkInternalName ( desc , start + 1 , index , null ) ; } catch ( IllegalArgumentException unused ) { throw new IllegalArgumentException ( "Invalid descriptor: " + desc ) ; } return index + 1 ; default : throw new IllegalArgumentException ( "Invalid descriptor: " + desc ) ; } }
checks that a the given substring is a valid type descriptor .
