Java Code Examples for sun.reflect.ConstantPool#getUTF8At()

The following examples show how to use sun.reflect.ConstantPool#getUTF8At() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationParser.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static Object parseStringArray(int length,
                                ByteBuffer buf,  ConstantPool constPool) {
    String[] result = new String[length];
    boolean typeMismatch = false;
    int tag = 0;

    for (int i = 0; i < length; i++) {
        tag = buf.get();
        if (tag == 's') {
            int index = buf.getShort() & 0xFFFF;
            result[i] = constPool.getUTF8At(index);
        } else {
            skipMemberValue(tag, buf);
            typeMismatch = true;
        }
    }
    return typeMismatch ? exceptionProxy(tag) : result;
}
 
Example 2
Source File: AnnotationParser.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static Object parseStringArray(int length,
                                ByteBuffer buf,  ConstantPool constPool) {
    String[] result = new String[length];
    boolean typeMismatch = false;
    int tag = 0;

    for (int i = 0; i < length; i++) {
        tag = buf.get();
        if (tag == 's') {
            int index = buf.getShort() & 0xFFFF;
            result[i] = constPool.getUTF8At(index);
        } else {
            skipMemberValue(tag, buf);
            typeMismatch = true;
        }
    }
    return typeMismatch ? exceptionProxy(tag) : result;
}
 
Example 3
Source File: AnnotationParser.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static Object parseStringArray(int length,
                                ByteBuffer buf,  ConstantPool constPool) {
    String[] result = new String[length];
    boolean typeMismatch = false;
    int tag = 0;

    for (int i = 0; i < length; i++) {
        tag = buf.get();
        if (tag == 's') {
            int index = buf.getShort() & 0xFFFF;
            result[i] = constPool.getUTF8At(index);
        } else {
            skipMemberValue(tag, buf);
            typeMismatch = true;
        }
    }
    return typeMismatch ? exceptionProxy(tag) : result;
}
 
Example 4
Source File: AnnotationParser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static Object parseStringArray(int length,
                                ByteBuffer buf,  ConstantPool constPool) {
    String[] result = new String[length];
    boolean typeMismatch = false;
    int tag = 0;

    for (int i = 0; i < length; i++) {
        tag = buf.get();
        if (tag == 's') {
            int index = buf.getShort() & 0xFFFF;
            result[i] = constPool.getUTF8At(index);
        } else {
            skipMemberValue(tag, buf);
            typeMismatch = true;
        }
    }
    return typeMismatch ? exceptionProxy(tag) : result;
}
 
Example 5
Source File: AnnotationParser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static Object parseStringArray(int length,
                                ByteBuffer buf,  ConstantPool constPool) {
    String[] result = new String[length];
    boolean typeMismatch = false;
    int tag = 0;

    for (int i = 0; i < length; i++) {
        tag = buf.get();
        if (tag == 's') {
            int index = buf.getShort() & 0xFFFF;
            result[i] = constPool.getUTF8At(index);
        } else {
            skipMemberValue(tag, buf);
            typeMismatch = true;
        }
    }
    return typeMismatch ? exceptionProxy(tag) : result;
}
 
Example 6
Source File: AnnotationParser.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Parses the enum constant member value at the current position in the
 * specified byte buffer, resolving constant references in the specified
 * constant pool.  The cursor of the byte buffer must point to a
 * "enum_const_value structure" as described in the
 * RuntimeVisibleAnnotations_attribute:
 *
 *       {
 *           u2   type_name_index;
 *           u2   const_name_index;
 *       } enum_const_value;
 */
private static Object parseEnumValue(Class enumType, ByteBuffer buf,
                                     ConstantPool constPool,
                                     Class container) {
    int typeNameIndex = buf.getShort() & 0xFFFF;
    String typeName  = constPool.getUTF8At(typeNameIndex);
    int constNameIndex = buf.getShort() & 0xFFFF;
    String constName = constPool.getUTF8At(constNameIndex);

    if (!typeName.endsWith(";")) {
        // support now-obsolete early jsr175-format class files.
        if (!enumType.getName().equals(typeName))
        return new AnnotationTypeMismatchExceptionProxy(
            typeName + "." + constName);
    } else if (enumType != parseSig(typeName, container)) {
        return new AnnotationTypeMismatchExceptionProxy(
            typeName + "." + constName);
    }

    try {
        return  Enum.valueOf(enumType, constName);
    } catch(IllegalArgumentException e) {
        return new EnumConstantNotPresentExceptionProxy(
            (Class<? extends Enum>)enumType, constName);
    }
}
 
