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);
}
}
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;
}
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);
}
}
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);
}
}
Aggregations