OPAL is a Scala-based framework for the static analysis, manipulation and creation of Java bytecode.
OPAL is a Scala-based framework for the static analysis, manipulation and creation of Java bytecode. OPAL is designed with performance, scalability and adaptability in mind.
Its main components are:
Common
) which provides generally useful data-structures and algorithms
for static analyses.Static Analysis Infrastructure
)) that can be used to
create arbitrary representations.
Bytecode Disassembler
).Bytecode Representation
- org.opalj.br).Abstract Interpretation Framework
- org.opalj.ai).Unless explicitly noted, OPAL is thread safe. I.e., the classes defined by OPAL can be considered to be thread safe unless otherwise stated. (For example, it is possible to read and process class files concurrently without explicit synchronization on the client side.)
null
ValuesUnless explicitly noted, OPAL does not null
values
I.e., fields that are accessible will never contain null
values and methods will
never return null
. If a method accepts null
as a value for a parameter or
returns a null
value it is always explicitly documented.
In general, the behavior of methods that are passed null
values is undefined unless
explicitly documented.
For efficiency reasons, OPAL sometimes uses mutable data-structures internally.
After construction time, these data-structures are generally represented using
their generic interfaces (e.g., scala.collection.{Set,Map}
). However, a downcast
(e.g., to add/remove elements) is always forbidden as it would effectively prevent
thread-safety.
OPAL makes heavy use of Scala's Assertion Facility to facilitate writing correct
code. Hence, for production builds (after thorough testing(!)) it is
highly recommend to build OPAL again using -Xdisable-assertions
.
Implementation of an abstract interpretation (ai) framework – also referred to as OPAL.
Implementation of an abstract interpretation (ai) framework – also referred to as OPAL.
Please note that OPAL/the abstract interpreter just refers to the classes and traits
defined in this package (ai
). The classes and traits defined in the sub-packages
(in particular in domain
) are not considered to be part of the core of OPAL/the
abstract interpreter.
This framework assumes that the analyzed bytecode is valid; i.e., the JVM's
bytecode verifier would be able to verify the code. Furthermore, load-time errors
(e.g., LinkageErrors
) are – by default – completely ignored to facilitate the
analysis of parts of a project. In general, if the presented bytecode is not valid,
the result is undefined (i.e., OPAL may report meaningless results, crash or run
indefinitely).
org.opalj.ai.AI - Implements the abstract interpreter that processes a methods code and uses an analysis-specific domain to perform the abstract computations.
org.opalj.ai.Domain - The core interface between the abstract interpretation framework and the abstract domain that is responsible for performing the abstract computations.
Helper classes and functionality related to specifying architectural concerns.
Implementation of an eDSL for creating Java bytecode.
Implementation of an eDSL for creating Java bytecode. The eDSL is designed to facilitate
the creation of correct class files; i.e., whenever possible it tries to fill wholes. For
example, when an interface is specified the library automatically ensures that the super
class type is (initially) set to java.lang.Object
as required by the JVM specification.
This package in particular provides functionality to convert org.opalj.br classes to org.opalj.da classes.
Implementation of a library for parsing Java bytecode and creating arbitrary representations.
Implementation of a library for parsing Java bytecode and creating arbitrary representations.
OPAL's primary representation of Java byte code is the org.opalj.br representation which is defined in the respective package. A second representation that represents bytecode one-by-one is found in the org.opalj.da package.
Common constants and type definitions used across OPAL.
In this representation of Java bytecode references to a Java class file's constant pool and to attributes are replaced by direct references to the corresponding constant pool entries.
In this representation of Java bytecode references to a Java class file's constant pool and to attributes are replaced by direct references to the corresponding constant pool entries. This facilitates developing analyses and fosters comprehension.
Based on the fact that indirect references to constant pool entries are resolved and replaced by direct references this representation is called the resolved representation.
This representation of Java bytecode is considered as OPAL's standard representation for writing Scala based analyses. This representation is engineered such that it facilitates writing analyses that use pattern matching.
Defines functionality commonly useful when processing Java bytecode.
Defines functionality commonly useful when processing Java bytecode.
OPAL's collection library is primarily designed with high performance in mind.
OPAL's collection library is primarily designed with high performance in mind. I.e., all methods provided by the collection library are reasonably optimized. However, providing a very large number of methods is a non-goal. Overall, OPAL's collection library provides:
Hence, OPAL's collection library complements Scala's default collection library and is not
intended to replace it. Integration with Scala's collection library is primarily provided
by means of iterators (OPAL's Iterator
s inherit from Scala's Iterator
s). Furthermore
the companion object of each of OPAL's collection classes generally provides factory methods
that facilitate the conversion from Scala collection classes to OPAL collection classes.
The collection library is growing. Nevertheless, the existing classes are production ready.
Common constants, factory methods and objects used throughout OPAL when performing concurrent computations.
Common constants, factory methods and objects used throughout OPAL when performing concurrent computations.
Defines helper values and methods related to modeling constraints.
Defines helper values and methods related to modeling constraints.
Defines common control abstractions.
Defines common control abstractions.
Defines convenience methods related to representing certain class file elements.
Defines convenience methods related to representing certain class file elements.
Functionality to extract dependencies between class files.
Functionality to extract dependencies between class files.
The fixpoint computations framework (fpcf
) is a general framework to perform fixpoint
computations of properties ordered by a lattice.
The fixpoint computations framework (fpcf
) is a general framework to perform fixpoint
computations of properties ordered by a lattice. The framework in particular supports the
development of static analyses.
In this case, the fixpoint computations/static analyses are generally operating on the code and need to be executed until the computations have reached their (implicit) fixpoint. The fixpoint framework explicitly supports resolving cyclic dependencies/computations. A prime use case of the fixpoint framework are all those analyses that may interact with the results of other analyses.
For example, an analysis that analyzes all field write accesses to determine if we can refine a field's type (for the purpose of the analysis) can (reuse) the information about the return types of methods, which however may depend on the refined field types.
The framework is generic enough to facilitate the implementation of anytime algorithms.
This framework assumes that all data-structures (e.g., dependee lists and properties) that are passed to the framework are effectively immutable! (Effectively immutable means that a data structure is never updated after it was passed to the framework.)
,The dependency relation is as follows:
“A depends on B”
===
“A is the depender, B is the dependee”.
===
“B is depended on by A”
The very core of the framework is described in: Lattice Based Modularization of Static Analyses
This package defines graph algorithms as well as factory methods to describe and compute graphs and trees.
This package defines graph algorithms as well as factory methods to describe and compute graphs and trees.
This package supports the following types of graphs:
Various io-related helper methods and classes.
Various io-related helper methods and classes.
The implementations of the methods rely on Java NIO(2).
Defines implicit conversions to wrap some types of analyses such that they generate results of type org.opalj.br.analyses.ReportableAnalysisResult.
Defines implicit conversions to wrap some types of analyses such that they generate results of type org.opalj.br.analyses.ReportableAnalysisResult.
Common definitions related to the definition and processing of three address code.
Common definitions related to the definition and processing of three address code.
Utility methods.
Utility methods.
Provides a general query interface for querying a value's properties.
Provides a general query interface for querying a value's properties.