04.16.03
javac compiler and visitor pattern issues
I’m currently trying to augment the java compiler to support auto-boxing of primitives. The problem I’m currently facing is that there is no OO way to mutate objects in the visitor pattern. In the visitor pattern, you can call obj.visit(this), and then it will call the appropriate method. Once inside this method, its impossible to mutate the type of the parameter you have passed in. This is an inherent benefit/problem with recursive decent design. So of course the correct approach is to modify the code one level up. However, the design of sun’s java compiler doesnt make this easy without a moderate amount of modification to the code.