jamesfredley opened a new pull request, #15558:
URL: https://github.com/apache/grails-core/pull/15558

   ## Canary build: how far are we from Groovy 6?
   
   Built on top of [#15557](https://github.com/apache/grails-core/pull/15557) 
(the Groovy 5.0.3 canary), this branch bumps `groovy.version` to 
`6.0.0-SNAPSHOT` and documents every additional change required to get the 
framework compiling and core tests passing.
   
   **Draft / do-not-merge.** Purely exploratory. Intended as a reference for 
how much of Grails 8 already compiles against Groovy 6, and which upstream 
Groovy 6 bugs need to be reported.
   
   ## What it adds on top of `grails8-groovy5-sb4`
   
   Single commit: `canary: test Groovy 6.0.0-SNAPSHOT` + `fix: Groovy 6 
VerifyError in DefaultConstraintFactory default parameter`
   
   - **`dependencies.gradle`**: `groovy.version` 5.0.3 → 6.0.0-SNAPSHOT. 
Resolves from `https://repository.apache.org/content/groups/snapshots/` which 
is already configured in `build-logic/.../GrailsRepoSettingsPlugin.groovy` for 
the `org.apache.groovy.*` group.
   
   - **`gradle/test-config.gradle`**: 
`-Dspock.iKnowWhatImDoing.disableGroovyVersionCheck=true` now applied via 
`tasks.withType(GroovyCompile).configureEach` so it also covers module-specific 
compile tasks. Spock 2.4-groovy-5.0 is the latest released artifact; its 
`SpockTransform` is registered via `META-INF/services` so the Groovy compiler 
loads it for every source set, and all compiles fail with 
`IncompatibleGroovyVersionException` unless the flag is set globally.
   
   - **`DefaultHalViewHelper.groovy`**: reorder the `association instanceof 
ToMany && !(association instanceof Basic)` / `else if (association instanceof 
ToOne)` cascade to check `ToOne` first. Groovy 6's flow typing narrows 
`association` in the else branch in a way that conflicts with the later `ToOne` 
check (`Incompatible instanceof types: Basic and ToOne`). The reordered form is 
equivalent because `ToOne` and `ToMany` are sibling `Association` subtypes.
   
   - **`AbstractHibernateGormInstanceApi.groovy`**: fix a **pre-existing 
operator-precedence bug** caught by Groovy 6's stricter instanceof type 
checking.
       - Before: `if (association instanceof ToOne && !association instanceof 
Embedded)`
       - After: `if (association instanceof ToOne && !(association instanceof 
Embedded))`
     Without the parentheses, `!association` is evaluated first (to a boolean) 
and `instanceof Embedded` is then checked against a boolean. The whole left 
side of the `&&` had been dead code on every Groovy version - this bug 
pre-exists the Groovy 6 bump.
   
   - **`DefaultConstraintFactory.groovy`**: split the default-parameter 
signature into two explicit constructors. Groovy 6.0.0-SNAPSHOT generates 
invalid bytecode for `(..., List<Class> targetTypes = [Object])` inside 
`@CompileStatic` classes - at runtime every instantiation raises `VerifyError: 
Type 'java/lang/Object' is not assignable to 'java/util/ArrayList'`, which 
cascades into `Validateable.validate()` and grails-datastore-core bean wiring.
   
   ## Build status
   
   | | Groovy 5.0.3 baseline | Groovy 6.0.0-SNAPSHOT |
   |---|---|---|
   | `./gradlew classes testClasses -PskipTests -x cyclonedxBom -x 
:grails-geb:compileTestFixturesGroovy` | **575 tasks PASS** | **573 tasks 
PASS** |
   | `./gradlew :grails-geb:compileTestFixturesGroovy` | **PASS** | **FAIL** 
(same ASM `Frame.putAbstractType` bug as 5.0.4+) |
   | Core unit tests (`grails-async-core`, `grails-bootstrap`, 
`grails-validation`, `grails-core`) | **PASS** | **PASS** |
   
   ## Known issues on Groovy 6 (not on Groovy 5.0.3)
   
   1. **grails-geb testFixtures ASM bug persists**: the `Frame.putAbstractType` 
AssertionError that appeared in Groovy 5.0.4 is still in 6.0.0-SNAPSHOT. 
`Frame.class` is byte-for-byte identical across 
5.0.3/5.0.4/5.0.5/6.0.0-SNAPSHOT, so the bug is in Groovy's bytecode 
**generator**, not the embedded ASM library. Likely a change to how closures / 
trait helper methods generate stack maps, introduced between 5.0.3 and 5.0.4 
and not yet fixed.
   
   2. **`grails-datastore-core:GormMappingSyntaxTests` / 
`JpaMappingSyntaxTests`**: `IllegalStateException: GORM has not been 
initialized correctly or has already been shutdown`. Likely static-state test 
isolation changing under Groovy 6; not a compilation issue.
   
   3. **`grails-fields` display widget tests**: `NullPointerException` in 
Spring's `AbstractBindingResult.addAllErrors` on `Errors.getObjectName()`. 
Downstream effect of the GORM initialization issue above.
   
   ## What should be reported upstream to Groovy
   
   - `DefaultConstraintFactory.<init>` bytecode verification failure from a 
`List` default parameter under `@CompileStatic`.
   - `Frame.putAbstractType` AssertionError when compiling grails-geb's 
trait-heavy testFixtures (same bug that blocks Groovy 5.0.4+).
   
   Spock is blocking Groovy 6 adoption until there is a `2.5-groovy-6.0` or 
`2.4-groovy-6.0` artifact. The global 
`spock.iKnowWhatImDoing.disableGroovyVersionCheck=true` is a temporary bridge.
   
   Assisted-by: Claude Code <[email protected]>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to