Example 7
Source File: AnnotationParser.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
private static Object parseStringArray(int length,
                                ByteBuffer buf,  ConstantPool constPool) {
    String[] result = new String[length];
    boolean typeMismatch = false;
    int tag = 0;

    for (int i = 0; i < length; i++) {
        tag = buf.get();
        if (tag == 's') {
            int index = buf.getShort() & 0xFFFF;
            result[i] = constPool.getUTF8At(index);
        } else {
            skipMemberValue(tag, buf);
            typeMismatch = true;
        }
    }
    return typeMismatch ? exceptionProxy(tag) : result;
}
 
Example 8
Source File: AnnotationParser.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses the primitive or String annotation member value indicated by
 * the specified tag byte at the current position in the specified byte
 * buffer, resolving constant reference in the specified constant pool.
 * The cursor of the byte buffer must point to an annotation member value
 * of the type indicated by the specified tag, as described in the
 * RuntimeVisibleAnnotations_attribute:
 *
 *       u2   const_value_index;
 */
private static Object parseConst(int tag,
                                 ByteBuffer buf, ConstantPool constPool) {
    int constIndex = buf.getShort() & 0xFFFF;
    switch(tag) {
      case 'B':
        return Byte.valueOf((byte) constPool.getIntAt(constIndex));
      case 'C':
        return Character.valueOf((char) constPool.getIntAt(constIndex));
      case 'D':
        return Double.valueOf(constPool.getDoubleAt(constIndex));
      case 'F':
        return Float.valueOf(constPool.getFloatAt(constIndex));
      case 'I':
        return Integer.valueOf(constPool.getIntAt(constIndex));
      case 'J':
        return Long.valueOf(constPool.getLongAt(constIndex));
      case 'S':
        return Short.valueOf((short) constPool.getIntAt(constIndex));
      case 'Z':
        return Boolean.valueOf(constPool.getIntAt(constIndex) != 0);
      case 's':
        return constPool.getUTF8At(constIndex);
      default:
        throw new AnnotationFormatError(
            "Invalid member-value tag in annotation: " + tag);
    }
}
 
Example 9
Source File: AnnotationParser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses the enum constant member value at the current position in the
 * specified byte buffer, resolving constant references in the specified
 * constant pool.  The cursor of the byte buffer must point to a
 * "enum_const_value structure" as described in the
 * RuntimeVisibleAnnotations_attribute:
 *
 *       {
 *           u2   type_name_index;
 *           u2   const_name_index;
 *       } enum_const_value;
 */
@SuppressWarnings({"rawtypes", "unchecked"})
private static Object parseEnumValue(Class<? extends Enum> enumType, ByteBuffer buf,
                                     ConstantPool constPool,
                                     Class<?> container) {
    int typeNameIndex = buf.getShort() & 0xFFFF;
    String typeName  = constPool.getUTF8At(typeNameIndex);
    int constNameIndex = buf.getShort() & 0xFFFF;
    String constName = constPool.getUTF8At(constNameIndex);

    if (!typeName.endsWith(";")) {
        // support now-obsolete early jsr175-format class files.
        if (!enumType.getName().equals(typeName))
        return new AnnotationTypeMismatchExceptionProxy(
            typeName + "." + constName);
    } else if (enumType != parseSig(typeName, container)) {
        return new AnnotationTypeMismatchExceptionProxy(
            typeName + "." + constName);
    }

    try {
        return  Enum.valueOf(enumType, constName);
    } catch(IllegalArgumentException e) {
        return new EnumConstantNotPresentExceptionProxy(
            (Class<? extends Enum<?>>)enumType, constName);
    }
}
 
