These two steps are quite independent from each other, which makes it possible to replace either of the two without affecting the other. So, to achieve our goal, we can create a tree ourself, then hand it to the code generator to generate code. This is actually not a difficult task. The javac is very decently implemented, with a very clear separation between the two steps. Read the full article