From 2b972a10aebc70461db22b2bde79e2981d9149d5 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 22 Jul 1999 15:06:25 +0000 Subject: [PATCH] added getClass() git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1114 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/bytecode/TypeSignature.java | 39 ++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/jode/jode/bytecode/TypeSignature.java b/jode/jode/bytecode/TypeSignature.java index 700d4bc..d5ccf81 100644 --- a/jode/jode/bytecode/TypeSignature.java +++ b/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; }