[ 
https://issues.apache.org/jira/browse/GROOVY-11562?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King closed GROOVY-11562.
------------------------------

> final class property is not reported as final in its MetaProperty#modifiers
> ---------------------------------------------------------------------------
>
>                 Key: GROOVY-11562
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11562
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 4.0.24
>            Reporter: mgroovy
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 5.0.0-beta-1
>
>
> {code:java}
> static class FinalPropertyTable {
>   final column = "AssumeIAmASqlColumInstanceForThisToMakeSense"
> }
> // Problem: Test fails, even though FinalPropertyTable#column is declared as 
> final
> // Expected: Test passes
> @Test
> void 'Groovy 4-0-24 final class properties not final (simple)'() {
>   assert 
> Modifier.isFinal(FinalPropertyTable.metaClass.getMetaProperty('column').modifiers)
>  === true
> }
> /*
>   A more complete test, that checks multiple MetaProperty attributes at once.
>   Suggested use would be to create a multiline test result instead of the 
> println statements & write the resulting string to disk.
>   After that compare the resulting strings to check for regression/unexpected 
> changes of any of the MetaProperty attributes of a more complex test class 
> than the one above.
> */
> @Test
> void 'Groovy 4-0-24 final class properties not final (full)'() {
>   final mps = FinalPropertyTable.metaClass.properties
>   final mbpsDebugDataList = mps.collect { MetaProperty mp ->
>    [
>     name          : mp.name,
>     type: mp.type.simpleName,
>     'public': Modifier.isPublic(mp.modifiers),
>     'static': Modifier.isStatic(mp.modifiers),
>     'final' : Modifier.isFinal(mp.modifiers),
>     type_assignable: mp.type.isAssignableFrom(columnClass),
>     getter        : ((mp instanceof MetaBeanProperty) ? mp.getGetter() !== 
> null : null),
>     setter        : ((mp instanceof MetaBeanProperty) ? mp.getSetter() !== 
> null : null),
>     meta_bean_type: (mp.getClass().simpleName)
>    ]
>  }
>   mbpsDebugDataList.eachWithIndex { propertyDebugData, int i -> println "$i) 
> $propertyDebugData" }
>   assert mbpsDebugDataList.find { it['name'] == 'column' }['final'] === true
> }
>  {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to