Skip to content

IllegalAccessError when using package proptected members of a java class. #3663

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

Closed
scabug opened this issue Jul 12, 2010 · 4 comments
Closed
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jul 12, 2010

There are actually two bugs, which may or may not be related. The first bug occurs when extening a java class with package protected memebers.
The second bug occurs when methods using package protected members get inlined (requires -optimise switch).

Java class:

package test;

class PackageProtected {
    int foo;
}

Scala:

package test

final class Test extends PackageProtected {
  def bar = foo
}

package another {
  object Main {
    def bug1(t: Test) {
      // Can always be replicated.
      println(t.foo)
    }
    def bug2(t: Test) {
      // Conditions to replicate: must use -optimise, class Test must be final
      println(t.bar)
      //@noinline is a usable workaround
    }
    def main(args: Array[String]) {
      bug1(new Test)
      bug2(new Test)
    }
  }
}
@scabug
Copy link
Author

scabug commented Jul 12, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3663?orig=1
Reporter: @lexn82

@scabug
Copy link
Author

scabug commented Aug 6, 2010

@lrytz said:
both the java class and it's field are package-private. see http://download.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html

@scabug
Copy link
Author

scabug commented Aug 6, 2010

@lrytz said:
test in "test/pending/neg/t3663" (soon)

@scabug
Copy link
Author

scabug commented Aug 13, 2010

@adriaanm said:
(In r22755) closes #3663. disregard package nesting for access check of java syms

namers wasn't setting privateWithin on java-defined variables (btw, shouldn't clone carry over privateWithin?)
better treatment of linked class access boundary (only check for access within linked class if it actually exists)

would have liked more control for the test case: only javac should compile the java file, then scalac should compile the scala file and fail

review by odersky

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants