Skip to content

Dotty does not generate accessors for protected calls from inner classes, resulting in IllegalAccessError #2780

@bbarker

Description

@bbarker

I hazard a guess this is an issue with handling multiple classloaders. This small project demonstrates the issue.

The problem seems to occur when an anonymous or inner class is created that accesses a protected or private member in the outer class. However, I've only been able to reproduce the error when my outer class extends a class implemented in some (java) library - this is the HelloInput.scala example in the repo (and the protected variable in question is speed). The example in Main.scala uses the same approach with a minimal example implemented completely in the project, and seems to work fine.

Stack trace in dotty:

SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,run-main-group-0]
java.lang.IllegalAccessError: tried to access field com.jme3.app.LegacyApplication.speed from class HelloInput$$anon$1
        at HelloInput$$anon$1.onAnalog(HelloInput.scala:47)
        at com.jme3.input.InputManager.invokeAnalogs(InputManager.java:245)
        at com.jme3.input.InputManager.invokeUpdateActions(InputManager.java:215)
        at com.jme3.input.InputManager.update(InputManager.java:908)
        at com.jme3.app.LegacyApplication.update(LegacyApplication.java:725)
        at com.jme3.app.SimpleApplication.update(SimpleApplication.java:227)
        at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
        at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:193)
        at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232)
        at java.lang.Thread.run(Thread.java:748)

To reproduce:

  1. sbt runHelloInput
  2. Press 'j' or 'k' to trigger the method that will calles the IAE.

To compare to scalac, just change the scalaVersion := in build.sbt.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions