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

JUnit execution fails with InaccessibleObjectException: Unable to make public void ...() accessible: module ... does not "exports ..." to unnamed module #2409

Closed
hohwille opened this issue May 4, 2024 · 3 comments
Labels
needinfo Further information is requested

Comments

@hohwille
Copy link

hohwille commented May 4, 2024

Problem

I am using the JPMS (Java Platform Module System) in my OSS project.
Now I stumbled over a bug in Eclipse preventing my JUnit test to work:

  • I do have an abstract base test class extended by multiple test cases that resides in a parent package that is empty in src/main/java and therefore cannot be exported in module-info.java
  • This abstract base class has a public @Test method doing some generic tests to be covered by all extended test cases.
  • When I run a concrete (non-abstract) JUnit test from a sub-package that extends the abstract base test class then Eclipse tries to run the public test method from that abstract base test class but fails to do so.

The error is that I get this unexpected stacktrace:

java.lang.reflect.InaccessibleObjectException: Unable to make public void io.github.mmm.entity.property.PropertyTest.testFactory() accessible: module io.github.mmm.entity.bean does not "exports io.github.mmm.entity.property" to unnamed module @4550bb58
	at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:391)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:367)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:315)
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:203)
	at java.base/java.lang.reflect.Method.setAccessible(Method.java:197)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

image

Links

Hints

Please note that mvn via maven-surefire-plugin does not cause this error and in the terminal, I can run my tests successfully with mvn test. As it seems mvn had the same bug but it has been fixed many years ago: https://issues.apache.org/jira/browse/SUREFIRE-1909

So maybe using add-opens could help to fix this.

Environment

Eclipse IDE for Java Developers (includes Incubating components)

Version: 2024-03 (4.31.0)
Build id: 20240307-1437
@iloveeclipse
Copy link
Member

I can't find Eclipse project there. Many issues in JDT are related to the way how projects are setup. Please provide some simple self containing example that shows the issue, ideally as a zipped project.

@iloveeclipse iloveeclipse added the needinfo Further information is requested label May 7, 2024
@jukzi
Copy link
Contributor

jukzi commented Jun 25, 2024

Closing due to missing information

@jukzi jukzi closed this as not planned Won't fix, can't repro, duplicate, stale Jun 25, 2024
@hohwille
Copy link
Author

hohwille commented Oct 2, 2024

I can't find Eclipse project there. Many issues in JDT are related to the way how projects are setup.

For the record: All I do is "import as existing maven project".
I also analyzed and described the problem in detail.
Surely if Eclipse is drowning in issues, this is not high prio and can be ignored. I have a workaround by moving the abstract base test to a different package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needinfo Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants