Skip to content

Commit

Permalink
Merge branch 'master' into java8inference
Browse files Browse the repository at this point in the history
  • Loading branch information
smillst authored Dec 12, 2023
2 parents d51402f + 8b53131 commit c6be973
Show file tree
Hide file tree
Showing 33 changed files with 128 additions and 102 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ ext {
autoValue : '1.10.4',
lombok : '1.18.30',
hashmapUtil : '0.0.1',
reflectionUtil : '1.1.0',
reflectionUtil : '1.1.2',
plumeUtil : '1.9.0',
errorprone : '2.23.0',
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report.qual;
package org.checkerframework.common.util.count.report.qual;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report.qual;
package org.checkerframework.common.util.count.report.qual;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report.qual;
package org.checkerframework.common.util.count.report.qual;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report.qual;
package org.checkerframework.common.util.count.report.qual;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report.qual;
package org.checkerframework.common.util.count.report.qual;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report.qual;
package org.checkerframework.common.util.count.report.qual;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand All @@ -11,7 +11,7 @@

/**
* An annotation intended solely for representing an unqualified type in the qualifier hierarchy for
* the Report Checker.
* the Report Checker. This is the only type qualifier in the type hierarchy.
*/
@Documented
@Retention(RetentionPolicy.SOURCE) // do not store in class file
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report.qual;
package org.checkerframework.common.util.count.report.qual;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report.qual;
package org.checkerframework.common.util.count.report.qual;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand Down
42 changes: 34 additions & 8 deletions checker/bin-devel/count-suppression-reasons
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
# To invoke it, pass a type system name; for example:
# count-suppression-reasons nullness
# The argument to this script is actually a regular expression.
# Command-line arguments (which must appear before the type system name):
# -d debug
# -i REGEX include matches for the grep basic regex
# -x REGEX exclude matches for the grep basic regex
# The -i argument (if any) is processed before the -x argument (if any).

# The "reason" for a warning suppression is the Java line comment after it:
# @SuppressWarnings("nullness") // here is the reason
Expand All @@ -19,15 +24,29 @@
# "interning:type.incompatible" // reason for interning suppression
# })

# Some reasons are ignored, notably "true positive" and
# "count-suppression-reasons-ignore"; see below for the full list.

# This script is useful to determine the most frequent reasons for warning
# suppressions, to help checker developers decide what featuers to add to
# their type systems. However, use common.util.count.AnnotationStatistics
# to count the total number of warning suppressions (for example, to report
# in a paper), because this script gives only an approximate count.

# To debug, pass --debug as the first command-line argument.
# To debug, pass the -d command-line argument.
debug=0

while getopts dx:i: flag
do
case "${flag}" in
d) debug=1;;
x) exclude=${OPTARG};;
i) include=${OPTARG};;
\?) echo "Invalid option -$OPTARG"; exit 1;;
esac
done
shift $((OPTIND-1))

if [[ "$OSTYPE" == "darwin"* ]]; then
SED="gsed"
GREP="ggrep"
Expand All @@ -36,11 +55,6 @@ else
GREP="grep"
fi

if [ "$1" == "--debug" ] ; then
debug=1
shift
fi

if [ "$#" -ne 1 ]; then
echo "Usage: $0 TYPESYSTEM" >&2
exit 1
Expand All @@ -60,7 +74,9 @@ if [ "$regex" = "resourceleak" ]; then
fi

# Diagnostics
# echo "regex=${regex}"
if [ "$debug" -ne "0" ]; then
echo "checker regex=${regex}"
fi

