Package

org.opalj.br

analyses

Permalink

package analyses

Defines implicit conversions to wrap some types of analyses such that they generate results of type org.opalj.br.analyses.ReportableAnalysisResult.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. analyses
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Type Members

  1. trait Analysis[Source, +AnalysisResult] extends AnyRef

    Permalink

    Common trait that analyses should inherit from that want to use the general analysis framework AnalysisExecutor.

    Common trait that analyses should inherit from that want to use the general analysis framework AnalysisExecutor.

    Conceptual Idea

    An analysis is basically a mapping of a Project's resources to some result.

    Each analysis can produce (optionally) some result. E.g., a text describing a scenario that leads to a bug, a graph, a report that identifies a specific line or a combination thereof.

    However, an analysis should never rely on the location of a resource. If an analysis needs access to further resources, it should use the Project class.

  2. class AnalysisAggregator[Source, AnalysisResult] extends Analysis[Source, Iterable[AnalysisResult]]

    Permalink

    Aggregates several analyses such that they are treated as one afterwards.

    Aggregates several analyses such that they are treated as one afterwards.

    Thread Safety

    This class is thread safe.

    Implementation Note

    If you extend this class, make sure that all access to this classes (mutable) fields/ mutable data structures is synchronized on this.

  3. case class AnalysisException(message: String, cause: Throwable = null) extends RuntimeException with Product with Serializable

    Permalink

    Exception raised while the analysis is executed.

  4. trait AnalysisExecutor extends AnyRef

    Permalink

    Provides the necessary infrastructure to easily execute a given analysis that generates some analysis result that can be printed on the command line.

    Provides the necessary infrastructure to easily execute a given analysis that generates some analysis result that can be printed on the command line.

    To facilitate the usage of this trait several implicit conversions are defined that wrap standard analyses (org.opalj.br.analyses) such that they report results that are reportable.

    This class distinguishes between class files belonging to the code base under analysis and those that belong to the libraries. Those belonging to the libraries are loaded using the ClassFileReader for library classes (basically, all method bodies are skipped org.opalj.br.reader.Java8LibraryFramework). The parameter to specify library classes is -libcp=, the parameter to specify the "normal" classpath is -cp=.

    Control Flow

    1. The standard parameters are checked.
    2. The analysis is called to let it verify the analysis specific parameters.
    3. The Project is created.
    4. The analyze method of the Analysis is called with the project and the parameters.
    5. The results are printed.
  5. case class BasicReport(toConsoleString: String) extends ReportableAnalysisResult with Product with Serializable

    Permalink

    Result of some analysis that just consists of some text.

  6. type DeclaredMethods = Map[ObjectType, PartialCollection[Set[Method]]]

    Permalink
  7. abstract class DefaultOneStepAnalysis extends AnalysisExecutor with OneStepAnalysis[URL, BasicReport]

    Permalink

    Default implementation of one step analysis.

  8. class FieldAccessInformation extends AnyRef

    Permalink

    Stores the information where each field is read and written.

    Stores the information where each field is read and written. If the type hierarchy/the project is incomplete the results are also necessary incomplete.

  9. case class InconsistentProjectException(message: String) extends Exception with Product with Serializable

    Permalink

    Thrown if we identify that the project is not consistent.

  10. class InjectedClassesInformation extends AnyRef

    Permalink

    Stores the information which types of objects are (potentially) injected based on the annotations that are found in the project.

    Stores the information which types of objects are (potentially) injected based on the annotations that are found in the project. For example, by means of reflection or by a web server or some other comparable framework.

    This information is used to compute the entry points of a JaveEE application.

  11. class InstantiableClasses extends AnyRef

    Permalink

    Stores the information about those classes that are not instantiable.

    Stores the information about those classes that are not instantiable. The set of classes that are not instantiable is usually only a small fraction of all classes and hence, more efficient to store/access).

  12. type MultipleResultsAnalysis[Source, +AnalysisResult] = Analysis[Source, Iterable[AnalysisResult]]

    Permalink

    An analysis that may produce multiple results.

    An analysis that may produce multiple results. E.g., an analysis that looks for instances of bug patterns.

  13. trait OneStepAnalysis[Source, +AnalysisResult] extends Analysis[Source, AnalysisResult]

    Permalink

    An analysis that performs all computations in one step.

    An analysis that performs all computations in one step. Only very short-running analyses should use this interface!

  14. type ProgressEvent = analyses.ProgressEvents.Value

    Permalink
  15. trait ProgressManagement extends AnyRef

    Permalink

    Enables the management of the progress of a long running computation.

    Enables the management of the progress of a long running computation. Typically a long running progress such as an analysis is expected to report progress every 250 to 2000 milliseconds. It should -- however -- check every ~100 milliseconds the interrupted status to enable a timely termination.

    This trait defines a call-back interface that is implemented by some class that runs an analysis and which passes an instance of it to some analysis to report progress.

    Note

    Implementations must handle the case where a step that was started later finishes earlier than a previous step. In other words, even if the last step has ended, that does not mean that the analysis as a whole has already finished. Instead an implementation has to track how many steps have ended to determine when the whole analysis has ended.

    ,

    Implementations of this class must be thread safe if the analysis is multi- threaded.

  16. class Project[Source] extends ClassFileRepository

    Permalink

    Primary abstraction of a Java project; i.e., a set of classes that constitute a library, framework or application as well as the libraries or frameworks used by the former.

    Primary abstraction of a Java project; i.e., a set of classes that constitute a library, framework or application as well as the libraries or frameworks used by the former.

    This class has several purposes:

    1. It is a container for ClassFiles.
    2. It directly gives access to the project's class hierarchy.
    3. It serves as a container for project-wide information (e.g., a call graph, information about the mutability of classes, constant values,...) that can be queried using org.opalj.br.analyses.ProjectInformationKeys. The list of project wide information that can be made available is equivalent to the list of (concrete/singleton) objects implementing the trait org.opalj.br.analyses.ProjectInformationKey.

    Thread Safety

    This class is thread-safe.

    Prototyping Analyses/Querying Projects

    Projects can easily be created and queried using the Scala REPL. For example, to create a project, you can use:

    val JRE = "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib"
    val project = org.opalj.br.analyses.Project(new java.io.File(JRE))

    Now, to determine the number of methods that have at least one parameter of type int, you can use:

    project.methods.filter(_.parameterTypes.exists(_.isIntegerType)).size
    Source

    The type of the source of the class file. E.g., a URL, a File, a String or a Pair (JarFile,JarEntry). This information is needed for, e.g., presenting users meaningful messages w.r.t. the location of issues. We abstract over the type of the resource to facilitate the embedding in existing tools such as IDEs. E.g., in Eclipse IResource's are used to identify the location of a resource (e.g., a source or class file.)

  17. class ProjectIndex extends AnyRef

    Permalink

    An index that enables the efficient lookup of source elements (methods and fields) given the method's/field's name and the descriptor/field type.

    An index that enables the efficient lookup of source elements (methods and fields) given the method's/field's name and the descriptor/field type.

    Basically an index of the source elements (methods and fields) of a project.

    This index can be used, e.g., to resolve method calls based on the methods names.

    To get an instance of a project index call Project.get and pass in the ProjectIndexKey object.

  18. trait ProjectInformationKey[T <: AnyRef] extends AnyRef

    Permalink

    ProjecInformationKey objects are used to get/associate some (immutable) information with a project that should be computed on demand.

    ProjecInformationKey objects are used to get/associate some (immutable) information with a project that should be computed on demand. For example, imagine that you write an analysis that requires – as a foundation – the project's call graph. In this case, to get the call graph it is sufficient to pass the respective key to the Project object. If the call graph was already computed that one will be returned, otherwise the computation will be performed and the result will be cached for future usage before it is returned.

    Using Project Information

    If access to some project information is required it is sufficient to use the (singleton) instance of the respective ProjectInformationKey to get the respective project information.

    For example, let's assume that a call graph is needed. In this case the code to get the respective call graph would be:

    import ...{ComputedCallGraph,CHACallGraphKey}
    val project : Project = ???
    val ComputedCallGraph(callGraph,unresolved,ex) = project.get(CHACallGraphKey)
    // do something with the call graph

    Providing Project Information/Implementing ProjectInformationKey

    Making project wide information available on demand is done as follows.

    1. Implement the base analysis that computes the information given some project.
    2. Implement your ProjectInformationKey class that inherits from this trait and which calls the base analysis. It is recommended that the factory method (compute) is side-effect free.
    Threading

    Project takes care of threading related issues. The methods requirements and compute will never be called concurrently w.r.t. the same project object. However, concurrent calls may happen w.r.t. two different project objects.

    Caching

    Project takes care of the caching of the result of the computation of the information.

  19. type ProjectInformationKeys = Seq[ProjectInformationKey[_ <: AnyRef]]

    Permalink
  20. case class ReportableAnalysisAdapter[Source, AnalysisResult](analysis: Analysis[Source, AnalysisResult], converter: (AnalysisResult) ⇒ String) extends Analysis[Source, ReportableAnalysisResult] with Product with Serializable

    Permalink

    Source

    The type of the underlying source file.

    See also

    org.opalj.br.analyses for several predefined converter functions.

  21. trait ReportableAnalysisResult extends AnyRef

    Permalink

    Result of analyses that can be meaningfully represented using text.

  22. type SingleOptionalResultAnalysis[Source, +AnalysisResult] = Analysis[Source, Option[AnalysisResult]]

    Permalink

    An analysis that may produce a result.

  23. type SomeProject = Project[_]

    Permalink

    Type alias for Project's with an arbitrary sources.

  24. type StringConstantsInformation = Map[String, List[(Method, PC)]]

    Permalink

