10.4 Intermixing Groovy and Java with Joint Compilation
If the Groovy classes are precompiled, then we can use the .class files or JARs readily
from Java. Java sees no difference between the bytecode from Java and Groovy; we’ll have to add the Groovy JAR (discussed earlier) in our classpath, much like how we’ll have JARs for Spring, Hibernate, or other
frameworks/libraries we use.
What if we have Groovy source code instead of bytecode? Remember, when our Java class depends on other
Java classes, javac will compile any Java classes it deems necessary if it does not
find their bytecode. However, javac does not extend that kindness to
Groovy. Fortunately, groovyc supports joint compilation. When we compile Groovy code, it determines ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access