Before you can compile a program you have to decide where to put the generated code while the compiler runs. The original ACK Pascal front-end stores the generated code in a temporary file on disk and every time it generates code, it writes it to that file. In case of an error, the temporary file can be removed and when no error has occurred, the file can be renamed if necessary. Another way is to write all generated code to memory. In case of an error you just free the memory or else you write the generated code to disk.
The disadvantage of storing the generated code directly on disk is that it is not easy to search in the code or insert something in the middle of it. This is a big disadvantage in case of a Java class file. The constant_pool[] in a class file is a field that is almost at the beginning of the file, but all throughout the compiling process entries can be added to it. So when you store the class file on disk, you have to go through a some trouble to insert the constant_pool[] entries. A similar problem is that certain fields like constant_pool_count are only known when you are done compiling, which means they have to be changed in the file at the end of the compiling process.
This can all be done a lot easier if you store the generated code in one or more datastructures which you hold in memory until you are done and finally write the datastructures to a file on disk. When storing the generated code in datastructures it is simpler to insert fields in the code because you can make use of pointers. It is also very simple to change the fields of the class file. For these reasons I chose this option, which means that you have to come up with datastructures to hold the generated code.