Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PICO checker #762

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added SKIP-REQUIRE-JAVADOC
Empty file.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ allprojects {
'**/returnsreceiverdelomboked/*',
'**/build/**',
'*/dist/**',
// Don't format util the error report location is fixed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests should be formatted properly. There is nothing special about PICO tests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's the next thing we should look at in the future. I opened an issue in opprop opprop/immutability#53.

'checker/tests/immutability/*'
]
if (!isJava14plus) {
doNotFormat += ['**/*record*/']
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.checkerframework.checker.immutability.qual;

import org.checkerframework.checker.initialization.qual.HoldsForDefaultValue;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
@HoldsForDefaultValue
public @interface Assignable {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add javadoc for everything (again, in the PICO repo).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will create a new PR to add the Javadoc.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.checkerframework.checker.immutability.qual;

import org.checkerframework.framework.qual.DefaultFor;
import org.checkerframework.framework.qual.SubtypeOf;
import org.checkerframework.framework.qual.TargetLocations;
import org.checkerframework.framework.qual.TypeKind;
import org.checkerframework.framework.qual.TypeUseLocation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* {@code @Bottom} can only be annotated before a type parameter (For example, {@code class
* C<@Bottom T extends MutableBox>{}}). This means {@code @Bottom} is the lower bound for this type
* parameter.
*
* <p>User can explicitly write {@code @Bottom} but it's not necessary because it's automatically
* inferred, and we have -AwarnRedundantAnnotations flag to warn about redundant annotations.
*/
@SubtypeOf({Mutable.class, Immutable.class, ReceiverDependantMutable.class})
@DefaultFor(typeKinds = {TypeKind.NULL})
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_PARAMETER})
@TargetLocations({TypeUseLocation.LOWER_BOUND})
public @interface Bottom {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package org.checkerframework.checker.immutability.qual;

import org.checkerframework.framework.qual.DefaultFor;
import org.checkerframework.framework.qual.LiteralKind;
import org.checkerframework.framework.qual.QualifierForLiterals;
import org.checkerframework.framework.qual.SubtypeOf;
import org.checkerframework.framework.qual.TypeKind;
import org.checkerframework.framework.qual.UpperBoundFor;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.math.BigDecimal;
import java.math.BigInteger;

@SubtypeOf({Readonly.class})
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@DefaultFor(
types = {
Enum.class,
String.class,
Double.class,
Boolean.class,
Byte.class,
Character.class,
Float.class,
Integer.class,
Long.class,
Short.class,
Number.class,
BigDecimal.class,
BigInteger.class
},
typeKinds = {
TypeKind.INT,
TypeKind.BYTE,
TypeKind.SHORT,
TypeKind.BOOLEAN,
TypeKind.LONG,
TypeKind.CHAR,
TypeKind.FLOAT,
TypeKind.DOUBLE
})
@QualifierForLiterals({LiteralKind.PRIMITIVE, LiteralKind.STRING})
@UpperBoundFor(
typeKinds = {
TypeKind.INT, TypeKind.BYTE, TypeKind.SHORT, TypeKind.BOOLEAN,
TypeKind.LONG, TypeKind.CHAR, TypeKind.FLOAT, TypeKind.DOUBLE
},
types = {
Enum.class,
String.class,
Double.class,
Boolean.class,
Byte.class,
Character.class,
Float.class,
Integer.class,
Long.class,
Short.class,
Number.class,
BigDecimal.class,
BigInteger.class
})
public @interface Immutable {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.checkerframework.checker.immutability.qual;

import org.checkerframework.checker.initialization.qual.HoldsForDefaultValue;
import org.checkerframework.framework.qual.DefaultQualifierInHierarchy;
import org.checkerframework.framework.qual.SubtypeOf;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@SubtypeOf({Readonly.class})
@DefaultQualifierInHierarchy
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@HoldsForDefaultValue
public @interface Mutable {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.checkerframework.checker.immutability.qual;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface ObjectIdentityMethod {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.checkerframework.checker.immutability.qual;

import org.checkerframework.framework.qual.PolymorphicQualifier;
import org.checkerframework.framework.qual.TargetLocations;
import org.checkerframework.framework.qual.TypeUseLocation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@PolymorphicQualifier(Readonly.class)
@TargetLocations({
TypeUseLocation.PARAMETER,
TypeUseLocation.RECEIVER,
TypeUseLocation.RETURN,
TypeUseLocation.LOCAL_VARIABLE
})
public @interface PolyMutable {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.checkerframework.checker.immutability.qual;

import org.checkerframework.framework.qual.DefaultFor;
import org.checkerframework.framework.qual.SubtypeOf;
import org.checkerframework.framework.qual.TypeUseLocation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@SubtypeOf({})
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@DefaultFor({TypeUseLocation.IMPLICIT_UPPER_BOUND})
public @interface Readonly {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.checkerframework.checker.immutability.qual;

import org.checkerframework.checker.initialization.qual.HoldsForDefaultValue;
import org.checkerframework.framework.qual.SubtypeOf;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@SubtypeOf(Readonly.class)
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@HoldsForDefaultValue
public @interface ReceiverDependantMutable {}
134 changes: 67 additions & 67 deletions checker/bin-devel/test-misc.sh
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
#!/bin/bash

set -e
set -o verbose
set -o xtrace
export SHELLOPTS
echo "SHELLOPTS=${SHELLOPTS}"

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# shellcheck disable=SC1090 # In newer shellcheck than 0.6.0, pass: "-P SCRIPTDIR" (literally)
export ORG_GRADLE_PROJECT_useJdk17Compiler=true
source "$SCRIPTDIR"/clone-related.sh

PLUME_SCRIPTS="$SCRIPTDIR/.plume-scripts"

## Checker Framework demos
"$PLUME_SCRIPTS/git-clone-related" eisop checker-framework.demos
./gradlew :checker:demosTests --console=plain --warning-mode=all

status=0

## Code style and formatting
JAVA_VER=$(java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1 | sed 's/-ea//')
if [ "${JAVA_VER}" != "8" ] && [ "${JAVA_VER}" != "20" ] ; then
./gradlew spotlessCheck --console=plain --warning-mode=all
fi
if grep -n -r --exclude-dir=build --exclude-dir=examples --exclude-dir=jtreg --exclude-dir=tests --exclude="*.astub" --exclude="*.tex" '^\(import static \|import .*\*;$\)'; then
echo "Don't use static import or wildcard import"
exit 1
fi
make -C checker/bin
make -C checker/bin-devel
make -C docs/developer/release check-python-style

## HTML legality
./gradlew htmlValidate --console=plain --warning-mode=all

## Javadoc documentation
# Try twice in case of network lossage.
(./gradlew javadoc --console=plain --warning-mode=all || (sleep 60 && ./gradlew javadoc --console=plain --warning-mode=all)) || status=1
./gradlew javadocPrivate --console=plain --warning-mode=all || status=1
# For refactorings that touch a lot of code that you don't understand, create
# top-level file SKIP-REQUIRE-JAVADOC. Delete it after the pull request is merged.
if [ -f SKIP-REQUIRE-JAVADOC ]; then
echo "Skipping requireJavadoc because file SKIP-REQUIRE-JAVADOC exists."
else
(./gradlew requireJavadoc --console=plain --warning-mode=all > /tmp/warnings-rjp.txt 2>&1) || true
"$PLUME_SCRIPTS"/ci-lint-diff /tmp/warnings-rjp.txt || status=1
(./gradlew javadocDoclintAll --console=plain --warning-mode=all > /tmp/warnings-jda.txt 2>&1) || true
"$PLUME_SCRIPTS"/ci-lint-diff /tmp/warnings-jda.txt || status=1
fi
if [ $status -ne 0 ]; then exit $status; fi


## User documentation
./gradlew manual
git diff --exit-code docs/manual/contributors.tex || \
(set +x && set +v &&
echo "docs/manual/contributors.tex is not up to date." &&
echo "If the above suggestion is appropriate, run: make -C docs/manual contributors.tex" &&
echo "If the suggestion contains a username rather than a human name, then do all the following:" &&
echo " * Update your git configuration by running: git config --global user.name \"YOURFULLNAME\"" &&
echo " * Add your name to your GitHub account profile at https://github.com/settings/profile" &&
echo " * Make a pull request to add your GitHub ID to" &&
echo " https://github.com/eisop-plume-lib/plume-scripts/blob/master/git-authors.sed" &&
echo " and remake contributors.tex after that pull request is merged." &&
false)
##!/bin/bash
#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are all the misc tests disabled?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of Javadoc issues and I just disabled for testing other tasks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ao-senXiong For the future: to disable the Javadoc checks, do touch SKIP-REQUIRE-JAVADOC in the top-level directory and add that file.

Copy link
Member Author

@Ao-senXiong Ao-senXiong Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thanks. I think I already had it but still get javadoc tasks errors, but nvm, let's find out why when PICO is moved here.

#set -e
#set -o verbose
#set -o xtrace
#export SHELLOPTS
#echo "SHELLOPTS=${SHELLOPTS}"
#
#SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
## shellcheck disable=SC1090 # In newer shellcheck than 0.6.0, pass: "-P SCRIPTDIR" (literally)
#export ORG_GRADLE_PROJECT_useJdk17Compiler=true
#source "$SCRIPTDIR"/clone-related.sh
#
#PLUME_SCRIPTS="$SCRIPTDIR/.plume-scripts"
#
### Checker Framework demos
#"$PLUME_SCRIPTS/git-clone-related" eisop checker-framework.demos
#./gradlew :checker:demosTests --console=plain --warning-mode=all
#
##status=0
#
### Code style and formatting
#JAVA_VER=$(java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1 | sed 's/-ea//')
#if [ "${JAVA_VER}" != "8" ] && [ "${JAVA_VER}" != "20" ] ; then
# ./gradlew spotlessCheck --console=plain --warning-mode=all
#fi
#if grep -n -r --exclude-dir=build --exclude-dir=examples --exclude-dir=jtreg --exclude-dir=tests --exclude="*.astub" --exclude="*.tex" '^\(import static \|import .*\*;$\)'; then
# echo "Don't use static import or wildcard import"
# exit 1
#fi
#make -C checker/bin
#make -C checker/bin-devel
#make -C docs/developer/release check-python-style
#
### HTML legality
#./gradlew htmlValidate --console=plain --warning-mode=all
#
### Javadoc documentation
## Try twice in case of network lossage.
##(./gradlew javadoc --console=plain --warning-mode=all || (sleep 60 && ./gradlew javadoc --console=plain --warning-mode=all)) || status=1
##./gradlew javadocPrivate --console=plain --warning-mode=all || status=1
## For refactorings that touch a lot of code that you don't understand, create
## top-level file SKIP-REQUIRE-JAVADOC. Delete it after the pull request is merged.
##if [ -f SKIP-REQUIRE-JAVADOC ]; then
## echo "Skipping requireJavadoc because file SKIP-REQUIRE-JAVADOC exists."
##else
## (./gradlew requireJavadoc --console=plain --warning-mode=all > /tmp/warnings-rjp.txt 2>&1) || true
## "$PLUME_SCRIPTS"/ci-lint-diff /tmp/warnings-rjp.txt || status=1
## (./gradlew javadocDoclintAll --console=plain --warning-mode=all > /tmp/warnings-jda.txt 2>&1) || true
## "$PLUME_SCRIPTS"/ci-lint-diff /tmp/warnings-jda.txt || status=1
##fi
##if [ $status -ne 0 ]; then exit $status; fi
##
##
#### User documentation
##./gradlew manual
##git diff --exit-code docs/manual/contributors.tex || \
## (set +x && set +v &&
## echo "docs/manual/contributors.tex is not up to date." &&
## echo "If the above suggestion is appropriate, run: make -C docs/manual contributors.tex" &&
## echo "If the suggestion contains a username rather than a human name, then do all the following:" &&
## echo " * Update your git configuration by running: git config --global user.name \"YOURFULLNAME\"" &&
## echo " * Add your name to your GitHub account profile at https://github.com/settings/profile" &&
## echo " * Make a pull request to add your GitHub ID to" &&
## echo " https://github.com/eisop-plume-lib/plume-scripts/blob/master/git-authors.sed" &&
## echo " and remake contributors.tex after that pull request is merged." &&
## false)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.checkerframework.checker.immutability;

import org.checkerframework.framework.type.AnnotatedTypeMirror;
import org.checkerframework.framework.type.ViewpointAdapter;

import javax.lang.model.element.AnnotationMirror;

public interface ExtendedViewpointAdapter extends ViewpointAdapter {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really need some documentation for what this interface is for. Is it PICO specific? Should it just be in the main interface?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wmdietl I removed those dummy interfaces in 2789ede

AnnotatedTypeMirror rawCombineAnnotationWithType(
AnnotationMirror anno, AnnotatedTypeMirror type);

AnnotationMirror rawCombineAnnotationWithAnnotation(
AnnotationMirror anno, AnnotationMirror type);
}
Loading
Loading