Package org.datanucleus.enhancer
Class EnhancerClassChecker
- java.lang.Object
-
- org.datanucleus.enhancer.asm.ClassVisitor
-
- org.datanucleus.enhancer.EnhancerClassChecker
-
public class EnhancerClassChecker extends ClassVisitor
Visitor used to check the enhancement state of a class. Checks the methods/fields present against what is required for enhancement.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
enhanced
Flag for whether the class is enhanced.protected ClassEnhancer
enhancer
Enhancer for the class.protected Set<ClassField>
fieldsRequired
Set of fields required to be present.protected boolean
logErrors
Whether to log any errors at error level.protected Set<ClassMethod>
methodsRequired
Set of methods required to be present.-
Fields inherited from class org.datanucleus.enhancer.asm.ClassVisitor
api, cv
-
-
Constructor Summary
Constructors Constructor Description EnhancerClassChecker(ClassEnhancer enhancer, boolean logErrors)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
hasInterface(String[] interfaces, String intf)
Convenience method to check if a particular interface is present in the list.boolean
isEnhanced()
Accessor for whether the class is considered enhanced.protected void
reportError(String msg)
Convenience method to report an error in the enhancement of this class.void
visit(int version, int access, String name, String signature, String supername, String[] interfaces)
Method to visit the header of the classAnnotationVisitor
visitAnnotation(String desc, boolean visible)
Method to visit a class annotationsvoid
visitAttribute(Attribute attr)
Method to visit a non-standard attributevoid
visitEnd()
Visit the end of the classFieldVisitor
visitField(int access, String name, String desc, String signature, Object value)
Visit a field of the class.void
visitInnerClass(String name, String outerName, String innerName, int access)
Visit an inner class of the classMethodVisitor
visitMethod(int access, String name, String desc, String signature, String[] exceptions)
Visit a method of the classvoid
visitOuterClass(String owner, String name, String desc)
Visit an outer class.void
visitSource(String source, String debug)
Visit the source of the class-
Methods inherited from class org.datanucleus.enhancer.asm.ClassVisitor
visitModule, visitNestHost, visitNestMember, visitPermittedSubclass, visitRecordComponent, visitTypeAnnotation
-
-
-
-
Field Detail
-
enhancer
protected ClassEnhancer enhancer
Enhancer for the class.
-
fieldsRequired
protected Set<ClassField> fieldsRequired
Set of fields required to be present.
-
methodsRequired
protected Set<ClassMethod> methodsRequired
Set of methods required to be present.
-
enhanced
protected boolean enhanced
Flag for whether the class is enhanced. Set in the visit process.
-
logErrors
protected boolean logErrors
Whether to log any errors at error level.
-
-
Constructor Detail
-
EnhancerClassChecker
public EnhancerClassChecker(ClassEnhancer enhancer, boolean logErrors)
Constructor.- Parameters:
enhancer
- The class enhancerlogErrors
- Whether to log any errors at error level
-
-
Method Detail
-
isEnhanced
public boolean isEnhanced()
Accessor for whether the class is considered enhanced. Should only be run after passing this class to the reader as a visitor.- Returns:
- Whether the class is enhanced.
-
reportError
protected void reportError(String msg)
Convenience method to report an error in the enhancement of this class.- Parameters:
msg
- The message
-
visit
public void visit(int version, int access, String name, String signature, String supername, String[] interfaces)
Method to visit the header of the class- Overrides:
visit
in classClassVisitor
- Parameters:
version
- Version of the class fileaccess
- Access typename
- name of the classsignature
- signature of the classsupername
- superclass nameinterfaces
- interface(s)
-
hasInterface
protected boolean hasInterface(String[] interfaces, String intf)
Convenience method to check if a particular interface is present in the list.- Parameters:
interfaces
- The list of interfaces implementedintf
- The interface we are looking for- Returns:
- Whether it is present
-
visitAnnotation
public AnnotationVisitor visitAnnotation(String desc, boolean visible)
Method to visit a class annotations- Overrides:
visitAnnotation
in classClassVisitor
- Parameters:
desc
- descriptor of the annotationvisible
- Whether visible- Returns:
- The visitor
-
visitAttribute
public void visitAttribute(Attribute attr)
Method to visit a non-standard attribute- Overrides:
visitAttribute
in classClassVisitor
- Parameters:
attr
- the attribute
-
visitEnd
public void visitEnd()
Visit the end of the class- Overrides:
visitEnd
in classClassVisitor
-
visitField
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value)
Visit a field of the class.- Overrides:
visitField
in classClassVisitor
- Parameters:
access
- Access for the fieldname
- name of the fielddesc
- Descriptor of the fieldsignature
- signature of the fieldvalue
- initial value- Returns:
- The visitor for the field
-
visitInnerClass
public void visitInnerClass(String name, String outerName, String innerName, int access)
Visit an inner class of the class- Overrides:
visitInnerClass
in classClassVisitor
- Parameters:
name
- Internal name of the classouterName
- name of the outer classinnerName
- name of the inner classaccess
- access of the inner class
-
visitMethod
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)
Visit a method of the class- Overrides:
visitMethod
in classClassVisitor
- Parameters:
access
- Access for the fieldname
- name of the fielddesc
- Descriptor of the fieldsignature
- signature of the fieldexceptions
- Exceptions thrown- Returns:
- visitor for the method
-
visitOuterClass
public void visitOuterClass(String owner, String name, String desc)
Visit an outer class.- Overrides:
visitOuterClass
in classClassVisitor
- Parameters:
owner
- owner for the outer classname
- name of the outer classdesc
- Descriptor of the outer class
-
visitSource
public void visitSource(String source, String debug)
Visit the source of the class- Overrides:
visitSource
in classClassVisitor
- Parameters:
source
- name of source filedebug
- debug info
-
-