How do I execute the checker framework on just one class?

292 Views Asked by At

Background

I am using the checker framework with gradle as so:

build.gradle:

plugins {
         id 'org.checkerframework' version '0.6.3'
}

checkerFramework {
    checkers = [
            'org.checkerframework.checker.nullness.NullnessChecker',
            'org.checkerframework.checker.tainting.TaintingChecker'
    ]
}
apply plugin: 'org.checkerframework'

Right now it is looking at all the classes in my build when I run ./gradlew build. I do not want the checker framework to look at every class but only a particular .java file.

Question

How do I limit the checker framework to running a static analysis on one .java file?

1

There are 1 best solutions below

0
mernst On

One way is to only run javac on one class. Your build system has a way to do this, or you can run javac on the command line.

Alternately, use the -AonlyDefs command-line option. It takes a regex argument and suppresses all warnings except those in classes whose names match the regex, even if the checker is run on more classes.

For example:

javac -processor ... '-AonlyDefs=^mypackage\.MyClass$'