Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
scabug opened this issue Sep 28, 2011 · 4 comments

Comments

@scabug
Copy link

commented Sep 28, 2011

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
}
@scabug

This comment has been minimized.

Copy link
Author

commented Sep 28, 2011

Imported From: https://issues.scala-lang.org/browse/SI-5037?orig=1
Reporter: @lexn82
Affected Versions: 2.9.1
Other Milestones: 2.10.0-M3, 2.10.0

@scabug

This comment has been minimized.

Copy link
Author

commented Sep 28, 2011

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

@scabug

This comment has been minimized.

Copy link
Author

commented May 12, 2012

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

@scabug

This comment has been minimized.

Copy link
Author

commented May 12, 2012

@paulp said:
Test in f1d81c9b9b and thanks for not closing it without a test.

@scabug scabug closed this May 12, 2012

@scabug scabug added this to the 2.9.2 milestone Apr 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.