Package org.datanucleus.enhancer
Class EnhancerClassAdapter
- java.lang.Object
-
- org.datanucleus.enhancer.asm.ClassVisitor
-
- org.datanucleus.enhancer.EnhancerClassAdapter
-
public class EnhancerClassAdapter extends ClassVisitor
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
Fields Modifier and Type Field Description protected ClassEnhancerenhancerThe underlying enhancer.protected booleanhasDefaultConstructorWhether a default constructor is present.protected booleanhasDetachedStateWhether the field xxxDetachedState is present.protected booleanhasSerialVersionUIDWhether the field serialVersionUID is present.protected booleanhasStaticInitialisationWhether the class already has a static init block.protected booleanhasWriteObjectWhether the method writeObject(ObjectOutputStream) is present.protected booleanneedsClone-
Fields inherited from class org.datanucleus.enhancer.asm.ClassVisitor
api, cv
-
-
Constructor Summary
Constructors Constructor Description EnhancerClassAdapter(ClassVisitor cv, ClassEnhancer enhancer)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidvisit(int version, int access, String name, String signature, String superName, String[] interfaces)Method called to visit the header of the class.voidvisitEnd()Method called at the end of the class.FieldVisitorvisitField(int access, String name, String desc, String signature, Object value)Method called when a field of the class is visited.MethodVisitorvisitMethod(int access, String name, String desc, String signature, String[] exceptions)Method called when a method of the class is visited.-
Methods inherited from class org.datanucleus.enhancer.asm.ClassVisitor
visitAnnotation, visitAttribute, visitInnerClass, visitModule, visitNestHost, visitNestMember, visitOuterClass, visitPermittedSubclass, visitRecordComponent, visitSource, visitTypeAnnotation
-
-
-
-
Field Detail
-
enhancer
protected ClassEnhancer 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.
-
hasDetachedState
protected boolean hasDetachedState
Whether the field xxxDetachedState 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.
-
needsClone
protected boolean needsClone
-
-
Constructor Detail
-
EnhancerClassAdapter
public EnhancerClassAdapter(ClassVisitor cv, ClassEnhancer enhancer)
Constructor. If the writer is null it means we just have to check the enhancement status- Parameters:
cv- The writer visitorenhancer- ClassEnhancer
-
-
Method Detail
-
visit
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces)Method called to visit the header of the class.- Overrides:
visitin classClassVisitor- Parameters:
version- Version of this classaccess- Access for the classname- name of the classsignature- Signature of the classsuperName- Superclass name (if any)interfaces- Interface(s) implemented
-
visitField
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value)
Method called when a field of the class is visited.- Overrides:
visitFieldin classClassVisitor- Parameters:
access- Access typename- Name of the fielddesc- Descriptor of the fieldsignature- Signature of the fieldvalue- Value of the field- Returns:
- FieldVisitor
-
visitMethod
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)
Method called when a method of the class is visited.- Overrides:
visitMethodin classClassVisitor- Parameters:
access- Access for the methodname- Name of the methoddesc- Descriptorsignature- Signatureexceptions- 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.- Overrides:
visitEndin classClassVisitor
-
-