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

IllegalAccessError exception is raised when accessing inherited static field

    XMLWordPrintableJSON

    Details

      Description

      The same problem as in related issue but with static fields.

      a/b/PackageScopedParent.java:

      package a.b;
      
      class PackageScopedParent {
        public static final String TEST = "test";
      }
      

      a/b/PublicChildren.java:

      package a.b;
      
      public class PublicChildren extends PackageScopedParent {
      }
      

      c/Usage.groovy:

      package c
      
      import a.b.PublicChildren
      import groovy.transform.CompileStatic
      
      @CompileStatic
      class Usage {
        static void main(String[] args) {
          println PublicChildren.TEST
        }
      }
      

      error:

      java.lang.IllegalAccessError: failed to access class a.b.PackageScopedParent from class c.Usage (a.b.PackageScopedParent and c.Usage are in unnamed module of loader 'app')
        at c.Usage.main(Usage.groovy:9)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                emilles Eric Milles
                Reporter:
                grv87 Basil Peace
              • Votes:
                0 Vote for this issue
                Watchers:
                1 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