// A RuntimeException should not cause an
// UndeclaredThrowableException, so we catch and re-throw it
// that before throwable.
if (handle_throwable_exception && handle_runtime_exception) {
mg.addExceptionHandler(tryStart, tryEnd, rethrowLocation,
new ObjectType("java.lang.RuntimeException"));
}
// If anything else is thrown, it is wrapped in an
// UndeclaredThrowable
if (handle_throwable_exception) {
InstructionHandle handlerStart = il.append(new ASTORE(1));
il
.append(new NEW(
cp
.addClass("java.lang.reflect.UndeclaredThrowableException")));
il.append(InstructionConstants.DUP);
il.append(new ALOAD(1));
il.append(new INVOKESPECIAL(cp.addMethodref(
"java.lang.reflect.UndeclaredThrowableException", "<init>",
"(Ljava/lang/Throwable;)V")));
il.append(new ATHROW());
mg.addExceptionHandler(tryStart, tryEnd, handlerStart,
new ObjectType("java.lang.Throwable"));
}
//
// DONE
//