Class EnhancerMethodAdapter
java.lang.Object
org.datanucleus.enhancer.asm.MethodVisitor
org.datanucleus.enhancer.EnhancerMethodAdapter
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
FieldsModifier and TypeFieldDescriptionprotected ClassEnhancerThe enhancer for this class.(package private) booleanprotected StringDescriptor for the method being adapted.protected StringName for the method being adapted.Fields inherited from class MethodVisitor
api, mv -
Constructor Summary
ConstructorsConstructorDescriptionEnhancerMethodAdapter(MethodVisitor mv, ClassEnhancer enhancer, String methodName, String methodDesc) Constructor for the method adapter. -
Method Summary
Modifier and TypeMethodDescriptionvoidvisitFieldInsn(int opcode, String owner, String name, String desc) Method to intercept any calls to fields.voidvisitInsn(int opcode) Method to intercept any general instructions.voidvisitLabel(Label label) Visits a label.Methods inherited from class MethodVisitor
getDelegate, 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 Details
-
enhancer
The enhancer for this class. -
methodName
Name for the method being adapted. -
methodDescriptor
Descriptor for the method being adapted. -
firstLabel
boolean firstLabel
-
-
Constructor Details
-
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 Details
-
visitLabel
Description copied from class:MethodVisitorVisits a label. A label designates the instruction that will be visited just after it.- Overrides:
visitLabelin classMethodVisitor- Parameters:
label- aLabelobject.
-
visitFieldInsn
Method to intercept any calls to fields.- Overrides:
visitFieldInsnin 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:
visitInsnin classMethodVisitor- Parameters:
opcode- Operation
-