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

The following examples show how to use com.sun.tools.classfile.Instruction#accept() . 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: DeadCodeGeneratedForEmptyTryTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
void checkClassFile(final Path path) throws Exception {
    ClassFile classFile = ClassFile.read(
            new BufferedInputStream(Files.newInputStream(path)));
    constantPool = classFile.constant_pool;
    utf8Index = constantPool.getUTF8Index("STR_TO_LOOK_FOR");
    for (Method method: classFile.methods) {
        if (method.getName(constantPool).equals("methodToLookFor")) {
            Code_attribute codeAtt = (Code_attribute)method.attributes.get(Attribute.Code);
            for (Instruction inst: codeAtt.getInstructions()) {
                inst.accept(codeVisitor, null);
            }
        }
    }
    Assert.check(numberOfRefToStr == 1,
            "There should only be one reference to a CONSTANT_String_info structure in the generated code");
}
 
Example 2
Source File: DeadCodeGeneratedForEmptyTryTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
void checkClassFile(final Path path) throws Exception {
    ClassFile classFile = ClassFile.read(
            new BufferedInputStream(Files.newInputStream(path)));
    constantPool = classFile.constant_pool;
    utf8Index = constantPool.getUTF8Index("STR_TO_LOOK_FOR");
    for (Method method: classFile.methods) {
        if (method.getName(constantPool).equals("methodToLookFor")) {
            Code_attribute codeAtt = (Code_attribute)method.attributes.get(Attribute.Code);
            for (Instruction inst: codeAtt.getInstructions()) {
                inst.accept(codeVisitor, null);
            }
        }
    }
    Assert.check(numberOfRefToStr == 1,
            "There should only be one reference to a CONSTANT_String_info structure in the generated code");
}
 
Example 3
Source File: DeadCodeGeneratedForEmptyTryTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
void checkClassFile(final Path path) throws Exception {
    ClassFile classFile = ClassFile.read(
            new BufferedInputStream(Files.newInputStream(path)));
    constantPool = classFile.constant_pool;
    utf8Index = constantPool.getUTF8Index("STR_TO_LOOK_FOR");
    for (Method method: classFile.methods) {
        if (method.getName(constantPool).equals("methodToLookFor")) {
            Code_attribute codeAtt = (Code_attribute)method.attributes.get(Attribute.Code);
            for (Instruction inst: codeAtt.getInstructions()) {
                inst.accept(codeVisitor, null);
            }
        }
    }
    Assert.check(numberOfRefToStr == 1,
            "There should only be one reference to a CONSTANT_String_info structure in the generated code");
}
 
Example 4
Source File: DeadCodeGeneratedForEmptyTryTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
void checkClassFile(final Path path) throws Exception {
    ClassFile classFile = ClassFile.read(
            new BufferedInputStream(Files.newInputStream(path)));
    constantPool = classFile.constant_pool;
    utf8Index = constantPool.getUTF8Index("STR_TO_LOOK_FOR");
    for (Method method: classFile.methods) {
        if (method.getName(constantPool).equals("methodToLookFor")) {
            Code_attribute codeAtt = (Code_attribute)method.attributes.get(Attribute.Code);
            for (Instruction inst: codeAtt.getInstructions()) {
                inst.accept(codeVisitor, null);
            }
        }
    }
    Assert.check(numberOfRefToStr == 1,
            "There should only be one reference to a CONSTANT_String_info structure in the generated code");
}
 
Example 5
Source File: DeadCodeGeneratedForEmptyTryTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
void checkClassFile(final Path path) throws Exception {
    ClassFile classFile = ClassFile.read(
            new BufferedInputStream(Files.newInputStream(path)));
    constantPool = classFile.constant_pool;
    utf8Index = constantPool.getUTF8Index("STR_TO_LOOK_FOR");
    for (Method method: classFile.methods) {
        if (method.getName(constantPool).equals("methodToLookFor")) {
            Code_attribute codeAtt = (Code_attribute)method.attributes.get(Attribute.Code);
            for (Instruction inst: codeAtt.getInstructions()) {
                inst.accept(codeVisitor, null);
            }
        }
    }
    Assert.check(numberOfRefToStr == 1,
            "There should only be one reference to a CONSTANT_String_info structure in the generated code");
}
 
Example 6
Source File: DeadCodeGeneratedForEmptyTryTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
void checkClassFile(final Path path) throws Exception {
    ClassFile classFile = ClassFile.read(
            new BufferedInputStream(Files.newInputStream(path)));
    constantPool = classFile.constant_pool;
    utf8Index = constantPool.getUTF8Index("STR_TO_LOOK_FOR");
    for (Method method: classFile.methods) {
        if (method.getName(constantPool).equals("methodToLookFor")) {
            Code_attribute codeAtt = (Code_attribute)method.attributes.get(Attribute.Code);
            for (Instruction inst: codeAtt.getInstructions()) {
                inst.accept(codeVisitor, null);
            }
        }
    }
    Assert.check(numberOfRefToStr == 1,
            "There should only be one reference to a CONSTANT_String_info structure in the generated code");
}
 
