[jira] [Commented] (GROOVY-8585) too many accessedVariable

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (GROOVY-8585) too many accessedVariable

JIRA jira@apache.org

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

Daniel Sun commented on GROOVY-8585:
------------------------------------

[~paulk] Thanks for your explanation :)

> too many accessedVariable
> -------------------------
>
>                 Key: GROOVY-8585
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8585
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Daniel Sun
>            Assignee: Daniel Sun
>            Priority: Critical
>
> VariableExpression `str`  has endless accessedVariable, i.e. accessedVariable -> accessedVariable -> ... -> accessedVariable -> ...
> {code:java}
>             def x() {
>                 String str = 'hello'
>             }
> {code}
> VariableExpression Snippet
> {code:java}
>     public void setAccessedVariable(Variable origin) {
>         checkVariable(origin);
>         this.accessedVariable = origin;
>     }
> // the code added just for check
> public static boolean checkVariable(Variable origin) {
>         if (!(origin instanceof VariableExpression)) {
>             return false;
>         }
>         int cnt = 0;
>         for (VariableExpression ve = (VariableExpression) origin; ve != null; ve = (VariableExpression) ve.getAccessedVariable()) {
>             cnt++;
>             if (cnt > 1000) {
>                 throw new RuntimeException("too many accessedVariable");
>             }
>         }
>         return false;
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)