Example 10
Source File: AnnotationParser.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses the enum constant member value at the current position in the
 * specified byte buffer, resolving constant references in the specified
 * constant pool.  The cursor of the byte buffer must point to a
 * "enum_const_value structure" as described in the
 * RuntimeVisibleAnnotations_attribute:
 *
 *       {
 *           u2   type_name_index;
 *           u2   const_name_index;
 *       } enum_const_value;
 */
@SuppressWarnings({"rawtypes", "unchecked"})
private static Object parseEnumValue(Class<? extends Enum> enumType, ByteBuffer buf,
                                     ConstantPool constPool,
                                     Class<?> container) {
    int typeNameIndex = buf.getShort() & 0xFFFF;
    String typeName  = constPool.getUTF8At(typeNameIndex);
    int constNameIndex = buf.getShort() & 0xFFFF;
    String constName = constPool.getUTF8At(constNameIndex);

    if (!typeName.endsWith(";")) {
        // support now-obsolete early jsr175-format class files.
        if (!enumType.getName().equals(typeName))
        return new AnnotationTypeMismatchExceptionProxy(
            typeName + "." + constName);
    } else if (enumType != parseSig(typeName, container)) {
        return new AnnotationTypeMismatchExceptionProxy(
            typeName + "." + constName);
    }

    try {
        return  Enum.valueOf(enumType, constName);
    } catch(IllegalArgumentException e) {
        return new EnumConstantNotPresentExceptionProxy(
            (Class<? extends Enum<?>>)enumType, constName);
    }
}
 
Example 11
Source File: AnnotationParser.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses the primitive or String annotation member value indicated by
 * the specified tag byte at the current position in the specified byte
 * buffer, resolving constant reference in the specified constant pool.
 * The cursor of the byte buffer must point to an annotation member value
 * of the type indicated by the specified tag, as described in the
 * RuntimeVisibleAnnotations_attribute:
 *
 *       u2   const_value_index;
 */
private static Object parseConst(int tag,
                                 ByteBuffer buf, ConstantPool constPool) {
    int constIndex = buf.getShort() & 0xFFFF;
    switch(tag) {
      case 'B':
        return Byte.valueOf((byte) constPool.getIntAt(constIndex));
      case 'C':
        return Character.valueOf((char) constPool.getIntAt(constIndex));
      case 'D':
        return Double.valueOf(constPool.getDoubleAt(constIndex));
      case 'F':
        return Float.valueOf(constPool.getFloatAt(constIndex));
      case 'I':
        return Integer.valueOf(constPool.getIntAt(constIndex));
      case 'J':
        return Long.valueOf(constPool.getLongAt(constIndex));
      case 'S':
        return Short.valueOf((short) constPool.getIntAt(constIndex));
      case 'Z':
        return Boolean.valueOf(constPool.getIntAt(constIndex) != 0);
      case 's':
        return constPool.getUTF8At(constIndex);
      default:
        throw new AnnotationFormatError(
            "Invalid member-value tag in annotation: " + tag);
    }
}
 
Example 12
Source File: AnnotationParser.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses the primitive or String annotation member value indicated by
 * the specified tag byte at the current position in the specified byte
 * buffer, resolving constant reference in the specified constant pool.
 * The cursor of the byte buffer must point to an annotation member value
 * of the type indicated by the specified tag, as described in the
 * RuntimeVisibleAnnotations_attribute:
 *
 *       u2   const_value_index;
 */
private static Object parseConst(int tag,
                                 ByteBuffer buf, ConstantPool constPool) {
    int constIndex = buf.getShort() & 0xFFFF;
    switch(tag) {
      case 'B':
        return Byte.valueOf((byte) constPool.getIntAt(constIndex));
      case 'C':
        return Character.valueOf((char) constPool.getIntAt(constIndex));
      case 'D':
        return Double.valueOf(constPool.getDoubleAt(constIndex));
      case 'F':
        return Float.valueOf(constPool.getFloatAt(constIndex));
      case 'I':
        return Integer.valueOf(constPool.getIntAt(constIndex));
      case 'J':
        return Long.valueOf(constPool.getLongAt(constIndex));
      case 'S':
        return Short.valueOf((short) constPool.getIntAt(constIndex));
      case 'Z':
        return Boolean.valueOf(constPool.getIntAt(constIndex) != 0);
      case 's':
        return constPool.getUTF8At(constIndex);
      default:
        throw new AnnotationFormatError(
            "Invalid member-value tag in annotation: " + tag);
    }
}
 
