Skip to content

Add subpackage controls to package annotations - #138

Open
aosen-xiong wants to merge 2 commits into
eisop:masterfrom
aosen-xiong:eisop-1990
Open

Add subpackage controls to package annotations#138
aosen-xiong wants to merge 2 commits into
eisop:masterfrom
aosen-xiong:eisop-1990

Conversation

@aosen-xiong

Copy link
Copy Markdown
Collaborator

Adds applyToSubpackages to @AnnotatedFor, @HasQualifierParameter, and @ReportUse.

The element defaults to true, preserving existing behavior while allowing each annotation to be limited to the package where it is written.

Corresponding Checker Framework issue: eisop/checker-framework#1990

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends three Checker Framework package-level annotations with an applyToSubpackages element, enabling callers to control whether a package annotation should propagate to subpackages while keeping the current default behavior.

Changes:

  • Add boolean applyToSubpackages() default true; to @AnnotatedFor, @HasQualifierParameter, and @ReportUse.
  • Update Javadoc to describe the new subpackage-inheritance control and its interaction with enclosing packages.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/java.base/share/classes/org/checkerframework/framework/qual/HasQualifierParameter.java Adds applyToSubpackages and updates package-usage semantics in Javadoc.
src/java.base/share/classes/org/checkerframework/framework/qual/AnnotatedFor.java Adds applyToSubpackages and documents subpackage inheritance behavior.
src/java.base/share/classes/org/checkerframework/common/util/report/qual/ReportUse.java Expands Javadoc and adds applyToSubpackages to control package vs. subpackage reporting scope.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

* field to false to limit it to the package itself; doing so does not block an applicable
* {@code @HasQualifierParameter} on an enclosing package. It can be disabled on a specific class
* and its subclasses by writing {@code @NoQualifierParameter} on that class. This annotation may
* not be written on the same class as {@code NoQualifierParameter} for the same hierarchy.
@aosen-xiong aosen-xiong closed this Sep 1, 2026
@aosen-xiong aosen-xiong reopened this Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants