com.sun.tools.classfile.Opcode Java Examples

The following examples show how to use com.sun.tools.classfile.Opcode. 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: TestDirectSuperInterfaceInvoke.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
void verifyDefaultBody(String classFile) {
    String workDir = System.getProperty("test.classes");
    File file = new File(workDir, classFile);
    try {
        final ClassFile cf = ClassFile.read(file);
        for (Method m : cf.methods) {
            Code_attribute codeAttr = (Code_attribute)m.attributes.get(Attribute.Code);
            for (Instruction instr : codeAttr.getInstructions()) {
                if (instr.getOpcode() == Opcode.INVOKESPECIAL) {
                    int pc_index = instr.getShort(1);
                    CPRefInfo ref = (CPRefInfo)cf.constant_pool.get(pc_index);
                    String className = ref.getClassName();
                    if (className.equals("BaseInterface"))
                        throw new IllegalStateException("Must not directly refer to TestedInterface");
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new Error("error reading " + file +": " + e);
    }
}
 
Example #2
Source File: TestDirectSuperInterfaceInvoke.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
void verifyDefaultBody(String classFile) {
    String workDir = System.getProperty("test.classes");
    File file = new File(workDir, classFile);
    try {
        final ClassFile cf = ClassFile.read(file);
        for (Method m : cf.methods) {
            Code_attribute codeAttr = (Code_attribute)m.attributes.get(Attribute.Code);
            for (Instruction instr : codeAttr.getInstructions()) {
                if (instr.getOpcode() == Opcode.INVOKESPECIAL) {
                    int pc_index = instr.getShort(1);
                    CPRefInfo ref = (CPRefInfo)cf.constant_pool.get(pc_index);
                    String className = ref.getClassName();
                    if (className.equals("BaseInterface"))
                        throw new IllegalStateException("Must not directly refer to TestedInterface");
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new Error("error reading " + file +": " + e);
    }
}
 
Example #3
Source File: TestDirectSuperInterfaceInvoke.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
void verifyDefaultBody(String classFile) {
    String workDir = System.getProperty("test.classes");
    File file = new File(workDir, classFile);
    try {
        final ClassFile cf = ClassFile.read(file);
        for (Method m : cf.methods) {
            Code_attribute codeAttr = (Code_attribute)m.attributes.get(Attribute.Code);
            for (Instruction instr : codeAttr.getInstructions()) {
                if (instr.getOpcode() == Opcode.INVOKESPECIAL) {
                    int pc_index = instr.getShort(1);
                    CPRefInfo ref = (CPRefInfo)cf.constant_pool.get(pc_index);
                    String className = ref.getClassName();
                    if (className.equals("BaseInterface"))
                        throw new IllegalStateException("Must not directly refer to TestedInterface");
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new Error("error reading " + file +": " + e);
    }
}
 
Example #4
Source File: TestDirectSuperInterfaceInvoke.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
void verifyDefaultBody(String classFile) {
    String workDir = System.getProperty("test.classes");
    File file = new File(workDir, classFile);
    try {
        final ClassFile cf = ClassFile.read(file);
        for (Method m : cf.methods) {
            Code_attribute codeAttr = (Code_attribute)m.attributes.get(Attribute.Code);
            for (Instruction instr : codeAttr.getInstructions()) {
                if (instr.getOpcode() == Opcode.INVOKESPECIAL) {
                    int pc_index = instr.getShort(1);
                    CPRefInfo ref = (CPRefInfo)cf.constant_pool.get(pc_index);
                    String className = ref.getClassName();
                    if (className.equals("BaseInterface"))
                        throw new IllegalStateException("Must not directly refer to TestedInterface");
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new Error("error reading " + file +": " + e);
    }
}
 
Example #5
Source File: TestDirectSuperInterfaceInvoke.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
void verifyDefaultBody(String classFile) {
    String workDir = System.getProperty("test.classes");
    File file = new File(workDir, classFile);
    try {
        final ClassFile cf = ClassFile.read(file);
        for (Method m : cf.methods) {
            Code_attribute codeAttr = (Code_attribute)m.attributes.get(Attribute.Code);
            for (Instruction instr : codeAttr.getInstructions()) {
                if (instr.getOpcode() == Opcode.INVOKESPECIAL) {
                    int pc_index = instr.getShort(1);
                    CPRefInfo ref = (CPRefInfo)cf.constant_pool.get(pc_index);
                    String className = ref.getClassName();
                    if (className.equals("BaseInterface"))
                        throw new IllegalStateException("Must not directly refer to TestedInterface");
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new Error("error reading " + file +": " + e);
    }
}
 
Example #6
Source File: TestDirectSuperInterfaceInvoke.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
void verifyDefaultBody(String classFile) {
    String workDir = System.getProperty("test.classes");
    File file = new File(workDir, classFile);
    try {
        final ClassFile cf = ClassFile.read(file);
        for (Method m : cf.methods) {
            Code_attribute codeAttr = (Code_attribute)m.attributes.get(Attribute.Code);
            for (Instruction instr : codeAttr.getInstructions()) {
                if (instr.getOpcode() == Opcode.INVOKESPECIAL) {
                    int pc_index = instr.getShort(1);
                    CPRefInfo ref = (CPRefInfo)cf.constant_pool.get(pc_index);
                    String className = ref.getClassName();
                    if (className.equals("BaseInterface"))
                        throw new IllegalStateException("Must not directly refer to TestedInterface");
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new Error("error reading " + file +": " + e);
    }
}
 
Example #7
Source File: TestDirectSuperInterfaceInvoke.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
void verifyDefaultBody(String classFile) {
    String workDir = System.getProperty("test.classes");
    File file = new File(workDir, classFile);
    try {
        final ClassFile cf = ClassFile.read(file);
        for (Method m : cf.methods) {
            Code_attribute codeAttr = (Code_attribute)m.attributes.get(Attribute.Code);
            for (Instruction instr : codeAttr.getInstructions()) {
                if (instr.getOpcode() == Opcode.INVOKESPECIAL) {
                    int pc_index = instr.getShort(1);
                    CPRefInfo ref = (CPRefInfo)cf.constant_pool.get(pc_index);
                    String className = ref.getClassName();
                    if (className.equals("BaseInterface"))
                        throw new IllegalStateException("Must not directly refer to TestedInterface");
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new Error("error reading " + file +": " + e);
    }
}
 
Example #8
Source File: TestDirectSuperInterfaceInvoke.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
void verifyDefaultBody(String classFile) {
    String workDir = System.getProperty("test.classes");
    File file = new File(workDir, classFile);
    try {
        final ClassFile cf = ClassFile.read(file);
        for (Method m : cf.methods) {
            Code_attribute codeAttr = (Code_attribute)m.attributes.get(Attribute.Code);
            for (Instruction instr : codeAttr.getInstructions()) {
                if (instr.getOpcode() == Opcode.INVOKESPECIAL) {
                    int pc_index = instr.getShort(1);
                    CPRefInfo ref = (CPRefInfo)cf.constant_pool.get(pc_index);
                    String className = ref.getClassName();
                    if (className.equals("BaseInterface"))
                        throw new IllegalStateException("Must not directly refer to TestedInterface");
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new Error("error reading " + file +": " + e);
    }
}
 
Example #9
Source File: ClassReader.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitConstantPoolRefAndValue(Instruction i, int i1, int i2, Void p) {
    // workaround for a potential bug in classfile
    Element ie = new Element(i.getMnemonic());
    if (i.getOpcode().equals(Opcode.IINC_W)) {
        ie.setAttr("loc", "" + i1);
        ie.setAttr("num", "" + i2);
    } else {
        ie.setAttr("ref", x.getCpString(i1));
        ie.setAttr("val", "" + i2);
    }
    return ie;
}
 
Example #10
Source File: ClassReader.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitConstantPoolRefAndValue(Instruction i, int i1, int i2, Void p) {
    // workaround for a potential bug in classfile
    Element ie = new Element(i.getMnemonic());
    if (i.getOpcode().equals(Opcode.IINC_W)) {
        ie.setAttr("loc", "" + i1);
        ie.setAttr("num", "" + i2);
    } else {
        ie.setAttr("ref", x.getCpString(i1));
        ie.setAttr("val", "" + i2);
    }
    return ie;
}
 
Example #11
Source File: ClassReader.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitNoOperands(Instruction i, Void p) {
    Opcode o = i.getOpcode();
    Element e = new Element(i.getMnemonic());
    if (o.opcode > 0xab && o.opcode <= 0xb1) {
        e.setAttr("pc", "" + i.getPC());
    }
    return e;
}
 
Example #12
Source File: ClassReader.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitConstantPoolRefAndValue(Instruction i, int i1, int i2, Void p) {
    // workaround for a potential bug in classfile
    Element ie = new Element(i.getMnemonic());
    if (i.getOpcode().equals(Opcode.IINC_W)) {
        ie.setAttr("loc", "" + i1);
        ie.setAttr("num", "" + i2);
    } else {
        ie.setAttr("ref", x.getCpString(i1));
        ie.setAttr("val", "" + i2);
    }
    return ie;
}
 
Example #13
Source File: ClassReader.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitNoOperands(Instruction i, Void p) {
    Opcode o = i.getOpcode();
    Element e = new Element(i.getMnemonic());
    if (o.opcode > 0xab && o.opcode <= 0xb1) {
        e.setAttr("pc", "" + i.getPC());
    }
    return e;
}
 
Example #14
Source File: ClassReader.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitConstantPoolRefAndValue(Instruction i, int i1, int i2, Void p) {
    // workaround for a potential bug in classfile
    Element ie = new Element(i.getMnemonic());
    if (i.getOpcode().equals(Opcode.IINC_W)) {
        ie.setAttr("loc", "" + i1);
        ie.setAttr("num", "" + i2);
    } else {
        ie.setAttr("ref", x.getCpString(i1));
        ie.setAttr("val", "" + i2);
    }
    return ie;
}
 
Example #15
Source File: ClassReader.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitNoOperands(Instruction i, Void p) {
    Opcode o = i.getOpcode();
    Element e = new Element(i.getMnemonic());
    if (o.opcode > 0xab && o.opcode <= 0xb1) {
        e.setAttr("pc", "" + i.getPC());
    }
    return e;
}
 
Example #16
Source File: ClassReader.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitConstantPoolRefAndValue(Instruction i, int i1, int i2, Void p) {
    // workaround for a potential bug in classfile
    Element ie = new Element(i.getMnemonic());
    if (i.getOpcode().equals(Opcode.IINC_W)) {
        ie.setAttr("loc", "" + i1);
        ie.setAttr("num", "" + i2);
    } else {
        ie.setAttr("ref", x.getCpString(i1));
        ie.setAttr("val", "" + i2);
    }
    return ie;
}
 
Example #17
Source File: ClassReader.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitNoOperands(Instruction i, Void p) {
    Opcode o = i.getOpcode();
    Element e = new Element(i.getMnemonic());
    if (o.opcode > 0xab && o.opcode <= 0xb1) {
        e.setAttr("pc", "" + i.getPC());
    }
    return e;
}
 
Example #18
Source File: ClassReader.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitConstantPoolRefAndValue(Instruction i, int i1, int i2, Void p) {
    // workaround for a potential bug in classfile
    Element ie = new Element(i.getMnemonic());
    if (i.getOpcode().equals(Opcode.IINC_W)) {
        ie.setAttr("loc", "" + i1);
        ie.setAttr("num", "" + i2);
    } else {
        ie.setAttr("ref", x.getCpString(i1));
        ie.setAttr("val", "" + i2);
    }
    return ie;
}
 
Example #19
Source File: ClassReader.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitNoOperands(Instruction i, Void p) {
    Opcode o = i.getOpcode();
    Element e = new Element(i.getMnemonic());
    if (o.opcode > 0xab && o.opcode <= 0xb1) {
        e.setAttr("pc", "" + i.getPC());
    }
    return e;
}
 
Example #20
Source File: ClassReader.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitConstantPoolRefAndValue(Instruction i, int i1, int i2, Void p) {
    // workaround for a potential bug in classfile
    Element ie = new Element(i.getMnemonic());
    if (i.getOpcode().equals(Opcode.IINC_W)) {
        ie.setAttr("loc", "" + i1);
        ie.setAttr("num", "" + i2);
    } else {
        ie.setAttr("ref", x.getCpString(i1));
        ie.setAttr("val", "" + i2);
    }
    return ie;
}
 
Example #21
Source File: ClassReader.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitNoOperands(Instruction i, Void p) {
    Opcode o = i.getOpcode();
    Element e = new Element(i.getMnemonic());
    if (o.opcode > 0xab && o.opcode <= 0xb1) {
        e.setAttr("pc", "" + i.getPC());
    }
    return e;
}
 
Example #22
Source File: ClassReader.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitConstantPoolRefAndValue(Instruction i, int i1, int i2, Void p) {
    // workaround for a potential bug in classfile
    Element ie = new Element(i.getMnemonic());
    if (i.getOpcode().equals(Opcode.IINC_W)) {
        ie.setAttr("loc", "" + i1);
        ie.setAttr("num", "" + i2);
    } else {
        ie.setAttr("ref", x.getCpString(i1));
        ie.setAttr("val", "" + i2);
    }
    return ie;
}
 
Example #23
Source File: ClassReader.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitNoOperands(Instruction i, Void p) {
    Opcode o = i.getOpcode();
    Element e = new Element(i.getMnemonic());
    if (o.opcode > 0xab && o.opcode <= 0xb1) {
        e.setAttr("pc", "" + i.getPC());
    }
    return e;
}
 
Example #24
Source File: ClassReader.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitConstantPoolRefAndValue(Instruction i, int i1, int i2, Void p) {
    // workaround for a potential bug in classfile
    Element ie = new Element(i.getMnemonic());
    if (i.getOpcode().equals(Opcode.IINC_W)) {
        ie.setAttr("loc", "" + i1);
        ie.setAttr("num", "" + i2);
    } else {
        ie.setAttr("ref", x.getCpString(i1));
        ie.setAttr("val", "" + i2);
    }
    return ie;
}
 
Example #25
Source File: ClassReader.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitNoOperands(Instruction i, Void p) {
    Opcode o = i.getOpcode();
    Element e = new Element(i.getMnemonic());
    if (o.opcode > 0xab && o.opcode <= 0xb1) {
        e.setAttr("pc", "" + i.getPC());
    }
    return e;
}
 
Example #26
Source File: ClassReader.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitConstantPoolRefAndValue(Instruction i, int i1, int i2, Void p) {
    // workaround for a potential bug in classfile
    Element ie = new Element(i.getMnemonic());
    if (i.getOpcode().equals(Opcode.IINC_W)) {
        ie.setAttr("loc", "" + i1);
        ie.setAttr("num", "" + i2);
    } else {
        ie.setAttr("ref", x.getCpString(i1));
        ie.setAttr("val", "" + i2);
    }
    return ie;
}
 
Example #27
Source File: ClassReader.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitNoOperands(Instruction i, Void p) {
    Opcode o = i.getOpcode();
    Element e = new Element(i.getMnemonic());
    if (o.opcode > 0xab && o.opcode <= 0xb1) {
        e.setAttr("pc", "" + i.getPC());
    }
    return e;
}
 
Example #28
Source File: ClassReader.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitConstantPoolRefAndValue(Instruction i, int i1, int i2, Void p) {
    // workaround for a potential bug in classfile
    Element ie = new Element(i.getMnemonic());
    if (i.getOpcode().equals(Opcode.IINC_W)) {
        ie.setAttr("loc", "" + i1);
        ie.setAttr("num", "" + i2);
    } else {
        ie.setAttr("ref", x.getCpString(i1));
        ie.setAttr("val", "" + i2);
    }
    return ie;
}
 
Example #29
Source File: ClassReader.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitNoOperands(Instruction i, Void p) {
    Opcode o = i.getOpcode();
    Element e = new Element(i.getMnemonic());
    if (o.opcode > 0xab && o.opcode <= 0xb1) {
        e.setAttr("pc", "" + i.getPC());
    }
    return e;
}
 
Example #30
Source File: ClassReader.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitConstantPoolRefAndValue(Instruction i, int i1, int i2, Void p) {
    // workaround for a potential bug in classfile
    Element ie = new Element(i.getMnemonic());
    if (i.getOpcode().equals(Opcode.IINC_W)) {
        ie.setAttr("loc", "" + i1);
        ie.setAttr("num", "" + i2);
    } else {
        ie.setAttr("ref", x.getCpString(i1));
        ie.setAttr("val", "" + i2);
    }
    return ie;
}