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

IllegalAccessException while object's method invocation #86

Open
sskorol opened this issue Sep 3, 2019 · 1 comment
Open

IllegalAccessException while object's method invocation #86

sskorol opened this issue Sep 3, 2019 · 1 comment

Comments

@sskorol
Copy link

sskorol commented Sep 3, 2019

Expected behavior and actual behavior:

Method invocation on objects shouldn't fail with IllegalAccessException.

When I call:

on(annotation).call("methodName").get();

the following exception occurs:

Log
java.lang.IllegalAccessException: class org.joor.Reflect (in module org.jooq.joor) cannot access class com.sun.proxy.jdk.proxy2.$Proxy9 (in module jdk.proxy2) because module jdk.proxy2 does not export com.sun.proxy.jdk.proxy2 to module org.jooq.joor
org.joor.ReflectException: java.lang.IllegalAccessException: class org.joor.Reflect (in module org.jooq.joor) cannot access class com.sun.proxy.jdk.proxy2.$Proxy9 (in module jdk.proxy2) because module jdk.proxy2 does not export com.sun.proxy.jdk.proxy2 to module org.jooq.joor
	at org.jooq.joor/org.joor.Reflect.on(Reflect.java:896)
	at org.jooq.joor/org.joor.Reflect.call(Reflect.java:563)
	at org.jooq.joor/org.joor.Reflect.call(Reflect.java:516)
	at io.github.sskorol.reflection/io.github.sskorol.reflection.testcases.ReflectionTests.lambda$shouldAccessAnnotationValues$5(ReflectionTests.java:27)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:361)
	at java.base/java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.fillBuffer(StreamSpliterators.java:210)
	at java.base/java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.doAdvance(StreamSpliterators.java:161)
	at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.tryAdvance(StreamSpliterators.java:300)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:278)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
	at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:278)
	at java.base/java.util.stream.WhileOps$1$1.accept(WhileOps.java:99)
	at [email protected]/one.util.streamex.StreamEx$2.tryAdvance(StreamEx.java:2741)
	at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
	at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:550)
	at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
	at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:517)
	at [email protected]/one.util.streamex.AbstractStreamEx.toArray(AbstractStreamEx.java:344)
	at [email protected]/one.util.streamex.AbstractStreamEx.toList(AbstractStreamEx.java:1186)
	at io.github.sskorol.reflection/io.github.sskorol.reflection.testcases.ReflectionTests.shouldAccessAnnotationValues(ReflectionTests.java:28)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at [email protected]/org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
	at [email protected]/org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:584)
	at [email protected]/org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:172)
	at [email protected]/org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
	at [email protected]/org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:804)
	at [email protected]/org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:145)
	at [email protected]/org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
	at [email protected]/org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
	at [email protected]/org.testng.TestRunner.privateRun(TestRunner.java:770)
	at [email protected]/org.testng.TestRunner.run(TestRunner.java:591)
	at [email protected]/org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
	at [email protected]/org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
	at [email protected]/org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
	at [email protected]/org.testng.SuiteRunner.run(SuiteRunner.java:304)
	at [email protected]/org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
	at [email protected]/org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
	at [email protected]/org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
	at [email protected]/org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
	at [email protected]/org.testng.TestNG.runSuites(TestNG.java:1032)
	at [email protected]/org.testng.TestNG.run(TestNG.java:1000)
	at org.gradle.api.internal.tasks.testing.testng.TestNGTestClassProcessor.runTests(TestNGTestClassProcessor.java:141)
	at org.gradle.api.internal.tasks.testing.testng.TestNGTestClassProcessor.stop(TestNGTestClassProcessor.java:90)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
	at com.sun.proxy.$Proxy2.stop(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:132)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
	at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:412)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalAccessException: class org.joor.Reflect (in module org.jooq.joor) cannot access class com.sun.proxy.jdk.proxy2.$Proxy9 (in module jdk.proxy2) because module jdk.proxy2 does not export com.sun.proxy.jdk.proxy2 to module org.jooq.joor
	at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:361)
	at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:591)
	at java.base/java.lang.reflect.Method.invoke(Method.java:558)
	at org.jooq.joor/org.joor.Reflect.on(Reflect.java:892)
	... 79 more

Not really sure how can I export a module (which seems dynamic) to joor.

Steps to reproduce the problem:

Here's a sample project: https://github.com/sskorol/reflective-access

Just run ./gradlew test

This line actually causes an issue:
https://github.com/sskorol/reflective-access/blob/master/src/test/java/io/github/sskorol/reflection/testcases/ReflectionTests.java#L27

The main idea is to retrieve field annotation's values.

Note that the same code had perfectly worked on Java 8.

Versions:

  • jOOR: 0.9.12
  • Java: OpenJDK 11.0.2

@lukaseder

@sskorol
Copy link
Author

sskorol commented Sep 10, 2019

@lukaseder lukaseder added this to the Version 0.9.16 milestone Aug 23, 2023
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