// if the method is extending something, then we have
// to test if the handler is initialized...
if (md.isImplemented()) {
ga.dup();
Label ok = ga.newLabel();
ga.ifNonNull(ok);
ga.loadThis();
ga.loadArgs();
ga.invokeConstructor(superType, m);
ga.returnValue();
ga.mark(ok);
}
ga.loadThis();
ga.getStatic(selfType, field_name, PROXY_METHOD_TYPE);
if (m.getArgumentTypes().length == 0) {
// load static empty array
ga.getStatic(JAVA_PROXY_TYPE, "NO_ARGS", Type
.getType(Object[].class));
} else {
// box arguments
ga.loadArgArray();
}
Label before = ga.mark();
ga.invokeInterface(INVOCATION_HANDLER_TYPE,
INVOCATION_HANDLER_INVOKE_METHOD);
Label after = ga.mark();
ga.unbox(m.getReturnType());
ga.returnValue();
// this is a simple rethrow handler
Label rethrow = ga.mark();
ga.visitInsn(Opcodes.ATHROW);
for (int i = 0; i < ex.length; i++) {
ga.visitTryCatchBlock(before, after, rethrow, ex[i]
.getInternalName());
}
ga.visitTryCatchBlock(before, after, rethrow, "java/lang/Error");
ga.visitTryCatchBlock(before, after, rethrow,
"java/lang/RuntimeException");
Type thr = Type.getType(Throwable.class);
Label handler = ga.mark();
Type udt = Type.getType(UndeclaredThrowableException.class);
int loc = ga.newLocal(thr);
ga.storeLocal(loc, thr);
ga.newInstance(udt);
ga.dup();