Convert Clojure expression to bytecode

I’ve been looking for an API I can use in the REPL to better understand Clojure’s compiler. What I’m hoping to find is something where I can pass it a quoted form, and get the bytecode back.

  '(def x (fn [x] (+ x y))))

       0: ldc           #34                 // String user              
       2: ldc           #36                 // String x       
       4: invokestatic  #42                 // Method clojure/lang/RT.var:(Ljava/lang/String;Ljava/lang/String;)Lclojure/lang/Var;

Does something like this exist?

1 Like

Perhaps one of the following?

The latter outputs Java source code, though.

1 Like

clj-java-decompiler can output bytecode too. Just use disassemble function instead of decompile.

For larger functions the Java output is much more readable though.


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.