You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2023/04/26 21:15:00 UTC

[jira] [Resolved] (GROOVY-11027) Boolean isProperty() method does not create synthetic Boolean property

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

Eric Milles resolved GROOVY-11027.
----------------------------------
    Resolution: Duplicate

This was an intended change for Groovy 4.  There is more description / discussion in GROOVY-9382, GROOVY-10133, GROOVY-10707, GROOVY-10821.

> Boolean isProperty() method does not create synthetic Boolean property
> ----------------------------------------------------------------------
>
>                 Key: GROOVY-11027
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11027
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 4.0.9, 4.0.10, 4.0.11
>            Reporter: Jason Garrett
>            Priority: Minor
>
> A class that defines a Boolean (object, not primitive) method isMyProperty() does not have the corresponding synthetic Boolean property.
> The main method of this class:
> {code:java}
> class SyntheticBooleanProperty {
>     Boolean isMyProperty() {
>        return null
>     }
>     static void main(args) {
>        assert (new SyntheticBooleanProperty()).myProperty == null
>     }
> } {code}
> Fails with a MissingPropertyException:
> {code:java}
> Exception in thread "main" groovy.lang.MissingPropertyException: No such property: myProperty for class: SyntheticBooleanProperty
>     at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:67)
>     at org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures.unwrap(IndyGuardsFiltersAndSignatures.java:161)
>     at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
>     at SyntheticBooleanProperty.main(SyntheticBooleanProperty.groovy:7) {code}
> This does not happen if the method's return type is (primitive) boolean.  It can be worked around by adding a Boolean getMyProperty() method.
> This happens with and without CompileStatic, and goes back at least as far as version 4.0.9.
> Here is a [live demo|https://gwc-experiment.appspot.com/?g=groovy_4_0&codez=eJy1UbFOxDAMnclXWJ1g6e2VWECMBSTYTgwlddtwTRwl7l0r1H8nzbVHe8x4SBQ_2--9WGlLjsFbkoe0LUydvlmUqlKyYEVGCNkW3kM-PMb7W0CIB6IWCwPK58OrI4uOh9u7GZzCIXfOALsOY26Mp4Cb3Q4YPYMNw9CDqoAb5UEjN1SGedAZSVqjYSxFKF6R1chXbGd8xbfVM-OjGK9cvE8KsGc0pYeN3dlCiRUkUed6YrKxWKsjmuzynGL5JD28fH7BPRg8LbmgZqnCPjDytjN2pPpCFZNBfu2IjsN5L7nyXpl6KXnqJdpJcwbPBL6TDdgZymA1qSIH0X22aPnLvE9-G5KPf2aO-xAbET-xhssO].



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