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 2019/08/05 02:25:00 UTC

[jira] [Commented] (GROOVY-9153) StaticInvocationWriter modifies shared global node ConstantExpression.NULL

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

Eric Milles commented on GROOVY-9153:
-------------------------------------

It is still quite possible for {{StaticInvocationWriter}} to modify one of the shared {{ConstantExpression}} definitions.  One example is AutoClone, which creates invokeMethod calls with ConstantExpression.NULL arguments.  The test CanonicalComponentsTransformTest hits this case.

> StaticInvocationWriter modifies shared global node ConstantExpression.NULL
> --------------------------------------------------------------------------
>
>                 Key: GROOVY-9153
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9153
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Eric Milles
>            Assignee: Daniel Sun
>            Priority: Major
>             Fix For: 2.5.8, 3.0.0-beta-2
>
>         Attachments: ConstantExpression.java
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> In the case of a static groovy method call like {{File.createTempDir()}} when {{@CompileStatic}} is applied, {{StaticInvocationWriter}}'s {{writeDirectMethodCall}} and {{loadArguments}} mutate the shared global constant node {{ConstantExpression.NULL}}.
> Relevant bits:
> {code:java}
>     protected boolean writeDirectMethodCall(final MethodNode target, final boolean implicitThis, final Expression receiver, final TupleExpression args) {
>         ...
>         if (target instanceof ExtensionMethodNode) {
>             ...
>             if (emn.isStaticExtension()) {
>                 // it's a static extension method
>                 argumentList.add(0, ConstantExpression.NULL);
>             } else {
>                 ....
>             }
>             Parameter[] parameters = node.getParameters();
>             loadArguments(argumentList, parameters);
> ...
>     protected void loadArguments(List<Expression> argumentList, Parameter[] para) {
>         ...
>                 // This is repeated 3 times in the method:
>                 Expression expression = argumentList.get(i);
>                 expression.putNodeMetaData(PARAMETER_TYPE, para[i].getType());
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)