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.
This package contains definitions of common domains that can be used for the implementation of analyses.
This package contains definitions of common domains that can be used for the implementation of analyses.
In general, we distinguish two types of domains. First, domains that define a
general interface (on top of the one defined by Domain), but do not directly
provide an implementation. Hence, whenever you develop a new Domain
you should
consider implementing/using these domains to maximize reusability. Second,
Domain
s that implement a specific interface (trait). In this case, we further
distinguish between domains that provide a default implementation (per interface
only one of these Domain
s can be used to create a final Domain
) and
those that can be stacked and basically refine the overall functionality.
Examples
Domain
's respective methods. However, it does provide a
default implementation. Hence, a typical pattern is:class MyDomain extends Domain with ... with DefaultHandlingOfMethodResults with RecordThrownExceptions
Unless explicitly documented, a domain is never thread-safe. The general programming
model is to use one Domain
object per code block/method and therefore, thread-safety
is not required for Domain
s that are used for the evaluation of methods. However
domains that are used to adapt/transfer values should be thread safe
(see org.opalj.ai.domain.ValuesCoordinatingDomain for further details).
Common utility functionality.
Common utility functionality.