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

Access to java.lang.Object is forbidden

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.1
    • 2.3.11, 2.4.2
    • None
    • None

    Description

      I have the following code:

      import groovy.transform.CompileStatic
      
      @CompileStatic
      class Test {
          static private String str = "My String"
      
          static void test() {
              println myStr
          }
         
          static String getMyStr() {
              return "${str.replace(" ", "")}"
          }
      }
      
      Test.test()
      

      However, running this code via Groovy 2.4.1 throws the following error:

      Access to java.lang.Object#myStr is forbidden at line: -1, column: -1

      Attachments

        Activity

          People

            melix Cédric Champeau
            haimat Matthias Brandstetter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: