The first sign something was wrong was the JVM bombing out with a “java.lang.OutOfMemoryError: PermGen space” error. All I’d done was change a gsp, so I restarted and after a long wait the same thing happened and it was then I noticed that the compiler just kept recompiling 4 classes in a loop until the JVM bombed.
This had happened to me once before when I’d managed to set the time incorrectly on my PC so some of my files appeared to be modified in the future. However this time I’d not done anything of the sort.
The file name must match the class name!
Trawling through old message board posts I found the answer – I’d renamed one of my classes but I hadn’t used an Intellij Idea refactor, I’d just renamed it so the class name and file name were different (notably, the offending file had been changed some time before the problem manifested). The problem was hidden because the Idea project view showed the new name but the actual file still had the old name and that was enough to fool groovyc into thinking it needed to run again.
I noticed in the Grails JIRA that the bug is marked as fixed against 1.2 M4 and I’m using 1.2.1 so it looks like it may be a regression in the current version. I raised a new issue and while checking out the problem I also noticed that if your class is in the default package the problem doesn’t happen.
Hopefully it won’t have taken you 2 hours to find out that a compile loop means an out of date file name! I think we need better compiler warnings from groovyc.