Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9153

StaticInvocationWriter modifies shared global node ConstantExpression.NULL

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.5.8, 3.0.0-beta-2
    • None
    • None

    Description

      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:

          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());
      

      Attachments

        1. ConstantExpression.java
          7 kB
          Eric Milles

        Issue Links

          Activity

            People

              daniel_sun Daniel Sun
              emilles Eric Milles
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h