Packages

  • package root
    Definition Classes
    root
  • package org
    Definition Classes
    root
  • package opalj

    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:

    • a library (Common) which provides generally useful data-structures and algorithms for static analyses.
    • a framework for implementing lattice based static analyses (Static Analysis Infrastructure)
    • a framework for parsing Java bytecode (Bytecode Infrastructure) that can be used to create arbitrary representations.
    • a library to create a one-to-one in-memory representation of Java bytecode (Bytecode Disassembler).
    • a library to create a representation of Java bytecode that facilitates writing simple static analyses (Bytecode Representation - org.opalj.br).
    • a scalable, easily customizable framework for the abstract interpretation of Java bytecode (Abstract Interpretation Framework - org.opalj.ai).
    • a library to extract dependencies between code elements and to facilitate checking architecture definitions.
    • a library for the lightweight manipulation and creation of Java bytecode (Bytecode Assembler).

    General Design Decisions

    Thread Safety

    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.)

    No null Values

    Unless 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.

    No Typecasts for Collections

    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. Furthermore, the concrete data-structure is always considered an implementation detail and may change at any time.

    Assertions

    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.

    Definition Classes
    org
  • package ai

    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.

    Definition Classes
    opalj
    Note

    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).

    See also

    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.

  • package av
    Definition Classes
    opalj
  • package ba

    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.

    Definition Classes
    opalj
  • package bc
    Definition Classes
    opalj
  • package bi

    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.

    This Package

    Common constants and type definitions used across OPAL.

    Definition Classes
    opalj
  • package br

    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.

    Definition Classes
    opalj
  • package bytecode

    Defines functionality commonly useful when processing Java bytecode.

    Defines functionality commonly useful when processing Java bytecode.

    Definition Classes
    opalj
  • package collection

    Defines helper methods related to Scala's and OPAL's collections APIs.

    Defines helper methods related to Scala's and OPAL's collections APIs.

    Definition Classes
    opalj
  • package concurrent

    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.

    Definition Classes
    opalj
  • package constraints

    Defines helper values and methods related to modeling constraints.

    Defines helper values and methods related to modeling constraints.

    Definition Classes
    opalj
  • package control

    Defines common control abstractions.

    Defines common control abstractions.

    Definition Classes
    opalj
  • package da

    Defines convenience methods related to representing certain class file elements.

    Defines convenience methods related to representing certain class file elements.

    Definition Classes
    opalj
  • package de

    Functionality to extract dependencies between class files.

    Functionality to extract dependencies between class files.

    Definition Classes
    opalj
  • package fpcf

    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.

    Definition Classes
    opalj
    Note

    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 the datastructure 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

  • package graphs

    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:

    1. graphs based on explicitly connected nodes (org.opalj.graphs.Node),
    2. graphs where the relationship between the nodes are encoded externally (org.opalj.graphs.Graph).
    Definition Classes
    opalj
  • AbstractDominatorTree
  • AbstractGraph
  • ControlDependencies
  • DefaultMutableMode
  • DefaultMutableNode
  • DominanceFrontiers
  • DominatorTree
  • Graph
  • MutableNode
  • MutableNodeLike
  • Node
  • PostDominatorTree
  • UnidirectionalGraph
  • VirtualUnidirectionalGraph
  • package hermes
    Definition Classes
    opalj
  • package io

    Various io-related helper methods and classes.

    Various io-related helper methods and classes.

    Definition Classes
    opalj
    Note

    The implementations of the methods rely on Java NIO(2).

  • package issues

    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.

    Definition Classes
    opalj
  • package log
    Definition Classes
    opalj
  • package support
    Definition Classes
    opalj
  • package tac

    Common definitions related to the definition and processing of three address code.

    Common definitions related to the definition and processing of three address code.

    Definition Classes
    opalj
  • package util

    Utility methods.

    Utility methods.

    Definition Classes
    opalj
  • package value

    Provides a general query interface for querying a value's properties.

    Provides a general query interface for querying a value's properties.

    Definition Classes
    opalj
p

org.opalj

graphs

package graphs

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:

  1. graphs based on explicitly connected nodes (org.opalj.graphs.Node),
  2. graphs where the relationship between the nodes are encoded externally (org.opalj.graphs.Graph).
