You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Andres Almiray (Jira)" <ji...@apache.org> on 2020/06/27 08:19:00 UTC

[jira] [Commented] (GROOVY-8147) Dynamic non existing property access with different MissingPropertyException

    [ https://issues.apache.org/jira/browse/GROOVY-8147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17146831#comment-17146831 ] 

Andres Almiray commented on GROOVY-8147:
----------------------------------------

Property access occurs using 2 different methods (`getProperty` vs. `getAt`)

> Dynamic non existing property access with different MissingPropertyException
> ----------------------------------------------------------------------------
>
>                 Key: GROOVY-8147
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8147
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.4.7, 2.5.0-alpha-1, 3.0.4
>            Reporter: Maik Igloffstein
>            Priority: Minor
>
> {code}new Propy()."$foo"{code}
> Throws a {{org.codehaus.groovy.runtime.metaclass.MissingPropertyExceptionNoStack}}.
> {code}new Propy()[foo]{code}
> Throws a {{groovy.lang.MissingPropertyException}}.
> Why? How to force throwing a MissingPropertyException instead of MissingPropertyExceptionNoStack?
> h3. Example code
> {code}
> class Propy {
> }
> def foo = 'bar'
> def e1,e2
> try {
>     new Propy()."$foo"
> } catch (e) {
>     e1 = e
> }
> try {
>     new Propy()[foo]
> } catch (e) {
>     e2 = e
> }
> println "${e1.'class'.name} != ${e2.'class'.name}"
> assert e1.'class'.name != e2.'class'.name // but why?!
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)