org.datanucleus.enhancer.asm
Class JdoPropertyGetterAdapter

java.lang.Object
  extended by org.objectweb.asm.MethodAdapter
      extended by org.datanucleus.enhancer.asm.JdoPropertyGetterAdapter
All Implemented Interfaces:
org.objectweb.asm.MethodVisitor

public class JdoPropertyGetterAdapter
extends org.objectweb.asm.MethodAdapter

Adapter for property getter methods in JDO-enabled classes. This adapter processes the getXXX method and

When detachable this will be (CHECK_READ variant)
 YYY getZZZ()
 {
     if (jdoFlags > 0 && jdoStateManager != null && !jdoStateManager.isLoaded(this, 0))
         return (Integer) jdoStateManager.getObjectField(this, 0, jdoGetXXX());
     if (jdoIsDetached() && !((BitSet) jdoDetachedState[2]).get(0))
         throw new JDODetachedFieldAccessException
             ("You have just attempted to access property \"id\" yet this field was not detached ...");
     return jdoGetXXX();
 }
 
and when not detachable
 YYY getZZZ()
 {
     if (jdoFlags > 0 && jdoStateManager != null && !jdoStateManager.isLoaded(this, 0))
         return (Integer) jdoStateManager.getObjectField(this, 0, jdoGetXXX());
     return jdoGetXXX();
 }
 
There are other variants for MEDIATE_READ and NORMAL_READ


Field Summary
protected  ASMClassEnhancer enhancer
          The enhancer for this class.
protected  org.objectweb.asm.MethodVisitor jdoVisitor
          Visitor for the jdoGetXXX method.
protected static org.datanucleus.util.Localiser LOCALISER
          Localisation of messages.
protected  java.lang.String methodDescriptor
          Descriptor for the method being adapted.
protected  java.lang.String methodName
          Name for the method being adapted.
protected  org.datanucleus.metadata.AbstractMemberMetaData mmd
          MetaData for the property.
 
Fields inherited from class org.objectweb.asm.MethodAdapter
mv
 
Constructor Summary
JdoPropertyGetterAdapter(org.objectweb.asm.MethodVisitor mv, ASMClassEnhancer enhancer, java.lang.String methodName, java.lang.String methodDesc, org.datanucleus.metadata.AbstractMemberMetaData mmd, org.objectweb.asm.ClassVisitor cv)
          Constructor for the method adapter.
 
Method Summary
static void generateGetXXXMethod(org.objectweb.asm.MethodVisitor mv, org.datanucleus.metadata.AbstractMemberMetaData mmd, java.lang.String asmClassName, java.lang.String asmClassDesc)
          Convenience method to use the MethodVisitor to generate the code for the method getXXX() for the property with the specified MetaData.
 org.objectweb.asm.AnnotationVisitor visitAnnotation(java.lang.String arg0, boolean arg1)
           
 org.objectweb.asm.AnnotationVisitor visitAnnotationDefault()
           
 void visitAttribute(org.objectweb.asm.Attribute arg0)
           
 void visitCode()
           
 void visitEnd()
          Method called at the end of visiting the getXXX method.
 void visitFieldInsn(int arg0, java.lang.String arg1, java.lang.String arg2, java.lang.String arg3)
           
 void visitFrame(int arg0, int arg1, java.lang.Object[] arg2, int arg3, java.lang.Object[] arg4)
           
 void visitIincInsn(int arg0, int arg1)
           
 void visitInsn(int arg0)
           
 void visitIntInsn(int arg0, int arg1)
           
 void visitJumpInsn(int arg0, org.objectweb.asm.Label arg1)
           
 void visitLabel(org.objectweb.asm.Label arg0)
           
 void visitLdcInsn(java.lang.Object arg0)
           
 void visitLineNumber(int arg0, org.objectweb.asm.Label arg1)
           
 void visitLocalVariable(java.lang.String arg0, java.lang.String arg1, java.lang.String arg2, org.objectweb.asm.Label arg3, org.objectweb.asm.Label arg4, int arg5)
           
 void visitLookupSwitchInsn(org.objectweb.asm.Label arg0, int[] arg1, org.objectweb.asm.Label[] arg2)
           
 void visitMaxs(int arg0, int arg1)
           
 void visitMethodInsn(int arg0, java.lang.String arg1, java.lang.String arg2, java.lang.String arg3)
           
 void visitMultiANewArrayInsn(java.lang.String arg0, int arg1)
           
 org.objectweb.asm.AnnotationVisitor visitParameterAnnotation(int arg0, java.lang.String arg1, boolean arg2)
           
 void visitTableSwitchInsn(int arg0, int arg1, org.objectweb.asm.Label arg2, org.objectweb.asm.Label[] arg3)
           
 void visitTryCatchBlock(org.objectweb.asm.Label arg0, org.objectweb.asm.Label arg1, org.objectweb.asm.Label arg2, java.lang.String arg3)
           
 void visitTypeInsn(int arg0, java.lang.String arg1)
           
 void visitVarInsn(int arg0, int arg1)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static org.datanucleus.util.Localiser LOCALISER