greplines=$(mktemp /tmp/count-suppression-reasons."$(date +%Y%m%d-%H%M%S)"-XXX)
countedreasons=$(mktemp /tmp/count-suppression-reasons."$(date +%Y%m%d-%H%M%S)"-XXX)
Expand All @@ -71,11 +87,21 @@ countedreasons=$(mktemp /tmp/count-suppression-reasons."$(date +%Y%m%d-%H%M%S)"-
# include "@SuppressWarnings" because it might appear on the previous line.
# * @AssumeAssertion(checkername)
# This grep command captures a few stray lines; users should ignore them.
# This grep command assumes that tests are not annotated, and it hard-codes ignoring "annotated-jdk", "jdk", "true positive", "// TP" (as an alias for "true positive"), and "count-suppression-reasons-ignore".
# This grep command assumes that tests are not annotated, and it hard-codes ignoring "annotated-jdk", "jdk", "true positive", "TP" (as an alias for "true positive"), and "count-suppression-reasons-ignore".
${GREP} -n --recursive --include='*.java' "\"${regex}[:\"]\(.*[^;]\)\?\(\$\|//\)\|@AssumeAssertion(${regex})" \
| grep -v "@AnnotatedFor" | grep -v "/tests/" \
| grep -v "/annotated-jdk/" | grep -v "/jdk/" | grep -v "^jdk/" | grep -v "true positive" | grep -v "// TP" | grep -v "count-suppression-reasons-ignore" > "${greplines}"

if [ -n "$include" ] ; then
mv "${greplines}" "${greplines}-i"
grep -- "$include" "${greplines}-i" > "${greplines}"
fi
if [ -n "$exclude" ] ; then
mv "${greplines}" "${greplines}-x"
grep -v -- "$exclude" "${greplines}-x" > "${greplines}"
fi


total=$(wc -l < "${greplines}")
## Don't output a total, to avoid people using this approximate count.
# echo "Total: $total"
Expand Down
12 changes: 6 additions & 6 deletions checker/tests/wpi-many/testin.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
https://github.com/kelloggm/wpi-many-tests-bcel-util bed1372c5c6de5c90f3a17d5ce228b882faa0da2
https://github.com/kelloggm/wpi-many-tests-bibtex-clean 14770af9a6c973fd8a7920e22e40a501ba6fd2dc
https://github.com/kelloggm/wpi-many-tests-ensures-called-methods 20361e992d8c24aa48de62f1130f977d6b3c0ef1
https://github.com/kelloggm/wpi-many-tests-html-pretty-print 96eb875ca7c9a67d6e3d61d634011c7354064dab
https://github.com/kelloggm/-wpi-many-tests-bibtex-clean c7715b8a60dd296926cc64d0bba9761caca88ab0
https://github.com/kelloggm/wpi-many-tests-bcel-util b8f661c24014328e4cef6f55b2772cc5e62233df
https://github.com/kelloggm/wpi-many-tests-bibtex-clean 2d82118d66f118d89f2f69c847badd5179e34c0a
https://github.com/kelloggm/wpi-many-tests-ensures-called-methods 326bc8abfcf635c97b13f1e8d6df9f4b1c7d4bfe
https://github.com/kelloggm/wpi-many-tests-html-pretty-print f4a7268f8f6e7014db59d208e6c0e8fae72ec0fd
https://github.com/kelloggm/-wpi-many-tests-bibtex-clean 28fb7e20f011fc754112ead28d6a81eb0093b392
# This comment line tests that the commenting feature works (if it doesn't, then this line will be read and fail, as it's not a URL).
https://github.com/Nargeshdb/wpi-many-tests-owning-field 1b73c81021f598717226243f99417c0cad54be82
https://github.com/Nargeshdb/wpi-many-tests-owning-field f98270f6de95061df5faa9eba7f6c2fc27bc0de6
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Method, constructor, lambda, and method reference type inference has been
greatly improved. The `-AconservativeUninferredTypeArguments` option is
no longer necessary and has been removed.

In `org.checkerframework.common.util.debug`, renamed `EmptyProcessor` to `DoNothingProcessor`.
Removed `org.checkerframework.common.util.report.DoNothingChecker`.
Moved `ReportChecker` from `org.checkerframework.common.util.report` to `org.checkerframework.common.util.count.report`.

**Implementation details:**

**Closed issues:**
Expand Down
3 changes: 2 additions & 1 deletion docs/developer/developer-manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ <h2 id="Counting_annotations">Counting annotations</h2>
<ul>
<li><a href="https://checkerframework.org/api/org/checkerframework/common/util/count/AnnotationStatistics.html">AnnotationStatistics</a></li>
<li><a href="https://checkerframework.org/api/org/checkerframework/common/util/count/JavaCodeStatistics.html">JavaCodeStatistics</a></li>
<li><a href="https://github.com/typetools/checker-framework/blob/master/checker/bin-devel/count-suppression-reasons">count-suppression-reasons"></a></li>
<li><a href="https://checkerframework.org/api/org/checkerframework/common/util/count/report/ReportChecker.html">ReportChecker</a></li>
<li><a href="https://github.com/typetools/checker-framework/blob/master/checker/bin-devel/count-suppression-reasons">count-suppression-reasons</a></li>
</ul>


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import org.checkerframework.common.util.report.qual.*;
import org.checkerframework.common.util.count.report.qual.*;

package java.util.concurrent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* @summary Adapted test case for Issue 2147
* https://github.com/typetools/checker-framework/issues/2147 using framework package quals
*
* @compile/fail/ref=WithoutStub.out -XDrawDiagnostics -processor org.checkerframework.common.util.report.ReportChecker -AstubWarnIfNotFound AnnotationFileParserEnumTest.java
* @compile/fail/ref=WithStub.out -XDrawDiagnostics -processor org.checkerframework.common.util.report.ReportChecker -AstubWarnIfNotFound -Astubs=AnnotationFileParserEnum.astub AnnotationFileParserEnumTest.java
* @compile/fail/ref=WithoutStub.out -XDrawDiagnostics -processor org.checkerframework.common.util.count.report.ReportChecker -AstubWarnIfNotFound AnnotationFileParserEnumTest.java
* @compile/fail/ref=WithStub.out -XDrawDiagnostics -processor org.checkerframework.common.util.count.report.ReportChecker -AstubWarnIfNotFound -Astubs=AnnotationFileParserEnum.astub AnnotationFileParserEnumTest.java
*/

import static java.util.concurrent.TimeUnit.*;

import java.util.concurrent.TimeUnit;
import org.checkerframework.common.util.report.qual.*;
import org.checkerframework.common.util.count.report.qual.*;

public class AnnotationFileParserEnumTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
* </ul>
*
* @see JavaCodeStatistics
* @see org.checkerframework.common.util.count.report.ReportChecker
*/
/*
* TODO: add an option to only list declaration or type annotations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.checkerframework.javacutil.TreeUtils;

/**
* An annotation processor for counting the size of Java code:
* An annotation processor for counting a few specific aspects about the size of Java code:
*
* <ul>
* <li>The number of type parameter declarations and uses.
Expand All @@ -39,6 +39,7 @@
* </pre>
*
* @see AnnotationStatistics
* @see org.checkerframework.common.util.count.report.ReportChecker
*/
@SupportedSourceVersion(SourceVersion.RELEASE_8)
public class JavaCodeStatistics extends SourceChecker {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.checkerframework.common.util.count.report;

import javax.annotation.processing.SupportedOptions;
import org.checkerframework.common.basetype.BaseTypeChecker;

/**
* The Report Checker performs semantic searches over a program, for example, to find all methods
* that override a specific method, all classes that inherit from a specific class, or all uses of
* do-while-loops (and not also while loops!).
*
* <p>The search is specified in two different ways.
*
* <p>The first way is to write a stub specification file using the annotations in {@code
* org.checkerframework.common.util.count.report.qual.*}. You can see examples in the Checker
* Framework repository at {@code framework/tests/report/reporttest.astub} and {@code
* framework/jtreg/StubParserEnum/AnnotationFileParserEnum.astub}.
*
* <p>The second way is the {@code -AreportTreeKinds} and {@code -AreportModifiers} options, which
* search for specific tree kinds or modifiers.
*
* <p>Some similar features are available from IDEs (e.g., show references), but this tool provides
* much more flexibility and a command-line tool.
*
* <p>Options:
*
* <ul>
* <li><code>-AreportTreeKinds</code>: comma-separated list of <code>Tree.Kind</code>s that should
* be reported
* <li><code>-AreportModifiers</code>: comma-separated list of modifiers that should be reported
* </ul>
*
* @see org.checkerframework.common.util.count.AnnotationStatistics
* @see org.checkerframework.common.util.count.JavaCodeStatistics
*/
@SupportedOptions({"reportTreeKinds", "reportModifiers"})
public class ReportChecker extends BaseTypeChecker {

/** Creates a ReportChecker. */
public ReportChecker() {}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.checkerframework.common.util.report;
package org.checkerframework.common.util.count.report;

import com.sun.source.tree.ArrayAccessTree;
import com.sun.source.tree.AssignmentTree;
Expand Down Expand Up @@ -29,13 +29,13 @@
import org.checkerframework.common.basetype.BaseTypeChecker;
import org.checkerframework.common.basetype.BaseTypeValidator;
import org.checkerframework.common.basetype.BaseTypeVisitor;
import org.checkerframework.common.util.report.qual.ReportCall;
import org.checkerframework.common.util.report.qual.ReportCreation;
import org.checkerframework.common.util.report.qual.ReportInherit;
import org.checkerframework.common.util.report.qual.ReportOverride;
import org.checkerframework.common.util.report.qual.ReportReadWrite;
import org.checkerframework.common.util.report.qual.ReportUse;
import org.checkerframework.common.util.report.qual.ReportWrite;
import org.checkerframework.common.util.count.report.qual.ReportCall;
import org.checkerframework.common.util.count.report.qual.ReportCreation;
import org.checkerframework.common.util.count.report.qual.ReportInherit;
import org.checkerframework.common.util.count.report.qual.ReportOverride;
import org.checkerframework.common.util.count.report.qual.ReportReadWrite;
import org.checkerframework.common.util.count.report.qual.ReportUse;
import org.checkerframework.common.util.count.report.qual.ReportWrite;
import org.checkerframework.framework.type.AnnotatedTypeFactory;
import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType;
import org.checkerframework.framework.util.AnnotatedTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@
import javax.lang.model.element.TypeElement;

/**
* Empty simple processor.
* This is an annotation processor that does nothing.
*
* <p>It is useful in debugging compiler behavior with an annotation processor present.
* <p>Use it when you are required to provide an annotation processor, or when you want to debug
* compiler behavior with an annotation processor present.
*/
@SupportedAnnotationTypes("*")
public class EmptyProcessor extends AbstractProcessor {
public class DoNothingProcessor extends AbstractProcessor {

/** Creates a DoNothingProcessor. */
public DoNothingProcessor() {}

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
System.out.println("Empty Processor run!");
return false;
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ReportModifiersTest extends CheckerFrameworkPerDirectoryTest {
public ReportModifiersTest(List<File> testFiles) {
super(
testFiles,
org.checkerframework.common.util.report.ReportChecker.class,
org.checkerframework.common.util.count.report.ReportChecker.class,
"report",
"-AreportModifiers=native");
}
Expand Down
Loading

0 comments on commit c6be973

Please sign in to comment.