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

The following examples show how to use sun.reflect.ConstantPool#getUTF8At() . These examples are extracted from open source projects. 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
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
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
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
/**
 * 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 5
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
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 7
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
/**
 * 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 9
/**
 * 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 10
/**
 * 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 11
/**
 * 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 12
/**
 * 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 13
/**
 * 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 14
/**
 * 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
/**
 * 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 16
/**
 * 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 17
/**
 * 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 18
/**
 * 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 19
/**
 * 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 20
/**
 * 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);
    }
}