Localisation of messages.


enhancer

protected ASMClassEnhancer enhancer
The enhancer for this class.


methodName

protected java.lang.String methodName
Name for the method being adapted.


methodDescriptor

protected java.lang.String methodDescriptor
Descriptor for the method being adapted.


mmd

protected org.datanucleus.metadata.AbstractMemberMetaData mmd
MetaData for the property.


jdoVisitor

protected org.objectweb.asm.MethodVisitor jdoVisitor
Visitor for the jdoGetXXX method.

Constructor Detail

JdoPropertyGetterAdapter

public JdoPropertyGetterAdapter(org.objectweb.asm.MethodVisitor mv,
                                ASMClassEnhancer enhancer,
                                java.lang.String methodName,
                                java.lang.String methodDesc,
                                org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                org.objectweb.asm.ClassVisitor cv)
Constructor for the method adapter.

Parameters:
mv - MethodVisitor
enhancer - ClassEnhancer for the class with the method
methodName - Name of the method
methodDesc - Method descriptor
mmd - MetaData for the property
cv - ClassVisitor
Method Detail

visitEnd

public void visitEnd()
Method called at the end of visiting the getXXX method. This is used to add the jdoGetXXX method with the same code as is present originally in the getXXX method.

Specified by:
visitEnd in interface org.objectweb.asm.MethodVisitor
Overrides:
visitEnd in class org.objectweb.asm.MethodAdapter

generateGetXXXMethod

public static void generateGetXXXMethod(org.objectweb.asm.MethodVisitor mv,
                                        org.datanucleus.metadata.AbstractMemberMetaData mmd,
                                        java.lang.String asmClassName,
                                        java.lang.String asmClassDesc)
Convenience method to use the MethodVisitor to generate the code for the method getXXX() for the property with the specified MetaData.

Parameters:
mv - MethodVisitor
mmd - MetaData for the property
asmClassName - ASM class name for the owning class
asmClassDesc - ASM descriptor for the owning class

visitAnnotation

public org.objectweb.asm.AnnotationVisitor visitAnnotation(java.lang.String arg0,
                                                           boolean arg1)
Specified by:
visitAnnotation in interface org.objectweb.asm.MethodVisitor
Overrides:
visitAnnotation in class org.objectweb.asm.MethodAdapter

visitAnnotationDefault

public org.objectweb.asm.AnnotationVisitor visitAnnotationDefault()
Specified by:
visitAnnotationDefault in interface org.objectweb.asm.MethodVisitor
Overrides:
visitAnnotationDefault in class org.objectweb.asm.MethodAdapter

visitAttribute

public void visitAttribute(org.objectweb.asm.Attribute arg0)
Specified by:
visitAttribute in interface org.objectweb.asm.MethodVisitor
Overrides:
visitAttribute in class org.objectweb.asm.MethodAdapter

visitCode

public void visitCode()
Specified by:
visitCode in interface org.objectweb.asm.MethodVisitor
Overrides:
visitCode in class org.objectweb.asm.MethodAdapter

visitFieldInsn

public void visitFieldInsn(int arg0,
                           java.lang.String arg1,
                           java.lang.String arg2,
                           java.lang.String arg3)
Specified by:
visitFieldInsn in interface org.objectweb.asm.MethodVisitor
Overrides:
visitFieldInsn in class org.objectweb.asm.MethodAdapter

visitFrame

public void visitFrame(int arg0,
                       int arg1,
                       java.lang.Object[] arg2,
                       int arg3,
                       java.lang.Object[] arg4)
Specified by:
visitFrame in interface org.objectweb.asm.MethodVisitor
Overrides:
visitFrame in class org.objectweb.asm.MethodAdapter

visitIincInsn

public void visitIincInsn(int arg0,
                          int arg1)
Specified by:
visitIincInsn in interface org.objectweb.asm.MethodVisitor
Overrides:
visitIincInsn in class org.objectweb.asm.MethodAdapter

visitInsn

public void visitInsn(int arg0)
Specified by:
visitInsn in interface org.objectweb.asm.MethodVisitor
Overrides:
visitInsn in class org.objectweb.asm.MethodAdapter

visitIntInsn

public void visitIntInsn(int arg0,
                         int arg1)
