private static Class parseType()

in core/src/main/java/org/apache/commons/proxy2/impl/MethodSignature.java [156:183]


    private static Class<?> parseType(String internal, SignaturePosition pos) throws ClassNotFoundException
    {
        final int here = pos.getIndex();
        final char c = internal.charAt(here);

        switch (c)
        {
        case '[':
            pos.next();
            final Class<?> componentType = parseType(internal, pos);
            return Array.newInstance(componentType, 0).getClass();
        case 'L':
            pos.next();
            final int type = pos.getIndex();
            final int semi = internal.indexOf(';', type);
            Validate.isTrue(semi > 0, "Type at index %d of method signature \"%s\" not terminated by semicolon",
                    Integer.valueOf(here), internal);
            final String className = internal.substring(type, semi).replace('/', '.');
            Validate.notBlank(className, "Invalid classname at position %d of method signature \"%s\"",
                    Integer.valueOf(type), internal);
            pos.setIndex(semi + 1);
            return Class.forName(className);
        default:
            throw new IllegalArgumentException(String.format(
                    "Unexpected character at index %d of method signature \"%s\"",
                    Integer.valueOf(here), internal));
        }
    }