added getClass()

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1114 379699f6-c40d-0410-875b-85095c16579e
branch_1_1
jochen 25 years ago
parent ed15fe5b9a
commit 2b972a10ae
  1. 39
      jode/jode/bytecode/TypeSignature.java

@ -67,8 +67,45 @@ public class TypeSignature {
}
/**
* Check if the given type is a two slot type.
* Generate a Class for a type signature. This is the pendant to
* getSignature.
* @param typeSig a single type signature
* @return the Class object representing that type.
*/
public static Class getClass(String typeSig)
throws ClassNotFoundException
{
switch(typeSig.charAt(0)) {
case 'Z':
return Boolean.TYPE;
case 'B':
return Byte.TYPE;
case 'C':
return Character.TYPE;
case 'S':
return Short.TYPE;
case 'I':
return Integer.TYPE;
case 'F':
return Float.TYPE;
case 'J':
return Long.TYPE;
case 'D':
return Double.TYPE;
case 'V':
return Void.TYPE;
case 'L':
typeSig = typeSig.substring(1, typeSig.length()-1)
.replace('/','.');
/* fall through */
case '[':
return Class.forName(typeSig);
}
throw new IllegalArgumentException(typeSig);
}
/**
* Check if the given type is a two slot type. */
private static boolean usingTwoSlots(char type) {
return "JD".indexOf(type) >= 0;
}

Loading…
Cancel
Save