JVM exceptions are weird: a decompiler perspective
19 days ago
- #JVM
- #Java
- #Decompilation
- The author discusses challenges in decompiling Java class files, especially with handling exceptional control flow like try-catch blocks.
- JVM uses a stack-based approach for instructions, with exceptions handled via an exception table that specifies regions and handlers.
- Exception table entries can overlap or nest in non-intuitive ways, complicating decompilation.
- Java's 'finally' blocks are duplicated on each exit path, leading to complex bytecode patterns.
- JVM instructions can throw exceptions in unexpected ways, including during operations like 'return'.
- The JVM has two type checkers: one using StackMapTable and another for older class files without it.
- Exception handling ranges can cross control flow constructs, but exemption ranges cannot.
- The author proposes treating exception handlers as special cases in the decompiler's intermediate representation.