package analyses
Defines commonly useful type aliases.
- Alphabetic
- By Inheritance
- analyses
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
trait
Analysis[Source, +AnalysisResult] extends AnyRef
Common trait that analyses can inherit from when they want to use the general analysis framework AnalysisExecutor.
Common trait that analyses can inherit from when they 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
Projectclass. -
class
AnalysisAggregator[Source, AnalysisResult] extends Analysis[Source, Iterable[AnalysisResult]]
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 class' (mutable) fields/ mutable data structures is synchronized on
this. -
case class
AnalysisException(message: String, cause: Throwable = null) extends RuntimeException with Product with Serializable
Exception raised while the analysis is executed.
-
trait
AnalysisExecutor extends AnyRef
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
ClassFileReaderfor 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
-
case class
BasicReport(toConsoleString: String) extends ReportableAnalysisResult with Product with Serializable
Result of some analysis that just consists of some text.
Result of some analysis that just consists of some text.
- toConsoleString
A string printed to the console.
-
class
DeclaredMethods extends AnyRef
The set of all org.opalj.br.DeclaredMethods (potentially used by the property store).
-
abstract
class
DefaultOneStepAnalysis extends AnalysisExecutor with OneStepAnalysis[URL, ReportableAnalysisResult]
Default implementation of the AnalysisExecutor which facilitates the development of analyses which are executed in one step.
-
class
FieldAccessInformation extends AnyRef
Stores the information where each field is read and written.
Stores the information where each field is read and written. If the project is incomplete the results are also necessarily incomplete. Reflective and comparable accesses are not considered.
-
case class
InconsistentProjectException(message: String, severity: Level = Warn) extends Exception with Product with Serializable
Thrown when the framework determines that the project is not consistent.
-
class
JavaProject extends AnyRef
Enables the querying of a project.
Enables the querying of a project.
- Note
The interface of this class was designed with Java interoperability in mind!
-
final
class
MethodDeclarationContext extends Ordered[MethodDeclarationContext]
Encapsulates the information about a non-abstract, non-private, non-static method which is not an initializer (
<(cl)init>) and which is required when determining potential call targets.Encapsulates the information about a non-abstract, non-private, non-static method which is not an initializer (
<(cl)init>) and which is required when determining potential call targets.- Note
A class may have -- w.r.t. a given package name -- at most one package visible method which has a specific name and descriptor combination. For methods with protected or public visibility a class always has at most one method with a given name and descriptor.
,Equality is defined based on the name, descriptor and declaring package of a method (the concrete declaring class is not considered!).
-
case class
MethodInfo[Source](source: Source, method: Method) extends Product with Serializable
Encapsulates the source of a method.
- case class ModuleDefinition[Source](module: ClassFile, source: Option[Source]) extends Product with Serializable
-
type
MultipleResultsAnalysis[Source, +AnalysisResult] = Analysis[Source, Iterable[AnalysisResult]]
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.
-
trait
OneStepAnalysis[Source, +AnalysisResult] extends Analysis[Source, AnalysisResult]
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 as reporting progress is not supported.
- type ProgressEvent = analyses.ProgressEvents.Value
-
trait
ProgressManagement extends AnyRef
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 of this class must be thread safe if the analysis is multi- threaded.
,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.
-
class
Project[Source] extends ProjectLike
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:
- It is a container for
ClassFiles. - It directly gives access to the project's class hierarchy.
- 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.
One of the most important project information keys is the
PropertyStoreKeywhich gives access to the property store.
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 project = org.opalj.br.analyses.Project(org.opalj.bytecode.JRELibraryFolder)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, aFile, aStringor 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 EclipseIResource's are used to identify the location of a resource (e.g., a source or class file.)
- It is a container for
-
trait
ProjectBasedAnalysis extends AnyRef
Common super trait of all analyses that use the fixpoint computations framework.
Common super trait of all analyses that use the fixpoint computations framework. In general, an analysis computes a org.opalj.fpcf.Property by processing some entities, e.g.: ´classes´, ´methods´ or ´fields´.
-
class
ProjectIndex extends AnyRef
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. The index contains fields with public, protected,
<default>and private visibility.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 method's names and/or descriptors.
To get an instance of a project index call Project.get and pass in the ProjectIndexKey object.
- See also
FieldAccessInformation to get the information where a field is accessed.
-
trait
ProjectInformationKey[T <: AnyRef, I <: AnyRef] extends AnyRef
ProjecInformationKeyobjects are used to get/associate some (immutable) information with a project that should be computed on demand.ProjecInformationKeyobjects 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
ProjectInformationKeyto get the respective project information.For example, let's assume that an index of all fields and methods is needed. In this case the code to get the index would be:
import ...{ProjectIndex,ProjectIndexKey} val project : Project = ??? val projectIndex = project.get(ProjectIndexKey) // do something with the index
Providing Project Information/Implementing
ProjectInformationKeyMaking project wide information available on demand is done as follows.
- Implement the base analysis that computes the information given some project.
- Implement your
ProjectInformationKeyclass 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
projectobject. 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.
- T
The type of the information object that is derived.
- I
The type of information used at initialization time.
- type ProjectInformationKeys = Seq[ProjectInformationKey[_ <: AnyRef, _ <: AnyRef]]
-
abstract
class
ProjectLike extends ClassFileRepository
Enables project wide lookups of methods and fields as required to determine the target(s) of an invoke or field access instruction.
Enables project wide lookups of methods and fields as required to determine the target(s) of an invoke or field access instruction.
- Note
The current implementation is based on the correct project assumption; i.e., if the bytecode of the project as a whole is not valid, the result is generally undefined. Just one example of a violation of the assumption would be, if we have two interfaces which define a non-abstract method with the same signature and both interfaces are implemented by a third interface which does not override these methods. In this case the result of a
resolveMethodReferenceis not defined, because the code base as a whole is not valid.
-
case class
ReportableAnalysisAdapter[Source, AnalysisResult](analysis: Analysis[Source, AnalysisResult], converter: (AnalysisResult) ⇒ String) extends Analysis[Source, ReportableAnalysisResult] with Product with Serializable
- Source
The type of the underlying source file.
- See also
org.opalj.br.analyses for several predefined converter functions.
-
trait
ReportableAnalysisResult extends AnyRef
Result of analyses that can be meaningfully represented using text.
-
type
SingleOptionalResultAnalysis[Source, +AnalysisResult] = Analysis[Source, Option[AnalysisResult]]
An analysis that may produce a result.
-
type
SomeProject = Project[_]
Type alias for Project's with an arbitrary sources.
- type StringConstantsInformation = Map[String, ConstArray[PCInMethod]]
-
final
class
VirtualFormalParameter extends AnyRef
Explicitly models a formal parameter of an virtual method to make it possible to store it in the property store and to compute properties for it.
Explicitly models a formal parameter of an virtual method to make it possible to store it in the property store and to compute properties for it. In contrast to the VirtualFormalParameter, which models a parameter of a concrete method, virtual methods include every possible method that overrides the method attached to the VirtualForwardingMethod.
The first parameter explicitly defined by the method will have the origin
-2, the second one will have the origin-3and so on. That is, the origin of an explicitly declared parameter is always-(parameter_index + 2). The origin of thethisparameter is-1.It should be used to aggregate the properties for every VirtualFormalParameter of a method included in this virtual method.
- Note
The computational type category of the parameters is ignored to ease the mapping.
,This encoding is also used by the default three address code representation generated using a local data-flow analysis (see org.opalj.tac.TACAI). In case of the bytecode based data-flow analysis the origin used by the analysis reflects the position of the parameter value on the tac; see org.opalj.ai.parameterIndexToValueOrigin.
-
class
VirtualFormalParameters extends AnyRef
The set of all explicit and implicit virtual formal method parameters in a project.
The set of all explicit and implicit virtual formal method parameters in a project. The set also contains virtual formal parameters of library methods.
Value Members
-
object
BasicMethodInfo
Defines a simplified extractor for a MethodInfo object.
-
object
BasicReport extends Serializable
Defines factory methods for BasicReports.
-
object
DeclaredMethodsKey extends ProjectInformationKey[DeclaredMethods, Nothing]
The key object to get information about all declared methods.
The key object to get information about all declared methods.
To get the index use the org.opalj.br.analyses.Project's
getmethod and pass inthisobject.- Note
See org.opalj.br.DeclaredMethod for further details.
Example: -
object
FieldAccessInformationAnalysis
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 does not take reflective field accesses into account.
,The analysis is internally parallelized and should not be run with other analyses in parallel.
,Fields which are not accessed at all are not further considered.
-
object
FieldAccessInformationKey extends ProjectInformationKey[FieldAccessInformation, Nothing]
The key object to get global field access information.
The key object to get global field access information.
To get the index use the Project's
getmethod and pass inthisobject.
Example: - object JavaProject
-
object
MethodDeclarationContext
Definition of factory and extractor methods for MethodDeclarationContext objects.
- implicit object MethodDeclarationContextOrdering extends Ordering[MethodDeclarationContext]
-
object
ProgressEvents extends Enumeration
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.
-
object
ProgressManagement
Factory for a function to create a default progress management object that basically does not track the progress.
-
object
Project
Definition of factory methods to create Projects.
-
object
ProjectIndex
Factory for ProjectIndex objects.
-
object
ProjectIndexKey extends ProjectInformationKey[ProjectIndex, Nothing]
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.
To get the index use the Project's
getmethod and pass inthisobject.
Example: - object ProjectLike
-
object
ProjectTypeConfigFactory
Factory to create
Configobjects with a given project type (see org.opalj.ProjectTypes).Factory to create
Configobjects with a given project type (see org.opalj.ProjectTypes).This is particularly useful for testing purposes as it facilitates tests which are independent of the current (default) configuration.
- object ReportableAnalysisAdapter extends Serializable
- object ReportableAnalysisResult
-
object
StringConstantsInformationKey extends ProjectInformationKey[StringConstantsInformation, Nothing]
The key object to get information about all string constants found in the project's code.
The key object to get information about all string constants found in the project's code.
To get the index use the Project's
getmethod and pass inthisobject.
Example: - object VirtualFormalParameter
-
object
VirtualFormalParametersKey extends ProjectInformationKey[VirtualFormalParameters, Nothing]
The key object to get information about all virtual formal parameters.
The key object to get information about all virtual formal parameters.
To get the index use the org.opalj.br.analyses.Project's
getmethod and pass inthisobject.- Note
See org.opalj.br.analyses.VirtualFormalParameter and VirtualFormalParameters for further details.
Example: