Bytecode Instrumentation

| 2004 JavaOne
SM
Conference | Session 3042 Copyright Hewlett Packard Co., 2004.
21
JRat (BCEL-based) jrat.sourceforge.net
public class MyMath {
public int max(int a, int b) {
return (a > b) ? a : b;
}
}
public class MyMath
{
static final MethodHandler HANDLER_FOR_max_0 =
HandlerFactory.getMethodHandler( "org.package.MyMath", "max",
"(II)I");
private final int max__shiftone_JRat(int a, int b) {
return (a > b) ? a : b;
}
public int max(int a, int b) {
long start = 0L;
Object args[] = null;
boolean success = false;
try {
HANDLER_FOR_max_0.onMethodStart(this, args);
start = System.currentTimeMillis();
int result = max__shiftone_JRat(a,b);
success = true;
return result;
}
catch(Throwable t) {
HANDLER_FOR_max_0.onMethodError(this, args, t);
throw t;
}
finally {
HANDLER_FOR_max_0.onMethodFinish(this, args, null,
System.currentTimeMillis() - start, success);
}
}
}
Wrapping for
collection of
timing information