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 { /** diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index afad2ac0f46b..581afa059699 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -3,6 +3,9 @@ Version 3.49.5-eisop1 (July ??, 2025) **User-visible changes:** +The new command-line option '-AnoBytecodeStorage' configures the Checker Framework to not store defaulted annotations in +bytecode. + The new command-line option `-AonlyAnnotatedFor` suppresses all type-checking errors and warnings outside the scope of a corresponding `@AnnotatedFor` annotation. Note that the `@AnnotatedFor` annotation must include the checker's name to enable warnings from that checker. diff --git a/framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java b/framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java index 0c0c9a37d1a2..d816b53a6c71 100644 --- a/framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java +++ b/framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java @@ -218,6 +218,10 @@ // org.checkerframework.framework.source.SourceChecker.useConservativeDefault "useConservativeDefaultsForUncheckedCode", + // Whether to store defaulted annotations in bytecode. + // org.checkerframework.framework.type.AnnotatedTypeFactory.postProcessClassTree + "noBytecodeStorage", + // Whether to assume sound concurrent semantics or // simplified sequential semantics // org.checkerframework.framework.flow.CFAbstractTransfer.sequentialSemantics diff --git a/framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java b/framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java index cb28a2142a5e..bfb8095f90e6 100644 --- a/framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java +++ b/framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java @@ -1532,10 +1532,14 @@ public void preProcessClassTree(ClassTree classTree) {} *
The default implementation uses this to store the defaulted AnnotatedTypeMirrors and * inherited declaration annotations back into the corresponding Elements. Subclasses might want * to override this method if storing defaulted types is not desirable. + * + * @param tree the ClassTree that has been processed */ public void postProcessClassTree(ClassTree tree) { - TypesIntoElements.store(processingEnv, this, tree); - DeclarationsIntoElements.store(processingEnv, this, tree); + if (!checker.hasOption("noBytecodeStorage")) { + TypesIntoElements.store(processingEnv, this, tree); + DeclarationsIntoElements.store(processingEnv, this, tree); + } if (typeInformationPresenter != null) { typeInformationPresenter.process(tree, getPath(tree));