From 26b4df8b8bb965d13f1aecc99a1e3682062f4be0 Mon Sep 17 00:00:00 2001 From: Nima Karimipour Date: Tue, 19 Nov 2024 11:51:52 -0800 Subject: [PATCH] Update README.md - Annotator example (#261) Add a package statement to the Annotator's expected input and output. Without it, if users copy the example directly, the class will not be recognized as annotated, and the Annotator will fail to infer any annotations. This update ensures consistency. --- README.md | 2 ++ sample/build.gradle | 2 +- .../src/main/java/edu/ucr/cs/riple/annotator/sample/Test.java | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b41004c0..d12436ed 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ The final output of Annotator is a source code that passes NullAway checks with In the code below, `NullAway` reports five warnings. ```java +package com.example; class Test{ Object f1 = null; // warning: assigning @Nullable expression to @NonNull field Object f2 = null; // warning: assigning @Nullable expression to @NonNull field @@ -49,6 +50,7 @@ For unresolved errors, suppression annotations are injected. The output below shows the result of running `Annotator` on the code above. ```java +package com.example; import javax.annotation.Nullable; // added by Annotator import org.jspecify.annotations.NullUnmarked; // added by Annotator diff --git a/sample/build.gradle b/sample/build.gradle index df2fe935..b6b2a953 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -57,7 +57,7 @@ tasks.withType(JavaCompile).configureEach { options.errorprone { check("NullAway", CheckSeverity.ERROR) check("AnnotatorScanner", CheckSeverity.ERROR) - option("NullAway:AnnotatedPackages", "edu.ucr.cs.riple") + option("NullAway:AnnotatedPackages", "com.example") option("NullAway:SerializeFixMetadata", "true") option("NullAway:FixSerializationConfigPath", nullaway_config_path) option("AnnotatorScanner:ConfigPath", scanner_config_path) diff --git a/sample/src/main/java/edu/ucr/cs/riple/annotator/sample/Test.java b/sample/src/main/java/edu/ucr/cs/riple/annotator/sample/Test.java index 2dbf12aa..a9c3edf2 100644 --- a/sample/src/main/java/edu/ucr/cs/riple/annotator/sample/Test.java +++ b/sample/src/main/java/edu/ucr/cs/riple/annotator/sample/Test.java @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -package edu.ucr.cs.riple.annotator.sample; +package com.example; public class Test { Object f1 = null;