org.datanucleus.enhancer.asm
Class JdoClassAdapter

java.lang.Object
  extended by org.objectweb.asm.ClassAdapter
      extended by org.datanucleus.enhancer.asm.JdoClassAdapter
All Implemented Interfaces:
org.objectweb.asm.ClassVisitor

public class JdoClassAdapter
extends org.objectweb.asm.ClassAdapter

Adapter visitor class for providing enhancement of an existing class using ASM. Is created with its own ClassWriter, and is passed to a ClassReader to visit the class. All parts of the class to be enhanced are fed through the different visitXXX methods here allowing intervention to either enhance an existing method, or to add on new fields/methods/interfaces.


Field Summary
protected  ASMClassEnhancer enhancer
          The underlying enhancer.
protected  boolean hasDefaultConstructor
          Whether a default constructor is present.
protected  boolean hasJdoDetachedState
          Whether the field jdoDetachedState is present.
protected  boolean hasSerialVersionUID
          Whether the field serialVersionUID is present.
protected  boolean hasStaticInitialisation
          Whether the class already has a static init block.
protected  boolean hasWriteObject
          Whether the method writeObject(ObjectOutputStream) is present.
protected static org.datanucleus.util.Localiser LOCALISER
          Localisation of messages
 
Fields inherited from class org.objectweb.asm.ClassAdapter
cv
 
Constructor Summary
JdoClassAdapter(org.objectweb.asm.ClassVisitor cv, ASMClassEnhancer enhancer)
          Constructor.
 
Method Summary
 void visit(int version, int access, java.lang.String name, java.lang.String signature, java.lang.String superName, java.lang.String[] interfaces)
          Method called to visit the header of the class.
 void visitEnd()
          Method called at the end of the class.
 org.objectweb.asm.FieldVisitor visitField(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.Object value)
          Method called when a field of the class is visited.
 org.objectweb.asm.MethodVisitor visitMethod(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.String[] exceptions)
          Method called when a method of the class is visited.
 
Methods inherited from class org.objectweb.asm.ClassAdapter
visitAnnotation, visitAttribute, visitInnerClass, visitOuterClass, visitSource
 
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 underlying enhancer.


hasDefaultConstructor

protected boolean hasDefaultConstructor
Whether a default constructor is present. Set if found, and then processed in visitEnd.


hasSerialVersionUID

protected boolean hasSerialVersionUID
Whether the field serialVersionUID is present. Set if found, and processed in visitEnd.


hasJdoDetachedState

protected boolean hasJdoDetachedState
Whether the field jdoDetachedState is present. Set if found, and processed in visitEnd.


hasWriteObject

protected boolean hasWriteObject
Whether the method writeObject(ObjectOutputStream) is present. Set if found, and processed in visitEnd.


hasStaticInitialisation

protected boolean hasStaticInitialisation
Whether the class already has a static init block. Set if found, and processed in visitEnd.

Constructor Detail

JdoClassAdapter

public JdoClassAdapter(org.objectweb.asm.ClassVisitor cv,
                       ASMClassEnhancer enhancer)
Constructor. If the writer is null it means we just have to check the enhancement status

Parameters:
cv - The writer visitor
Method Detail

visit

public void visit(int version,
                  int access,
                  java.lang.String name,
                  java.lang.String signature,
                  java.lang.String superName,
                  java.lang.String[] interfaces)
Method called to visit the header of the class.

Specified by:
visit in interface org.objectweb.asm.ClassVisitor
Overrides:
visit in class org.objectweb.asm.ClassAdapter
Parameters:
version - Version of this class
access - Access for the class
name - name of the class
signature - Signature of the class
superName - Superclass name (if any)
interfaces - Interface(s) implemented

visitField

public org.objectweb.asm.FieldVisitor visitField(int access,
                                                 java.lang.String name,
                                                 java.lang.String desc,
                                                 java.lang.String signature,
                                                 java.lang.Object value)
Method called when a field of the class is visited.

Specified by:
visitField in interface org.objectweb.asm.ClassVisitor
Overrides:
visitField in class org.objectweb.asm.ClassAdapter
Parameters:
access - Access type
name - Name of the field
desc - Descriptor of the field
signature - Signature of the field
value - Value of the field
Returns:
FieldVisitor

visitMethod

public org.objectweb.asm.MethodVisitor visitMethod(int access,
                                                   java.lang.String name,
                                                   java.lang.String desc,
                                                   java.lang.String signature,
                                                   java.lang.String[] exceptions)
Method called when a method of the class is visited.

Specified by:
visitMethod in interface org.objectweb.asm.ClassVisitor
Overrides:
visitMethod in class org.objectweb.asm.ClassAdapter
Parameters:
access - Access for the method
name - Name of the method
desc - Descriptor
signature - Signature
exceptions - Exceptions that this method is declared to throw
Returns:
Visitor to visit this (or null if not wanting to visit it)

visitEnd

public void visitEnd()
Method called at the end of the class.

Specified by:
visitEnd in interface org.objectweb.asm.ClassVisitor
Overrides:
visitEnd in class org.objectweb.asm.ClassAdapter


Copyright © 2009. All Rights Reserved.