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 Details

    • 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.
    • firstLabel

      boolean firstLabel
  • Constructor Details

    • EnhancerMethodAdapter

      public EnhancerMethodAdapter(MethodVisitor mv, ClassEnhancer enhancer, String methodName, String methodDesc)
      Constructor for the method adapter.
      Parameters:
      mv - MethodVisitor
      enhancer - ClassEnhancer for the class with the method
      methodName - Name of the method
      methodDesc - descriptor for the method
  • Method Details

    • 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 class MethodVisitor
      Parameters:
      label - a Label object.
    • visitFieldInsn

      public void visitFieldInsn(int opcode, String owner, String name, String desc)
      Method to intercept any calls to fields.
      Overrides:
      visitFieldInsn in class MethodVisitor
      Parameters:
      opcode - Operation
      owner - Owner class
      name - Name of the field
      desc - 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 class MethodVisitor
      Parameters:
      opcode - Operation