- 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 booleanenhancedFlag for whether the class is enhanced.protected ClassEnhancerenhancerEnhancer for the class.protected Set<ClassField>fieldsRequiredSet of fields required to be present.protected booleanlogErrorsWhether to log any errors at error level.protected Set<ClassMethod>methodsRequiredSet 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 booleanhasInterface(String[] interfaces, String intf)Convenience method to check if a particular interface is present in the list.booleanisEnhanced()Accessor for whether the class is considered enhanced.protected voidreportError(String msg)Convenience method to report an error in the enhancement of this class.voidvisit(int version, int access, String name, String signature, String supername, String[] interfaces)Method to visit the header of the classAnnotationVisitorvisitAnnotation(String desc, boolean visible)Method to visit a class annotationsvoidvisitAttribute(Attribute attr)Method to visit a non-standard attributevoidvisitEnd()Visit the end of the classFieldVisitorvisitField(int access, String name, String desc, String signature, Object value)Visit a field of the class.voidvisitInnerClass(String name, String outerName, String innerName, int access)Visit an inner class of the classMethodVisitorvisitMethod(int access, String name, String desc, String signature, String[] exceptions)Visit a method of the classvoidvisitOuterClass(String owner, String name, String desc)Visit an outer class.voidvisitSource(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:
visitin 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:
visitAnnotationin 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:
visitAttributein classClassVisitor- Parameters:
attr- the attribute
-
visitEnd
public void visitEnd()
Visit the end of the class- Overrides:
visitEndin classClassVisitor
-
visitField
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value)
Visit a field of the class.- Overrides:
visitFieldin 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:
visitInnerClassin 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:
visitMethodin 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:
visitOuterClassin 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:
visitSourcein classClassVisitor- Parameters:
source- name of source filedebug- debug info
-
-