Repository navigation
Conversation
MergedAnnotation.asMap(Function, Adapt...) bounds its type variable by Map<String, Object>, yet three call sites in spring-core pass factories that create AnnotationAttributes, which extends LinkedHashMap<String, @nullable Object>. Under JSpecify that type is outside the bound, and NullAway with full generic type inference (uber/NullAway#1585) reports it in AbstractMergedAnnotation.asAnnotationAttributes() and in AnnotationUtils.getAnnotationAttributes() and computeDefaultValues(): error: [NullAway] incompatible types: AnnotationAttributes cannot be converted to Map<String, Object> (AnnotationAttributes is a subtype of Map<String, @nullable Object>) Declare the bound as Map<String, ? super Object> in MergedAnnotation and its implementations. For javac this admits exactly what the old bound did, while under JSpecify it admits both Map<String, Object> and Map<String, @nullable Object>, and asMap can still put attribute values into the map. Map<String, @nullable Object> would be the obvious bound, but it rejects factories of Map<String, Object>: the same NullAway build reports "LinkedHashMap<String, Object> cannot be converted to Map<String, @nullable Object>" for such a factory. The factory-less asMap(Adapt...) keeps returning Map<String, Object>: the map it builds never holds null, since asMap skips attributes whose value is null. Signed-off-by: Vladimir Sitnikov <sitnikov.vladimir@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
MergedAnnotation.asMap(Function, Adapt...)boundsTbyMap<String, Object>, butAnnotationAttributesextendsLinkedHashMap<String, @Nullable Object>. NullAway with full generic type inference (uber/NullAway#1585) therefore rejects the three spring-core calls that pass anAnnotationAttributesfactory (AbstractMergedAnnotation.java:192,AnnotationUtils.java:884,:930): "AnnotationAttributes cannot be converted to Map<String, Object>".The bound becomes
Map<String, ? super Object>. For javac it is the same bound as before. Under JSpecify it admits bothMap<String, Object>andMap<String, @Nullable Object>.Map<String, @Nullable Object>was rejected: with it, the same NullAway build reports "LinkedHashMap<String, Object>cannot be converted toMap<String, @Nullable Object>" for a caller'sMap<String, Object>factory.Verified with a NullAway snapshot built from subhramit/NullAway@3ed1de8a9: the three errors are gone, and a probe call with a
LinkedHashMap<String, Object>factory compiles../gradlew :spring-core:checkpasses with the current NullAway 0.14.0. No test is added: the change only affects nullness annotations, which are not visible at runtime.