Specified by:
visitIntInsn in interface org.objectweb.asm.MethodVisitor
Overrides:
visitIntInsn in class org.objectweb.asm.MethodAdapter

visitJumpInsn

public void visitJumpInsn(int arg0,
                          org.objectweb.asm.Label arg1)
Specified by:
visitJumpInsn in interface org.objectweb.asm.MethodVisitor
Overrides:
visitJumpInsn in class org.objectweb.asm.MethodAdapter

visitLabel

public void visitLabel(org.objectweb.asm.Label arg0)
Specified by:
visitLabel in interface org.objectweb.asm.MethodVisitor
Overrides:
visitLabel in class org.objectweb.asm.MethodAdapter

visitLdcInsn

public void visitLdcInsn(java.lang.Object arg0)
Specified by:
visitLdcInsn in interface org.objectweb.asm.MethodVisitor
Overrides:
visitLdcInsn in class org.objectweb.asm.MethodAdapter

visitLineNumber

public void visitLineNumber(int arg0,
                            org.objectweb.asm.Label arg1)
Specified by:
visitLineNumber in interface org.objectweb.asm.MethodVisitor
Overrides:
visitLineNumber in class org.objectweb.asm.MethodAdapter

visitLocalVariable

public void visitLocalVariable(java.lang.String arg0,
                               java.lang.String arg1,
                               java.lang.String arg2,
                               org.objectweb.asm.Label arg3,
                               org.objectweb.asm.Label arg4,
                               int arg5)
Specified by:
visitLocalVariable in interface org.objectweb.asm.MethodVisitor
Overrides:
visitLocalVariable in class org.objectweb.asm.MethodAdapter

visitLookupSwitchInsn

public void visitLookupSwitchInsn(org.objectweb.asm.Label arg0,
                                  int[] arg1,
                                  org.objectweb.asm.Label[] arg2)
Specified by:
visitLookupSwitchInsn in interface org.objectweb.asm.MethodVisitor
Overrides:
visitLookupSwitchInsn in class org.objectweb.asm.MethodAdapter

visitMaxs

public void visitMaxs(int arg0,
                      int arg1)
Specified by:
visitMaxs in interface org.objectweb.asm.MethodVisitor
Overrides:
visitMaxs in class org.objectweb.asm.MethodAdapter

visitMethodInsn

public void visitMethodInsn(int arg0,
                            java.lang.String arg1,
                            java.lang.String arg2,
                            java.lang.String arg3)
Specified by:
visitMethodInsn in interface org.objectweb.asm.MethodVisitor
Overrides:
visitMethodInsn in class org.objectweb.asm.MethodAdapter

visitMultiANewArrayInsn

public void visitMultiANewArrayInsn(java.lang.String arg0,
                                    int arg1)
Specified by:
visitMultiANewArrayInsn in interface org.objectweb.asm.MethodVisitor
Overrides:
visitMultiANewArrayInsn in class org.objectweb.asm.MethodAdapter

visitParameterAnnotation

public org.objectweb.asm.AnnotationVisitor visitParameterAnnotation(int arg0,
                                                                    java.lang.String arg1,
                                                                    boolean arg2)
Specified by:
visitParameterAnnotation in interface org.objectweb.asm.MethodVisitor
Overrides:
visitParameterAnnotation in class org.objectweb.asm.MethodAdapter

visitTableSwitchInsn

public void visitTableSwitchInsn(int arg0,
                                 int arg1,
                                 org.objectweb.asm.Label arg2,
                                 org.objectweb.asm.Label[] arg3)
Specified by:
visitTableSwitchInsn in interface org.objectweb.asm.MethodVisitor
Overrides:
visitTableSwitchInsn in class org.objectweb.asm.MethodAdapter

visitTryCatchBlock

public void visitTryCatchBlock(org.objectweb.asm.Label arg0,
                               org.objectweb.asm.Label arg1,
                               org.objectweb.asm.Label arg2,
                               java.lang.String arg3)
Specified by:
visitTryCatchBlock in interface org.objectweb.asm.MethodVisitor
Overrides:
visitTryCatchBlock in class org.objectweb.asm.MethodAdapter

visitTypeInsn

public void visitTypeInsn(int arg0,
                          java.lang.String arg1)
Specified by:
visitTypeInsn in interface org.objectweb.asm.MethodVisitor
Overrides:
visitTypeInsn in class org.objectweb.asm.MethodAdapter

visitVarInsn

public void visitVarInsn(int arg0,
                         int arg1)
Specified by:
visitVarInsn in interface org.objectweb.asm.MethodVisitor
Overrides:
visitVarInsn in class org.objectweb.asm.MethodAdapter


Copyright © 2009. All Rights Reserved.