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

Unexpected bahavior for classes with properties of type RuntimeException #831

Closed
kostadin-kar opened this issue Jun 22, 2023 · 1 comment

Comments

@kostadin-kar
Copy link

Disclaimer: this could be no bug.
Firstly, thank you for all the support, time and effort you put into managing the EqualsVerifier library and helping out people in need!

Describe the bug
I stumbled across an issue (possibly) with EqualsVerifier, when attempting to test the methods of a class, which has a property of type RuntimeException in Java 17. This is probably due to the new modular structure of the language. It worked successfully on Java 11. A workaround is to replace the property from RuntimeException to Throwable. I also tried other classes from the java.lang package (for Thread the test succeeds, for Processor it doesn't).
So my question is: is this the expected behavior or should the framework handle these cases? Thanks in advance!

To Reproduce
Run the test and observe the behavior

Code that triggers the behavior
I've attached a minimal project to reproduce the problem as a tar file.
reproduce 2.zip

Error message

java.lang.AssertionError: EqualsVerifier found a problem in class com.example.demo.Dummy.
-> Unable to make field private transient java.lang.Class java.lang.StackTraceElement.declaringClassObject accessible: module java.base does not "opens java.lang" to unnamed module @a38d7a3

Expected behavior
Exceptions as class fields should be considered during checks for equals/hashCode imho (unless something more architectural is preventing it)

EqualsVerifier version
3.13.2

Additional Info
OS: macOS Ventura 13.4.1
IDE: Intellij IDEA 2021.2.2
Java 17.0.7

@jqno
Copy link
Owner

jqno commented Jun 23, 2023

Thanks for the elaborate issue description!

The problem is that EqualsVerifier does some reflection on all of a class's fields, and this is not allowed for classes from Java's APIs. This is something I can fix in the EqualsVerifier codebase, and I have: version 3.14.3 is now out, and it should solve your problem!

@jqno jqno closed this as completed Jun 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