Example 13
Source File: AnnotationParser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses the primitive or String annotation member value indicated by
 * the specified tag byte at the current position in the specified byte
 * buffer, resolving constant reference in the specified constant pool.
 * The cursor of the byte buffer must point to an annotation member value
 * of the type indicated by the specified tag, as described in the
 * RuntimeVisibleAnnotations_attribute:
 *
 *       u2   const_value_index;
 */
private static Object parseConst(int tag,
                                 ByteBuffer buf, ConstantPool constPool) {
    int constIndex = buf.getShort() & 0xFFFF;
    switch(tag) {
      case 'B':
        return Byte.valueOf((byte) constPool.getIntAt(constIndex));
      case 'C':
        return Character.valueOf((char) constPool.getIntAt(constIndex));
      case 'D':
        return Double.valueOf(constPool.getDoubleAt(constIndex));
      case 'F':
        return Float.valueOf(constPool.getFloatAt(constIndex));
      case 'I':
        return Integer.valueOf(constPool.getIntAt(constIndex));
      case 'J':
        return Long.valueOf(constPool.getLongAt(constIndex));
      case 'S':
        return Short.valueOf((short) constPool.getIntAt(constIndex));
      case 'Z':
        return Boolean.valueOf(constPool.getIntAt(constIndex) != 0);
      case 's':
        return constPool.getUTF8At(constIndex);
      default:
        throw new AnnotationFormatError(
            "Invalid member-value tag in annotation: " + tag);
    }
}
 
Example 14
Source File: AnnotationParser.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses the enum constant member value at the current position in the
 * specified byte buffer, resolving constant references in the specified
 * constant pool.  The cursor of the byte buffer must point to a
 * "enum_const_value structure" as described in the
 * RuntimeVisibleAnnotations_attribute:
 *
 *       {
 *           u2   type_name_index;
 *           u2   const_name_index;
 *       } enum_const_value;
 */
@SuppressWarnings({"rawtypes", "unchecked"})
private static Object parseEnumValue(Class<? extends Enum> enumType, ByteBuffer buf,
                                     ConstantPool constPool,
                                     Class<?> container) {
    int typeNameIndex = buf.getShort() & 0xFFFF;
    String typeName  = constPool.getUTF8At(typeNameIndex);
    int constNameIndex = buf.getShort() & 0xFFFF;
    String constName = constPool.getUTF8At(constNameIndex);

    if (!typeName.endsWith(";")) {
        // support now-obsolete early jsr175-format class files.
        if (!enumType.getName().equals(typeName))
        return new AnnotationTypeMismatchExceptionProxy(
            typeName + "." + constName);
    } else if (enumType != parseSig(typeName, container)) {
        return new AnnotationTypeMismatchExceptionProxy(
            typeName + "." + constName);
    }

    try {
        return  Enum.valueOf(enumType, constName);
    } catch(IllegalArgumentException e) {
        return new EnumConstantNotPresentExceptionProxy(
            (Class<? extends Enum<?>>)enumType, constName);
    }
}
 
Example 15
Source File: AnnotationParser.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses the enum constant member value at the current position in the
 * specified byte buffer, resolving constant references in the specified
 * constant pool.  The cursor of the byte buffer must point to a
 * "enum_const_value structure" as described in the
 * RuntimeVisibleAnnotations_attribute:
 *
 *       {
 *           u2   type_name_index;
 *           u2   const_name_index;
 *       } enum_const_value;
 */
