Package

org.opalj.fpcf

analysis

Permalink

package analysis

Visibility
  1. Public
  2. All

Type Members

  1. class CallBySignatureTargetAnalysis extends FPCFAnalysis

    Permalink

    This analysis computes the CallBySignature property.

    This analysis computes the CallBySignature property. I.e., it determines the call-by-signature targets of an interface method.

    It is in particular relevant when analyzing software libraries and not whole applications, since applications cannot be extended anymore w.r.t. to subtyping.

    Note

    This analysis implements a direct property computation that is only executed when required.

  2. class CallableFromClassesInOtherPackagesAnalysis extends FPCFAnalysis

    Permalink

    This Analysis determines the ´ClientCallable´ property of a method.

    This Analysis determines the ´ClientCallable´ property of a method. A method is considered as leaked if it is overridden in every immediate non-abstract subclass.

    In the following scenario, m defined by B overrides m in C and (in this specific scenario) m in C is also always overridden.

    /*package visible*/ class C { public Object m() }
    /*package visible*/ abstract class A extends C { /*empty*/ }
    public class B extends A { public Object m() }
  3. class EscapeAnalysis extends AnyRef

    Permalink

    A shallow analysis that determines for each new object that is created within a method if it escapes the scope of the method.

    A shallow analysis that determines for each new object that is created within a method if it escapes the scope of the method.

    An object escapes the scope of a method if:

    • ... it is assigned to a field,
    • ... it is passed to a method,
    • ... it is stored in an array,
    • ... it is returned,
    • ... the object itself leaks it's self reference (this) by:
      • ... storing this in some static field or,
      • ... storing it's self reference in a data-structure (another object or array) passed to it (by assigning to a field or calling a method),
      • ... if a superclass leaks the self reference.

    This analysis can be used as a foundation for an analysis that determines whether all instances created for a specific class never escape the creating method and, hence, respective types cannot occur.

  4. class FactoryMethodAnalysis extends FPCFAnalysis

    Permalink

    This analysis identifies a project's factory methods.

    This analysis identifies a project's factory methods.

    A method is no factory method if:

    • it is not static and does not invoke the constructor of the class where it is declared.

    This information is relevant in various contexts, e.g., to determine the instantiability of a class.

    Usage

    Use the FPCFAnalysesManagerKey to query the analysis manager of a project. You can run the analysis afterwards as follows:

    val analysisManager = project.get(FPCFAnalysisManagerKey)
    analysisManager.run(FactoryMethodAnalysis)

    For detailed information see the documentation of the analysis manager.

    The results of this analysis are stored in the property store of the project. You can receive the results as follows:

    val theProjectStore = theProject.get(SourceElementsPropertyStoreKey)
    val factoryMethods = theProjectStore.entities { (p: Property) ⇒
    p == IsFactoryMethod
    }
    Note

    Native methods are considered as factory methods because they might instantiate the class.

  5. class FieldMutabilityAnalysis extends FPCFAnalysis

    Permalink

    Determines if a field is always initialized at most once or if a field is or can be mutated after (lazy) initialization.

  6. class InheritableByNewSubtypesAnalysis extends FPCFAnalysis

    Permalink

    This analysis computes the InheritableByNewTypes property.* I.e., it determines whether a method can directly be inherited by a future subtype.

    This analysis computes the InheritableByNewTypes property.* I.e., it determines whether a method can directly be inherited by a future subtype. This is in particular important when analyzing libraries.

    The analysis assumes that packages that start with "java." are closed, i.e., that no client can put a class into these specific packages.

    Usage

    Use the FPCFAnalysesManagerKey to query the analysis manager of a project. You can run the analysis afterwards as follows:

    val analysisManager = project.get(FPCFAnalysisManagerKey)
    analysisManager.run(InheritableByNewSubtypesAnalysis)

    For detailed information see the documentation of the analysis manager.

    The results of this analysis are stored in the property store of the project. You can receive the results as follows:

    val thePropertyStore = theProject.get(SourceElementsPropertyStoreKey)
    val property = thePropertyStore(method, InheritableByNewTypes.Key)
    property match {
      case Some(IsInheritableByNewTypes) => ...
      case Some(NotInheritableByNewTypes) => ...
      case None => ... // this happens only if a not supported entity is passed to the computation.
    }

    Implementation

    This analysis computes the org.opalj.fpcf.properties.InheritableByNewTypes property. Since this makes only sense when libraries are analyzed, using the application mode will result in the org.opalj.fpcf.properties.NotInheritableByNewTypes for every given entity.

    This analysis considers all scenarios that are documented by the org.opalj.fpcf.properties.InheritableByNewTypes property.

    Note

    This analysis implements a direct property computation that is only executed when required.

  7. class MethodAccessibilityAnalysis extends FPCFAnalysis

    Permalink

  8. class ObjectImmutabilityAnalysis extends FPCFAnalysis

    Permalink

    Determines the mutability of instances of a specific class.

    Determines the mutability of instances of a specific class. In case the class is abstract the (implicit) assumption is made that all abstract methods (if any) are/can be implemented without necessarily/always requiring additional state; i.e., only the currently defined fields are take into consideration. An interfaces is always considered to be immutable. If you need to know if all possible instances of an interface or some type; i.e., all instances of the classes that implement the respective interface/inherit from some class are immutable, you can query the org.opalj.fpcf.properties.TypeImmutability property.

    In case of incomplete class hierarchies or if the class hierarchy is complete, but some class files are not found the sound approximation is done that the respective classes are mutable.

    This analysis uses the org.opalj.fpcf.properties.FieldMutability property to determine those fields which could be final, but which are not declared as final.

  9. class PurityAnalysis extends FPCFAnalysis

    Permalink

    This analysis determines whether a method is pure.

    This analysis determines whether a method is pure. I.e., whether the method only operates on the given state (i.e., the method is pure) or depends on other state/mutable global state; the given state may include the state of the current object that is the receiver of the call if the object/receiver is immutable.

    This analysis follows the definition found on wikipedia:

    [...] a function may be considered a pure function if both of the following statements about the function hold:

    • The function always evaluates to the same result value given the same argument value(s). The function result value cannot depend on any hidden information or state that may change while program execution proceeds or between different executions of the program, nor can it depend on any external input from I/O devices.

    Hence, using true constants (e.g., Math.e) is not a problem as well as creating intermediate (mutable) data structures. Furthermore, instance method based calls can also be pure if the receiving object is (effectively final) or was created as part of the evaluation of the method.

    • Evaluation of the result does not cause any semantically observable side effect or output, such as mutation of mutable objects or output to I/O devices. The result value need not depend on all (or any) of the argument values. However, it must depend on nothing other than the argument values. The function may return multiple result values and these conditions must apply to all returned values for the function to be considered pure. If an argument is "call-by-reference", any parameter mutation will alter the value of the argument outside the function, which will render the function impure. However, if the referenced object is immutable it is ok.
  10. class SimpleInstantiabilityAnalysis extends FPCFAnalysis

    Permalink

    This analysis determines which classes can never be instantiated (e.g., java.lang.Math).

    This analysis determines which classes can never be instantiated (e.g., java.lang.Math).

    A class is not instantiable if:

    • it only defines private constructors and these constructors are not called by any static method and the class does not implement Serializable.
    Note

    The analysis does not take reflective instantiations into account!

    ,

    This analysis depends on the project configuration which encodes the analysis mode. Different analysis modes are: library with open or closed packages assumption or application This information is relevant in various contexts, e.g., to determine precise call graph. For example, instance methods of those objects that cannot be created are always dead.

    Usage

    Use the FPCFAnalysesManagerKey to query the analysis manager of a project. You can run the analysis afterwards as follows:

    val analysisManager = project.get(FPCFAnalysisManagerKey)
    analysisManager.run(InstantiabilityAnalysis)

    For detailed information see the documentation of the analysis manager. The results of this analysis are stored in the property store of the project. You can receive the results as follows:

    val theProjectStore = theProject.get(SourceElementsPropertyStoreKey)
    val instantiableClasses = theProjectStore.entities { (p: Property) ⇒
    p == Instantiable
    }

    This information is relevant in various contexts, e.g., to determine precise call graph. For example, instance methods of those objects that cannot be created are always dead.

  11. class TypeExtensibilityAnalysis extends FPCFAnalysis

    Permalink

    Determines if a class is extensible (i.e., can be inherited from).

    Determines if a class is extensible (i.e., can be inherited from). This property generally depends on the kind of the project. If the project is an application, all classes are considered to be closed; i.e., the class hierarchy is considered to be fixed; if the analyzed project is a library, then the result depends on the concrete assumption about the openness of the library.

    However, package visible classes in packages starting with "java." are always treated as not client extensible as this would require that those classes are defined in the respective package which is prevented by the default ClassLoader in all cases.

    Note

    Since the computed property is a set property, other analyses have to wait till the property is computed.

  12. class TypeImmutabilityAnalysis extends FPCFAnalysis

    Permalink

    Determines the mutability of a specific type.

