This problem was discovered in a Jenkins pipeline, but then nailed down and found it failed with groovyc compiler too.
Creating a script with two nested enums, like:
And compiling with groovyc script.groovy makes the compiler freeze with 100% CPU usage.
In Jenkins, this results in the Job and executor being freezed and zombie (need to kill the job and executor thread), but I am reporting this to Jenkins as an independent issue.
As the problem seems to happen in a stripped down groovy script, I am reporting it here too.