Search in sources :

Example 1 with LocalVariableTypeTable_attribute

use of com.sun.tools.classfile.LocalVariableTypeTable_attribute in project ceylon-compiler by ceylon.

the class T7005371 method verifyLocalVariableTypeTableAttr.

void verifyLocalVariableTypeTableAttr(File f) {
    System.err.println("verify: " + f);
    try {
        ClassFile cf = ClassFile.read(f);
        Method testMethod = null;
        for (Method m : cf.methods) {
            if (m.getName(cf.constant_pool).equals(TEST_METHOD_NAME)) {
                testMethod = m;
                break;
            }
        }
        if (testMethod == null) {
            throw new Error("Missing method: " + TEST_METHOD_NAME);
        }
        Code_attribute code = (Code_attribute) testMethod.attributes.get(Attribute.Code);
        if (code == null) {
            throw new Error("Missing Code attribute for method: " + TEST_METHOD_NAME);
        }
        LocalVariableTypeTable_attribute lvt_table = (LocalVariableTypeTable_attribute) code.attributes.get(Attribute.LocalVariableTypeTable);
        if (lvt_table == null) {
            throw new Error("Missing LocalVariableTypeTable attribute for method: " + TEST_METHOD_NAME);
        }
        if (lvt_table.local_variable_table_length != LVT_LENGTH) {
            throw new Error("LocalVariableTypeTable has wrong size" + "\nfound: " + lvt_table.local_variable_table_length + "\nrequired: " + LVT_LENGTH);
        }
        String sig = cf.constant_pool.getUTF8Value(lvt_table.local_variable_table[0].signature_index);
        if (sig == null || !sig.equals(LVT_SIG_TYPE)) {
            throw new Error("LocalVariableTypeTable has wrong signature" + "\nfound: " + sig + "\nrequired: " + LVT_SIG_TYPE);
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new Error("error reading " + f + ": " + e);
    }
}
Also used : ClassFile(com.sun.tools.classfile.ClassFile) Code_attribute(com.sun.tools.classfile.Code_attribute) LocalVariableTypeTable_attribute(com.sun.tools.classfile.LocalVariableTypeTable_attribute) Method(com.sun.tools.classfile.Method)

Example 2 with LocalVariableTypeTable_attribute

use of com.sun.tools.classfile.LocalVariableTypeTable_attribute in project jdk8u_jdk by JetBrains.

the class AnnotationsElementVisitor method visitLocalVariableTypeTable.

@Override
public Element visitLocalVariableTypeTable(LocalVariableTypeTable_attribute lvtt, Element p) {
    String name = x.getCpString(lvtt.attribute_name_index);
    for (LocalVariableTypeTable_attribute.Entry e : lvtt.local_variable_table) {
        Element l = new Element(name);
        l.setAttr("bci", "" + e.start_pc);
        l.setAttr("span", "" + e.length);
        l.setAttr("name", x.getCpString(e.name_index));
        l.setAttr("type", x.getCpString(e.signature_index));
        l.setAttr("slot", "" + e.index);
        l.trimToSize();
        p.add(l);
    }
    // already added to parent
    return null;
}
Also used : Element(xmlkit.XMLKit.Element) LocalVariableTypeTable_attribute(com.sun.tools.classfile.LocalVariableTypeTable_attribute)

Example 3 with LocalVariableTypeTable_attribute

use of com.sun.tools.classfile.LocalVariableTypeTable_attribute in project ceylon by eclipse.

the class T7005371 method verifyLocalVariableTypeTableAttr.

void verifyLocalVariableTypeTableAttr(File f) {
    System.err.println("verify: " + f);
    try {
        ClassFile cf = ClassFile.read(f);
        Method testMethod = null;
        for (Method m : cf.methods) {
            if (m.getName(cf.constant_pool).equals(TEST_METHOD_NAME)) {
                testMethod = m;
                break;
            }
        }
        if (testMethod == null) {
            throw new Error("Missing method: " + TEST_METHOD_NAME);
        }
        Code_attribute code = (Code_attribute) testMethod.attributes.get(Attribute.Code);
        if (code == null) {
            throw new Error("Missing Code attribute for method: " + TEST_METHOD_NAME);
        }
        LocalVariableTypeTable_attribute lvt_table = (LocalVariableTypeTable_attribute) code.attributes.get(Attribute.LocalVariableTypeTable);
        if (lvt_table == null) {
            throw new Error("Missing LocalVariableTypeTable attribute for method: " + TEST_METHOD_NAME);
        }
        if (lvt_table.local_variable_table_length != LVT_LENGTH) {
            throw new Error("LocalVariableTypeTable has wrong size" + "\nfound: " + lvt_table.local_variable_table_length + "\nrequired: " + LVT_LENGTH);
        }
        String sig = cf.constant_pool.getUTF8Value(lvt_table.local_variable_table[0].signature_index);
        if (sig == null || !sig.equals(LVT_SIG_TYPE)) {
            throw new Error("LocalVariableTypeTable has wrong signature" + "\nfound: " + sig + "\nrequired: " + LVT_SIG_TYPE);
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new Error("error reading " + f + ": " + e);
    }
}
Also used : ClassFile(com.sun.tools.classfile.ClassFile) Code_attribute(com.sun.tools.classfile.Code_attribute) LocalVariableTypeTable_attribute(com.sun.tools.classfile.LocalVariableTypeTable_attribute) Method(com.sun.tools.classfile.Method)

Example 4 with LocalVariableTypeTable_attribute

use of com.sun.tools.classfile.LocalVariableTypeTable_attribute in project ceylon-compiler by ceylon.

the class LocalVariableTypeTableWriter method reset.

public void reset(Code_attribute attr) {
    codeAttr = attr;
    pcMap = new HashMap<Integer, List<LocalVariableTypeTable_attribute.Entry>>();
    LocalVariableTypeTable_attribute lvt = (LocalVariableTypeTable_attribute) (attr.attributes.get(Attribute.LocalVariableTypeTable));
    if (lvt == null)
        return;
    for (int i = 0; i < lvt.local_variable_table.length; i++) {
        LocalVariableTypeTable_attribute.Entry entry = lvt.local_variable_table[i];
        put(entry.start_pc, entry);
        put(entry.start_pc + entry.length, entry);
    }
}
Also used : LocalVariableTypeTable_attribute(com.sun.tools.classfile.LocalVariableTypeTable_attribute) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

LocalVariableTypeTable_attribute (com.sun.tools.classfile.LocalVariableTypeTable_attribute)4 ClassFile (com.sun.tools.classfile.ClassFile)2 Code_attribute (com.sun.tools.classfile.Code_attribute)2 Method (com.sun.tools.classfile.Method)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Element (xmlkit.XMLKit.Element)1