Don't use @Target({}) to prevent users from writing a type qualifier#7502
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughSix qualifier annotations— Suggested reviewers
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@checker-qual/src/main/java/org/checkerframework/checker/fenum/qual/FenumUnqualified.java`:
- Line 23: Add the missing import for ElementType so the annotation usage
"@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})" compiles: add an
import for java.lang.annotation.ElementType near the other imports in the
FenumUnqualified file (referencing the ElementType symbol used in the class).
In
`@checker-qual/src/main/java/org/checkerframework/checker/lock/qual/LockHeld.java`:
- Line 22: The Target annotation on the LockHeld declaration references
ElementType but the import is missing; add the import for
java.lang.annotation.ElementType so the `@Target`({ElementType.TYPE_USE,
ElementType.TYPE_PARAMETER}) compiles—i.e., in the LockHeld source add an import
for ElementType alongside the existing annotation imports (the class/annotation
name to change is LockHeld and the annotation is `@Target`).
In
`@checker-qual/src/main/java/org/checkerframework/checker/lock/qual/LockPossiblyHeld.java`:
- Line 26: Add the missing import for ElementType used in the `@Target` annotation
of LockPossiblyHeld: add an import for java.lang.annotation.ElementType (or
import java.lang.annotation.*) at the top of the file so the annotation
`@Target`({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) compiles; update the
imports near the class declaration containing LockPossiblyHeld.
In
`@checker-qual/src/main/java/org/checkerframework/checker/signature/qual/SignatureUnknown.java`:
- Line 20: The annotation usage `@Target`({ElementType.TYPE_USE,
ElementType.TYPE_PARAMETER}) references java.lang.annotation.ElementType but the
import is missing; add the missing import (import
java.lang.annotation.ElementType;) to the SignatureUnknown.java file so the
`@Target` annotation compiles correctly alongside the existing `@Target` usage in
the SignatureUnknown declaration.
In
`@checker-qual/src/main/java/org/checkerframework/common/aliasing/qual/MaybeLeaked.java`:
- Line 24: The file MaybeLeaked.java uses ElementType in the `@Target` annotation
but does not import it; add the missing import for
java.lang.annotation.ElementType at the top of MaybeLeaked.java so the
annotation `@Target`({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) compiles
(ensure the existing Target import remains correct and do not remove any other
imports).
In
`@checker-qual/src/main/java/org/checkerframework/common/subtyping/qual/Unqualified.java`:
- Line 24: Add the missing import for ElementType in Unqualified.java: import
java.lang.annotation.ElementType; so the `@Target`({ElementType.TYPE_USE,
ElementType.TYPE_PARAMETER}) annotation resolves; update the imports at the top
of the file where other annotation imports (e.g., Target/Retention) are declared
to include ElementType.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (7)
checker-qual/src/main/java/org/checkerframework/checker/fenum/qual/FenumUnqualified.javachecker-qual/src/main/java/org/checkerframework/checker/lock/qual/LockHeld.javachecker-qual/src/main/java/org/checkerframework/checker/lock/qual/LockPossiblyHeld.javachecker-qual/src/main/java/org/checkerframework/checker/signature/qual/SignatureUnknown.javachecker-qual/src/main/java/org/checkerframework/common/aliasing/qual/MaybeLeaked.javachecker-qual/src/main/java/org/checkerframework/common/subtyping/qual/Unqualified.javaframework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (6)
checker-qual/src/main/java/org/checkerframework/common/aliasing/qual/MaybeLeaked.java (1)
4-4: MissingElementTypeimport now added.The previously flagged compilation error is resolved.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@checker-qual/src/main/java/org/checkerframework/common/aliasing/qual/MaybeLeaked.java` at line 4, The compilation error was caused by a missing import for ElementType used in the MaybeLeaked annotation; add the import statement "import java.lang.annotation.ElementType;" to the top of the MaybeLeaked.java file (where other imports are declared) so references to ElementType in the annotation's `@Target` or related code resolve correctly.checker-qual/src/main/java/org/checkerframework/checker/lock/qual/LockPossiblyHeld.java (1)
4-4: MissingElementTypeimport now added.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@checker-qual/src/main/java/org/checkerframework/checker/lock/qual/LockPossiblyHeld.java` at line 4, There is a duplicate import of java.lang.annotation.ElementType in LockPossiblyHeld.java; remove the extra import so the import block only contains a single import java.lang.annotation.ElementType entry (ensure the file compiles and no other duplicate imports remain).checker-qual/src/main/java/org/checkerframework/checker/lock/qual/LockHeld.java (1)
4-4: MissingElementTypeimport now added.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@checker-qual/src/main/java/org/checkerframework/checker/lock/qual/LockHeld.java` at line 4, The import for java.lang.annotation.ElementType in LockHeld.java appears duplicated; remove the redundant import statement so only a single import of ElementType remains (search for the import line referencing ElementType in the LockHeld file and delete the duplicate).checker-qual/src/main/java/org/checkerframework/checker/fenum/qual/FenumUnqualified.java (1)
4-4: MissingElementTypeimport now added.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@checker-qual/src/main/java/org/checkerframework/checker/fenum/qual/FenumUnqualified.java` at line 4, The file now contains a redundant import of java.lang.annotation.ElementType; open the FenumUnqualified class and remove the duplicate import so there is only a single import statement for ElementType (ensure the import for ElementType appears once and leave other imports unchanged).checker-qual/src/main/java/org/checkerframework/checker/signature/qual/SignatureUnknown.java (1)
4-4: MissingElementTypeimport now added.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@checker-qual/src/main/java/org/checkerframework/checker/signature/qual/SignatureUnknown.java` at line 4, Remove the redundant import of java.lang.annotation.ElementType in SignatureUnknown.java: ensure the file has at most one import for ElementType (or remove it entirely if unused), clean up any duplicate or unused imports in the SignatureUnknown class, and recompile to verify no unused-import warnings remain.checker-qual/src/main/java/org/checkerframework/common/subtyping/qual/Unqualified.java (1)
4-4: MissingElementTypeimport now added.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@checker-qual/src/main/java/org/checkerframework/common/subtyping/qual/Unqualified.java` at line 4, Unqualified.java is missing the ElementType import; add the import statement "import java.lang.annotation.ElementType;" to the top of the file so any `@Target` or ElementType references compile (ensure it appears alongside existing java.lang.annotation imports and there is no duplicate import), and remove the stray "[duplicate_comment]" note from the review/diff metadata if it was accidentally included.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@checker-qual/src/main/java/org/checkerframework/checker/fenum/qual/FenumUnqualified.java`:
- Line 24: The FenumUnqualified annotation's Javadoc forbids source use but
changing its `@Target` made that unenforceable; update the annotation declaration
for FenumUnqualified to include `@InvisibleQualifier` (and restore the restrictive
`@Target` if desired) so it cannot be written in source, or alternatively
implement checker-level rejection in the fenum checker (e.g., in the
type-annotation processing code that handles FenumUnqualified) to report an
error whenever FenumUnqualified appears in source; locate the annotation
declaration for FenumUnqualified and either add the `@InvisibleQualifier` marker
or add a validation hook in the checker code that rejects source occurrences.
In
`@checker-qual/src/main/java/org/checkerframework/checker/signature/qual/SignatureUnknown.java`:
- Line 21: The SignatureUnknown annotation currently allows source use (it has
`@Target`({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})) but lacks the
framework-level prevention used by other hidden qualifiers; add the
`@InvisibleQualifier` annotation to the SignatureUnknown declaration
(class/annotation SignatureUnknown) so it cannot be written in source code,
matching the pattern used by LockHeld, LockPossiblyHeld, MaybeLeaked, and
Unqualified and preserving the existing `@Target` settings.
---
Duplicate comments:
In
`@checker-qual/src/main/java/org/checkerframework/checker/fenum/qual/FenumUnqualified.java`:
- Line 4: The file now contains a redundant import of
java.lang.annotation.ElementType; open the FenumUnqualified class and remove the
duplicate import so there is only a single import statement for ElementType
(ensure the import for ElementType appears once and leave other imports
unchanged).
In
`@checker-qual/src/main/java/org/checkerframework/checker/lock/qual/LockHeld.java`:
- Line 4: The import for java.lang.annotation.ElementType in LockHeld.java
appears duplicated; remove the redundant import statement so only a single
import of ElementType remains (search for the import line referencing
ElementType in the LockHeld file and delete the duplicate).
In
`@checker-qual/src/main/java/org/checkerframework/checker/lock/qual/LockPossiblyHeld.java`:
- Line 4: There is a duplicate import of java.lang.annotation.ElementType in
LockPossiblyHeld.java; remove the extra import so the import block only contains
a single import java.lang.annotation.ElementType entry (ensure the file compiles
and no other duplicate imports remain).
In
`@checker-qual/src/main/java/org/checkerframework/checker/signature/qual/SignatureUnknown.java`:
- Line 4: Remove the redundant import of java.lang.annotation.ElementType in
SignatureUnknown.java: ensure the file has at most one import for ElementType
(or remove it entirely if unused), clean up any duplicate or unused imports in
the SignatureUnknown class, and recompile to verify no unused-import warnings
remain.
In
`@checker-qual/src/main/java/org/checkerframework/common/aliasing/qual/MaybeLeaked.java`:
- Line 4: The compilation error was caused by a missing import for ElementType
used in the MaybeLeaked annotation; add the import statement "import
java.lang.annotation.ElementType;" to the top of the MaybeLeaked.java file
(where other imports are declared) so references to ElementType in the
annotation's `@Target` or related code resolve correctly.
In
`@checker-qual/src/main/java/org/checkerframework/common/subtyping/qual/Unqualified.java`:
- Line 4: Unqualified.java is missing the ElementType import; add the import
statement "import java.lang.annotation.ElementType;" to the top of the file so
any `@Target` or ElementType references compile (ensure it appears alongside
existing java.lang.annotation imports and there is no duplicate import), and
remove the stray "[duplicate_comment]" note from the review/diff metadata if it
was accidentally included.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (6)
checker-qual/src/main/java/org/checkerframework/checker/fenum/qual/FenumUnqualified.javachecker-qual/src/main/java/org/checkerframework/checker/lock/qual/LockHeld.javachecker-qual/src/main/java/org/checkerframework/checker/lock/qual/LockPossiblyHeld.javachecker-qual/src/main/java/org/checkerframework/checker/signature/qual/SignatureUnknown.javachecker-qual/src/main/java/org/checkerframework/common/aliasing/qual/MaybeLeaked.javachecker-qual/src/main/java/org/checkerframework/common/subtyping/qual/Unqualified.java
No description provided.