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

Avoid call to inaccessible protected java method through self type #10794

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

lrytz
Copy link
Member

@lrytz lrytz commented Jun 13, 2024

With a self type self: J =>, calling a method this.p which is protected and defined in Java is not valid and results in an IllegalAccessError at runtime.

If the class with the self type overrides the method, use that class as the receiver type. Otherwise issue an error.

Fixes scala/bug#13007

@scala-jenkins scala-jenkins added this to the 2.13.15 milestone Jun 13, 2024
@som-snytt
Copy link
Contributor

som-snytt commented Jun 13, 2024

TIL scala-dev#143.

This changes super invocation of java interface

         1: invokespecial #15                 // InterfaceMethod T.f:()I

to

         1: invokespecial #15                 // Method B.f:()I

in the run test in t1.

With a self type `self: J =>`, calling a method `this.p` which is
protected and defined in Java is not valid and results in an
`IllegalAccessError` at runtime.

If the class with the self type overrides the method, use that class
as the receiver type. Otherwise issue an error.
@lrytz
Copy link
Member Author

lrytz commented Jun 14, 2024

Moved my change to be more local, le compilateur is a bit touchy around here.

@lrytz lrytz merged commit 88cfc02 into scala:2.13.x Jun 19, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

Call on self type leads to IllegalAccessError
4 participants