Scala Programming Language
  1. Scala Programming Language
  2. SI-5037

IllegalAccessError when accessing private[this] final var from an inner class.

    Details

      Description

      The following code produces IllegalAccessError when run. Since the variable is annotated as private[this] the compiler should catch the access violation at compile time.

      object Test {
        def main(args: Array[String]) {
          val t = new Test
          t.inner.foo()
        }
      }
      
      class Test {
        class Inner {
          def foo() { bar = false }
        }
        val inner = new Inner
        private[this] final var bar = true
      }
      

        Activity

        Hide
        Paul Phillips added a comment -

        The access is legal in scala, the bug is that the generated bytecode doesn't accomodate jvm realities.

        Show
        Paul Phillips added a comment - The access is legal in scala, the bug is that the generated bytecode doesn't accomodate jvm realities.
        Hide
        Simon Ochsenreither added a comment -

        It seems to work on 2.9.2 and 2.10 trunk, but I can't find a test for it in the sources.

        Show
        Simon Ochsenreither added a comment - It seems to work on 2.9.2 and 2.10 trunk, but I can't find a test for it in the sources.
        Hide
        Paul Phillips added a comment -

        Test in f1d81c9b9b and thanks for not closing it without a test.

        Show
        Paul Phillips added a comment - Test in f1d81c9b9b and thanks for not closing it without a test.

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Aleksey Nikiforov
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development