Package org.datanucleus.enhancer
Class EnhancerMethodAdapter
- java.lang.Object
-
- org.datanucleus.enhancer.asm.MethodVisitor
-
- org.datanucleus.enhancer.EnhancerMethodAdapter
-
public class EnhancerMethodAdapter extends MethodVisitor
Adapter for methods in persistence-enabled classes allowing enhancement of direct access to user fields. Currently performs the following updates- Any GETFIELD on a field of a Persistable class is replaced by a call to dnGetXXX()
- Any PUTFIELD on a field of a Persistable class is replaced by a call to dnSetXXX()
- Any clone() method that has no superclass but calls clone() is changed to call dnSuperClone()
- Any static class initialisation adds on the "InitClass" instructions
- Any user-provided "writeObject" method will have "dnPreSerialize" added before the user method code.
-
-
Field Summary
Fields Modifier and Type Field Description protected ClassEnhancer
enhancer
The enhancer for this class.protected String
methodDescriptor
Descriptor for the method being adapted.protected String
methodName
Name for the method being adapted.-
Fields inherited from class org.datanucleus.enhancer.asm.MethodVisitor
api, mv
-
-
Constructor Summary
Constructors Constructor Description EnhancerMethodAdapter(MethodVisitor mv, ClassEnhancer enhancer, String methodName, String methodDesc)
Constructor for the method adapter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
visitFieldInsn(int opcode, String owner, String name, String desc)
Method to intercept any calls to fields.void
visitInsn(int opcode)
Method to intercept any general instructions.void
visitLabel(Label label)
Visits a label.-
Methods inherited from class org.datanucleus.enhancer.asm.MethodVisitor
visitAnnotableParameterCount, visitAnnotation, visitAnnotationDefault, visitAttribute, visitCode, visitEnd, visitFrame, visitIincInsn, visitInsnAnnotation, visitIntInsn, visitInvokeDynamicInsn, visitJumpInsn, visitLdcInsn, visitLineNumber, visitLocalVariable, visitLocalVariableAnnotation, visitLookupSwitchInsn, visitMaxs, visitMethodInsn, visitMethodInsn, visitMultiANewArrayInsn, visitParameter, visitParameterAnnotation, visitTableSwitchInsn, visitTryCatchAnnotation, visitTryCatchBlock, visitTypeAnnotation, visitTypeInsn, visitVarInsn
-
-
-
-
Field Detail
-
enhancer
protected ClassEnhancer enhancer
The enhancer for this class.
-
methodName
protected String methodName
Name for the method being adapted.
-
methodDescriptor
protected String methodDescriptor
Descriptor for the method being adapted.
-
-
Constructor Detail
-
EnhancerMethodAdapter
public EnhancerMethodAdapter(MethodVisitor mv, ClassEnhancer enhancer, String methodName, String methodDesc)
Constructor for the method adapter.- Parameters:
mv
- MethodVisitorenhancer
- ClassEnhancer for the class with the methodmethodName
- Name of the methodmethodDesc
- descriptor for the method
-
-
Method Detail
-
visitLabel
public void visitLabel(Label label)
Description copied from class:MethodVisitor
Visits a label. A label designates the instruction that will be visited just after it.- Overrides:
visitLabel
in classMethodVisitor
- Parameters:
label
- aLabel
object.
-
visitFieldInsn
public void visitFieldInsn(int opcode, String owner, String name, String desc)
Method to intercept any calls to fields.- Overrides:
visitFieldInsn
in classMethodVisitor
- Parameters:
opcode
- Operationowner
- Owner classname
- Name of the fielddesc
- Descriptor for the field
-
visitInsn
public void visitInsn(int opcode)
Method to intercept any general instructions. We use it to intercept any RETURN on a static initialisation block so we can append to it.- Overrides:
visitInsn
in classMethodVisitor
- Parameters:
opcode
- Operation
-
-