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

Java 16 issue illegal access #43

Open
nithril opened this issue Jun 25, 2021 · 9 comments
Open

Java 16 issue illegal access #43

nithril opened this issue Jun 25, 2021 · 9 comments

Comments

@nithril
Copy link

nithril commented Jun 25, 2021

Hello,

Please note it appears that jena-sparql-api is not compatible with java 16.

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make java.lang.invoke.MethodHandles$Lookup(java.lang.Class) accessible: module java.base does not "opens java.lang.invoke" to unnamed module @7494e528
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:188)
	at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:181)
	at org.aksw.jena_sparql_api.mapper.proxy.MapperProxyUtils.proxyDefaultMethod(MapperProxyUtils.java:2048)
	at org.aksw.jena_sparql_api.mapper.proxy.MapperProxyUtils.createProxyFactory(MapperProxyUtils.java:1401)
	... 133 more

Have you planned to make it compatible?

@Aklakan
Copy link
Member

Aklakan commented Jun 26, 2021

Hi, thanks for the report.

As a quick fix, adding the following --add-opens JVM options should mitigate the issue with the reflective access:

java --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED [-cp/-jar...]

I need to investigate whether it is possible to devise a solution for Java 16+ that makes the proxy mapper system work out-of-the-box.

The background is, that the core module provides (besides other things) the RDFConnectionEx interface which extends Jena's RDFConnection interface with a getMetaData method akin to JDBC's connection class. Because we are in the RDF world, that metadata is just a resource in an RDF model. However, a default Java view with certain essential attributes is provided with RDFConnectionMetadata - and this view is generated by the proxy system. Of course, custom views can be obtained using connEx.getMetaData().as(CustomView.class). So because the proxy system already simplifies such fundamental tasks and also makes things more flexible I wouldn't want to separate this feature out.

Note for myself: This stack overflow post may contain helpful information.

@Aklakan
Copy link
Member

Aklakan commented Jul 4, 2021

Turns out that one of the answers of the stack overflow post pointed to class in the spring framework which so far solved at least the MethodHandles issue; it seems that dynamic collection getters (<T> Collection<T> getFoo(Class<T> clz)) yet trigger another illigal access exception with cglib.

@nithril
Copy link
Author

nithril commented Nov 1, 2021

Hello,

Can I do smth to help you? Maybe can you point out what should be updated and give some hint on how :)

With Java 17, the "add-opens" option does not exist anymore.

@Aklakan
Copy link
Member

Aklakan commented Nov 3, 2021

Hi, I am about to complete a quite big restructuring and some refactoring of this project in order to improve modularity and disentangle certain awkward dependencies; I'll come back to this issue once this is complete which should be during next week.

@Aklakan
Copy link
Member

Aklakan commented Dec 8, 2021

Time passes on so quickly ... in any case I finally managed to migrate from cglib to bytebuddy and the first couple of my apps that used to show illegal access warnings no longer show them; its currently in the refactored code based and still needs to be pushed to this repo though :/

@nithril
Copy link
Author

nithril commented Dec 27, 2021

Great news and job! 👍

@KonradHoeffner
Copy link

@Aklakan: I would be very happy to see the new version, I tried to fix some errors in LIMES and this is a problem when running it under Java 16.

@Aklakan
Copy link
Member

Aklakan commented Mar 10, 2022

the refactoring of jena-sparq-api "jenax" (simply for jena extensions) 4.4.0-1 is available on mvn central https://mvnrepository.com/artifact/org.aksw.jenax

i hope it doesn't take that long anymore to merge the code back into this repo :)

@nithril
Copy link
Author

nithril commented Mar 10, 2022

Thank you very much 👍

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

3 participants