@SuppressWarnings({"rawtypes", "unchecked"})
private static Object parseEnumValue(Class<? extends Enum> enumType, ByteBuffer buf,
                                     ConstantPool constPool,
                                     Class<?> container) {
    int typeNameIndex = buf.getShort() & 0xFFFF;
    String typeName  = constPool.getUTF8At(typeNameIndex);
    int constNameIndex = buf.getShort() & 0xFFFF;
    String constName = constPool.getUTF8At(constNameIndex);

    if (!typeName.endsWith(";")) {
        // support now-obsolete early jsr175-format class files.
        if (!enumType.getName().equals(typeName))
        return new AnnotationTypeMismatchExceptionProxy(
            typeName + "." + constName);
    } else if (enumType != parseSig(typeName, container)) {
        return new AnnotationTypeMismatchExceptionProxy(
            typeName + "." + constName);
    }

    try {
        return  Enum.valueOf(enumType, constName);
    } catch(IllegalArgumentException e) {
        return new EnumConstantNotPresentExceptionProxy(
            (Class<? extends Enum<?>>)enumType, constName);
    }
}
 
Example 16
Source File: AnnotationParser.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses the enum constant member value at the current position in the
 * specified byte buffer, resolving constant references in the specified
 * constant pool.  The cursor of the byte buffer must point to a
 * "enum_const_value structure" as described in the
 * RuntimeVisibleAnnotations_attribute:
 *
 *       {
 *           u2   type_name_index;
 *           u2   const_name_index;
 *       } enum_const_value;
 */
@SuppressWarnings({"rawtypes", "unchecked"})
private static Object parseEnumValue(Class<? extends Enum> enumType, ByteBuffer buf,
                                     ConstantPool constPool,
                                     Class<?> container) {
    int typeNameIndex = buf.getShort() & 0xFFFF;
    String typeName  = constPool.getUTF8At(typeNameIndex);
    int constNameIndex = buf.getShort() & 0xFFFF;
    String constName = constPool.getUTF8At(constNameIndex);

    if (!typeName.endsWith(";")) {
        // support now-obsolete early jsr175-format class files.
        if (!enumType.getName().equals(typeName))
        return new AnnotationTypeMismatchExceptionProxy(
            typeName + "." + constName);
    } else if (enumType != parseSig(typeName, container)) {
        return new AnnotationTypeMismatchExceptionProxy(
            typeName + "." + constName);
    }

    try {
        return  Enum.valueOf(enumType, constName);
    } catch(IllegalArgumentException e) {
        return new EnumConstantNotPresentExceptionProxy(
            (Class<? extends Enum<?>>)enumType, constName);
    }
}
 
Example 17
Source File: AnnotationParser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses the enum constant member value at the current position in the
 * specified byte buffer, resolving constant references in the specified
 * constant pool.  The cursor of the byte buffer must point to a
 * "enum_const_value structure" as described in the
 * RuntimeVisibleAnnotations_attribute:
 *
 *       {
 *           u2   type_name_index;
 *           u2   const_name_index;
 *       } enum_const_value;
 */
@SuppressWarnings({"rawtypes", "unchecked"})
private static Object parseEnumValue(Class<? extends Enum> enumType, ByteBuffer buf,
                                     ConstantPool constPool,
                                     Class<?> container) {
    int typeNameIndex = buf.getShort() & 0xFFFF;
    String typeName  = constPool.getUTF8At(typeNameIndex);
    int constNameIndex = buf.getShort() & 0xFFFF;
    String constName = constPool.getUTF8At(constNameIndex);

    if (!typeName.endsWith(";")) {
        // support now-obsolete early jsr175-format class files.
        if (!enumType.getName().equals(typeName))
        return new AnnotationTypeMismatchExceptionProxy(
            typeName + "." + constName);
    } else if (enumType != parseSig(typeName, container)) {
        return new AnnotationTypeMismatchExceptionProxy(
            typeName + "." + constName);
    }

    try {
        return  Enum.valueOf(enumType, constName);
    } catch(IllegalArgumentException e) {
        return new EnumConstantNotPresentExceptionProxy(
            (Class<? extends Enum<?>>)enumType, constName);
    }
}
 
Example 18
Source File: AnnotationParser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses the primitive or String annotation member value indicated by
 * the specified tag byte at the current position in the specified byte
 * buffer, resolving constant reference in the specified constant pool.
 * The cursor of the byte buffer must point to an annotation member value
 * of the type indicated by the specified tag, as described in the
 * RuntimeVisibleAnnotations_attribute:
 *
 *       u2   const_value_index;
 */
