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

static compilation fails at runtime for calling private constructor

    XMLWordPrintableJSON

Details

    Description

      class Foo{
        private Foo(){}
      }
      @CompileStatic
      class Bar {
        def foo(){new Foo()}
      }
      

      This fails with
      java.lang.IllegalAccessError: tried to access method Foo.<init>()V from class Bar

      The reason is that @TypeChecked makes no accessiblity check, but @CompileStatic needs that. In case of methods it fails, because StaticInvocationWriter is doing the check. Better would be to check during method selection already, because another accessible member might be missed otherwise (see GROOVY-6632 for this)

      Attachments

        Issue Links

          Activity

            People

              blackdrag Jochen Theodorou
              blackdrag Jochen Theodorou
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: