From 4de1896882f23b4ce979540232e94b81b1fbb816 Mon Sep 17 00:00:00 2001 From: Alex Cook Date: Mon, 5 Jan 2026 11:03:07 -0500 Subject: [PATCH 1/5] feat: change AnnotatedFor retention to RUNTIME --- .../java/org/checkerframework/framework/qual/AnnotatedFor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checker-qual/src/main/java/org/checkerframework/framework/qual/AnnotatedFor.java b/checker-qual/src/main/java/org/checkerframework/framework/qual/AnnotatedFor.java index 48c4f7ab47f7..135da508f9c9 100644 --- a/checker-qual/src/main/java/org/checkerframework/framework/qual/AnnotatedFor.java +++ b/checker-qual/src/main/java/org/checkerframework/framework/qual/AnnotatedFor.java @@ -26,7 +26,7 @@ * @checker_framework.manual #compiling-libraries Compiling partially-annotated libraries */ @Documented -@Retention(RetentionPolicy.SOURCE) +@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.PACKAGE}) public @interface AnnotatedFor { /** From 56527fcfcd3928c8c33a397185bebc18020ba360 Mon Sep 17 00:00:00 2001 From: Alex Cook Date: Mon, 5 Jan 2026 11:10:17 -0500 Subject: [PATCH 2/5] doc: update AnnotatedFor javadoc to mention retention policy --- .../java/org/checkerframework/framework/qual/AnnotatedFor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checker-qual/src/main/java/org/checkerframework/framework/qual/AnnotatedFor.java b/checker-qual/src/main/java/org/checkerframework/framework/qual/AnnotatedFor.java index 135da508f9c9..200474664bb2 100644 --- a/checker-qual/src/main/java/org/checkerframework/framework/qual/AnnotatedFor.java +++ b/checker-qual/src/main/java/org/checkerframework/framework/qual/AnnotatedFor.java @@ -16,7 +16,7 @@ * using it in a fully-annotated library nor in an application that does not export APIs for * clients. * - *

This annotation has no effect unless the {@code + *

This annotation is retained in bytecode but has no effect unless the {@code * -AuseConservativeDefaultsForUncheckedCode=source} command-line argument is supplied. Ordinarily, * the {@code -AuseConservativeDefaultsForUncheckedCode=source} command-line argument causes * unannotated locations to be defaulted using conservative defaults, and it suppresses all From 7a73f2003036ae1ab0d569813ce1c273eddfc9d9 Mon Sep 17 00:00:00 2001 From: Alex Cook Date: Mon, 5 Jan 2026 11:38:47 -0500 Subject: [PATCH 3/5] doc: update CHANGELOG with AnnotatedFor comment. --- docs/CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 0e9bc2282367..590c5793bded 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -38,13 +38,15 @@ The Nullness Checker now recognizes references to private, final fields with zer The `ClassBound` annotation can now be used with anonymous types. +The `AnnotatedFor` annotation is now retained in bytecode. + **Implementation details:** The `AbstractNodeVisitor` now has more summary methods, following the class hierarchy of `Node` and conceptual categories. **Closed issues:** -eisop#1247, eisop#1263, eisop#1310, typetools#7096. +eisop#1247, eisop#1263, eisop#1310, eisop#1481, typetools#7096. Version 3.49.5 (June 30, 2025) From 78ce82f9776171f3bbadad99625c3b8c79976a6b Mon Sep 17 00:00:00 2001 From: Alex Cook Date: Mon, 5 Jan 2026 11:46:22 -0500 Subject: [PATCH 4/5] doc(manual): minimal manual update to mention AnnotatedFor bytecode retention --- docs/manual/annotating-libraries.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/manual/annotating-libraries.tex b/docs/manual/annotating-libraries.tex index db580a20531c..f0aac7a2fff9 100644 --- a/docs/manual/annotating-libraries.tex +++ b/docs/manual/annotating-libraries.tex @@ -390,7 +390,7 @@ The \refqualclass{framework/qual}{AnnotatedFor} annotation, written on a class, indicates that the class has been annotated for certain type -systems. For example, \<@AnnotatedFor(\ttlcb"nullness", "regex"\ttrcb)> means that +systems. This annotation will be retained in bytecode. For example, \<@AnnotatedFor(\ttlcb"nullness", "regex"\ttrcb)> means that the programmer has written annotations for the Nullness and Regular Expression type systems. If one of those two type-checkers is run, the \<-AuseConservativeDefaultsForUncheckedCode=source,bytecode> command-line argument From d55704ccae9bf048ccda9ae80788cb8c30d64116 Mon Sep 17 00:00:00 2001 From: Alex Cook Date: Mon, 5 Jan 2026 12:19:25 -0500 Subject: [PATCH 5/5] doc(manual): mention AnnoatatedFor in runtime retention discussion --- docs/manual/faq.tex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/manual/faq.tex b/docs/manual/faq.tex index 8f4516755bb2..e895efcdc6e6 100644 --- a/docs/manual/faq.tex +++ b/docs/manual/faq.tex @@ -1612,9 +1612,9 @@ \subsectionAndLabel{Why are type annotations declared with \<@Retention(RetentionPolicy.RUNTIME)>?}{faq-runtime-retention} -Annotations such as \refqualclass{checker/nullness/qual}{NonNull} are -declared with -\<\sunjavadocanno{java.base/java/lang/annotation/Retention.html}{Retention}(RetentionPolicy.\sunjavadoc{java.base/java/lang/annotation/RetentionPolicy.html\#RUNTIME}{RUNTIME})>. In other words, +Annotations such as \refqualclass{checker/nullness/qual}{NonNull} +and \refqualclass{framework/qual}{AnnotatedFor} are declared with +\<\sunjavadocanno{java.base/java/lang/annotation/Retention.html}{Retention}(RetentionPolicy.\sunjavadoc{java.base/java/lang/annotation/RetentionPolicy.html\#RUNTIME}{RUNTIME})>. In other words, these type annotations are available to tools at run time. Such run-time tools could check the annotations (like an \ statement), type-check dynamically-loaded code, check casts and \ operations, resolve