private static Object parseConst(int tag,
                                 ByteBuffer buf, ConstantPool constPool) {
    int constIndex = buf.getShort() & 0xFFFF;
    switch(tag) {
      case 'B':
        return Byte.valueOf((byte) constPool.getIntAt(constIndex));
      case 'C':
        return Character.valueOf((char) constPool.getIntAt(constIndex));
      case 'D':
        return Double.valueOf(constPool.getDoubleAt(constIndex));
      case 'F':
        return Float.valueOf(constPool.getFloatAt(constIndex));
      case 'I':
        return Integer.valueOf(constPool.getIntAt(constIndex));
      case 'J':
        return Long.valueOf(constPool.getLongAt(constIndex));
      case 'S':
        return Short.valueOf((short) constPool.getIntAt(constIndex));
      case 'Z':
        return Boolean.valueOf(constPool.getIntAt(constIndex) != 0);
      case 's':
        return constPool.getUTF8At(constIndex);
      default:
        throw new AnnotationFormatError(
            "Invalid member-value tag in annotation: " + tag);
    }
}
 
Example 19
Source File: AnnotationParser.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses the primitive or String annotation member value indicated by
 * the specified tag byte at the current position in the specified byte
 * buffer, resolving constant reference in the specified constant pool.
 * The cursor of the byte buffer must point to an annotation member value
 * of the type indicated by the specified tag, as described in the
 * RuntimeVisibleAnnotations_attribute:
 *
 *       u2   const_value_index;
 */
private static Object parseConst(int tag,
                                 ByteBuffer buf, ConstantPool constPool) {
    int constIndex = buf.getShort() & 0xFFFF;
    switch(tag) {
      case 'B':
        return Byte.valueOf((byte) constPool.getIntAt(constIndex));
      case 'C':
        return Character.valueOf((char) constPool.getIntAt(constIndex));
      case 'D':
        return Double.valueOf(constPool.getDoubleAt(constIndex));
      case 'F':
        return Float.valueOf(constPool.getFloatAt(constIndex));
      case 'I':
        return Integer.valueOf(constPool.getIntAt(constIndex));
      case 'J':
        return Long.valueOf(constPool.getLongAt(constIndex));
      case 'S':
        return Short.valueOf((short) constPool.getIntAt(constIndex));
      case 'Z':
        return Boolean.valueOf(constPool.getIntAt(constIndex) != 0);
      case 's':
        return constPool.getUTF8At(constIndex);
      default:
        throw new AnnotationFormatError(
            "Invalid member-value tag in annotation: " + tag);
    }
}
 
Example 20
Source File: AnnotationParser.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses the enum constant member value at the current position in the
 * specified byte buffer, resolving constant references in the specified
 * constant pool.  The cursor of the byte buffer must point to a
 * "enum_const_value structure" as described in the
 * RuntimeVisibleAnnotations_attribute:
 *
 *       {
 *           u2   type_name_index;
 *           u2   const_name_index;
 *       } enum_const_value;
 */
@SuppressWarnings({"rawtypes", "unchecked"})
private static Object parseEnumValue(Class<? extends Enum> enumType, ByteBuffer buf,
                                     ConstantPool constPool,
                                     Class<?> container) {
    int typeNameIndex = buf.getShort() & 0xFFFF;
    String typeName  = constPool.getUTF8At(typeNameIndex);
    int constNameIndex = buf.getShort() & 0xFFFF;
    String constName = constPool.getUTF8At(constNameIndex);

    if (!typeName.endsWith(";")) {
        // support now-obsolete early jsr175-format class files.
        if (!enumType.getName().equals(typeName))
        return new AnnotationTypeMismatchExceptionProxy(
            typeName + "." + constName);
    } else if (enumType != parseSig(typeName, container)) {
        return new AnnotationTypeMismatchExceptionProxy(
            typeName + "." + constName);
    }

    try {
        return  Enum.valueOf(enumType, constName);
    } catch(IllegalArgumentException e) {
        return new EnumConstantNotPresentExceptionProxy(
            (Class<? extends Enum<?>>)enumType, constName);
    }
}