Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the Clojure compiler generates JVM bytecode?

What library/api does the Clojure compiler (which is just a jar/java application) uses to generate the JVM bytecode? I'm curious since the bytecode is being generated at runtime by java and not javac, so its a java program that outputs jvm bytecode.

like image 232
user1644340 Avatar asked Feb 08 '14 04:02

user1644340


People also ask

How is Java bytecode generated?

How is Byte Code generated? Compiler converts the source code or the Java program into the Byte Code(or machine code), and secondly, the Interpreter executes the byte code on the system. The Interpreter can also be called JVM(Java Virtual Machine).

Does clojure run on the JVM?

Clojure is the result of all this. It's a LISP functional programming language running on the JVM designed for concurrent programs.

Does clojure compile to Java?

Clojure programs get compiled to Java bytecode and executed within a JVM process. Clojure programs also have access to Java libraries, and you can easily interact with them using Clojure's interop facilities.

Is bytecode generated by JVM?

JVM runs the bytecode, Java compiler generates it. However, applications can generate the bytecode while they run, but the generated bytecode is again executed by the JVM.


1 Answers

Clojure uses a Java library called ASM to generate bytecode. A fork of a part of the lib is embedded into the clojure project here: https://github.com/clojure/clojure/tree/master/src/jvm/clojure/asm

like image 121
noisesmith Avatar answered Oct 21 '22 12:10

noisesmith