public abstract class AbstractWovenProxyMethodAdapter
extends org.objectweb.asm.commons.GeneratorAdapter
WovenProxyConcreteMethodAdapter
is used for weaving instance methods
WovenProxyAbstractMethodAdapter
is used to provide a delegating
implementation of an interface method.
Roughly (but not exactly because it's easier to write working bytecode
if you don't have to exactly recreate the Java!) this is trying to
do the following:
if(dispatcher != null) {
int returnValue;
Object token = null;
boolean inInvoke = false;
try {
Object toInvoke = dispatcher.call();
if(listener != null)
token = listener.preInvoke(toInvoke, method, args);
inInvoke = true;
returnValue = ((Template) toInvoke).doStuff(args);
inInvoke = false;
if(listener != null)
listener.postInvoke(token, toInvoke, method, args);
} catch (Throwable e){
// whether the the exception is an error is an application decision
// if we catch an exception we decide carefully which one to
// throw onwards
Throwable exceptionToRethrow = null;
// if the exception came from a precall or postcall
// we will rethrow it
if (!inInvoke) {
exceptionToRethrow = e;
}
// if the exception didn't come from precall or postcall then it
// came from invoke
// we will rethrow this exception if it is not a runtime
// exception, but we must unwrap InvocationTargetExceptions
else {
if (!(e instanceof RuntimeException)) {
exceptionToRethrow = e;
}
}
try {
if(listener != null)
listener.postInvokeExceptionalReturn(token, method, null, e);
} catch (Throwable f) {
// we caught an exception from
// postInvokeExceptionalReturn
// if we haven't already chosen an exception to rethrow then
// we will throw this exception
if (exceptionToRethrow == null) {
exceptionToRethrow = f;
}
}
// if we made it this far without choosing an exception we
// should throw e
if (exceptionToRethrow == null) {
exceptionToRethrow = e;
}
throw exceptionToRethrow;
}
}
//...original method body
Modifier and Type | Field and Description |
---|---|
protected org.objectweb.asm.commons.Method |
currentTransformMethod
The current method
|
protected org.objectweb.asm.Type |
typeBeingWoven
The type of
this |
Constructor and Description |
---|
AbstractWovenProxyMethodAdapter(org.objectweb.asm.MethodVisitor mv,
int access,
String name,
String desc,
String methodStaticFieldName,
org.objectweb.asm.commons.Method currentTransformMethod,
org.objectweb.asm.Type typeBeingWoven,
org.objectweb.asm.Type methodDeclaringType,
boolean isMethodDeclaringTypeInterface,
boolean isDefaultMethod)
Construct a new method adapter
|
Modifier and Type | Method and Description |
---|---|
protected void |
unwrapEqualsArgument()
This method unwraps woven proxy instances for use in the right-hand side
of equals methods
|
abstract void |
visitCode() |
abstract void |
visitMaxs(int stack,
int locals) |
protected void |
writeDispatcher()
Write out the bytecode instructions necessary to do the dispatch.
|
arrayLength, arrayLoad, arrayStore, box, cast, catchException, checkCast, dup, dup2, dup2X1, dup2X2, dupX1, dupX2, endMethod, getAccess, getArgumentTypes, getField, getLocalType, getName, getReturnType, getStatic, goTo, ifCmp, ifICmp, ifNonNull, ifNull, ifZCmp, iinc, instanceOf, invokeConstructor, invokeDynamic, invokeInterface, invokeStatic, invokeVirtual, loadArg, loadArgArray, loadArgs, loadArgs, loadLocal, loadLocal, loadThis, mark, mark, math, monitorEnter, monitorExit, newArray, newInstance, newLabel, not, pop, pop2, push, push, push, push, push, push, push, push, putField, putStatic, ret, returnValue, setLocalType, storeArg, storeLocal, storeLocal, swap, swap, tableSwitch, tableSwitch, throwException, throwException, unbox, valueOf
newLocal, newLocalMapping, updateNewLocals, visitFrame, visitIincInsn, visitLocalVariable, visitLocalVariableAnnotation, visitVarInsn
visitAnnotableParameterCount, visitAnnotation, visitAnnotationDefault, visitAttribute, visitEnd, visitFieldInsn, visitInsn, visitInsnAnnotation, visitIntInsn, visitInvokeDynamicInsn, visitJumpInsn, visitLabel, visitLdcInsn, visitLineNumber, visitLookupSwitchInsn, visitMethodInsn, visitMethodInsn, visitMultiANewArrayInsn, visitParameter, visitParameterAnnotation, visitTableSwitchInsn, visitTryCatchAnnotation, visitTryCatchBlock, visitTypeAnnotation, visitTypeInsn
protected final org.objectweb.asm.commons.Method currentTransformMethod
protected final org.objectweb.asm.Type typeBeingWoven
this
public AbstractWovenProxyMethodAdapter(org.objectweb.asm.MethodVisitor mv, int access, String name, String desc, String methodStaticFieldName, org.objectweb.asm.commons.Method currentTransformMethod, org.objectweb.asm.Type typeBeingWoven, org.objectweb.asm.Type methodDeclaringType, boolean isMethodDeclaringTypeInterface, boolean isDefaultMethod)
mv
- - the method visitor to write toaccess
- - the access modifiers on this methodname
- - the name of this methoddesc
- - the descriptor of this methodmethodStaticFieldName
- - the name of the static field that will hold
the Method
representing
this method.currentTransformMethod
- - the ASM representation of this methodproxyType
- - the type being woven that contains this methodpublic abstract void visitCode()
visitCode
in class org.objectweb.asm.MethodVisitor
public abstract void visitMaxs(int stack, int locals)
visitMaxs
in class org.objectweb.asm.commons.LocalVariablesSorter
protected final void writeDispatcher()
protected final void unwrapEqualsArgument()
Copyright © 2018. All rights reserved.