borinquenkid opened a new pull request, #16661:
URL: https://github.com/apache/grails-core/pull/16661
Stacks on #16576 (java-to-groovy conversion for `build-logic/docs-core` and
`grails-gradle/common`+`model`).
Behaviour-preserving idiom pass over that conversion's output (14 of the 35
files in scope; the rest were already idiomatic or are interfaces/DTOs left
untouched).
**Applied**
- Property syntax for unambiguous getters (`Class.getName()` → `.name`,
`URL`/`File`/`URLConnection`/`Throwable`/`Resource` accessors,
`Class.isArray()`/`.getComponentType()` → `.array`/`.componentType`)
- Map-read subscript (`map.get(k)` → `map[k]`)
- `.equals()` on Strings → `==`
- `str.length() == 0` → `isEmpty()`
- `StringBuilder.append(` → `<<`
- String concatenation → GString where it lands in a `String`-typed slot
- Dropped redundant casts after `instanceof` flow typing
- `x != null ? x.foo() : null` → `x?.foo()`
- `for (X x : coll)` → `for (X x in coll)`
- Dropped an unnecessary `public` modifier on `StringEscapeCategory`'s
static methods
**Deliberately left** (documented per-site in the commit body):
`Environment.getName()` (shadows `Enum.name()` differently),
`DefaultResourceLoader.getClassLoader()` field-priority call, a
closure-shared-variable cast the type checker rejects dropping,
`Class.newInstance()` (avoids widening a public API's checked-exception
surface), `SpringIOUtils`'s `in`/`out` parameter names across ~8 overloads
(real Tier-A hit, judged disproportionate as a standalone rename),
`ClassPathResource#nullSafeEquals`'s `.equals()` on an `Object` that may be an
array, trivial getter/setter pairs that would add a public setter that doesn't
exist today, and one Javadoc-bearing getter.
**Found during verification**: `map[k] = v` (subscript assignment) compiles
to a dynamic `ScriptBytecodeAdapter.invokeMethodN("putAt", ...)` call under
`@CompileStatic` here, unlike the read form which resolves statically. All ~10
sites introduced by this pass were reverted back to `.put(k, v)`; the read-only
subscript conversions were kept.
This revision also carries forward the rename-compliance fix from #16576
(`DefaultCommandLine.groovy` keeping semicolons temporarily) merged and
resolved to its fully idiomatic end state — the semicolons and the
`@SuppressWarnings` from that fix are removed here, completing the 3-stage
conversion→cleanup split for that file.
**Verification**
- `build-logic`: compile/test green (`StringEscapeCategorySpec` 2/2; one
pre-existing, unrelated `FetchTagsTaskSpec` sandbox failure)
- `grails-gradle`: compile green for `common`+`model`; `codeStyle` 0
CodeNarc violations; full `test` 456/456, 0 failures
- `javap -c -p` dynamic-dispatch audit clean on every changed class after
the `putAt` fix
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]