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

Unable to make field private ... accessible: module ... does not "opens ..." to module com.sun.xml.bind #1815

Open
mkarg opened this issue Oct 7, 2024 · 2 comments

Comments

@mkarg
Copy link
Member

mkarg commented Oct 7, 2024

While I am using Java SE / EE for decades, I need to confess that I am a newbie with Java Modules. Kindly begging for help!

I have written some JAXB elements in Java and want to package them as a Java Module using the following module-info declaration:

...
opens ... to jakarta.xml.bind, com.sun.xml.bind;
...

That is working pretty well. I can even remove the to part and it still works. 😄

But what I actually want to write is this, as any JAXB implementation shall be able to reflect (but not anybody):

...
opens ... to jakarta.xml.bind;
...

Unfortunately, what happens is this:

java.lang.reflect.InaccessibleObjectException: Unable to make field private ... accessible: module ... does not "opens ..." to module com.sun.xml.bind
        at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:387)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:363)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:311)
        at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:180)
        at java.base/java.lang.reflect.Field.setAccessible(Field.java:174)
        at [email protected]/org.glassfish.jaxb.runtime.v2.runtime.reflect.Accessor$FieldReflection.<init>(Accessor.java:213)

What am I doing wrong?

@mkarg
Copy link
Member Author

mkarg commented Oct 9, 2024

@lukasj Kindly asking for your help. :-)

@lukasj
Copy link
Member

lukasj commented Oct 11, 2024

Can you share simple reproducer and/or relevant parts of the dependency tree? One needs to figure out what is going on in this method - someone - either API or this piece of code - is not properly passing down the opens declaration

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

2 participants