Package org.datanucleus.enhancer
Class EnhancerClassChecker
java.lang.Object
org.datanucleus.enhancer.asm.ClassVisitor
org.datanucleus.enhancer.EnhancerClassChecker
Visitor used to check the enhancement state of a class.
Checks the methods/fields present against what is required for enhancement.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Flag for whether the class is enhanced.protected ClassEnhancer
Enhancer for the class.protected Set
<ClassField> Set of fields required to be present.protected boolean
Whether to log any errors at error level.protected Set
<ClassMethod> Set of methods required to be present.Fields inherited from class org.datanucleus.enhancer.asm.ClassVisitor
api, cv
-
Constructor Summary
ConstructorsConstructorDescriptionEnhancerClassChecker
(ClassEnhancer enhancer, boolean logErrors) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
hasInterface
(String[] interfaces, String intf) Convenience method to check if a particular interface is present in the list.boolean
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 classvisitAnnotation
(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 classvisitField
(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 classvisitMethod
(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 classMethods inherited from class org.datanucleus.enhancer.asm.ClassVisitor
getDelegate, visitModule, visitNestHost, visitNestMember, visitPermittedSubclass, visitRecordComponent, visitTypeAnnotation
-
Field Details
-
enhancer
Enhancer for the class. -
fieldsRequired
Set of fields required to be present. -
methodsRequired
Set of methods required to be present. -
enhanced
protected boolean enhancedFlag for whether the class is enhanced. Set in the visit process. -
logErrors
protected boolean logErrorsWhether to log any errors at error level.
-
-
Constructor Details
-
EnhancerClassChecker
Constructor.- Parameters:
enhancer
- The class enhancerlogErrors
- Whether to log any errors at error level
-
-
Method Details
-
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
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
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
Method to visit a class annotations- Overrides:
visitAnnotation
in classClassVisitor
- Parameters:
desc
- descriptor of the annotationvisible
- Whether visible- Returns:
- The visitor
-
visitAttribute
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
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
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
Visit the source of the class- Overrides:
visitSource
in classClassVisitor
- Parameters:
source
- name of source filedebug
- debug info
-