@Override Class<?> loadClass() { return getType(); }
/** * Parse a type signature. * * @param parser * The parser * @param definingClass * The class containing the type descriptor. * @return The parsed type descriptor or type signature. * @throws ParseException * If the type signature could not be parsed. */ static TypeSignature parse(final Parser parser, final String definingClass) throws ParseException { final ReferenceTypeSignature referenceTypeSignature = ReferenceTypeSignature .parseReferenceTypeSignature(parser, definingClass); if (referenceTypeSignature != null) { return referenceTypeSignature; } final BaseTypeSignature baseTypeSignature = BaseTypeSignature.parse(parser); if (baseTypeSignature != null) { return baseTypeSignature; } return null; }
case 'B': parser.next(); return new BaseTypeSignature("byte"); case 'C': parser.next(); return new BaseTypeSignature("char"); case 'D': parser.next(); return new BaseTypeSignature("double"); case 'F': parser.next(); return new BaseTypeSignature("float"); case 'I': parser.next(); return new BaseTypeSignature("int"); case 'J': parser.next(); return new BaseTypeSignature("long"); case 'S': parser.next(); return new BaseTypeSignature("short"); case 'Z': parser.next(); return new BaseTypeSignature("boolean"); case 'V': parser.next(); return new BaseTypeSignature("void"); default: return null;
} else if (elementTypeSig instanceof BaseTypeSignature) { targetElementTypeName = ((BaseTypeSignature) elementTypeSig).getTypeStr();
Collections.<TypeSignature> emptyList(), new BaseTypeSignature("void"), Collections.<ClassRefOrTypeVariableSignature> emptyList());
@Override <T> Class<T> loadClass(final Class<T> superclassOrInterfaceType) { final Class<?> type = getType(); if (!superclassOrInterfaceType.isAssignableFrom(type)) { throw new IllegalArgumentException( "Primitive class " + baseType + " cannot be cast to " + superclassOrInterfaceType.getName()); } @SuppressWarnings("unchecked") final Class<T> classT = (Class<T>) type; return classT; }
@Override protected String getClassName() { if (className == null) { getTypeSignature(); if (typeSignature instanceof BaseTypeSignature) { className = ((BaseTypeSignature) typeSignature).getType().getName(); } else if (typeSignature instanceof ClassRefTypeSignature) { className = ((ClassRefTypeSignature) typeSignature).getFullyQualifiedClassName(); } else { throw new IllegalArgumentException("Got unexpected type " + typeSignature.getClass().getName() + " for ref type signature: " + typeDescriptorStr); } } return className; }
/** * Loads the referenced class, returning a {@code Class<?>} reference for the referenced class. * * @param ignoreExceptions * if true, ignore exceptions and instead return null if the class could not be loaded. * @return The {@code Class<?>} reference for the referenced class. * @throws IllegalArgumentException * if the class could not be loaded and ignoreExceptions was false. */ @Override public Class<?> loadClass(final boolean ignoreExceptions) { getTypeSignature(); if (typeSignature instanceof BaseTypeSignature) { return ((BaseTypeSignature) typeSignature).getType(); } else if (typeSignature instanceof ClassRefTypeSignature) { return ((ClassRefTypeSignature) typeSignature).loadClass(ignoreExceptions); } else { throw new IllegalArgumentException("Got unexpected type " + typeSignature.getClass().getName() + " for ref type signature: " + typeDescriptorStr); } }
} else if (elementTypeSig instanceof BaseTypeSignature) { eltClass = ((BaseTypeSignature) elementTypeSig).getType();