· 6 years ago · Mar 31, 2019, 04:18 PM
1Bytecode Disassembler Plugin for IntelliJ
2======
3
4This plugin integrates OPAL into IntelliJ to ease the analysis of Java bytecode. In particular,
5if offers two new views (bytecode and three-address code) for a class file alongside the standard view which IntelliJ provides.
6
7
8
9
10OPAL is an extensible, Java bytecode processing, engineering, manipulation and analysis library written in Scala 2.12.x.
11OPAL supports Java 10 Bytecode and has preliminary support for Java 11; OPAL in particular provides support to facilitate
12the analysis of Java 8 lambda expressions (Invokedynamic instructions). See [OPAL Project](http://www.opal-project.de/) for further details.
13
14## Install
15
16To install the plugin, please follow the instructions provided by JetBrains:
17https://www.jetbrains.com/help/idea/managing-plugins.html
18
19## Features
20
21### Viewing The Output
22
23To view the bytecode or three-address code (TAC), you need to open a class file. Once opened, you can change between the views
24by navigating through the tabs at the bottom of the editor.
25
26
27
28To ease the navigation to a class file, we have provided a couple of shortcuts via context menus and hotkeys. In particular,
29you can open a specific view
30
31- via the context menu of a class file (right click on a class file)
32- via the context menu of a java file (right click on a java file)
33- via the context menu of a PsiClass (right click on a class name in a java or jbc editor, see GIF below. Alternatively you can use the hotkeys [Ctrl + Right Click] for bytecode and [Ctrl + Alt + Right Click] for three-address code.[Ctrl + Right Click] for bytecode and [Ctrl + Alt + Right Click] for three-address code.
34
35
36
37You can also view class files that are contained within an external library simply by opening them:
38
39
40
41### Going To A Declaration
42
43The editors provide functionality to jump to a declaration via [Ctrl + B] or [Ctrl + Left Click], as is standard in IntelliJ.
44This works for
45
46- any fully qualified name apart from lambdas
47- for invoked methods
48- as well as for methods and fields that belong to the file that is currently being viewed.
49
50It, however, does not work for <clinit>().
51
52Everything that is marked can be jumped to. The red arrow shows to which class the method belongs to.
53
54You can also jump to the fields of "this" class file.
55
56
57### Jump Between The Editors
58
59It's possible to jump back and forth between methods in the "Bytecode" and "TAC" editors. This can be done by pressing
60the key combination [Ctrl + Middle Mouse Button] on a method name, or via the context menu.
61
62
63
64### Even More Jumps (Bytecode Editor)
65
66You can also jump between instructions within the bytecode editor. This is possible for the if and goto instructions,
67e.g. *GOTO*, *IFGT*, and *IFNULL*. These take the jump destination (a program counter value) as input,
68thus the caret will be placed at that program counter value. To do this, press [Alt + Shift + 1] on one such instruction.
69
70
71
72Furthermore it's possible to directly jump to a line in the source code that corresponds to an instruction. To do this,
73press [Alt + Shift + 2] on an instruction, or use the context menu. IntelliJ will then navigate to the source file, if available, and place the caret
74at the line number of the instruction.
75
76
77
78### Highlighting Exceptions (Bytecode Editor)
79
80You can highlight exception areas in the bytecode editor. Open the exception table, if it exists, and place the caret on one of the exceptions.
81Then, the key combination [Alt Shift 3] will create a highlighted range in the gutter and jump to the beginning of it. The range
82covers all instructions in a try (red) and catch (green) block. Hovering over the highlighted area will display the name of the exception.
83Pressing on the highlighted area will bring you back to the exception table. A context menu entry is also provided.
84
85[!Exception Area.](images_readme/exception_marker.gif "Mark Exception Area")
86
87
88### Structure View (Bytecode Editor)
89
90The structure view has, for the most part, the same look and feel as a normal java file. Additionally though,
91it's possible to jump to the various tables (e.g. the local variable table) in the bytecode editor, if present:
92
93
94
95## Known Issues
96
97- Navigation through the structure view requires pressing enter, or alternatively double clicking if an element has no children
98- The "Go To Declaration" [Ctrl + B] cannot switch from (e.g.) "Bytecode" to "Text" if the source file is not present. Instead, it will randomly position the caret in the bytecode editor
99
100## Miscellaneous
101
102- At the moment the TAC editor lacks some of the functionality. In particular, method bodies are mostly just highlighted text.