Skip to content

Add support for nested annotations to JDK Javac plugin #1410

@msridhar

Description

@msridhar

Follow up to #1407. Now that library models support nested annotations within method parameter / return types, we should parse such annotations from jspecify/jdk and generate astubx for them. Here is an example method where this support should be useful; we should be able to encode the @NonNull annotation within Class<@NonNull E> type. (See also #1409)

Rough steps (and should be done in multiple PRs):

  1. Update jdk-javac-plugin to parse the nested annotations and generate corresponding JSON. Basically the JSON should encode the information in a NestedAnnotationInfo object for each nested annotation (annotation type and path through the type to get to its position). For each parameter position and for the return type, there could be multiple such annotations. In LibraryModels this is encoded as an ImmutableSetMultimap<Integer, NestedAnnotationInfo>, where -1 represents the return type.
  2. Update com.uber.nullaway.jdkannotations.AstubxGenerator to generate astubx from the JSON of step 1.
  3. Update NullAway's astubx parser to parse the data and include it in its external library models, and check support is working with an integration test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    jspecifyRelated to support for jspecify standard (see jspecify.dev)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions