yasson
yasson copied to clipboard
Java module system: "access to public member failed" when using 'opens' x to 'y'
Describe the bug Allowing runtime-only access to a package by org.eclipse.yasson is not working. I have a module-info file containing the following statement:
opens nl.scuro.media.model to org.eclipse.yasson;
This should allow Yasson to be able to read this package when (de)serializing. Unfortunately, I get an error:
Caused by: java.lang.IllegalAccessException: access to public member failed: nl.scuro.media.model.MediaRefClientWrapper.getMediaRef[Ljava.lang.Object;@6af6a361/invokeVirtual, from public Lookup
at java.base/java.lang.invoke.MemberName.makeAccessException(MemberName.java:955)
I can work around this by exporting my package:
exports nl.scuro.media.model;
But I there are scenarios where one doesn't want to export globally.
To Reproduce Create a simple project with a module-info file and package containing a POJO. Add Yasson as a dependency and open this package to org.eclipse.yasson.
Expected behavior I would expect Yasson to be able to access all classes in the opened package.
System information:
- OS: Linux
- Java Version: 17
- Yasson Version: 2.0.4
Additional context While I'm not very experienced with the module system yet, this seems to be incorrect behavior.