sbglasius commented on PR #16296: URL: https://github.com/apache/grails-core/pull/16296#issuecomment-5590481801
@jdaugherty Pushed `e9932f371f` with what we agreed on Slack: - **The warning.** Every non-public bean class is reported once, through its own logger (`org.apache.grails.common.reflect.ReflectionUtils`), so one logging line silences it. The bookkeeping runs *before* the log level is consulted, so "once" doesn't depend on how logging is configured, and it holds class names rather than `Class` references so no class loader is pinned. JDK/Groovy/Spring classes aren't reported — nobody reading the log can declare those public. `warnOnNonPublicClass` is the seam to delete if Groovy stops compiling anonymous classes as non-public. - **One shared utility, not a fifth.** The widening block was copy-pasted in all four marshallers; it now lives in `org.apache.grails.common.reflect.ReflectionUtils` in grails-common, which is already on the compile classpath of every module that could need it. I left the GORM one alone — `org.grails.datastore.mapping.reflect.ReflectionUtils` is published, public since 1.0, with 8 call sites — so the full move you suggested is #16326 rather than growing this PR into a cross-module API change. - **Java and Groovy aligned** (Mattias's open point): the Java marshallers gated their field loop on `canAccess`, so a public field on a non-public class was silently dropped where the Groovy ones emitted it. Both now widen a field copy, and skip rather than fail when a field genuinely can't be widened (a class in a named module that doesn't open its package). - **Upgrade guide §54**, since that field change alters response payloads and the warning needs a documented off switch. On forcing the fix instead of handling it: for the shape in the original report there's no modifier to add — an anonymous class can't be declared public — which is what the warning is for, pointing people at the named-class fix. -- 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]
