/** * Makes a localVariableType from a given signature. * @return LocalVariableType * @throws RuntimeException if the signature could not be parsed. */ public static LocalVariableType parse(String signature) { int dimensions = 0; for(int i = 0; i < signature.length(); i++) { if(signature.charAt(i) == '[') dimensions++; else break; } try { javassist.bytecode.SignatureAttribute.Type objectType = SignatureAttribute.toFieldSignature(signature); if(objectType instanceof ArrayType) objectType = ((ArrayType) objectType).getComponentType(); if(objectType instanceof ClassType) { String typeName = ((ClassType) objectType).getName(); return new LocalVariableType(signature, addArrayTypeInfo(typeName, dimensions), typeName, false, dimensions); } throw new RuntimeException("not a class ?"); } catch(Exception e) { // not a class String typeName = primitiveSymbols.get("" + signature.charAt(dimensions)); if(typeName == null) throw new RuntimeException("unknown signature: " + signature, e); return new LocalVariableType(signature, addArrayTypeInfo(typeName, dimensions), typeName, true, dimensions); } }
for (int i = 0 ; i < types.length ; i++) if (types[i].getName().equals(parent.getName()))
/** * Get the fully qualified name for a generic type * * @param type the type * @return the name */ static String getClassNameForGenericType(ClassType type) { if (type.getDeclaringClass() == null) return type.getName(); StringBuilder sb = new StringBuilder(type.getName()); while(type.getDeclaringClass() != null) { sb.insert(0, type.getDeclaringClass().getName() + "$"); type = type.getDeclaringClass(); } return sb.toString(); }
for (int i = 0 ; i < types.length ; i++) if (types[i].getName().equals(parent.getName()))
/** * Get the fully qualified name for a generic type * * @param type the type * @return the name */ static String getClassNameForGenericType(ClassType type) { if (type.getDeclaringClass() == null) return type.getName(); StringBuilder sb = new StringBuilder(type.getName()); while(type.getDeclaringClass() != null) { sb.insert(0, type.getDeclaringClass().getName() + "$"); type = type.getDeclaringClass(); } return sb.toString(); }