Class BCELUtil


  • public abstract class BCELUtil
    extends java.lang.Object
    Utility methods for detectors and analyses using BCEL.
    Author:
    David Hovemeyer
    • Constructor Detail

      • BCELUtil

        public BCELUtil()
    • Method Detail

      • getMethodDescriptor

        public static MethodDescriptor getMethodDescriptor​(org.apache.bcel.classfile.JavaClass jclass,
                                                           org.apache.bcel.classfile.Method method)
        Construct a MethodDescriptor from JavaClass and method.
        Parameters:
        jclass - a JavaClass
        method - a Method belonging to the JavaClass
        Returns:
        a MethodDescriptor identifying the method
      • getCalledMethodDescriptor

        public static MethodDescriptor getCalledMethodDescriptor​(org.apache.bcel.generic.InvokeInstruction inv,
                                                                 org.apache.bcel.generic.ConstantPoolGen cpg)
        Get a MethodDescriptor describing the method called by given InvokeInstruction.
        Parameters:
        inv - the InvokeInstruction
        cpg - ConstantPoolGen of class containing instruction
        Returns:
        MethodDescriptor describing the called method
      • getAccessedFieldDescriptor

        public static FieldDescriptor getAccessedFieldDescriptor​(org.apache.bcel.generic.FieldInstruction fins,
                                                                 org.apache.bcel.generic.ConstantPoolGen cpg)
        Get FieldDescriptor describing the field accessed by given FieldInstruction.
        Parameters:
        fins - a FieldInstruction
        cpg - ConstantPoolGen for the method containing the FieldInstruction
        Returns:
        FieldDescriptor describing the field accessed by given FieldInstruction
      • getClassDescriptor

        public static ClassDescriptor getClassDescriptor​(org.apache.bcel.classfile.JavaClass jclass)
        Construct a ClassDescriptor from a JavaClass.
        Parameters:
        jclass - a JavaClass
        Returns:
        a ClassDescriptor identifying that JavaClass
      • preTiger

        public static boolean preTiger​(org.apache.bcel.classfile.JavaClass jclass)
        Checks if classfile was compiled for pre 1.5 target
      • getClassDescriptor

        @Deprecated
        public static ClassDescriptor getClassDescriptor​(org.apache.bcel.generic.ObjectType type)
        Get a ClassDescriptor for the class described by given ObjectType object.
        Parameters:
        type - an ObjectType
        Returns:
        a ClassDescriptor for the class described by the ObjectType
      • throwClassNotFoundException

        @Deprecated
        public static void throwClassNotFoundException​(ClassDescriptor classDescriptor)
                                                throws java.lang.ClassNotFoundException
        Throw a ClassNotFoundException to indicate that class named by given ClassDescriptor cannot be found. The exception message is formatted in a way that can be decoded by ClassNotFoundExceptionParser.
        Parameters:
        classDescriptor - ClassDescriptor naming a class that cannot be found
        Throws:
        java.lang.ClassNotFoundException
        See Also:
        ClassNotFoundExceptionParser
      • getObjectTypeInstance

        public static org.apache.bcel.generic.ObjectType getObjectTypeInstance​(@DottedClassName
                                                                               java.lang.String className)
      • getObjectTypeInstance

        public static org.apache.bcel.generic.ObjectType getObjectTypeInstance​(java.lang.Class<?> clazz)
      • isSynthetic

        public static boolean isSynthetic​(org.apache.bcel.classfile.FieldOrMethod m)
      • isSynthetic

        public static boolean isSynthetic​(org.apache.bcel.classfile.JavaClass j)
      • isSynthetic

        public static boolean isSynthetic​(org.apache.bcel.generic.FieldGenOrMethodGen m)