Java version AdoptOpenJDK (build 25.262-b10, mixed mode)
Gradle version 6.6.1
Groovy version 3.0.5
We have an IDE-like app which allows our coders to develop groovy scripts and classes.
Essentially, the coders would write groovy sources and test them in the app.
We made a CustomClassLoader which is created and destroyed for each test run, so that the app need no be restarted every time there is code change.
In Groovy 3.0.5, the GroovyClassLoader's cache is refactored to use StampedCommonCache, which does not support recursion.
This is the distilled simplified version of our CustomClassLoader:
Essentially, it uses the GroovyClassLoader.parseClass() for our test classes.
Here are the 2 classes to demonstrate the issue:
And the test harness:
The harness attempt to load Foo.groovy.
The sequence of events would be:
- Since Foo implements Bar, CustomClassLoader is called to load Bar
- which in turn calls GroovyClassLoader.parseClass(Bar.groovy)
- and sourceCache.getAndPut(Bar)
- Since StampedCommonCache does not support recursion, the loading hangs.
The attached project can be run using ./gradlew run to demonstrate the hanging.
It seems to me that the GroovyClassLoader needs to support recursion for this use case.
Or perhaps the CustomClassLoader is implemented wrongly?
Groovy 2.5.12 does not have this issue because its GroovyClassLoader uses ConcurrentCommonCache.