Class FieldAnnotation

    • Constructor Detail

      • FieldAnnotation

        public FieldAnnotation​(@DottedClassName
                               java.lang.String className,
                               java.lang.String fieldName,
                               java.lang.String fieldSig,
                               boolean isStatic)
        Constructor.
        Parameters:
        className - the name of the class containing the field
        fieldName - the name of the field
        fieldSig - the type signature of the field
      • FieldAnnotation

        public FieldAnnotation​(@DottedClassName
                               java.lang.String className,
                               java.lang.String fieldName,
                               java.lang.String fieldSig,
                               java.lang.String fieldSourceSig,
                               boolean isStatic)
      • FieldAnnotation

        public FieldAnnotation​(@DottedClassName
                               java.lang.String className,
                               java.lang.String fieldName,
                               java.lang.String fieldSig,
                               int accessFlags)
        Constructor.
        Parameters:
        className - the name of the class containing the field
        fieldName - the name of the field
        fieldSig - the type signature of the field
        accessFlags - accessFlags for the field
    • Method Detail

      • fromVisitedField

        public static FieldAnnotation fromVisitedField​(PreorderVisitor visitor)
        Factory method. Class name, field name, and field signatures are taken from the given visitor, which is visiting the field.
        Parameters:
        visitor - the visitor which is visiting the field
        Returns:
        the FieldAnnotation object
      • fromReferencedField

        public static FieldAnnotation fromReferencedField​(DismantleBytecode visitor)
        Factory method. Class name, field name, and field signatures are taken from the given visitor, which is visiting a reference to the field (i.e., a getfield or getstatic instruction).
        Parameters:
        visitor - the visitor which is visiting the field reference
        Returns:
        the FieldAnnotation object
      • fromBCELField

        public static FieldAnnotation fromBCELField​(@DottedClassName
                                                    java.lang.String className,
                                                    org.apache.bcel.classfile.Field field)
        Factory method. Construct from class name and BCEL Field object.
        Parameters:
        className - the name of the class which defines the field
        field - the BCEL Field object
        Returns:
        the FieldAnnotation
      • fromBCELField

        public static FieldAnnotation fromBCELField​(org.apache.bcel.classfile.JavaClass jClass,
                                                    org.apache.bcel.classfile.Field field)
        Factory method. Construct from class name and BCEL Field object.
        Parameters:
        jClass - the class which defines the field
        field - the BCEL Field object
        Returns:
        the FieldAnnotation
      • fromFieldDescriptor

        public static FieldAnnotation fromFieldDescriptor​(FieldDescriptor fieldDescriptor)
        Factory method. Construct from a FieldDescriptor.
        Parameters:
        fieldDescriptor - the FieldDescriptor
        Returns:
        the FieldAnnotation
      • toXField

        public XField toXField()
      • getFieldName

        public java.lang.String getFieldName()
        Get the field name.
      • getFieldSignature

        public java.lang.String getFieldSignature()
        Get the type signature of the field.
      • isStatic

        public boolean isStatic()
        Return whether or not the field is static.
      • isRead

        public static FieldAnnotation isRead​(org.apache.bcel.generic.Instruction ins,
                                             org.apache.bcel.generic.ConstantPoolGen cpg)
        Is the given instruction a read of a field?
        Parameters:
        ins - the Instruction to check
        cpg - ConstantPoolGen of the method containing the instruction
        Returns:
        the Field if the instruction is a read of a field, null otherwise
      • isWrite

        public static FieldAnnotation isWrite​(org.apache.bcel.generic.Instruction ins,
                                              org.apache.bcel.generic.ConstantPoolGen cpg)
        Is the instruction a write of a field?
        Parameters:
        ins - the Instruction to check
        cpg - ConstantPoolGen of the method containing the instruction
        Returns:
        the Field if instruction is a write of a field, null otherwise
      • accept

        public void accept​(BugAnnotationVisitor visitor)
        Description copied from interface: BugAnnotation
        Accept a BugAnnotationVisitor.
        Parameters:
        visitor - the visitor to accept
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • writeXML

        public void writeXML​(XMLOutput xmlOutput)
                      throws java.io.IOException
        Description copied from interface: XMLWriteable
        Write this object to given XMLOutput.
        Parameters:
        xmlOutput - the XMLOutput for the document
        Throws:
        java.io.IOException
      • writeXML

        public void writeXML​(XMLOutput xmlOutput,
                             boolean addMessages,
                             boolean isPrimary)
                      throws java.io.IOException
        Throws:
        java.io.IOException