Value Members

  1. object AnalysisModeConfigFactory

    Permalink

    Simple factory that can create a new config by a given analysis mode.

    Simple factory that can create a new config by a given analysis mode. This is necessary for test purposes because the analysis mode, which is configured in the configuration file, has to be ignored to implement config file independent tests.

  2. object BasicReport extends Serializable

    Permalink

    Defines factory methods for BasicReports.

  3. object FieldAccessInformationAnalysis

    Permalink

    This analysis determines where each field is accessed.

    This analysis determines where each field is accessed.

    Usage

    Use the FieldAccessInformationKey to query a project about the field access information.

    val accessInformation = project.get(FieldAccessInformationKey)
    Note

    The analysis is internally parallelized and should not be run with other analyses in parallel.

    ,

    The analysis does not take reflective field accesses into account.

  4. object FieldAccessInformationKey extends ProjectInformationKey[FieldAccessInformation]

    Permalink

    The key object to get global field access information.

    The key object to get global field access information.

    Example:
    1. To get the index use the Project's get method and pass in this object.

  5. object InjectedClassesInformationAnalysis

    Permalink

    Factory to create InjectedClassesInformation.

  6. object InjectedClassesInformationKey extends ProjectInformationKey[InjectedClassesInformation]

    Permalink

    The key object to get information about the types of objects that are potentially injected.

    The key object to get information about the types of objects that are potentially injected. For example, by a web framework or a dependency injection framework.

    Example:
    1. To get the index use the Project's get method and pass in this object.

  7. object InstantiableClassesAnalysis

    Permalink

    A very basic analysis which identifies those classes that can never be instantiated (e.g., java.lang.Math).

    A very basic analysis which identifies those classes that can never be instantiated (e.g., java.lang.Math).

    A class is not (potentially) instantiable if:

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

    A more precise analysis is available that uses the fixpoint computations framework.

    ,

    The analysis does not take reflective instantiations into account!

    ,

    If this class is queried (after performing the analysis) about a class that was not analyzed, the result will be that the class is considered to be instantiable. This information is relevant in various contexts, e.g., to determine a precise call graph. For example, instance methods of those objects that cannot be created are always dead.

    Usage

    Use the InstantiableClassesKey to query a project about the instantiable classes.

    val instantiableClasses = project.get(InstantiableClassesKey)
    ,

    This analysis does not consider protected and/or package visible constructors as it assumes that classes may be added to the respective package later on (open-packages assumption.)

  8. object InstantiableClassesKey extends ProjectInformationKey[InstantiableClasses]

    Permalink

    The key object to get information about the classes that can be instantiated (either, directly or indirectly).

    The key object to get information about the classes that can be instantiated (either, directly or indirectly).

    Example:
    1. To get the index use the Project's get method and pass in this object.

  9. object ProgressEvents extends Enumeration

    Permalink

    Characterizes the type of an event related to a running analysis.

    Characterizes the type of an event related to a running analysis.

    See also

    ProgressManagement for further details.

  10. object ProgressManagement

    Permalink

    Factory for a function to create a default progress management object that basically does not track the progress.

  11. object Project

    Permalink

    Definition of factory methods to create Projects.

  12. object ProjectIndex

    Permalink

    Factory for ProjectIndex objects.

  13. object ProjectIndexKey extends ProjectInformationKey[ProjectIndex]

    Permalink

    The key object to get an index of the source elements of a project.

    The key object to get an index of the source elements of a project.

    Example:
    1. To get the index use the Project's get method and pass in this object.

  14. object ReportableAnalysisAdapter extends Serializable

    Permalink
  15. object ReportableAnalysisResult

    Permalink
  16. object SourceElementsPropertyStoreKey extends ProjectInformationKey[PropertyStore]

    Permalink

    The key object to get access to the properties store.

  17. object StringConstantsInformationKey extends ProjectInformationKey[StringConstantsInformation]

    Permalink

    The key object to get information about all string constants.

    The key object to get information about all string constants.

    Example:
    1. To get the index use the Project's get method and pass in this object.

Inherited from AnyRef

Inherited from Any

Ungrouped