paulk-asert opened a new pull request, #3341: URL: https://github.com/apache/groovy/pull/3341
[GROOVY-9646](https://issues.apache.org/jira/browse/GROOVY-9646) Formatting a value initialised `ResolveVisitor` through a static block in `FormatHelper`, and that ran the default-import file-system scan. Programs that format values but never compile anything paid for a scan they did not use. ## Changes - `ResolveVisitor`: the scan and its two maps move into a lazy holder, so the scan runs when the first type is resolved through the default imports. Both maps are still built from one scan result, which keeps the identity check from GROOVY-12725. - `FormatHelper`: the default imports are read in a small holder on the first `typeName` call, so plain formatting no longer loads `ResolveVisitor`. - `Groovy12725`: its reflective field lookup now goes through the holder. No assertions changed. - `Groovy9646`: new fresh-JVM tests. The formatting and `MissingMethodException` tests fail without the fix. The third checks that compiling still resolves default imports. ## Startup Median whole-process time, 40 fresh JVMs per case on JDK 17, compared with the base commit: | Scenario | Before | After | |---|---|---| | Format a value | 215 ms | 154 ms | | Build a `MissingMethodException` message | 210 ms | 163 ms | | Compile a script (control) | 406 ms | 410 ms | A repeat run agreed. The compile difference is within noise. ## Testing - `./gradlew build --continue -x checkstyleMain` passes. - `:checkstyleGate` and `:codenarcGate` pass. - `:checkstyleMain` was excluded locally because its worker runs out of heap, with or without this change. ## Known limits A message that needs a type name, such as a `MissingMethodException`, still initialises `ResolveVisitor`, but it no longer runs the scan. A backport to `GROOVY_6_0_X` will follow once this is merged. -- 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]
