Skip to content

Commit

Permalink
Update README.md - Annotator example (#261)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nimakarimipour authored Nov 19, 2024
1 parent 98163b2 commit 26b4df8
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
* THE SOFTWARE.
*/

package edu.ucr.cs.riple.annotator.sample;
package com.example;

public class Test {
Object f1 = null;

0 comments on commit 26b4df8

Please sign in to comment.