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

Using 'File.text = ' cause FileNotFoundException in Groovy 2.5.7 with @CompileStatic

    XMLWordPrintableJSON

    Details

      Description

      The following code, throws FileNotFoundException:

      @CompileStatic
      class Sample {
          static void main(String[] args) {
              new File("/tmp/sample.txt").text = "something"
          }
      }
      

      The cause is reported to be related to InputStream, however, in this case, it should be OutputStream. 

      The following throws no error:

      new File("/tmp/sample.txt").setText("something")

      If I use Groovy 2.5.6 or bellow (or without @CompileStatic), it works as expected. 

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                daniel_sun Daniel Sun
                Reporter:
                lepe A. Lepe
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: