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

"java.nio.file.Path.setText" does not work with CompileStatic on Groovy 2.5.7

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.5.7
    • 2.5.8, 3.0.0-beta-2
    • Static compilation
    • None
    • Linux. Java 11.

    Description

      Code like the following will not work correctly on Groovy 2.5.7 with @CompileStatic enabled (groovy-nio required):

      Files.createTempFile('will not', 'compile').text = 'Some Text'

      On Groovy 2.5.7 it compiles as

      String var1 = "Some Text";
      NioGroovyMethods.getText(Files.createTempFile("will not", "compile"));

      whereas Groovy 2.5.6 it compiled as

      String var1 = "Some Text";
      ScriptBytecodeAdapter.setProperty(var1, (Class)null, Files.createTempFile("will not", "compile"), (String)"text");

      The latter is working, the former is not.

      Calling Path.setText should call the setter and not the getter for property text when compiling statically!

      Attached is a sample project demonstrating the issue.

      Attachments

        1. gradle-nio-path-gettext.zip
          23 kB
          Jan Hackel

        Issue Links

          Activity

            People

              daniel_sun Daniel Sun
              jhunovis Jan Hackel
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: