Chasm can disassemble *.class
files and *.jar
files and output assembly in s-expression form.
Furthermore the main use case is to read s-expression assembly files and output *.class
or *.jar
files.
The s-expression syntax is both easy to parse and easy to generate.
Chasm uses the de-facto standard library ow2 ASM for bytecode generation. Since Chasm is only a minimal syntax on top of
ASM it is easy to keep it up to date with the current bytecode standard.
(class 53 (final public super) chasm/Main null java/lang/Object ()
(source "Main.java" null)
(inner-class chasm/Server$Command chasm/Server Command (abstract interface public static))
(inner-class java/lang/invoke/MethodHandles$Lookup java/lang/invoke/MethodHandles Lookup (final public static))
(method (public static) main "([Ljava/lang/String;)V" null (java/io/IOException)
(code
(label L0)
(line 13 L0)
(invokedynamic run "()Lchasm/Server$Command;"
(H invokestatic java/lang/invoke/LambdaMetafactory metafactory
"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;" false)
((T "(Ljava/nio/file/Path;[Ljava/lang/String;Ljava/io/PrintStream;)V")
(H invokestatic chasm/Main run
"(Ljava/nio/file/Path;[Ljava/lang/String;Ljava/io/PrintStream;)V" false)
(T "(Ljava/nio/file/Path;[Ljava/lang/String;Ljava/io/PrintStream;)V")))
(aload 0)
(invokestatic chasm/Server main "(Lchasm/Server$Command;[Ljava/lang/String;)V")
(label L1)
(line 14 L1)
(return)
(label L2)
(local args "[Ljava/lang/String;" null L0 L2 0)
(maxs 2 1)))
...
See example.chasm for the full example.
-
Build with
gradle
or use the precompiled binary indist
(reproducible build). -
Disassemble class/jar file to chasm with
chasm example.{class|jar} example.chasm
-
Assemble chasm to class/jar file with
chasm example.chasm example.{class|jar}
MIT (c) 2018 Daniel Mendler
ASM: a very small and fast Java bytecode manipulation framework Copyright (c) 2000-2011 INRIA, France Telecom All rights reserved.
-
-
Does perfect roundtrip like chasm
-
Overall more complex and more complex syntax
-
Not based on ObjectWeb ASM
-
-
-
Written in Python
-
Includes a decompiler
-