Class XFactory


  • public class XFactory
    extends java.lang.Object
    Factory methods for creating XMethod objects.
    Author:
    David Hovemeyer
    • Field Detail

      • DEBUG_UNRESOLVED

        public static final boolean DEBUG_UNRESOLVED
      • DEBUG_CIRCULARITY

        public static final boolean DEBUG_CIRCULARITY
    • Constructor Detail

      • XFactory

        public XFactory()
        Constructor.
    • Method Detail

      • canonicalizeAll

        public void canonicalizeAll()
      • intern

        public void intern​(XClass c)
      • allFields

        public java.util.Collection<XField> allFields()
      • addEmptyArrayField

        public void addEmptyArrayField​(XField f)
      • isEmptyArrayField

        public boolean isEmptyArrayField​(@CheckForNull
                                         XField f)
      • isCalled

        public boolean isCalled​(XMethod m)
      • getCalledMethods

        public java.util.Set<XMethod> getCalledMethods()
      • addFunctionThatMightBeMistakenForProcedures

        public void addFunctionThatMightBeMistakenForProcedures​(MethodDescriptor m)
      • isFunctionshatMightBeMistakenForProcedures

        public boolean isFunctionshatMightBeMistakenForProcedures​(MethodDescriptor m)
      • getReflectiveClasses

        public java.util.Set<ClassDescriptor> getReflectiveClasses()
      • isReflectiveClass

        public boolean isReflectiveClass​(ClassDescriptor c)
      • addReflectiveClasses

        public boolean addReflectiveClasses​(ClassDescriptor c)
      • isCalledDirectlyOrIndirectly

        public boolean isCalledDirectlyOrIndirectly​(XMethod m)
      • nameAndSignatureIsCalled

        public boolean nameAndSignatureIsCalled​(XMethod m)
      • isInterned

        @Deprecated
        public boolean isInterned​(XMethod m)
        Deprecated.
      • canonicalizeString

        public static java.lang.String canonicalizeString​(java.lang.String s)
      • createXMethod

        public static XMethod createXMethod​(java.lang.String className,
                                            org.apache.bcel.classfile.Method method)
        Create an XMethod object from a BCEL Method.
        Parameters:
        className - the class to which the Method belongs
        method - the Method
        Returns:
        an XMethod representing the Method
      • createXMethod

        public static XMethod createXMethod​(org.apache.bcel.classfile.JavaClass javaClass,
                                            org.apache.bcel.classfile.Method method)
        Create an XMethod object from a BCEL Method.
        Parameters:
        javaClass - the class to which the Method belongs
        method - the Method
        Returns:
        an XMethod representing the Method
      • assertDottedClassName

        public static void assertDottedClassName​(@DottedClassName
                                                 java.lang.String className)
      • assertSlashedClassName

        public static void assertSlashedClassName​(@SlashedClassName
                                                  java.lang.String className)
      • createXMethodUsingSlashedClassName

        public static XMethod createXMethodUsingSlashedClassName​(@SlashedClassName
                                                                 java.lang.String className,
                                                                 java.lang.String methodName,
                                                                 java.lang.String methodSig,
                                                                 boolean isStatic)
        Parameters:
        className -
        methodName -
        methodSig -
        isStatic -
        Returns:
        the created XMethod
      • createXMethod

        public static XMethod createXMethod​(@DottedClassName
                                            java.lang.String className,
                                            java.lang.String methodName,
                                            java.lang.String methodSig,
                                            boolean isStatic)
        Parameters:
        className -
        methodName -
        methodSig -
        isStatic -
        Returns:
        the created XMethod
      • profile

        public static void profile()
      • createXFieldUsingSlashedClassName

        public static XField createXFieldUsingSlashedClassName​(@SlashedClassName
                                                               java.lang.String className,
                                                               java.lang.String fieldName,
                                                               java.lang.String fieldSignature,
                                                               boolean isStatic)
        Create an XField object
        Parameters:
        className -
        fieldName -
        fieldSignature -
        isStatic -
        Returns:
        the created XField
      • createXField

        public static XField createXField​(@DottedClassName
                                          java.lang.String className,
                                          java.lang.String fieldName,
                                          java.lang.String fieldSignature,
                                          boolean isStatic)
        Create an XField object
        Parameters:
        className -
        fieldName -
        fieldSignature -
        isStatic -
        Returns:
        the created XField
      • createXField

        public static XField createXField​(org.apache.bcel.generic.FieldInstruction fieldInstruction,
                                          org.apache.bcel.generic.ConstantPoolGen cpg)
      • createXField

        public static XField createXField​(org.apache.bcel.classfile.JavaClass javaClass,
                                          org.apache.bcel.classfile.Field field)
      • createXField

        public static XField createXField​(java.lang.String className,
                                          org.apache.bcel.classfile.Field field)
        Create an XField object from a BCEL Field.
        Parameters:
        className - the name of the Java class containing the field
        field - the Field within the JavaClass
        Returns:
        the created XField
      • getExactXField

        public static XField getExactXField​(@SlashedClassName
                                            java.lang.String className,
                                            java.lang.String name,
                                            java.lang.String signature,
                                            boolean isStatic)
        Get an XField object exactly matching given class, name, and signature. May return an unresolved object (if the class can't be found, or does not directly declare named field).
        Parameters:
        className - name of class containing the field
        name - name of field
        signature - field signature
        isStatic - field access flags
        Returns:
        XField exactly matching class name, field name, and field signature
      • getExactXField

        @Nonnull
        public static XField getExactXField​(@SlashedClassName
                                            java.lang.String className,
                                            org.apache.bcel.classfile.Field f)
      • createXMethod

        public static XMethod createXMethod​(org.apache.bcel.generic.InvokeInstruction invokeInstruction,
                                            org.apache.bcel.generic.ConstantPoolGen cpg)
        Create an XMethod object from an InvokeInstruction.
        Parameters:
        invokeInstruction - the InvokeInstruction
        cpg - ConstantPoolGen from the class containing the instruction
        Returns:
        XMethod representing the method called by the InvokeInstruction
      • createXMethod

        public static XMethod createXMethod​(PreorderVisitor visitor)
        Create an XMethod object from the method currently being visited by the given PreorderVisitor.
        Parameters:
        visitor - the PreorderVisitor
        Returns:
        the XMethod representing the method currently being visited
      • createXField

        public static XField createXField​(PreorderVisitor visitor)
        Create an XField object from the field currently being visited by the given PreorderVisitor.
        Parameters:
        visitor - the PreorderVisitor
        Returns:
        the XField representing the method currently being visited
      • createXMethod

        public static XMethod createXMethod​(org.apache.bcel.generic.MethodGen methodGen)
      • getXClass

        @CheckForNull
        public XClass getXClass​(ClassDescriptor classDescriptor)
        Get the XClass object providing information about the class named by the given ClassDescriptor.
        Parameters:
        classDescriptor - a ClassDescriptor
        Returns:
        an XClass object providing information about the class, or null if the class cannot be found
      • compare

        public static <E extends ClassMember> int compare​(E lhs,
                                                          E rhs)
        Compare XMethod or XField object objects. All methods that implement XMethod or XField should delegate to this method when implementing compareTo(Object) if the right-hand object implements XField or XMethod.
        Parameters:
        lhs - an XMethod or XField
        rhs - an XMethod or XField
        Returns:
        comparison of lhs and rhs