Source
package.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. graphs
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. abstract class AbstractDominatorTree extends AnyRef

    Representation of a (post) dominator tree of, for example, a control flow graph.

    Representation of a (post) dominator tree of, for example, a control flow graph. To construct a (post)dominator tree use the companion objects' factory methods (apply).

  2. trait AbstractGraph[N] extends (N) ⇒ TraversableOnce[N]

    Represents a(n im)mutable (multi-)graph with (un)ordered edges.

  3. trait ControlDependencies extends AnyRef

    Represents the control-dependence information.

    Represents the control-dependence information.

    An instruction/statement is control dependent on a predicate (here: if, switch or any instruction that may throw an exception) if the value of the predicate controls the execution of the instruction.

    Note that the classical definition:

    Let G be a control flow graph; Let X and Y be nodes in G; Y is control dependent on X iff there exists a directed path P from X to Y with any Z in P \ X is not post-dominated by Y.

    Is not well suited for methods with potentially infinite loops, exceptions and multiple exit points. (See PostDominatorTree$.apply for further information.)

    Note

    In the context of static analysis an instruction (e.g., invoke, idiv,...) that may throw an exception that results in a different control-flow, is also a predicate additionally to all ifs and switches.

    ,

    If the underlying method/CFG contains infinite loops then it is expected that the dominance frontiers are already corrected if the used post dominator tree was augmented in the first place!

  4. class DefaultMutableNode[I] extends MutableNodeLike[I, DefaultMutableNode[I]] with MutableNode[I, DefaultMutableNode[I]]

    Default implementation of a mutable node of a graph.

    Default implementation of a mutable node of a graph.

    Thread Safety

    This is class is thread-safe.

  5. final class DominanceFrontiers extends ControlDependencies

    Representation of the dominance frontiers.

  6. final class DominatorTree extends AbstractDominatorTree

    A (standard) dominator tree.

  7. class Graph[N] extends AbstractGraph[N]

    Represents a mutable (multi-)graph with ordered edges.

    Represents a mutable (multi-)graph with ordered edges.

    Thread Safety

    This class is not thread-safe!

  8. trait MutableNode[I, N <: Node] extends Node

    Common interface of all mutable nodes of a directed graph.

    Common interface of all mutable nodes of a directed graph. This class basically serves as a small adapter class for some arbitrary node.

    I

    The type of the object that is associated with this node/the type of the object for which this node object is created.

    N

    The type of the node of the child nodes that can be added or removed.

    See also

    The demo project for example usages.

  9. class MutableNodeLike[I, N <: Node] extends MutableNode[I, N]

    Represents a mutable node of a directed graph.

    Represents a mutable node of a directed graph. This class serves as a base implementation of the MutableNode trait.

    Thread Safety

    This class is thread-safe. It is possible to add multiple child nodes concurrently.

    I

    The type of the object that is associated with this node/the type of the object for which this node object is created.

    See also

    The demo project for example usages.

  10. trait Node extends AnyRef

    Represents a node of some graph.

    Represents a node of some graph.

    Two nodes are considered equal if they have the same unique id.

    See also

    org.opalj.br.ClassHierarchy's toGraph method for an example usage.

  11. final class PostDominatorTree extends AbstractDominatorTree

    A representation of a post-dominator tree (see PostDominatorTree$#apply* for details regarding the properties).

    A representation of a post-dominator tree (see PostDominatorTree$#apply* for details regarding the properties).

    For information regarding issues related to using post-dominator trees for computing control dependence information see "A New Foundation for Control Dependence and Slicing for Modern Program Structures" (2007, Journal Version appeared in TOPLAS)

  12. class UnidirectionalGraph extends AbstractGraph[Int]

    Efficient representation of a mutable graph where the nodes are identified using consecutive int values.

    Efficient representation of a mutable graph where the nodes are identified using consecutive int values. This graph in particular supports the case where many nodes do not have successors. Computing the strongly connected components is particular efficient as no transformations are are required.

    Thread Safety

    This class is not thread-safe!

    Example:
    1. val g = new org.opalj.graphs.UnidirectionalGraph(10)() += (3,2) += (4,4) += (4,2) += (2, 4)
  13. class VirtualUnidirectionalGraph extends AbstractGraph[Int]

    Efficient representation of a mutable graph where the nodes are identified using consecutive int values (0,1,3,...).

    Efficient representation of a mutable graph where the nodes are identified using consecutive int values (0,1,3,...). This graph in particular supports the case where many nodes do not have successors. Furthermore, computing the strongly connected components is particular efficient as no transformations are required since we already use int values for the nodes.

    Thread Safety

    This class is not thread-safe!

    Example:
    1. Some nodes may have no successors:

      val edges = Map((0 -> List(1)),(1 -> List(0)),(2 -> List(3))/*,(3 -> List())*/)
      val successors : Int => Iterator[Int] = (i : Int) => {
      edges.get(i) match {case Some(successors) => successors.toIterator; case _ => Iterator.empty }
      }
      val vg = new org.opalj.graphs.VirtualUnidirectionalGraph(4/*max id of a node +1 */,successors)

Value Members

  1. def closedSCCs[N >: Null <: AnyRef](ns: Traversable[N], es: (N) ⇒ Traversable[N]): List[Iterable[N]]

    Identifies closed strongly connected components in directed (multi-)graphs.

    Identifies closed strongly connected components in directed (multi-)graphs.

    A closed strongly connected component (cSCC) is a non-empty set of nodes of a graph where each node belonging to the cSCC can explicitly be reached from another node and no node contains an edge to some node that does not belong to the same cSCC.

    Every such set is necessarily minimal/maximal.

    N

    The type of the graph's nodes. The nodes have to correctly implements equals and hashCode.

    ns

    The nodes of the graph.

    es

    A function that, given a node, returns all successor nodes. Basically, the edges of the graph.

    Note

    This implementation can handle (arbitrarily degenerated) graphs with up to Int.MaxValue nodes (if the VM is given enough memory!)

  2. final def closedSCCs[N >: Null <: AnyRef](g: Graph[N]): List[Iterable[N]]
  3. final lazy val dotToSVG: (String) ⇒ String

    Function to convert a given graphviz dot file to SVG.

    Function to convert a given graphviz dot file to SVG. The transformation is done using the vis-js.com library which is a translated version of graphviz to JavaScript.

    The first call, which will initialize the JavaScript engine, will take some time. Afterwards, the tranformation is much faster.

  4. def sccs(ns: Int, es: IntFunction[IntIterator], filterSingletons: Boolean = false): Chain[Chain[Int]]

    Implementation of Tarjan's algorithm for finding strongly connected components.

    Implementation of Tarjan's algorithm for finding strongly connected components. Compared to the standard implementation using non-tail recursive calls, this one uses an explicit stack to make the implementation scale to very large (degenerated) graphs. E.g., this implementation can handle graphs containing up to XXX nodes in a single cycle.

    ns

    The number of nodes. The nodes have to be consecutively numbered [0..ns-1].

    es

    A function that returns for a given node n the immediate successors for that node.

    filterSingletons

    Removes SCCs with just one node, where the node is not connected to itself. I.e., nodes which have a self-edge will be kept and other will be discarded.

    Example:
    1. A very simple, but very large cycle:

      def genGraph(max : Int) = {
           var i = 1;
           var g = Map[Int,List[Int]]((0,List(max-1)));
           while(i < max){ g += ((i,List(i-1))); i+=1; }
           g
      }
      val g = genGraph(100000)
      val es = (i:Int) => {g(i).toIterator}
      org.opalj.graphs.sccs(g.size,es).mkString("\n")

      A large graph:

      val g = Map((0,List(5)),(1,List(2)),(2,List(1,4)),(3,List(0)),(4,List(2)),(5,List(4,3,6)),(6,List(6)),(7, List()))
      val es = (i:Int) => { g(i).toIterator }
      org.opalj.graphs.sccs(g.size,es,filterSingletons = true).mkString("\n")
  5. def toAdjacencyMatrix(maxNodeId: Int, successors: (Int) ⇒ Set[Int]): Array[Byte]

    Returns the given graph as a CSV encoded adjacency matrix.

    Returns the given graph as a CSV encoded adjacency matrix.

    maxNodeId

    The id of the last node. The first node has to have the id 0. I.e., in case of a graph with just two nodes, the maxNodeId is 1.

    successors

    The successor nodes of the node with the given id; the function has to be defined for every node in the range [0..maxNodeId].

    returns

    an adjacency matrix describing the given graph encoded using CSV. The returned byte array an be directly saved and represents a valid CSV file.

    Example:
    1. For example, the graph p with the nodes A (id = 0),B (id = 1),C (id =2) and

      • an edge from A to B,
      • an edge from A to C and
      • an edge from C to B would be encoded as follows:
        0,1,1
        0,0,0
        0,1,0
        
    Note

    Though the function is optimized to handle very large graphs, encoding sparse graphs using adjacency matrixes is not recommended.

  6. def toDot(rootNodes: Traversable[_ <: Node], dir: String = "forward", ranksep: String = "0.8", fontname: String = "Helvetica", rankdir: String = "TB"): String

    Generates a string that describes a (multi-)graph using the ".dot/.gv" file format http://graphviz.org/pdf/dotguide.pdf.

    Generates a string that describes a (multi-)graph using the ".dot/.gv" file format http://graphviz.org/pdf/dotguide.pdf. The graph is defined by the given set of nodes.

    Requires that Node implements a content-based equals and hashCode method.

  7. object DefaultMutableMode
  8. object DominanceFrontiers

    Factory to compute DominanceFrontiers.

  9. object DominatorTree

    Factory to compute DominatorTrees.

  10. object Graph

    Defines factory methods to create simple graphs.

  11. object PostDominatorTree

    Factory for post dominator trees.

Inherited from AnyRef

Inherited from Any

Ungrouped