-
Notifications
You must be signed in to change notification settings - Fork 75
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
Class not found error when using equalsverifier in a Java module #746
Comments
Thanks for letting me know, and for creating the sample project. I was able to reproduce this quite quickly. I agree with you that things should just work when using modules. Indeed, I can load the Out of curiosity, are you running your unit tests on the module path? If so, how do you do that? |
I don't use modules myself and my experience with them is limited. However I'm also working on a testing library and I'd like it to support modules for users who do use them. I discovered this issue in my project. I then tested it with equalsverifier as it also supports a lot of java types, and this has led to this bug report. Ideally, I'd like to have a Maven test module (that is also a Java module) to verify the library works properly on the module path. However I haven't been able to get that to work in a multi-module Maven build as I'm using |
Yeah, I'd like to have some kind of test for this as well that I can run from Maven. Perhaps I could add a proper |
@sormuras has a nice blog post on this subject. |
Thanks, I think I've read that when I first looked into modules... will take another look when I pick this up. |
Happy to help, if needed. |
@jqno I just noticed that if you run the sample from the command line, the error does not occur. It works even without
Regarding the second error (
This also works using mvn exec and fails in IntelliJ. I created a separate sample to submit an Objenesis bug report, but at this point, I'm not even sure which behaviour is correct, IntelliJ or mvn exec. |
I noticed that too, I think the Maven exec plugin just puts everything on the classpath by default instead of on the modulepath, and that IntelliJ is a bit smarter about this. But I'll have to investigate more :) Did you submit something with Objenesis? If so, can you share the link? I'd like to follow that as well! |
Just did. GitHub is ahead of me :) |
I was going though old tickets, and tried this one again. It's still blocked on the Objenesis issue, unfortunately. I've added a label to make this clearer at a glance from the issues list. |
@jqno I ended up removing it as a dependency and using Not sure if this approach will work for EV. It could be a breaking change since Objenesis provides some additional strategies for instantiating classes, however those could be handled as they arise. Might be worth investigating. |
Thanks for the response. That could be a good workaround for individual cases, but it's not something I'd like to include in EqualsVerifier itself. Good to know about this option though, so I can refer others to it if they run into this. |
I think I'm getting similar issue. It's not
I'm trying to migrate into Java17. The project it OpenSource: https://bitbucket.org/i18n_church/church.i18n.processing.exception |
That's actually a different issue. OP is making their own modules, while you're extending a class form an existing, JDK-internal module. Unfortunately, in this case you'll have to adjust your build scripts to actually open the |
I finally have a solution for this. The issue with The error that pops up when this change is made, the It turns out that your project runs EqualsVerifier as a regular Java application, and unit tests (whether using Maven Surefire or IntelliJ) are...different. Somehow. It took me a while to figure that out, and I ended up opening a new ticket with Objenesis, and asking on StackOverflow 😅. The TL;DR is, if I add So. I just released EqualsVerifier 3.17.1, which loads I'm really sorry I took two years to resolve this issue. I know that you've moved on in the mean time, so you're probably not waiting for this one anymore, but still 😅. |
BTW, I've been looking at your Instancio project, and it looks very very nice. I'm tempted to try and see if I can use it for object instantiation in EqualsVerifier now, so I can get rid of my own messy code 😅 |
Hey @jqno, no worries at all and thank you for looking into this! It was a tricky one. I think we haven't really come around to modules yet. At least personally, I'm still getting used to them. Either way, I guess you'll be happy to finally close this issue :D
Thanks very much, it means a lot! I've been using EV for years and it would be amazing if my little project could contribute to it 😅 If it fits your needs and you decide to use it, please let me know if I can help in any way, or if you have any feedback. |
I have a couple of big projects for EqualsVerifier that I want to do. One of them is make it properly modular, so as part of that I really wanted to get this ticket resolved. Another is to re-do the instantiation logic to make it less complicated and more robust, which is where Instancio might come in :). I haven't decided yet which I want to do first, or when I actually have time to do one of them...but thanks for the offer, I'll definitely keep it in mind! |
Describe the bug
The error occurs when a project does not declare
requires java.sql
in itsmodule-info.java
.equalsverifier references classes from that package leading to the error.
To Reproduce
Minimal sample: https://github.com/armandino/equalsverifier-java9-module-bug
Error message
Expected behavior
If an application does not
require java.sql
equalsverifier should still work.Version
3.12.3 (no deps)
Additional context
Error occurs in
JavaApiPrefabValues
that importsjava.sql.*
classes. Loading them viaClass.forName
might be a potential solution (had to do something similar myself in another project).The text was updated successfully, but these errors were encountered: