Java Code Examples for com.sun.tools.classfile.ConstantPool#InvalidIndex

The following examples show how to use com.sun.tools.classfile.ConstantPool#InvalidIndex . 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: LambdaAsm.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
}
 
Example 2
Source File: StringSharingPlugin.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void scanConstantPool(Set<Integer> utf8Descriptors)
        throws Exception {
    for (int i = 1; i < cf.constant_pool.size(); i++) {
        try {
            ConstantPool.CPInfo info = cf.constant_pool.get(i);
            if (info instanceof ConstantPool.CONSTANT_NameAndType_info) {
                ConstantPool.CONSTANT_NameAndType_info nameAndType
                        = (ConstantPool.CONSTANT_NameAndType_info) info;
                utf8Descriptors.add(nameAndType.type_index);
            }
            if (info instanceof ConstantPool.CONSTANT_MethodType_info) {
                ConstantPool.CONSTANT_MethodType_info mt
                        = (ConstantPool.CONSTANT_MethodType_info) info;
                utf8Descriptors.add(mt.descriptor_index);
            }

            if (info instanceof ConstantPool.CONSTANT_Double_info
                    || info instanceof ConstantPool.CONSTANT_Long_info) {
                i++;
            }
        } catch (ConstantPool.InvalidIndex ex) {
            throw new IOException(ex);
        }
    }
}
 
Example 3
Source File: LambdaAsm.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
}
 
Example 4
Source File: LambdaAsm.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
}
 
Example 5
Source File: LambdaAsm.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
}
 
Example 6
Source File: LambdaAsm.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
}
 
Example 7
Source File: LambdaAsm.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
}
 
Example 8
Source File: ConstantWriter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
String stringValue(int constant_pool_index) {
    ClassFile classFile = classWriter.getClassFile();
    try {
        return stringValue(classFile.constant_pool.get(constant_pool_index));
    } catch (ConstantPool.InvalidIndex e) {
        return report(e);
    }
}
 
Example 9
Source File: TestAnnotationInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void testElementValue(TestResult testResult,
                             ClassFile classFile,
                             Annotation.element_value element_value)
        throws ConstantPool.InvalidIndex {
    testTag(testResult, element_value.tag);
    Annotation.Primitive_element_value ev =
            (Annotation.Primitive_element_value) element_value;
    ConstantPool.CONSTANT_Long_info info =
            (ConstantPool.CONSTANT_Long_info) classFile.constant_pool.get(ev.const_value_index);
    testResult.checkEquals(info.value, value, "const_value_index");
}
 
Example 10
Source File: AnnotationDefaultVerifier.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void testElementValue(
        TestResult testCase,
        ClassFile classFile,
        Annotation.element_value element_value,
        String[] values) throws ConstantPool.InvalidIndex {
    Annotation.Primitive_element_value ev =
            (Annotation.Primitive_element_value) element_value;
    ConstantPool.CONSTANT_Utf8_info info =
            (ConstantPool.CONSTANT_Utf8_info)
                    classFile.constant_pool.get(ev.const_value_index);
    testCase.checkEquals(info.value, values[0], "const_value_index");
}
 
Example 11
Source File: AnnotationDefaultVerifier.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void testElementValue(
        TestResult testCase,
        ClassFile classFile,
        Annotation.element_value element_value,
        String[] values) throws ConstantPool.InvalidIndex {
    Annotation.Primitive_element_value ev =
            (Annotation.Primitive_element_value) element_value;
    ConstantPool.CONSTANT_Double_info info =
            (ConstantPool.CONSTANT_Double_info)
                    classFile.constant_pool.get(ev.const_value_index);
    testCase.checkEquals(info.value, Double.parseDouble(values[0]), "const_value_index");
}
 
Example 12
Source File: AnnotationDefaultVerifier.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void testElementValue(
        TestResult testCase,
        ClassFile classFile,
        Annotation.element_value element_value,
        String[] values) throws ConstantPool.InvalidIndex {
    Annotation.Primitive_element_value ev =
            (Annotation.Primitive_element_value) element_value;
    ConstantPool.CONSTANT_Float_info info =
            (ConstantPool.CONSTANT_Float_info)
                    classFile.constant_pool.get(ev.const_value_index);
    testCase.checkEquals(info.value, Float.parseFloat(values[0]), "const_value_index");
}
 
Example 13
Source File: ConstantWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
String stringValue(int constant_pool_index) {
    ClassFile classFile = classWriter.getClassFile();
    try {
        return stringValue(classFile.constant_pool.get(constant_pool_index));
    } catch (ConstantPool.InvalidIndex e) {
        return report(e);
    }
}
 
Example 14
Source File: ConstantWriter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
String stringValue(int constant_pool_index) {
    ClassFile classFile = classWriter.getClassFile();
    try {
        return stringValue(classFile.constant_pool.get(constant_pool_index));
    } catch (ConstantPool.InvalidIndex e) {
        return report(e);
    }
}
 
Example 15
Source File: ConstantWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
String stringValue(int constant_pool_index) {
    ClassFile classFile = classWriter.getClassFile();
    try {
        return stringValue(classFile.constant_pool.get(constant_pool_index));
    } catch (ConstantPool.InvalidIndex e) {
        return report(e);
    }
}
 
Example 16
Source File: ConstantWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
String stringValue(int constant_pool_index) {
    ClassFile classFile = classWriter.getClassFile();
    try {
        return stringValue(classFile.constant_pool.get(constant_pool_index));
    } catch (ConstantPool.InvalidIndex e) {
        return report(e);
    }
}
 
Example 17
Source File: ConstantWriter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
String stringValue(int constant_pool_index) {
    ClassFile classFile = classWriter.getClassFile();
    try {
        return stringValue(classFile.constant_pool.get(constant_pool_index));
    } catch (ConstantPool.InvalidIndex e) {
        return report(e);
    }
}
 
Example 18
Source File: ConstantWriter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
String stringValue(int constant_pool_index) {
    ClassFile classFile = classWriter.getClassFile();
    try {
        return stringValue(classFile.constant_pool.get(constant_pool_index));
    } catch (ConstantPool.InvalidIndex e) {
        return report(e);
    }
}
 
Example 19
Source File: AnnotationDefaultVerifier.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public abstract void testElementValue(
TestResult testCase,
ClassFile classFile,
Annotation.element_value element_value,
String[] values)
throws ConstantPool.InvalidIndex, ConstantPool.UnexpectedEntry;
 
Example 20
Source File: AnnotationDefaultVerifier.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void testElementValue(int tag, TestResult testResult, ClassFile classFile,
                             Annotation.element_value element_value, String[] values)
        throws ConstantPool.UnexpectedEntry, ConstantPool.InvalidIndex {
    get(tag).testElementValue(testResult, classFile, element_value, values);
}