Class 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 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.
        mv - MethodVisitor
        enhancer - ClassEnhancer for the class with the method
        methodName - Name of the method
        methodDesc - 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.
        visitLabel in class MethodVisitor
        label - a Label object.
      • visitFieldInsn

        public void visitFieldInsn​(int opcode,
                                   String owner,
                                   String name,
                                   String desc)
        Method to intercept any calls to fields.
        visitFieldInsn in class MethodVisitor
        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.
        visitInsn in class MethodVisitor
        opcode - Operation