Java 类com.sun.tools.classfile.ConstantPool.CPInfo 实例源码

项目:jdk8u-jdk    文件:LambdaAsm.java   
static void checkMethod(String cname, String mname, ConstantPool cp,
        Code_attribute code) throws ConstantPool.InvalidIndex {
    for (Instruction i : code.getInstructions()) {
        String iname = i.getMnemonic();
        if ("invokespecial".equals(iname)
                || "invokestatic".equals(iname)) {
            int idx = i.getByte(2);
            System.out.println("Verifying " + cname + ":" + mname +
                    " instruction:" + iname + " index @" + idx);
            CPInfo cpinfo = cp.get(idx);
            if (cpinfo instanceof ConstantPool.CONSTANT_Methodref_info) {
                throw new RuntimeException("unexpected CP type expected "
                        + "InterfaceMethodRef, got MethodRef, " + cname
                        + ", " + mname);
            }
        }
    }
}
项目:openjdk-jdk10    文件:CreateSymbols.java   
Object convertConstantValue(CPInfo info, String descriptor) throws ConstantPoolException {
    if (info instanceof CONSTANT_Integer_info) {
        if ("Z".equals(descriptor))
            return ((CONSTANT_Integer_info) info).value == 1;
        else
            return ((CONSTANT_Integer_info) info).value;
    } else if (info instanceof CONSTANT_Long_info) {
        return ((CONSTANT_Long_info) info).value;
    } else if (info instanceof CONSTANT_Float_info) {
        return ((CONSTANT_Float_info) info).value;
    } else if (info instanceof CONSTANT_Double_info) {
        return ((CONSTANT_Double_info) info).value;
    } else if (info instanceof CONSTANT_String_info) {
        return ((CONSTANT_String_info) info).getString();
    }
    throw new IllegalStateException(info.getClass().getName());
}
项目:openjdk-jdk10    文件:CPoolRefClassContainingInlinedCts.java   
void checkReferences() throws IOException, ConstantPoolException {
    File testClasses = new File(System.getProperty("test.classes"));
    File file = new File(testClasses,
            CPoolRefClassContainingInlinedCts.class.getName() + ".class");
    ClassFile classFile = ClassFile.read(file);
    int i = 1;
    CPInfo cpInfo;
    while (i < classFile.constant_pool.size()) {
        cpInfo = classFile.constant_pool.get(i);
        if (cpInfo instanceof CONSTANT_Class_info) {
            checkClassName(((CONSTANT_Class_info)cpInfo).getName());
        }
        i += cpInfo.size();
    }
    if (numberOfReferencedClassesToBeChecked != 16) {
        throw new AssertionError("Class reference missing in the constant pool");
    }
}
项目:openjdk-jdk10    文件:LambdaAsm.java   
static void checkMethod(String cname, String mname, ConstantPool cp,
        Code_attribute code) throws ConstantPool.InvalidIndex {
    for (Instruction i : code.getInstructions()) {
        String iname = i.getMnemonic();
        if ("invokespecial".equals(iname)
                || "invokestatic".equals(iname)) {
            int idx = i.getByte(2);
            System.out.println("Verifying " + cname + ":" + mname +
                    " instruction:" + iname + " index @" + idx);
            CPInfo cpinfo = cp.get(idx);
            if (cpinfo instanceof ConstantPool.CONSTANT_Methodref_info) {
                throw new RuntimeException("unexpected CP type expected "
                        + "InterfaceMethodRef, got MethodRef, " + cname
                        + ", " + mname);
            }
        }
    }
}
项目:openjdk9    文件:CreateSymbols.java   
Object convertConstantValue(CPInfo info, String descriptor) throws ConstantPoolException {
    if (info instanceof CONSTANT_Integer_info) {
        if ("Z".equals(descriptor))
            return ((CONSTANT_Integer_info) info).value == 1;
        else
            return ((CONSTANT_Integer_info) info).value;
    } else if (info instanceof CONSTANT_Long_info) {
        return ((CONSTANT_Long_info) info).value;
    } else if (info instanceof CONSTANT_Float_info) {
        return ((CONSTANT_Float_info) info).value;
    } else if (info instanceof CONSTANT_Double_info) {
        return ((CONSTANT_Double_info) info).value;
    } else if (info instanceof CONSTANT_String_info) {
        return ((CONSTANT_String_info) info).getString();
    }
    throw new IllegalStateException(info.getClass().getName());
}
项目:openjdk9    文件:CPoolRefClassContainingInlinedCts.java   
void checkReferences() throws IOException, ConstantPoolException {
    File testClasses = new File(System.getProperty("test.classes"));
    File file = new File(testClasses,
            CPoolRefClassContainingInlinedCts.class.getName() + ".class");
    ClassFile classFile = ClassFile.read(file);
    int i = 1;
    CPInfo cpInfo;
    while (i < classFile.constant_pool.size()) {
        cpInfo = classFile.constant_pool.get(i);
        if (cpInfo instanceof CONSTANT_Class_info) {
            checkClassName(((CONSTANT_Class_info)cpInfo).getName());
        }
        i += cpInfo.size();
    }
    if (numberOfReferencedClassesToBeChecked != 16) {
        throw new AssertionError("Class reference missing in the constant pool");
    }
}
项目:openjdk9    文件:LambdaAsm.java   
static void checkMethod(String cname, String mname, ConstantPool cp,
        Code_attribute code) throws ConstantPool.InvalidIndex {
    for (Instruction i : code.getInstructions()) {
        String iname = i.getMnemonic();
        if ("invokespecial".equals(iname)
                || "invokestatic".equals(iname)) {
            int idx = i.getByte(2);
            System.out.println("Verifying " + cname + ":" + mname +
                    " instruction:" + iname + " index @" + idx);
            CPInfo cpinfo = cp.get(idx);
            if (cpinfo instanceof ConstantPool.CONSTANT_Methodref_info) {
                throw new RuntimeException("unexpected CP type expected "
                        + "InterfaceMethodRef, got MethodRef, " + cname
                        + ", " + mname);
            }
        }
    }
}
项目:jdk8u_jdk    文件:LambdaAsm.java   
static void checkMethod(String cname, String mname, ConstantPool cp,
        Code_attribute code) throws ConstantPool.InvalidIndex {
    for (Instruction i : code.getInstructions()) {
        String iname = i.getMnemonic();
        if ("invokespecial".equals(iname)
                || "invokestatic".equals(iname)) {
            int idx = i.getByte(2);
            System.out.println("Verifying " + cname + ":" + mname +
                    " instruction:" + iname + " index @" + idx);
            CPInfo cpinfo = cp.get(idx);
            if (cpinfo instanceof ConstantPool.CONSTANT_Methodref_info) {
                throw new RuntimeException("unexpected CP type expected "
                        + "InterfaceMethodRef, got MethodRef, " + cname
                        + ", " + mname);
            }
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:CPoolRefClassContainingInlinedCts.java   
void checkReferences() throws IOException, ConstantPoolException {
    File testClasses = new File(System.getProperty("test.classes"));
    File file = new File(testClasses,
            CPoolRefClassContainingInlinedCts.class.getName() + ".class");
    ClassFile classFile = ClassFile.read(file);
    int i = 1;
    CPInfo cpInfo;
    while (i < classFile.constant_pool.size()) {
        cpInfo = classFile.constant_pool.get(i);
        if (cpInfo instanceof CONSTANT_Class_info) {
            checkClassName(((CONSTANT_Class_info)cpInfo).getName());
        }
        i += cpInfo.size();
    }
    if (numberOfReferencedClassesToBeChecked != 16) {
        throw new AssertionError("Class reference missing in the constant pool");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:LambdaAsm.java   
static void checkMethod(String cname, String mname, ConstantPool cp,
        Code_attribute code) throws ConstantPool.InvalidIndex {
    for (Instruction i : code.getInstructions()) {
        String iname = i.getMnemonic();
        if ("invokespecial".equals(iname)
                || "invokestatic".equals(iname)) {
            int idx = i.getByte(2);
            System.out.println("Verifying " + cname + ":" + mname +
                    " instruction:" + iname + " index @" + idx);
            CPInfo cpinfo = cp.get(idx);
            if (cpinfo instanceof ConstantPool.CONSTANT_Methodref_info) {
                throw new RuntimeException("unexpected CP type expected "
                        + "InterfaceMethodRef, got MethodRef, " + cname
                        + ", " + mname);
            }
        }
    }
}
项目:jsr308-langtools    文件:CPoolRefClassContainingInlinedCts.java   
void checkReferences() throws IOException, ConstantPoolException {
    File testClasses = new File(System.getProperty("test.classes"));
    File file = new File(testClasses,
            CPoolRefClassContainingInlinedCts.class.getName() + ".class");
    ClassFile classFile = ClassFile.read(file);
    int i = 1;
    CPInfo cpInfo;
    while (i < classFile.constant_pool.size()) {
        cpInfo = classFile.constant_pool.get(i);
        if (cpInfo instanceof CONSTANT_Class_info) {
            checkClassName(((CONSTANT_Class_info)cpInfo).getName());
        }
        i += cpInfo.size();
    }
    if (numberOfReferencedClassesToBeChecked != 16) {
        throw new AssertionError("Class reference missing in the constant pool");
    }
}
项目:infobip-open-jdk-8    文件:CPoolRefClassContainingInlinedCts.java   
void checkReferences() throws IOException, ConstantPoolException {
    File testClasses = new File(System.getProperty("test.classes"));
    File file = new File(testClasses,
            CPoolRefClassContainingInlinedCts.class.getName() + ".class");
    ClassFile classFile = ClassFile.read(file);
    int i = 1;
    CPInfo cpInfo;
    while (i < classFile.constant_pool.size()) {
        cpInfo = classFile.constant_pool.get(i);
        if (cpInfo instanceof CONSTANT_Class_info) {
            checkClassName(((CONSTANT_Class_info)cpInfo).getName());
        }
        i += cpInfo.size();
    }
    if (numberOfReferencedClassesToBeChecked != 8) {
        throw new AssertionError("Class reference missing in the constant pool");
    }
}
项目:infobip-open-jdk-8    文件:LambdaAsm.java   
static void checkMethod(String cname, String mname, ConstantPool cp,
        Code_attribute code) throws ConstantPool.InvalidIndex {
    for (Instruction i : code.getInstructions()) {
        String iname = i.getMnemonic();
        if ("invokespecial".equals(iname)
                || "invokestatic".equals(iname)) {
            int idx = i.getByte(2);
            System.out.println("Verifying " + cname + ":" + mname +
                    " instruction:" + iname + " index @" + idx);
            CPInfo cpinfo = cp.get(idx);
            if (cpinfo instanceof ConstantPool.CONSTANT_Methodref_info) {
                throw new RuntimeException("unexpected CP type expected "
                        + "InterfaceMethodRef, got MethodRef, " + cname
                        + ", " + mname);
            }
        }
    }
}
项目:jdk8u-dev-jdk    文件:LambdaAsm.java   
static void checkMethod(String cname, String mname, ConstantPool cp,
        Code_attribute code) throws ConstantPool.InvalidIndex {
    for (Instruction i : code.getInstructions()) {
        String iname = i.getMnemonic();
        if ("invokespecial".equals(iname)
                || "invokestatic".equals(iname)) {
            int idx = i.getByte(2);
            System.out.println("Verifying " + cname + ":" + mname +
                    " instruction:" + iname + " index @" + idx);
            CPInfo cpinfo = cp.get(idx);
            if (cpinfo instanceof ConstantPool.CONSTANT_Methodref_info) {
                throw new RuntimeException("unexpected CP type expected "
                        + "InterfaceMethodRef, got MethodRef, " + cname
                        + ", " + mname);
            }
        }
    }
}
项目:OLD-OpenJDK8    文件:CPoolRefClassContainingInlinedCts.java   
void checkReferences() throws IOException, ConstantPoolException {
    File testClasses = new File(System.getProperty("test.classes"));
    File file = new File(testClasses,
            CPoolRefClassContainingInlinedCts.class.getName() + ".class");
    ClassFile classFile = ClassFile.read(file);
    int i = 1;
    CPInfo cpInfo;
    while (i < classFile.constant_pool.size()) {
        cpInfo = classFile.constant_pool.get(i);
        if (cpInfo instanceof CONSTANT_Class_info) {
            checkClassName(((CONSTANT_Class_info)cpInfo).getName());
        }
        i += cpInfo.size();
    }
    if (numberOfReferencedClassesToBeChecked != 8) {
        throw new AssertionError("Class reference missing in the constant pool");
    }
}
项目:OLD-OpenJDK8    文件:LambdaAsm.java   
static void checkMethod(String cname, String mname, ConstantPool cp,
        Code_attribute code) throws ConstantPool.InvalidIndex {
    for (Instruction i : code.getInstructions()) {
        String iname = i.getMnemonic();
        if ("invokespecial".equals(iname)
                || "invokestatic".equals(iname)) {
            int idx = i.getByte(2);
            System.out.println("Verifying " + cname + ":" + mname +
                    " instruction:" + iname + " index @" + idx);
            CPInfo cpinfo = cp.get(idx);
            if (cpinfo instanceof ConstantPool.CONSTANT_Methodref_info) {
                throw new RuntimeException("unexpected CP type expected "
                        + "InterfaceMethodRef, got MethodRef, " + cname
                        + ", " + mname);
            }
        }
    }
}
项目:OpenJSharp    文件:ClassTranslator.java   
ConstantPool translate(ConstantPool cp, Map<Object,Object> translations) {
    ConstantPool cp2 = (ConstantPool) translations.get(cp);
    if (cp2 == null) {
        ConstantPool.CPInfo[] pool2 = new ConstantPool.CPInfo[cp.size()];
        boolean eq = true;
        for (int i = 0; i < cp.size(); ) {
            ConstantPool.CPInfo cpInfo;
            try {
                cpInfo = cp.get(i);
            } catch (ConstantPool.InvalidIndex e) {
                throw new IllegalStateException(e);
            }
            ConstantPool.CPInfo cpInfo2 = translate(cpInfo, translations);
            eq &= (cpInfo == cpInfo2);
            pool2[i] = cpInfo2;
            if (cpInfo.getTag() != cpInfo2.getTag())
                throw new IllegalStateException();
            i += cpInfo.size();
        }

        if (eq)
            cp2 = cp;
        else
            cp2 = new ConstantPool(pool2);

        translations.put(cp, cp2);
    }
    return cp2;
}
项目:OpenJSharp    文件:ClassTranslator.java   
ConstantPool.CPInfo translate(ConstantPool.CPInfo cpInfo, Map<Object,Object> translations) {
    ConstantPool.CPInfo cpInfo2 = (ConstantPool.CPInfo) translations.get(cpInfo);
    if (cpInfo2 == null) {
        cpInfo2 = cpInfo.accept(this, translations);
        translations.put(cpInfo, cpInfo2);
    }
    return cpInfo2;
}
项目:OpenJSharp    文件:ClassTranslator.java   
public CPInfo visitClass(CONSTANT_Class_info info, Map<Object, Object> translations) {
    CONSTANT_Class_info info2 = (CONSTANT_Class_info) translations.get(info);
    if (info2 == null) {
        ConstantPool cp2 = translate(info.cp, translations);
        if (cp2 == info.cp)
            info2 = info;
        else
            info2 = new CONSTANT_Class_info(cp2, info.name_index);
        translations.put(info, info2);
    }
    return info;
}
项目:OpenJSharp    文件:ClassTranslator.java   
public CPInfo visitDouble(CONSTANT_Double_info info, Map<Object, Object> translations) {
    CONSTANT_Double_info info2 = (CONSTANT_Double_info) translations.get(info);
    if (info2 == null) {
        info2 = info;
        translations.put(info, info2);
    }
    return info;
}
项目:OpenJSharp    文件:ClassTranslator.java   
public CPInfo visitFieldref(CONSTANT_Fieldref_info info, Map<Object, Object> translations) {
    CONSTANT_Fieldref_info info2 = (CONSTANT_Fieldref_info) translations.get(info);
    if (info2 == null) {
        ConstantPool cp2 = translate(info.cp, translations);
        if (cp2 == info.cp)
            info2 = info;
        else
            info2 = new CONSTANT_Fieldref_info(cp2, info.class_index, info.name_and_type_index);
        translations.put(info, info2);
    }
    return info;
}
项目:OpenJSharp    文件:ClassTranslator.java   
public CPInfo visitFloat(CONSTANT_Float_info info, Map<Object, Object> translations) {
    CONSTANT_Float_info info2 = (CONSTANT_Float_info) translations.get(info);
    if (info2 == null) {
        info2 = info;
        translations.put(info, info2);
    }
    return info;
}
项目:OpenJSharp    文件:ClassTranslator.java   
public CPInfo visitInteger(CONSTANT_Integer_info info, Map<Object, Object> translations) {
    CONSTANT_Integer_info info2 = (CONSTANT_Integer_info) translations.get(info);
    if (info2 == null) {
        info2 = info;
        translations.put(info, info2);
    }
    return info;
}
项目:OpenJSharp    文件:ClassTranslator.java   
public CPInfo visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, Map<Object, Object> translations) {
    CONSTANT_InterfaceMethodref_info info2 = (CONSTANT_InterfaceMethodref_info) translations.get(info);
    if (info2 == null) {
        ConstantPool cp2 = translate(info.cp, translations);
        if (cp2 == info.cp)
            info2 = info;
        else
            info2 = new CONSTANT_InterfaceMethodref_info(cp2, info.class_index, info.name_and_type_index);
        translations.put(info, info2);
    }
    return info;
}
项目:OpenJSharp    文件:ClassTranslator.java   
public CPInfo visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, Map<Object, Object> translations) {
    CONSTANT_InvokeDynamic_info info2 = (CONSTANT_InvokeDynamic_info) translations.get(info);
    if (info2 == null) {
        ConstantPool cp2 = translate(info.cp, translations);
        if (cp2 == info.cp) {
            info2 = info;
        } else {
            info2 = new CONSTANT_InvokeDynamic_info(cp2, info.bootstrap_method_attr_index, info.name_and_type_index);
        }
        translations.put(info, info2);
    }
    return info;
}
项目:OpenJSharp    文件:ClassTranslator.java   
public CPInfo visitLong(CONSTANT_Long_info info, Map<Object, Object> translations) {
    CONSTANT_Long_info info2 = (CONSTANT_Long_info) translations.get(info);
    if (info2 == null) {
        info2 = info;
        translations.put(info, info2);
    }
    return info;
}
项目:OpenJSharp    文件:ClassTranslator.java   
public CPInfo visitNameAndType(CONSTANT_NameAndType_info info, Map<Object, Object> translations) {
    CONSTANT_NameAndType_info info2 = (CONSTANT_NameAndType_info) translations.get(info);
    if (info2 == null) {
        ConstantPool cp2 = translate(info.cp, translations);
        if (cp2 == info.cp)
            info2 = info;
        else
            info2 = new CONSTANT_NameAndType_info(cp2, info.name_index, info.type_index);
        translations.put(info, info2);
    }
    return info;
}
项目:OpenJSharp    文件:ClassTranslator.java   
public CPInfo visitMethodref(CONSTANT_Methodref_info info, Map<Object, Object> translations) {
    CONSTANT_Methodref_info info2 = (CONSTANT_Methodref_info) translations.get(info);
    if (info2 == null) {
        ConstantPool cp2 = translate(info.cp, translations);
        if (cp2 == info.cp)
            info2 = info;
        else
            info2 = new CONSTANT_Methodref_info(cp2, info.class_index, info.name_and_type_index);
        translations.put(info, info2);
    }
    return info;
}
项目:OpenJSharp    文件:ClassTranslator.java   
public CPInfo visitMethodHandle(CONSTANT_MethodHandle_info info, Map<Object, Object> translations) {
    CONSTANT_MethodHandle_info info2 = (CONSTANT_MethodHandle_info) translations.get(info);
    if (info2 == null) {
        ConstantPool cp2 = translate(info.cp, translations);
        if (cp2 == info.cp) {
            info2 = info;
        } else {
            info2 = new CONSTANT_MethodHandle_info(cp2, info.reference_kind, info.reference_index);
        }
        translations.put(info, info2);
    }
    return info;
}
项目:OpenJSharp    文件:ClassTranslator.java   
public CPInfo visitMethodType(CONSTANT_MethodType_info info, Map<Object, Object> translations) {
    CONSTANT_MethodType_info info2 = (CONSTANT_MethodType_info) translations.get(info);
    if (info2 == null) {
        ConstantPool cp2 = translate(info.cp, translations);
        if (cp2 == info.cp) {
            info2 = info;
        } else {
            info2 = new CONSTANT_MethodType_info(cp2, info.descriptor_index);
        }
        translations.put(info, info2);
    }
    return info;
}
项目:OpenJSharp    文件:ClassTranslator.java   
public CPInfo visitString(CONSTANT_String_info info, Map<Object, Object> translations) {
    CONSTANT_String_info info2 = (CONSTANT_String_info) translations.get(info);
    if (info2 == null) {
        ConstantPool cp2 = translate(info.cp, translations);
        if (cp2 == info.cp)
            info2 = info;
        else
            info2 = new CONSTANT_String_info(cp2, info.string_index);
        translations.put(info, info2);
    }
    return info;
}
项目:OpenJSharp    文件:ClassTranslator.java   
public CPInfo visitUtf8(CONSTANT_Utf8_info info, Map<Object, Object> translations) {
    CONSTANT_Utf8_info info2 = (CONSTANT_Utf8_info) translations.get(info);
    if (info2 == null) {
        info2 = info;
        translations.put(info, info2);
    }
    return info;
}
项目:openjdk-jdk10    文件:CreateSymbols.java   
private void addAttributes(FieldDescription desc, List<CPInfo> constantPool, Map<String, Attribute> attributes) {
    addGenericAttributes(desc, constantPool, attributes);
    if (desc.constantValue != null) {
        Pair<Integer, Character> constantPoolEntry =
                addConstant(constantPool, desc.constantValue, false);
        Assert.checkNonNull(constantPoolEntry);
        int constantValueString = addString(constantPool, Attribute.ConstantValue);
        attributes.put(Attribute.ConstantValue,
                       new ConstantValue_attribute(constantValueString, constantPoolEntry.fst));
    }
}
项目:openjdk-jdk10    文件:CreateSymbols.java   
private Annotation[] createAnnotations(List<CPInfo> constantPool, List<AnnotationDescription> desc) {
    Annotation[] result = new Annotation[desc.size()];
    int i = 0;

    for (AnnotationDescription ad : desc) {
        result[i++] = createAnnotation(constantPool, ad);
    }

    return result;
}
项目:openjdk-jdk10    文件:CreateSymbols.java   
private Annotation[][] createParameterAnnotations(List<CPInfo> constantPool, List<List<AnnotationDescription>> desc) {
    Annotation[][] result = new Annotation[desc.size()][];
    int i = 0;

    for (List<AnnotationDescription> paramAnnos : desc) {
        result[i++] = createAnnotations(constantPool, paramAnnos);
    }

    return result;
}
项目:openjdk-jdk10    文件:CreateSymbols.java   
private element_value_pair[] createElementPairs(List<CPInfo> constantPool, Map<String, Object> annotationAttributes) {
    element_value_pair[] pairs = new element_value_pair[annotationAttributes.size()];
    int i = 0;

    for (Entry<String, Object> e : annotationAttributes.entrySet()) {
        int elementNameString = addString(constantPool, e.getKey());
        element_value value = createAttributeValue(constantPool, e.getValue());
        pairs[i++] = new element_value_pair(elementNameString, value);
    }

    return pairs;
}
项目:openjdk-jdk10    文件:CreateSymbols.java   
private element_value createAttributeValue(List<CPInfo> constantPool, Object value) {
    Pair<Integer, Character> constantPoolEntry = addConstant(constantPool, value, true);
    if (constantPoolEntry != null) {
        return new Primitive_element_value(constantPoolEntry.fst, constantPoolEntry.snd);
    } else if (value instanceof EnumConstant) {
        EnumConstant ec = (EnumConstant) value;
        return new Enum_element_value(addString(constantPool, ec.type),
                                      addString(constantPool, ec.constant),
                                      'e');
    } else if (value instanceof ClassConstant) {
        ClassConstant cc = (ClassConstant) value;
        return new Class_element_value(addString(constantPool, cc.type), 'c');
    } else if (value instanceof AnnotationDescription) {
        Annotation annotation = createAnnotation(constantPool, ((AnnotationDescription) value));
        return new Annotation_element_value(annotation, '@');
    } else if (value instanceof Collection) {
        @SuppressWarnings("unchecked")
                Collection<Object> array = (Collection<Object>) value;
        element_value[] values = new element_value[array.size()];
        int i = 0;

        for (Object elem : array) {
            values[i++] = createAttributeValue(constantPool, elem);
        }

        return new Array_element_value(values, '[');
    }
    throw new IllegalStateException(value.getClass().getName());
}
项目:openjdk-jdk10    文件:CreateSymbols.java   
private static Pair<Integer, Character> addConstant(List<CPInfo> constantPool, Object value, boolean annotation) {
    if (value instanceof Boolean) {
        return Pair.of(addToCP(constantPool, new CONSTANT_Integer_info(((Boolean) value) ? 1 : 0)), 'Z');
    } else if (value instanceof Byte) {
        return Pair.of(addToCP(constantPool, new CONSTANT_Integer_info((byte) value)), 'B');
    } else if (value instanceof Character) {
        return Pair.of(addToCP(constantPool, new CONSTANT_Integer_info((char) value)), 'C');
    } else if (value instanceof Short) {
        return Pair.of(addToCP(constantPool, new CONSTANT_Integer_info((short) value)), 'S');
    } else if (value instanceof Integer) {
        return Pair.of(addToCP(constantPool, new CONSTANT_Integer_info((int) value)), 'I');
    } else if (value instanceof Long) {
        return Pair.of(addToCP(constantPool, new CONSTANT_Long_info((long) value)), 'J');
    } else if (value instanceof Float) {
        return Pair.of(addToCP(constantPool, new CONSTANT_Float_info((float) value)), 'F');
    } else if (value instanceof Double) {
        return Pair.of(addToCP(constantPool, new CONSTANT_Double_info((double) value)), 'D');
    } else if (value instanceof String) {
        int stringIndex = addString(constantPool, (String) value);
        if (annotation) {
            return Pair.of(stringIndex, 's');
        } else {
            return Pair.of(addToCP(constantPool, new CONSTANT_String_info(null, stringIndex)), 's');
        }
    }

    return null;
}
项目:openjdk-jdk10    文件:CreateSymbols.java   
private static int addString(List<CPInfo> constantPool, String string) {
    Assert.checkNonNull(string);

    int i = 0;
    for (CPInfo info : constantPool) {
        if (info instanceof CONSTANT_Utf8_info) {
            if (((CONSTANT_Utf8_info) info).value.equals(string)) {
                return i;
            }
        }
        i++;
    }

    return addToCP(constantPool, new CONSTANT_Utf8_info(string));
}
项目:openjdk-jdk10    文件:CreateSymbols.java   
private static int addToCP(List<CPInfo> constantPool, CPInfo entry) {
    int result = constantPool.size();

    constantPool.add(entry);

    if (entry.size() > 1) {
        constantPool.add(null);
    }

    return result;
}