Open cmacq2 opened 1 month ago
Sorry for the slow response, I was out of town for a few days.
I'm assuming that you're running your tests on the modulepath, not on the classpath, is that right?
Ignoring fields is intended for whether or not fields should participate in the equals contract. EqualsVerifier still needs to be able to instantiate every field, though, whether it's ignored or not. I realise that this is sometimes unclear, and I'm thinking about ways to make that clearer.
The workaround for your problem is not to ignore the HEX
field, but to add prefab values for it:
EqualsVerifier
.forClass(Foo.class)
.withPrefabValues(HexFormat.class, HexFormat.ofDelimiter(" "), HexFormat.ofDelimiter("/"))
.verify();
Please let me know if that helps.
Describe the bug
It appears equals verifier also attempts to reflect on
static final
class fields. This causes confusing/unexpected behaviour when those fields are not accessible (Java module system).Steps to reproduce
byte[]
.private static final
object of some inaccessible type such asHexFormat
(delimiter field is inaccessible)EqualsVerifier
away from the offending field by asking it to ignore it.Error message and version number
Code: EqualsVerifier invocation
Code: class under test
Additional context
No response