Java Code Examples for com.sun.tools.classfile.Instruction#getMnemonic()

The following examples show how to use com.sun.tools.classfile.Instruction#getMnemonic() . 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 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 2
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 3
Source File: ClassReader.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitLocalAndValue(Instruction i, int i1, int i2, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("loc", "" + i1);
    ie.setAttr("num", "" + i2);
    return ie;
}
 
Example 4
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 5
Source File: ClassReader.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitArrayType(Instruction i, TypeKind tk, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("num", "" + tk.value);
    ie.setAttr("val", tk.name);
    return ie;
}
 
Example 6
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 7
Source File: ClassReader.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitLocalAndValue(Instruction i, int i1, int i2, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("loc", "" + i1);
    ie.setAttr("num", "" + i2);
    return ie;
}
 
Example 8
Source File: ClassReader.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitUnknown(Instruction i, Void p) {
    Element e = new Element(i.getMnemonic());
    e.setAttr("pc", "" + i.getPC());
    e.setAttr("opcode", "" + i.getOpcode().opcode);
    return e;
}
 
Example 9
Source File: ClassReader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitLookupSwitch(Instruction i, int i1, int i2, int[] ints,
                                 int[] ints1, Void p) {
    Element ie = new Element(i.getMnemonic());
    int pc = i.getPC();
    ie.setAttr("lab", "" + (pc + i1));
    for (int k = 0 ; k < i2 ; k++) {
        Element c = new Element("Case");
        c.setAttr("num", "" + (ints[k]));
        c.setAttr("lab", "" + (pc + ints1[k]));
        c.trimToSize();
        ie.add(c);
    }
    return ie;
}
 
Example 10
Source File: ClassReader.java    From openjdk-jdk8u-backup 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 jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitArrayType(Instruction i, TypeKind tk, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("num", "" + tk.value);
    ie.setAttr("val", tk.name);
    return ie;
}
 
Example 12
Source File: ClassReader.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitUnknown(Instruction i, Void p) {
    Element e = new Element(i.getMnemonic());
    e.setAttr("pc", "" + i.getPC());
    e.setAttr("opcode", "" + i.getOpcode().opcode);
    return e;
}
 
Example 13
Source File: ClassReader.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Element visitLocal(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("loc", "" + i1);
    return ie;
}
 
Example 14
Source File: ClassReader.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Element visitLocal(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("loc", "" + i1);
    return ie;
}
 
Example 15
Source File: ClassReader.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Element visitLocal(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("loc", "" + i1);
    return ie;
}
 
Example 16
Source File: ClassReader.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Element visitBranch(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("lab", "" + (i.getPC() + i1));
    return ie;
}
 
Example 17
Source File: ClassReader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Element visitValue(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("num", "" + i1);
    return ie;
}
 
Example 18
Source File: ClassReader.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Element visitValue(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("num", "" + i1);
    return ie;
}
 
Example 19
Source File: ClassReader.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Element visitBranch(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("lab", "" + (i.getPC() + i1));
    return ie;
}
 
Example 20
Source File: ClassReader.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Element visitBranch(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("lab", "" + (i.getPC() + i1));
    return ie;
}