robovm
robovm copied to clipboard
java.lang.IllegalAccessError: Attempt to access private method/variable from anonymous inner class
Please use discussions for all things that are not reportable issues.
Please ensure you have given all the following requested information in your report.
Issue details
Please provide the details of your issue
Reproduction steps/code
private AudioFadeDirection fadeDirection = AudioFadeDirection.NONE;
public void playMusic(final int id, final boolean fade) {
actionQueue.add(new Runnable() {
@Override
public void run() {
fadeDirection = AudioFadeDirection.FADE_IN; // fails here claims it cant access private var from inner class
}
});
}
Configuration
Please provide the build system, version(s), and targets affected.
Build Tools:
- [x] IDEA plugin
- [ ] Eclipse plugin
- [x] Gradle plugin
Versions: 2.3.16
Please provide the version of RoboVM, XCode and JDK used
- Robovm: 2.3.16
- XCode: 13
- JDK: 11
Build Targets: arm64
Stacktrace
Exception in thread "main" java.lang.IllegalAccessError: Attempt to access field com.bitgate.curseofaros.engine.audio.MusicManager.fadeDirection from class com.bitgate.curseofaros.engine.audio.MusicManager$1
at com.bitgate.curseofaros.engine.audio.MusicManager$1.run(MusicManager.java:90)
at com.bitgate.curseofaros.engine.audio.MusicManager.act(MusicManager.java:183)
at com.bitgate.curseofaros.CurseOfAros.render(CurseOfAros.java:138)
at com.badlogic.gdx.backends.iosrobovm.IOSGraphics.draw(IOSGraphics.java:262)
at com.badlogic.gdx.backends.iosrobovm.IOSGraphics$1.draw(IOSGraphics.java:130)
at com.badlogic.gdx.backends.iosrobovm.IOSGraphics$1.$cb$drawRect$(IOSGraphics.java)
at org.robovm.apple.uikit.UIApplication.main(Native Method)
at org.robovm.apple.uikit.UIApplication.main(UIApplication.java:433)
at com.bitgate.curseofaros.IOSLauncher.main(IOSLauncher.java:67)
hi, could you please share a sample project to reproduce, as following works for me:
public class Test {
private int a;
public void foo() {
DispatchQueue.getMainQueue().async(new Runnable() {
@Override
public void run() {
System.out.println(a);
}
});
}
}
@dkimitsa it happens when you change:
sourceCompatibility = 1.8
targetCompatibility = 1.8
to
sourceCompatibility = 11
targetCompatibility = 11
in the default Mobivm project build.gradle file.
@jonatino java11 introduced JEP 181: Nest-Based Access Control and it doesn't generate accessor bridges for private fields anymore. Playing with adding basic nest-based AC support to RoboVM -- probably for static compiled code. but it will have limitations (like reflection will not be supported for a moment)