Repository navigation
Remove method-level Atomic annotations. - #56
Merged
Merged
Conversation
They are unnecessary, troublesome, and probably wrong. Unnecessary: We don't care about annotations on private and package-private APIs because users don't interact with them. The only reason that we have annotations here in the first place is that we we automatically translated every occurrence of plain `<T>` to `<T extends @nullable Object>` in classes that were already annotated for nullness in the upstream Checker Framework JDK. But that wasn't necessarily the right thing to do for private and package-private members, since the upstream Checker Framework JDK doesn't necessarily annotate those properly (nor do we). So it's likely that the upstream code "should" have used `<T extends [@nonnull] Object>`, which we would then have automatically translated to `<T>`, thus avoiding this problem. Troublesome: The JDK changed its definitions of these methods to no longer contain a type parameter at all in later JDK versions. As a result, we try to behave as if an annotation is present in a location that does not exist. That leads to problems, as discussed in Google bug 323609832. Probably wrong: I haven't looked much, but my guess is that a `ReflectionData` instance is associated with a `Class<T>` object. So, just as we declare `Class` with a non-nullable type parameter, we'd likely want to do the same with `ReflectionData`. If we were to do that (not that I bothered in this PR, though I could), then the `<T extends @nullable Object>` on the methods would create an out-of-bounds type argument.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
They are unnecessary, troublesome, and probably wrong.
Unnecessary: We don't care about annotations on private and
package-private APIs because users don't interact with them. The only
reason that we have annotations here in the first place is that we we
automatically translated every occurrence of plain
<T>to<T extends @Nullable Object>in classes that were already annotated for nullnessin the upstream Checker Framework JDK. But that wasn't necessarily the
right thing to do for private and package-private members, since the
upstream Checker Framework JDK doesn't necessarily annotate those
properly (nor do we). So it's likely that the upstream code "should"
have used
<T extends [@NonNull] Object>, which we would then haveautomatically translated to
<T>, thus avoiding this problem.Troublesome: The JDK changed its definitions of these methods to no
longer contain a type parameter at all in later JDK versions. As a
result, we try to behave as if an annotation is present in a location
that does not exist. That leads to problems, as discussed in Google bug
323609832.
Probably wrong: I haven't looked much, but my guess is that a
ReflectionDatainstance is associated with aClass<T>object. So,just as we declare
Classwith a non-nullable type parameter, we'dlikely want to do the same with
ReflectionData. If we were to do that(not that I bothered in this PR, though I could), then the
<T extends @Nullable Object>on the methods would create an out-of-bounds typeargument.