/** * {@inheritDoc} */ @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { // calling super to ensure the visitor pattern MethodVisitor methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); MethodInstrumentationConfig instrumentationConfig = shouldInstrument(name, desc); if (null != instrumentationConfig) { // using JSR inliner adapter in order to remove JSR/RET instructions // see http://mail-archive.ow2.org/asm/2008-11/msg00008.html // using only if we add byte code methodVisitor = new JSRInlinerAdapter(methodVisitor, access, name, desc, signature, exceptions); // go over all instrumentation points and create the method visitor for (IMethodInstrumentationPoint instrumentationPoint : instrumentationConfig.getAllInstrumentationPoints()) { // note that here we create a chain of method visitor by passing the current one to // the one being created, thus following the visitor pattern of ASM MethodVisitor mv = instrumenterFactory.getMethodVisitor(instrumentationPoint, methodVisitor, access, name, desc, enhancedExceptionSensor); // safety for the null returned method visitor if (null != mv) { methodVisitor = mv; } } // add to list so that we know which are applied appliedInstrumentationConfigs.add(instrumentationConfig); } return methodVisitor; }