Re: private fields returned by properties in Groovy 4

"James Daugherty via dev" <dev-GSC0n/0aZo1d/SJB6HiN2Ni2O/[email protected]>
Newsgroups gmane.comp.lang.groovy.devel
Message-ID <CAMGZ+-8+rxtKHqZyrep2jyEOvn1LRKJjZnS+7Ljb_3_ry3yC9Q@mail.gmail.com>
So something like this would be similar to the old behavior?

obj.metaClass.properties.findAll { Modifier.isPublic(it.modifiers)
}.collectEntries {
            PropertyValue pv = new PropertyValue(obj, it)
            [it.name, pv.getValue()]
        }

Is the concern that this is a breaking change and that's why it wasn't
back ported to Groovy 4?

On Mon, Nov 10, 2025 at 1:22 PM Milles, Eric (TR Technology) via dev
<dev-GSC0n/0aZo1d/SJB6HiN2Ni2O/[email protected]> wrote:
>
> The behavior of MetaClass#getProperties was changed for Groovy 4 as part of GROOVY-5169 (JSON serialization fix).  It was mentioned in some of the discussion and notes that getProperties() did return private properties in some edge cases — I don't have examples at hand.  With that in mind, it was recommended that callers check the modifiers of the MetaProperty instances and filter as necessary.
>
> getProperties() was amended to exclude inaccessible (to the caller) and synthetic properties as part of GROOVY-10438 and GROOVY-10555.  Since the caller is not propagated as thoroughly before Groovy 5, it is difficult to provide a good backport of the property filtering.  And this also falls within the realm of metaclass breaking changes.
>
>
>
> ________________________________
> From: James Daugherty <[email protected]>
> Sent: Monday, November 10, 2025 12:00 PM
> To: Groovy_Developers <dev-GSC0n/0aZo1d/SJB6HiN2Ni2O/[email protected]>; dev-FvxHgLy0BgRd/SJB6HiN2Ni2O/[email protected] <[email protected]>
> Subject: [EXT] private fields returned by properties in Groovy 4
>
> External Email: Use caution with links and attachments.
>
> Hi Everyone,
>
> I opened https://urldefense.com/v3/__https://issues.apache.org/jira/browse/GROOVY-11799__;!!GFN0sa3rsbfR8OLyAw!fZIzdacaMb2b19GYD9RTQgd1vL7DxEEknudlIj-_Tb9374PSrRrWqZUbjdtH7aF3RgLS3O3vyGrg-nUYBi-_kKPrLiQ$  but
> thought I'd reach out to the mailing list on this one.  It seems that
> Groovy 4 is including private fields as properties, which affects my
> own Grails application in multiple ways:
>
> 1. databinding (DataBindingLazyMetaPropertyMap in Grails) uses
> .properties to decide what to bind
> 2. json serialization is trying to serialize private fields that are
> recursive datastructures (Grails's Errors object).
>
> It seems this was fixed in Groovy 5 under
> https://urldefense.com/v3/__https://issues.apache.org/jira/browse/GROOVY-10438__;!!GFN0sa3rsbfR8OLyAw!fZIzdacaMb2b19GYD9RTQgd1vL7DxEEknudlIj-_Tb9374PSrRrWqZUbjdtH7aF3RgLS3O3vyGrg-nUYBi-_GJRYfa0$  but this wasn't
> back ported to Groovy 4.  It also appears that this was reported under
> Groovy 4 via https://urldefense.com/v3/__https://issues.apache.org/jira/browse/GROOVY-10555__;!!GFN0sa3rsbfR8OLyAw!fZIzdacaMb2b19GYD9RTQgd1vL7DxEEknudlIj-_Tb9374PSrRrWqZUbjdtH7aF3RgLS3O3vyGrg-nUYBi-_cERjHiw$  but it
> wasn't fixed.
>
> Can @Groovy_Developers  help me understand why this wasn't backported?
>  Is it possible we could get this fixed in 4.0.30?
>
> Regards,
> James
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.