[ https://issues.apache.org/jira/browse/GROOVY-11516?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17895282#comment-17895282 ]
Paul King commented on GROOVY-11516: ------------------------------------ [~blackdrag] That would be one of the cases I'd like to make more consistent: {code} import groovy.json.JsonOutput import groovy.transform.ToString @ToString(includeFields=true, includeNames=true) class Foo { public int amountIn$ = 10 public int amountInDollars = 20 } def foo = new Foo() assert foo.toString() == 'Foo(amountInDollars:20)' // in 4/5 assert JsonOutput.toJson(foo) == '{"amountIn$":10,"amountInDollars":20}' // currently in 4 assert JsonOutput.toJson(foo) == '{"amountInDollars":20}' // planned for 5 {code} The slightly tricky thing is that we have an easier opt-out using allNames for AST transforms, e.g.: {code} @ToString(includeFields=true, includeNames=true, allNames=true) class Foo { public int amountIn$ = 10 public int amountInDollars = 20 } def foo = new Foo() assert foo.toString() == 'Foo(amountIn$:10, amountInDollars:20)' {code} > Improve consistency of treatment for internal properties > -------------------------------------------------------- > > Key: GROOVY-11516 > URL: https://issues.apache.org/jira/browse/GROOVY-11516 > Project: Groovy > Issue Type: Improvement > Reporter: Paul King > Priority: Major > Labels: breaking > > In numerous places, property names containing a "$" are deemed internal but > not MetaClassImpl#getProperties. This means for instance that > JsonOutput.toJson() currently outputs such internal properties. > After this change, such properties would not normally be returned. No test > fails after such a change indicating that this is an edge case we haven't > covered previously. > This would be a breaking change if anyone is really on the existing edge case > behavior. If necessary, we could use a system property to re-enable the > system behavior. We already have a system property > "groovy.permissive.property.access". We could use > "groovy.dollar.property.access" as well but I wasn't planning to add this > unless we get feedback that some folks need it. -- This message was sent by Atlassian Jira (v8.20.10#820010)