Commit 871d81d8 authored by Pete Gillin's avatar Pete Gillin
Browse files

Fix a bug in ojluni.jaif for HashMap.entrySet().

Prior to this change, `make docs` or just `make
metalava-api-stubs-docs` was giving the warnings about not being able
to apply three annotations[1], and inspecting the
ojluni_jaif_annotated_srcs.srcjar showed that those annotations
mentioned were missing from the generated annotated source. With this
change, the warnings go away, and the annotations are correct in the
generated annotated source.

The previous ojluni.jaif fragment was produced by running the CF
extract-annotations tool, but it is incorrect. In the declaration
  public Set<Map.Entry<K,V>> entrySet()
the path `inner-type 3, 0` refers to the `Map`, not to the
`Map.Entry`; you need `inner-type 3, 0, 1, 0` to refer to the
`Map.Entry`. See the definition of the type-path production in the
JAIF spec[2] for details.

[1] These are the warnings:
Found class java.util.HashMap, but unable to insert @libcore.util.NonNull:
  @libcore.util.NonNull (nl=false) @ {GENERIC_ARRAY_LOCATION=GenericArrayLocationCriterion at ( [TYPE_ARGUMENT(0)] ), RETURN_TYPE=ReturnTypeCriterion for method: entrySet()Ljava/util/Set;, IN_METHOD=in method 'entrySet()Ljava/util/Set;', IN_CLASS=In class 'java.util.HashMap' (exactly)}
Found class java.util.HashMap, but unable to insert @libcore.util.NullFromTypeParam:
  @libcore.util.NullFromTypeParam (nl=false) @ {GENERIC_ARRAY_LOCATION=GenericArrayLocationCriterion at ( [TYPE_ARGUMENT(0), TYPE_ARGUMENT(0)] ), RETURN_TYPE=ReturnTypeCriterion for method: entrySet()Ljava/util/Set;, IN_METHOD=in method 'entrySet()Ljava/util/Set;', IN_CLASS=In class 'java.util.HashMap' (exactly)}
Found class java.util.HashMap, but unable to insert @libcore.util.NullFromTypeParam:
  @libcore.util.NullFromTypeParam (nl=false) @ {GENERIC_ARRAY_LOCATION=GenericArrayLocationCriterion at ( [TYPE_ARGUMENT(0), TYPE_ARGUMENT(1)] ), RETURN_TYPE=ReturnTypeCriterion for method: entrySet()Ljava/util/Set;, IN_METHOD=in method 'entrySet()Ljava/util/Set;', IN_CLASS=In class 'java.util.HashMap' (exactly)}

[2] https://checkerframework.org/annotation-file-utilities/annotation-file-format.html

Test: `make metalava-api-stubs-docs` and inspect ojluni_jaif_annotated_srcs.srcjar
Bug: 109869600
Change-Id: Ia923fd352b8ce510be344844a4409d090faf82a8
parent 460784a9
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment