-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Replace List<@Nullable Object> with List<?>
#4626
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
Conversation
|
It looks like AssertJ can't assert on values like Currently, the build fails because some of the JUnit tests attempt things like the following: var values = readFieldValues(fields, new ClassWithFields());
assertThat(values).containsExactly("enigma", 3.14, "text", 2.5, null, 42, "constant", 99);I'm not sure if AssertJ's |
|
A funny case is that an illegal // Modify local copy:
assertThrows(UnsupportedOperationException.class, () -> copy.set(0, "Boom!"));The code fails to compile with |
marcphilipp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a breaking change, I'm not convinced we should do it for public APIs. Could you please revert all changes except those in ReflectionUtils and its test class?
97bd188 to
d717c72
Compare
| @SuppressWarnings("unchecked") | ||
| List<Object> result = (List<Object>) ReflectionUtils.readFieldValues(fields, instance); | ||
| return result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not fond of this cast, however, it seems to be the least evil as the added suppression holds for a single statement only rather than a method.
The latter is easier to read, and it forbids list.add(...) at the compile-time. See https://jspecify.dev/docs/user-guide/#wildcard-bounds
|
Thanks, @vlsi! 👍 |
List<@Nullable Object> with List<?>
Overview
The latter is easier to read, and it forbids list.add(...) at the compile-time.
See https://jspecify.dev/docs/user-guide/#wildcard-bounds
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@APIannotations