use of com.sun.tools.classfile.Code_attribute.Exception_data in project ceylon-compiler by ceylon.
the class TryBlockWriter method reset.
public void reset(Code_attribute attr) {
indexMap = new HashMap<Exception_data, Integer>();
pcMap = new HashMap<Integer, List<Exception_data>>();
for (int i = 0; i < attr.exception_table.length; i++) {
Exception_data entry = attr.exception_table[i];
indexMap.put(entry, i);
put(entry.start_pc, entry);
put(entry.end_pc, entry);
put(entry.handler_pc, entry);
}
}
use of com.sun.tools.classfile.Code_attribute.Exception_data in project ceylon-compiler by ceylon.
the class TryBlockWriter method writeTrys.
public void writeTrys(Instruction instr, NoteKind kind) {
// get from Options?
String indent = space(2);
int pc = instr.getPC();
List<Exception_data> entries = pcMap.get(pc);
if (entries != null) {
for (ListIterator<Exception_data> iter = entries.listIterator(kind == NoteKind.END ? entries.size() : 0); kind == NoteKind.END ? iter.hasPrevious() : iter.hasNext(); ) {
Exception_data entry = kind == NoteKind.END ? iter.previous() : iter.next();
if (kind.match(entry, pc)) {
print(indent);
print(kind.text);
print("[");
print(indexMap.get(entry));
print("] ");
if (entry.catch_type == 0)
print("finally");
else {
print("#" + entry.catch_type);
print(" // ");
constantWriter.write(entry.catch_type);
}
println();
}
}
}
}
use of com.sun.tools.classfile.Code_attribute.Exception_data in project ceylon-compiler by ceylon.
the class Pos05 method verifyMulticatchExceptionRanges.
void verifyMulticatchExceptionRanges(File f) {
System.err.println("verify: " + f);
try {
int count = 0;
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("Test method not found");
}
Code_attribute ea = (Code_attribute) testMethod.attributes.get(Attribute.Code);
if (testMethod == null) {
throw new Error("Code attribute for test() method not found");
}
Exception_data firstExceptionTable = null;
for (int i = 0; i < ea.exception_table_langth; i++) {
if (firstExceptionTable == null) {
firstExceptionTable = ea.exception_table[i];
}
if (ea.exception_table[i].handler_pc != firstExceptionTable.handler_pc || ea.exception_table[i].start_pc != firstExceptionTable.start_pc || ea.exception_table[i].end_pc != firstExceptionTable.end_pc) {
throw new Error("Multiple overlapping catch clause found in generated code");
}
count++;
}
if (count != TYPES_IN_MULTICATCH) {
throw new Error("Wrong number of exception data found: " + count);
}
} catch (Exception e) {
e.printStackTrace();
throw new Error("error reading " + f + ": " + e);
}
}
Aggregations