diff --git a/build.gradle b/build.gradle index 4efdad8c0dab..7fd18299db50 100644 --- a/build.gradle +++ b/build.gradle @@ -1200,7 +1200,8 @@ subprojects { tasks.register("typecheck-part1") { description = "Run the Checker Framework on itself (part 1)" group = "Verification" - dependsOn("checkCompilerMessages", "checkFormatter", "checkInterning", "checkOptional", "checkPurity") + dependsOn("checkCompilerMessages", "checkFormatter", "checkInterning", "checkOptional") + // Can't run "checkPurity" because it issues too many warnings. } tasks.register("typecheck-part2") { description = "Run the Checker Framework on itself (part 2)" diff --git a/docs/manual/purity-checker.tex b/docs/manual/purity-checker.tex index 4b3d1b2f6528..6261c4e3db10 100644 --- a/docs/manual/purity-checker.tex +++ b/docs/manual/purity-checker.tex @@ -11,6 +11,8 @@ However, you may run just the Purity Checker by supplying the following command-line option to javac: \code{-processor org.checkerframework.framework.util.PurityChecker}. +That implies \<-AcheckPurityAnnotations>, so you do not need to supply +both options. The Checker Framework can infer purity annotations. If you supply the command-line option \<-AsuggestPureMethods>, then the @@ -61,9 +63,11 @@ by writing \refqualclass{dataflow/qual}{Deterministic} on the declaration of a method that is not deterministic. -To enable -checking of the annotations, supply the command-line option -\<-AcheckPurityAnnotations>. It is not enabled by default because of a high false +When you run the Purity Checker directly, it checks the annotations. +To enable checking of the annotations when running any other checker, +supply the command-line option \<-AcheckPurityAnnotations>. +For checkers other than the Purity Checker, it is not enabled by default +because of a high false positive rate. In the future, after a new purity-checking analysis is implemented, the Checker Framework will default to checking purity annotations. diff --git a/framework/src/main/java/org/checkerframework/framework/util/PurityChecker.java b/framework/src/main/java/org/checkerframework/framework/util/PurityChecker.java index 6d50face48b8..078b05af6f68 100644 --- a/framework/src/main/java/org/checkerframework/framework/util/PurityChecker.java +++ b/framework/src/main/java/org/checkerframework/framework/util/PurityChecker.java @@ -1,5 +1,6 @@ package org.checkerframework.framework.util; +import java.util.Map; import org.checkerframework.common.basetype.BaseTypeChecker; /** @@ -9,7 +10,25 @@ * flow-sensitive analysis */ public class PurityChecker extends BaseTypeChecker { - // There is no implementation here. + // Other than forcing -AcheckPurityAnnotations, there is no implementation here. // It uses functionality from BaseTypeChecker, which itself calls // dataflow's purity implementation. + + /** Creates a PurityChecker. */ + public PurityChecker() {} + + /** + * {@inheritDoc} + * + *
Checking purity annotations is the entire purpose of this checker, so this implementation
+ * behaves as if {@code -AcheckPurityAnnotations} was supplied on the command line.
+ */
+ @Override
+ public Map