Package org.datanucleus.enhancer
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 ClassEnhancer
The enhancer for this class.(package private) boolean
protected String
Descriptor for the method being adapted.protected String
Name for the method being adapted.Fields inherited from class org.datanucleus.enhancer.asm.MethodVisitor
api, mv
-
Constructor Summary
ConstructorsConstructorDescriptionEnhancerMethodAdapter
(MethodVisitor mv, ClassEnhancer enhancer, String methodName, String methodDesc) Constructor for the method adapter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
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: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
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
-