Class 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 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 enhancer
        logErrors - 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 class ClassVisitor
        Parameters:
        version - Version of the class file
        access - Access type
        name - name of the class
        signature - signature of the class
        supername - superclass name
        interfaces - 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 implemented
        intf - 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 class ClassVisitor
        Parameters:
        desc - descriptor of the annotation
        visible - Whether visible
        Returns:
        The visitor
      • visitAttribute

        public void visitAttribute​(Attribute attr)
        Method to visit a non-standard attribute
        Overrides:
        visitAttribute in class ClassVisitor
        Parameters:
        attr - the attribute
      • visitEnd

        public void visitEnd()
        Visit the end of the class
        Overrides:
        visitEnd in class ClassVisitor
      • visitField

        public FieldVisitor visitField​(int access,
                                       String name,
                                       String desc,
                                       String signature,
                                       Object value)
        Visit a field of the class.
        Overrides:
        visitField in class ClassVisitor
        Parameters:
        access - Access for the field
        name - name of the field
        desc - Descriptor of the field
        signature - signature of the field
        value - 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 class ClassVisitor
        Parameters:
        name - Internal name of the class
        outerName - name of the outer class
        innerName - name of the inner class
        access - 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 class ClassVisitor
        Parameters:
        access - Access for the field
        name - name of the field
        desc - Descriptor of the field
        signature - signature of the field
        exceptions - Exceptions thrown
        Returns:
        visitor for the method
      • visitOuterClass

        public void visitOuterClass​(String owner,
                                    String name,
                                    String desc)
        Visit an outer class.
        Overrides:
        visitOuterClass in class ClassVisitor
        Parameters:
        owner - owner for the outer class
        name - name of the outer class
        desc - Descriptor of the outer class
      • visitSource

        public void visitSource​(String source,
                                String debug)
        Visit the source of the class
        Overrides:
        visitSource in class ClassVisitor
        Parameters:
        source - name of source file
        debug - debug info