Skip to content

Commit

Permalink
Merge branch 'master' into ee3efcc
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst authored Jun 22, 2023
2 parents bce3e44 + 6926cb1 commit 462a13c
Show file tree
Hide file tree
Showing 234 changed files with 2,317 additions and 1,527 deletions.
1 change: 1 addition & 0 deletions SKIP-REQUIRE-JAVADOC
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove this file after the pull request is merged.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ subprojects {
// * Temporarily comment out "-Werror" elsewhere in this file
// * Repeatedly run `./gradlew clean compileJava` and fix all errors
// * Uncomment "-Werror"
ext.errorproneVersion = '2.19.1'
ext.errorproneVersion = '2.20.0'
errorprone group: 'com.google.errorprone', name: 'error_prone_core', version: errorproneVersion

// TODO: it's a bug that annotatedlib:guava requires the error_prone_annotations dependency.
Expand Down Expand Up @@ -907,6 +907,8 @@ subprojects {
tasks.create(name: "${junitClassName}", type: Test) {
description "Run ${junitClassName} tests."
include "**/${name}.class"
testClassesDirs = testing.suites.test.sources.output.classesDirs
classpath = testing.suites.test.sources.runtimeClasspath
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public static <T> void ifPresent(T primary, Consumer<@NonNull ? super @NonNull T
}

/**
* Return primary if it is non-null. If primary is null, invoke {@code other} and return the
* result of that invocation.
* Return {@code primary} if it is non-null. If {@code primary} is null, invoke {@code other} and
* return the result of that invocation.
*
* @see java.util.Optional#orElseGet(Supplier)
*/
Expand Down
156 changes: 156 additions & 0 deletions checker/bin-devel/checkout-historical.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#!/bin/sh

# When run in a Checker Framework checkout/clone, this clones the related
# repositories, then builds them and the Checker Framework. It sets the related
# repositories to their last commit before the Checker Framework's clone. This
# approximates the state of the repositories at that time.

# This is only an approximation because if the Checker Framework was on a
# branch, then the related repository might have also been on a branch that was
# subsequently merged (or squash-and-merged, so the commit no longer exists in
# the related repository).

# This script works at least through mid-April 2019.
# It does not work for mid-January 2019.

# # To verify that you can build an old version of the Checker Framework, do
# # preparation, then set two environment variables, and then run these
# # commands. See below for preparation and examples of setting the environment
# # variables.
# git clone https://github.com/typetools/checker-framework.git ${CHECKERFRAMEWORK}
# cd ${CHECKERFRAMEWORK}
# git checkout ${CFCOMMIT}
# /tmp/test-historical/checker-framework/checker/bin-devel/checkout-historical.sh
#
# # Preparation (only needs to be done once every)
# mkdir -p /tmp/test-historical
# git clone https://github.com/typetools/checker-framework.git
#
# # January 2023
# export CHECKERFRAMEWORK=/tmp/test-historical/checker-framework-202301
# export CFCOMMIT=9d60936fcd81827f3761d0244014a6e419133b16
#
# # July 2022
# export CHECKERFRAMEWORK=/tmp/test-historical/checker-framework-202207
# export CFCOMMIT=c37aff5ef28569e5bdadf681c81210d084de24df
#
# # January 2022
# export CHECKERFRAMEWORK=/tmp/test-historical/checker-framework-202201
# export CFCOMMIT=24364449c1bac6cee1896759e1ab5fc87ad5a70d
#
# # January 2021
# export CHECKERFRAMEWORK=/tmp/test-historical/checker-framework-202101
# export CFCOMMIT=f3cc3d328a70ef8e834bf2693be6cbb6a94ece63
#
# # January 2020
# export CHECKERFRAMEWORK=/tmp/test-historical/checker-framework-202001
# export CFCOMMIT=b7d026e424df2a04f8b9275bc2792cb03991425d
#
# # October 2019
# export CHECKERFRAMEWORK=/tmp/test-historical/checker-framework-201910
# export CFCOMMIT=b6e7558f3f0b0cf996f00039ca98a8d1fa798896
#
# # July 2019; use JDK 8
# export CHECKERFRAMEWORK=/tmp/test-historical/checker-framework-201907
# export CFCOMMIT=5000c1ecb72581aeebd3c10a2851cf003eeb554c
#
# # April 2019; use JDK 8
# export CHECKERFRAMEWORK=/tmp/test-historical/checker-framework-201904
# export CFCOMMIT=cc3b007addee9e241e4ef560d009fd212c478819
#
# # January 2019; use JDK 8
# # This fails because it references deleted repository https://bitbucket.org/typetools/jsr308-langtools
# export CHECKERFRAMEWORK=/tmp/test-historical/checker-framework-201901
# export CFCOMMIT=b76bd9dcd5839285a4dd9fd6c2d769647357f288
#
# # January 2018; use JDK 8
# # This fails, because plume-scripts does not exist.
# export CHECKERFRAMEWORK=/tmp/test-historical/checker-framework-201801
# export CFCOMMIT=1f48ddb600620454731170eb2628e5f7efa93c3e


# Fail the whole script if any command fails
set -e

# DEBUG=0
# # To enable debugging, uncomment the following line.
# # DEBUG=1

echo "Entering checker/bin-devel/checkout-historical.sh in $(pwd)"

commit_sha=$(git rev-parse HEAD)
commit_date=$(git show -s --format=%ci)

echo "Commit ${commit_sha}, date ${commit_date}"

git checkout -B __merge_eval__

# Initial commit is June 2018
echo "plume-scripts"
PLUME_SCRIPTS="checker/bin-devel/.plume-scripts"
if [ ! -d "$PLUME_SCRIPTS" ] ; then
git clone -q https://github.com/plume-lib/plume-scripts.git "${PLUME_SCRIPTS}"
fi
COMMIT="$(cd "${PLUME_SCRIPTS}" && git rev-list -n 1 --first-parent --before="${commit_date}" master)"
if [ -n "${COMMIT}" ] ; then
# COMMIT is non-empty
(cd "${PLUME_SCRIPTS}" && git checkout -B __merge_eval__ "${COMMIT}")
fi

# Initial commit is February 2018
echo "html-tools"
HTML_TOOLS="checker/bin-devel/.plume-scripts"
COMMIT="$(cd "${HTML_TOOLS}" && git rev-list -n 1 --first-parent --before="${commit_date}" master)"
if [ ! -d "$HTML_TOOLS" ] ; then
git clone -q https://github.com/plume-lib/html-tools.git "${HTML_TOOLS}"
fi
if [ -n "${COMMIT}" ] ; then
# COMMIT is non-empty
(cd "${HTML_TOOLS}" && git checkout -B __merge_eval__ "${COMMIT}")
fi

echo "Stubparser"
STUBPARSER="../stubparser"
if [ ! -d "${STUBPARSER}" ] ; then
git clone https://github.com/typetools/stubparser.git "${STUBPARSER}"
fi
(cd "${STUBPARSER}" && git checkout -B __merge_eval__ "$(git rev-list -n 1 --first-parent --before="${commit_date}" master)")
if [ -f ${STUBPARSER}/.build-without-test.sh ] ; then
STUBPARSER_BUILD=.build-without-test.sh
elif [ -f ${STUBPARSER}/.travis-build-without-test.sh ] ; then
STUBPARSER_BUILD=.travis-build-without-test.sh
else
echo "Can't find stubparser build script"
exit 1
fi
echo "Running: (cd ../stubparser/ && ./${STUBPARSER_BUILD})"
(cd ../stubparser/ && ./"${STUBPARSER_BUILD}")
echo "... done: (cd ../stubparser/ && ./${STUBPARSER_BUILD})"

echo "Annotation File Utilities"
AT="../annotation-tools"
if [ ! -d "${AT}" ] ; then
git clone https://github.com/typetools/annotation-tools.git "${AT}"
fi
(cd "${AT}" && git checkout -B __merge_eval__ "$(git rev-list -n 1 --first-parent --before="${commit_date}" master)")
if [ -f ${AT}/.build-without-test.sh ] ; then
AT_BUILD=.build-without-test.sh
elif [ -f ${AT}/.travis-build-without-test.sh ] ; then
AT_BUILD=.travis-build-without-test.sh
else
echo "Can't find stubparser build script"
exit 1
fi
echo "Running: (cd ${AT} && ./${AT_BUILD})"
(cd "${AT}" && ./${AT_BUILD})
echo "... done: (cd ${AT} && ./${AT_BUILD})"

JDK_DIR="../jdk"
if [ ! -d "${JDK_DIR}" ] ; then
git clone https://github.com/typetools/jdk.git $JDK_DIR
fi
(cd "${JDK_DIR}" && git checkout -B __merge_eval__ "$(git rev-list -n 1 --first-parent --before="${commit_date}" master)")

./gradlew assemble

echo Exiting checker/bin-devel/checkout-historical.sh in "$(pwd)"
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public Void visitMethodInvocation(MethodInvocationTree tree, AnnotatedTypeMirror
if (returnsThis(tree)) {
String methodName = TreeUtils.getMethodName(tree.getMethodSelect());
methodName = adjustMethodNameUsingValueChecker(methodName, tree);
AnnotationMirror oldAnno = type.getAnnotationInHierarchy(top);
AnnotationMirror oldAnno = type.getPrimaryAnnotationInHierarchy(top);
AnnotationMirror newAnno =
qualHierarchy.greatestLowerBound(oldAnno, createAccumulatorAnnotation(methodName));
type.replaceAnnotation(newAnno);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.checkerframework.checker.calledmethods;

import java.util.LinkedHashSet;
import java.util.Set;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.common.accumulation.AccumulationChecker;
import org.checkerframework.common.basetype.BaseTypeChecker;
Expand Down Expand Up @@ -80,9 +80,8 @@ private boolean isReturnsReceiverDisabled() {
}

@Override
protected LinkedHashSet<Class<? extends BaseTypeChecker>> getImmediateSubcheckerClasses() {
LinkedHashSet<Class<? extends BaseTypeChecker>> checkers =
super.getImmediateSubcheckerClasses();
protected Set<Class<? extends BaseTypeChecker>> getImmediateSubcheckerClasses() {
Set<Class<? extends BaseTypeChecker>> checkers = super.getImmediateSubcheckerClasses();
if (!isReturnsReceiverDisabled()) {
checkers.add(ReturnsReceiverChecker.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ private void handleEnsuresCalledMethodsVarArgs(
private @Nullable AnnotationMirror getUpdatedCalledMethodsType(
AnnotatedTypeMirror currentType, List<String> methodNames) {
AnnotationMirror type;
if (currentType == null || !currentType.isAnnotatedInHierarchy(atypeFactory.top)) {
if (currentType == null || !currentType.hasPrimaryAnnotationInHierarchy(atypeFactory.top)) {
type = atypeFactory.top;
} else {
type = currentType.getAnnotationInHierarchy(atypeFactory.top);
type = currentType.getPrimaryAnnotationInHierarchy(atypeFactory.top);
}

// Don't attempt to strengthen @CalledMethodsPredicate annotations, because that would
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public Void visitMethodInvocation(MethodInvocationTree tree, Void p) {
protected void reportMethodInvocabilityError(
MethodInvocationTree tree, AnnotatedTypeMirror found, AnnotatedTypeMirror expected) {

AnnotationMirror expectedCM = expected.getAnnotation(CalledMethods.class);
AnnotationMirror expectedCM = expected.getPrimaryAnnotation(CalledMethods.class);
if (expectedCM != null) {
AnnotationMirror foundCM = found.getAnnotation(CalledMethods.class);
AnnotationMirror foundCM = found.getPrimaryAnnotation(CalledMethods.class);
Set<String> foundMethods =
foundCM == null
? Collections.emptySet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import javax.lang.model.type.TypeMirror;
import org.checkerframework.checker.calledmethods.CalledMethodsAnnotatedTypeFactory;
import org.checkerframework.checker.calledmethods.qual.CalledMethods;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.type.AnnotatedTypeMirror;
import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedExecutableType;
import org.checkerframework.framework.util.AnnotatedTypes;
Expand Down Expand Up @@ -105,14 +106,7 @@ public void handleBuilderBuildMethod(AnnotatedExecutableType builderBuildType) {
createCalledMethodsForAutoValueClass(builderElement, autoValueClassElement);
// Only add the new @CalledMethods annotation if there is not already a @CalledMethods
// annotation present.
AnnotationMirror explicitCalledMethodsAnno =
builderBuildType
.getReceiverType()
.getAnnotationInHierarchy(
atypeFactory.getQualifierHierarchy().getTopAnnotation(newCalledMethodsAnno));
if (explicitCalledMethodsAnno == null) {
builderBuildType.getReceiverType().addAnnotation(newCalledMethodsAnno);
}
builderBuildType.getReceiverType().addMissingAnnotation(newCalledMethodsAnno);
}

@Override
Expand Down Expand Up @@ -221,9 +215,9 @@ private AnnotationMirror createCalledMethodsForAutoValueProperties(
*
* @param prop the property (i.e., field) name
* @param builderSetterNames names of all methods in the builder class
* @return the name of the setter for prop
* @return the name of the setter for prop, or null if it cannot be found
*/
private static String autoValuePropToBuilderSetterName(
private static @Nullable String autoValuePropToBuilderSetterName(
String prop, Set<String> builderSetterNames) {
String[] possiblePropNames;
if (prop.startsWith("get") && prop.length() > 3 && Character.isUpperCase(prop.charAt(3))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void wpiPrepareMethodForWriting(
super.wpiPrepareMethodForWriting(methodAnnos, inSupertypes, inSubtypes);
if (hasFormatMethodAnno(methodAnnos)) {
AnnotatedTypeMirror atm = methodAnnos.getParameterType(0);
atm.removeAnnotationByClass(org.checkerframework.checker.formatter.qual.Format.class);
atm.removePrimaryAnnotationByClass(org.checkerframework.checker.formatter.qual.Format.class);
}
}

Expand Down Expand Up @@ -165,7 +165,7 @@ public FormatterTreeAnnotator(AnnotatedTypeFactory atypeFactory) {

@Override
public Void visitLiteral(LiteralTree tree, AnnotatedTypeMirror type) {
if (!type.isAnnotatedInHierarchy(UNKNOWNFORMAT)) {
if (!type.hasPrimaryAnnotationInHierarchy(UNKNOWNFORMAT)) {
String format = null;
if (tree.getKind() == Tree.Kind.STRING_LITERAL) {
format = (String) tree.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public boolean isAsFormatCall(MethodInvocationNode node, AnnotatedTypeFactory at
return anno != null;
}

private ConversionCategory[] asFormatCallCategoriesLowLevel(MethodInvocationNode node) {
private ConversionCategory @Nullable [] asFormatCallCategoriesLowLevel(
MethodInvocationNode node) {
Node vararg = node.getArgument(1);
if (!(vararg instanceof ArrayCreationNode)) {
return null;
Expand Down Expand Up @@ -256,10 +257,10 @@ private FormatCall(
* @return an error description if the format string is not annotated as {@code @Format}, or
* null if it is
*/
public final Result<String> errMissingFormatAnnotation() {
if (!formatStringType.hasAnnotation(Format.class)) {
public final @Nullable Result<String> errMissingFormatAnnotation() {
if (!formatStringType.hasPrimaryAnnotation(Format.class)) {
String msg = "(is a @Format annotation missing?)";
AnnotationMirror inv = formatStringType.getAnnotation(InvalidFormat.class);
AnnotationMirror inv = formatStringType.getPrimaryAnnotation(InvalidFormat.class);
if (inv != null) {
msg = invalidFormatAnnotationToErrorMessage(inv);
}
Expand Down Expand Up @@ -338,7 +339,7 @@ public InvocationType visitNull(NullType t, Class<Void> p) {
* @see ConversionCategory
*/
public final ConversionCategory[] getFormatCategories() {
AnnotationMirror anno = formatStringType.getAnnotation(Format.class);
AnnotationMirror anno = formatStringType.getPrimaryAnnotation(Format.class);
return formatAnnotationToCategories(anno);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ protected boolean commonAssignmentCheck(
boolean result =
super.commonAssignmentCheck(varType, valueType, valueTree, errorKey, extraArgs);

AnnotationMirror rhs = valueType.getAnnotationInHierarchy(atypeFactory.UNKNOWNFORMAT);
AnnotationMirror lhs = varType.getAnnotationInHierarchy(atypeFactory.UNKNOWNFORMAT);
AnnotationMirror rhs = valueType.getPrimaryAnnotationInHierarchy(atypeFactory.UNKNOWNFORMAT);
AnnotationMirror lhs = varType.getPrimaryAnnotationInHierarchy(atypeFactory.UNKNOWNFORMAT);

// From the manual: "It is legal to use a format string with fewer format specifiers
// than required, but a warning is issued."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ public static Effect min(Effect l, Effect r) {
}

public static final class EffectRange {
public final Effect min, max;
public final Effect min;
public final Effect max;

public EffectRange(Effect min, Effect max) {
public EffectRange(@Nullable Effect min, @Nullable Effect max) {
assert (min != null || max != null);
// If one is null, fill in with the other
this.min = (min != null ? min : max);
Expand Down
Loading

0 comments on commit 462a13c

Please sign in to comment.