Example 7
Source File: CodeWriter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void writeInstr(Instruction instr) {
    print(String.format("%4d: %-13s ", instr.getPC(), instr.getMnemonic()));
    // compute the number of indentations for the body of multi-line instructions
    // This is 6 (the width of "%4d: "), divided by the width of each indentation level,
    // and rounded up to the next integer.
    int indentWidth = options.indentWidth;
    int indent = (6 + indentWidth - 1) / indentWidth;
    instr.accept(instructionPrinter, indent);
    println();
}
 
Example 8
Source File: CodeWriter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void writeInstr(Instruction instr) {
    print(String.format("%4d: %-13s ", instr.getPC(), instr.getMnemonic()));
    // compute the number of indentations for the body of multi-line instructions
    // This is 6 (the width of "%4d: "), divided by the width of each indentation level,
    // and rounded up to the next integer.
    int indentWidth = options.indentWidth;
    int indent = (6 + indentWidth - 1) / indentWidth;
    instr.accept(instructionPrinter, indent);
    println();
}
 
Example 9
Source File: CodeWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void writeInstr(Instruction instr) {
    print(String.format("%4d: %-13s ", instr.getPC(), instr.getMnemonic()));
    // compute the number of indentations for the body of multi-line instructions
    // This is 6 (the width of "%4d: "), divided by the width of each indentation level,
    // and rounded up to the next integer.
    int indentWidth = options.indentWidth;
    int indent = (6 + indentWidth - 1) / indentWidth;
    instr.accept(instructionPrinter, indent);
    println();
}
 
Example 10
Source File: CodeWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void writeInstr(Instruction instr) {
    print(String.format("%4d: %-13s ", instr.getPC(), instr.getMnemonic()));
    // compute the number of indentations for the body of multi-line instructions
    // This is 6 (the width of "%4d: "), divided by the width of each indentation level,
    // and rounded up to the next integer.
    int indentWidth = options.indentWidth;
    int indent = (6 + indentWidth - 1) / indentWidth;
    instr.accept(instructionPrinter, indent);
    println();
}
 
Example 11
Source File: CodeWriter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void writeInstr(Instruction instr) {
    print(String.format("%4d: %-13s ", instr.getPC(), instr.getMnemonic()));
    // compute the number of indentations for the body of multi-line instructions
    // This is 6 (the width of "%4d: "), divided by the width of each indentation level,
    // and rounded up to the next integer.
    int indentWidth = options.indentWidth;
    int indent = (6 + indentWidth - 1) / indentWidth;
    instr.accept(instructionPrinter, indent);
    println();
}
 
Example 12
Source File: CodeWriter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void writeInstr(Instruction instr) {
    print(String.format("%4d: %-13s ", instr.getPC(), instr.getMnemonic()));
    // compute the number of indentations for the body of multi-line instructions
    // This is 6 (the width of "%4d: "), divided by the width of each indentation level,
    // and rounded up to the next integer.
    int indentWidth = options.indentWidth;
    int indent = (6 + indentWidth - 1) / indentWidth;
    instr.accept(instructionPrinter, indent);
    println();
}
 
Example 13
Source File: ClassReader.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public Element visit(Instruction i) {
    Element ie =  i.accept(this, null);
    ie.trimToSize();
    return ie;
}
 
Example 14
Source File: ClassReader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public Element visit(Instruction i) {
    Element ie =  i.accept(this, null);
    ie.trimToSize();
    return ie;
}
 
Example 15
Source File: ClassReader.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public Element visit(Instruction i) {
    Element ie =  i.accept(this, null);
    ie.trimToSize();
    return ie;
}
 
Example 16
Source File: ClassReader.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public Element visit(Instruction i) {
    Element ie =  i.accept(this, null);
    ie.trimToSize();
    return ie;
}
 
Example 17
Source File: ClassReader.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public Element visit(Instruction i) {
    Element ie =  i.accept(this, null);
    ie.trimToSize();
    return ie;
}
 
Example 18
Source File: ClassReader.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public Element visit(Instruction i) {
    Element ie =  i.accept(this, null);
    ie.trimToSize();
    return ie;
}
 
Example 19
Source File: ClassReader.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public Element visit(Instruction i) {
    Element ie =  i.accept(this, null);
    ie.trimToSize();
    return ie;
}
 
Example 20
Source File: ClassReader.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public Element visit(Instruction i) {
    Element ie =  i.accept(this, null);
    ie.trimToSize();
    return ie;
}