Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the Groovy compiler work?

Tags:

groovy

Can anyone explain the Groovy compiler works? Does it compile:

  1. Groovy code -> Java code -> Bytecode

  2. Groovy code -> Bytecode

  3. Some other method

like image 680
bholl Avatar asked Jun 19 '15 20:06

bholl


People also ask

Do I need to compile Groovy?

The groovyc compiler is a necessity for compiling Groovy and Java together simultaneously. It can also be useful for compiling . class files to execute without need for recompilation every time the script is run.

Are Groovy scripts compiled?

Unlike Java, a Groovy source code file can be executed as an (uncompiled) script, if it contains code outside any class definition, if it is a class with a main method, or if it is a Runnable or GroovyTestCase. A Groovy script is fully parsed, compiled, and generated before executing (similar to Python and Ruby).

Is Groovy compiled to Java?

Groovy scripts can use any Java classes. They can be compiled to Java bytecode (in . class files) that can be invoked from normal Java classes. The Groovy compiler, groovyc, compiles both Groovy scripts and Java source files, however some Java syntax (such as nested classes) is not supported yet.

Is Groovy compiled or interpreted?

Groovy is both compiled and interpreted language as groovy code is compiled to JVM byte code also which is interpreted at runtime.


1 Answers

Groovy parses the source code with antlr via the groovy grammar description, then generates bytecode using asm

It does not require javac

like image 153
tim_yates Avatar answered Oct 02 '22 16:10

tim_yates