OPAL comes with a large number of tools to analyze and visualize various aspects related to Java Bytecode projects. These tools can be used as is or can be embedded into other tools. Some of the tools require Graphviz to visualize graphs which depict control- and data-flow information.
To use the tools, start
sbt, change to the
project OPAL-DeveloperTools project and call
run. Afterwards, you'll see the list of tools which can be run.
In contrast to most existing Java disassemblers, OPAL generates an HTML document to provide better syntax highlighting and advanced interaction.
To use the OPAL Java Bytecode Disassembler Java 8 is required.
Note, that the OPAL Disassembler is fast and can scan thousands of class files per second; this makes it also possible to use it to locate a certain class file. For example, if you want to find the jar which defines a specific class, e.g.,
java.util.HashMap$Entry, it is sufficient to specify the root folder of the JDK and let it automatically find the class for you. The generated HTML file will contain precise information where the class file was found. This also works if you specify the root of your
The bytecode Disassembler can be run programmatically as shown next:
val classFile : org.opalj.da.ClassFile = ...; val html = classFile.toXHTML() // println(html) // org.opalj.io.writeAndOpen(classFile.toXHTML().toString, "ClassFile", ".html")
Using the Java Bytecode Disassembler plugin, it is in particular possible to click on a type in a disassembled file to also disassemble the target type. This enables you to quickly navigate between ".class" files.
Screenshot of the OPAL Java Bytecode Disassembler in action:
The Bytecode Disassembler plugin provides you with both Bytecode and Three-Address-Code views for both source and ".class files". It also includes structural views to enable you to quickly navigate these views.
The Bytecode Disassembler plugin in action:
The Java Bytecode Workbench allows you to view Bytecode or Three-Address Code of your classes directly in Visual Studio Code.
If you are a developer of static analyses and suffered from the pain of having to support Invokedynamic (Java 7+) - in other words, Java lambda expressions and method references - then this is the tool for you! OPAL's project serializer rewrites Invokedynamic calls using plain-old standard Java bytecode instructions to facilitate the writing of static analyses! You no longer have to worry about Invokedynamics created by Java compilers.
Currently, we can rewrite Invokedynamics created by standard Java compilers and we are adding support to completely support Scala. Basically, OPAL replaces the Invokedynamic calls using Java's LambdaMetaFactory by a standard Invokestatic call which will create an instance of a newly created class (similar to what LambdaMetaFactory does). The object will encapsulate the relevant state used by the Lambda and implement the Lambda's functional interface. Later on, when the Lambda is evaluated the generated class will forward the call to the implementation method of the Lambda. The tool is currently in a beta version, but we already successfully rewrote JUnit 5 and were able to execute its entire test suite afterwards (originally over 3000 Invokedynamics).
OPAL's project serializer can be downloaded here.
If you want to see it in action, just use OPAL's Invokedynamic rectifier to rewrite your project and study the code afterwards using our Bytecode Disassembler (see below).