Value Members

  1. object CallBySignatureTargetAnalysis extends FPCFAnalysisRunner

    Permalink
  2. object CallableFromClassesInOtherPackagesAnalysis extends FPCFAnalysisRunner

    Permalink
  3. object EscapeAnalysis

    Permalink
  4. object FactoryMethodAnalysis extends FPCFAnalysisRunner

    Permalink

    Companion object for the FactoryMethodAnalysis class.

  5. object FieldMutabilityAnalysis extends FPCFAnalysisRunner

    Permalink
  6. object InheritableByNewSubtypesAnalysis extends FPCFAnalysisRunner

    Permalink
  7. object MethodAccessibilityAnalysis extends FPCFAnalysisRunner

    Permalink

    Companion object for the MethodAccessibilityAnalysis class.

  8. object ObjectImmutabilityAnalysis extends FPCFAnalysisRunner

    Permalink

    Runs an immutability analysis to determine the mutability of objects.

  9. object PurityAnalysis extends FPCFAnalysisRunner

    Permalink

  10. object SimpleInstantiabilityAnalysis extends FPCFAnalysisRunner

    Permalink

    Companion object for the SimpleInstantiabilityAnalysis class.

  11. object StaticMethodAccessibilityAnalysis extends FPCFAnalysisRunner

    Permalink

    Companion object for the StaticMethodAccessibilityAnalysis class.

  12. object TypeExtensibilityAnalysis extends FPCFAnalysisRunner

    Permalink
  13. object TypeImmutabilityAnalysis extends FPCFAnalysisRunner

    Permalink

    Starter for the type immutability analysis.

Ungrouped