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

IllegalAccessException with extending java class + self type annotation #4119

Closed
scabug opened this issue Dec 28, 2010 · 3 comments
Closed

Comments

@scabug
Copy link

scabug commented Dec 28, 2010

Requires Swing:

class TestProtectedInheritance extends AbstractListModel {
  thisModel =>
  val fn = () => {
    fireContentsChanged(TestProtectedInheritance.this, 0, 0)
  }
  fn()
  def getElementAt(index: Int) = null
  def getSize = 0
}
new TestProtectedInheritance

Generates:
java.lang.IllegalAccessError: tried to access method javax.swing.AbstractListModel.fireContentsChanged(Ljava/lang/Object;II)V from class ru.smarty.TestProtectedInheritance$$$$anonfun$$2

If I comment out self type declaration everything goes well:

class TestProtectedInheritance extends AbstractListModel {
//  thisModel =>
  val fn = () => {
    fireContentsChanged(TestProtectedInheritance.this, 0, 0)
  }
  fn()
  def getElementAt(index: Int) = null
  def getSize = 0
}

No exception.

Disassembler shows generation of proxy method
public void protected$$fireContentsChanged(TestProtectedInheritance paramTestProtectedInheritance, Object paramObject, int paramInt1, int paramInt2)
{
paramTestProtectedInheritance.fireContentsChanged(paramObject, paramInt1, paramInt2);
}
In second code while in first example code is made directly. No compile time error is given.

=== Additional information ===
Might be caused by #2296.

=== What versions of the following are you using? ===

  • Scala: 2.8.1
  • Java: jdk1.6.0_21
  • Operating system: Windows 7
@scabug
Copy link
Author

scabug commented Dec 28, 2010

Imported From: https://issues.scala-lang.org/browse/SI-4119?orig=1
Reporter: Yuri Malinov (yurimalinov)

@scabug
Copy link
Author

scabug commented Dec 28, 2010

@paulp said:
Fascinating, since the self-type a) does not specify any type and b) is never referenced, yet it is sufficient to cause miscompilation.

I think the test in superaccessors should be more like

-      def isSelfType = (host.thisSym != host) && {
+      def isSelfType = !(host.tpe <:< host.typeOfThis) && {

Not tested though.

@scabug
Copy link
Author

scabug commented Dec 31, 2010

@paulp said:
(In r23862) Modified the self-type protected accessor test to avoid unnecessary
runtime failures. Closes #4119, review by dragos.

@scabug scabug closed this as completed May 18, 2011
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

1 participant