Skip to content

Introduce @NullMarked aliasing#1304

Open
aosen-xiong wants to merge 17 commits into
eisop:masterfrom
aosen-xiong:nullmarked-alasing
Open

Introduce @NullMarked aliasing#1304
aosen-xiong wants to merge 17 commits into
eisop:masterfrom
aosen-xiong:nullmarked-alasing

Conversation

@aosen-xiong

@aosen-xiong aosen-xiong commented Jul 1, 2025

Copy link
Copy Markdown
Collaborator

Fixes #1299.

First merge #1331.

@wmdietl wmdietl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Still a draft, but some quick comments.

Comment thread checker/tests/nullness-nullmarked/NullMarkedSuppressError.java Outdated
Comment thread checker/tests/nullness-nullmarked/NullMarkedSuppressError.java
}

/**
* This method is almost similar to {@link

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be nice to find a solution without this duplication.

@aosen-xiong aosen-xiong Aug 26, 2025

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

With code refactoring in #1331, we can get rid of this code duplication.

EDIT: tested at aosen-xiong#13.

@aosen-xiong aosen-xiong marked this pull request as ready for review August 28, 2025 18:09
Copilot AI review requested due to automatic review settings May 25, 2026 15:07
@aosen-xiong aosen-xiong removed their assignment May 25, 2026

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

Note

Copilot was unable to run its full agentic suite in this review.

Adds JSpecify @NullMarked support by treating it as opting code into the Nullness type system (equivalent to @AnnotatedFor("nullness")) and refactors @AnnotatedFor scope checks into AnnotatedTypeFactory with caching.

Changes:

  • Alias JSpecify @NullMarked to both the Nullness default qualifier behavior and @AnnotatedFor("nullness").
  • Centralize and cache “is this element annotated for this checker (or upstream checker)?” logic in AnnotatedTypeFactory.
  • Update conservative-defaults and suppression logic to use the new centralized API; add/adjust tests and changelog entry.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
framework/src/main/java/org/checkerframework/framework/util/defaults/QualifierDefaults.java Switches conservative-default decision to use AnnotatedTypeFactory’s new @AnnotatedFor query.
framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java Introduces cached element-level @AnnotatedFor resolution and renames checker-matching helper.
framework/src/main/java/org/checkerframework/framework/stub/AnnotationFileParser.java Updates stub parsing to use renamed @AnnotatedFor applicability method.
framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java Replaces local @AnnotatedFor logic with an abstract hook implemented by subclasses.
framework/src/main/java/org/checkerframework/framework/source/AggregateChecker.java Implements new abstract SourceChecker hook (returns false).
framework/src/main/java/org/checkerframework/common/util/debug/SignaturePrinter.java Implements new abstract SourceChecker hook for the debug checker (returns false).
framework/src/main/java/org/checkerframework/common/util/count/JavaCodeStatistics.java Implements new abstract SourceChecker hook (returns false).
framework/src/main/java/org/checkerframework/common/util/count/AnnotationStatistics.java Implements new abstract SourceChecker hook (returns false).
framework/src/main/java/org/checkerframework/common/basetype/BaseTypeChecker.java Implements new abstract hook by delegating to the type factory.
docs/CHANGELOG.md Documents @NullMarked support as an alias for nullness opt-in.
checker/tests/nullness-nullmarked/NullMarkedSuppressError.java Adds regression test for onlyAnnotatedFor behavior with @NullMarked.
checker/src/test/java/org/checkerframework/checker/test/junit/NullnessNullMarkedTest.java Runs null-marked tests with -AonlyAnnotatedFor.
checker/src/main/java/org/checkerframework/checker/nullness/NullnessNoInitAnnotatedTypeFactory.java Adds alias mapping from @NullMarked to @AnnotatedFor("nullness").
Comments suppressed due to low confidence (1)

docs/CHANGELOG.md:1

  • The release date contains a placeholder (May ?, 2026). Replace ? with a concrete date or remove the date entirely until known, to avoid publishing ambiguous release metadata.
Version 3.49.5-eisop2 (May ?, 2026)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +6087 to +6088
throw new BugInCF(
"Call of QualifierDefaults.isElementAnnotatedForThisChecker with null");
/** Mapping from an Element to the source Tree of the declaration. */
private final Map<Element, Tree> elementToTreeCache;

/** A mapping of Element &rarr; Whether or not that element is AnnotatedFor this type system. */
Comment on lines 2885 to 2889
return true;
}
}
if (isAnnotatedForThisCheckerOrUpstreamChecker(elt)) {
// Return false immediately. Do NOT check for AnnotatedFor in the
// enclosing elements, because they may not have an @AnnotatedFor.
return false;
}
}
return false;
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.

Alias @NullMarked to mark code as annotated

3 participants