You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniel Sun (JIRA)" <ji...@apache.org> on 2018/05/15 02:48:00 UTC
[jira] [Resolved] (GROOVY-8585) too many accessedVariable
[ https://issues.apache.org/jira/browse/GROOVY-8585?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Sun resolved GROOVY-8585.
--------------------------------
Resolution: Not A Problem
Assignee: Daniel Sun
As the following code shows, vex references itself
org.codehaus.groovy.classgen.VariableScopeVisitor#declare(org.codehaus.groovy.ast.expr.VariableExpression)
{code:java}
vex.setAccessedVariable(vex);
{code}
> 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)