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

Move PICO to EISOP #1013

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
32a297b
Starting move PICO to EISOP
Ao-senXiong Dec 9, 2024
9cc1911
Remove static import and holder class
Ao-senXiong Dec 18, 2024
514a607
Clear star import and static import again
Ao-senXiong Dec 18, 2024
2a48ae3
Lots of Javadoc and remove some unused method
Ao-senXiong Dec 19, 2024
4260bd3
Remove dangling Javadoc
Ao-senXiong Dec 19, 2024
2e4fffd
Add Javadoc
Ao-senXiong Dec 19, 2024
7341fad
A few more Javadoc
Ao-senXiong Dec 19, 2024
7a4d4a3
Add PICO's annotation for format
Ao-senXiong Dec 19, 2024
cac7afa
Fix a few errors and add the very first test cases
Ao-senXiong Dec 19, 2024
6d911e4
Format poly and forbid RDM on static class
Ao-senXiong Dec 19, 2024
61601da
Yet another test case
Ao-senXiong Dec 19, 2024
646b5cb
Add object creation test
Ao-senXiong Dec 19, 2024
911355b
Use `PolyMutable` for iterator
Ao-senXiong Dec 20, 2024
d7cdc75
Rename qualifier to `PICO...`
Ao-senXiong Dec 20, 2024
cb648fe
Remove hack
Ao-senXiong Dec 20, 2024
63bd81e
Fixes misc-21 error
Ao-senXiong Dec 21, 2024
b09a116
Also test validity of annotation on interface and abstract class
Ao-senXiong Dec 22, 2024
fa1fdd7
Remove wrong todo and add JML readonly aliasing
Ao-senXiong Dec 22, 2024
cf0cc18
Apply spotless
Ao-senXiong Dec 22, 2024
2e82b65
Add assignability annotation test and improve the error message
Ao-senXiong Dec 19, 2024
96c92a9
Add RDM class test and initialization test
Ao-senXiong Dec 27, 2024
ebae3a8
Merge branch 'master' into pico-move
Ao-senXiong Dec 27, 2024
108a938
Add implicit mutable test
Ao-senXiong Dec 27, 2024
8bb7327
Add Definite Assignment test
Ao-senXiong Dec 27, 2024
c02a0b2
Delete Definite Assignment test as it is already tested in `PICOIniti…
Ao-senXiong Dec 27, 2024
b7ab62d
Add test for type use and inheritance
Ao-senXiong Dec 27, 2024
5808e34
A few small improvement
Ao-senXiong Dec 27, 2024
ecd1534
Add lhs to test object creation default
Ao-senXiong Dec 28, 2024
78f6d40
Add builder pattern test case
Ao-senXiong Dec 30, 2024
8a86b18
Additional error message
Ao-senXiong Dec 30, 2024
8af7401
Add viewpoint adaptation test
Ao-senXiong Dec 30, 2024
bacaf49
Add operator test
Ao-senXiong Dec 30, 2024
8025eb9
Add immutableclass and immutable list test cases
Ao-senXiong Dec 30, 2024
e357d7c
Add cast, enum and refine the RDM test cases
Ao-senXiong Dec 30, 2024
ce82ffa
Move some more operator test here
Ao-senXiong Dec 30, 2024
bb1dffd
Add adapt constructor parameter test, it is adapted correctly but met…
Ao-senXiong Dec 30, 2024
c90c1c7
Merge branch 'master' into pico-move
Ao-senXiong Dec 30, 2024
636e9da
Move all test cases over first
Ao-senXiong Dec 30, 2024
5d40b33
Remove committed wrong file
Ao-senXiong Dec 30, 2024
59b4e50
Rerun the test as it should use JDK from same branch name
Ao-senXiong Dec 31, 2024
ef3c155
Test with CI Debug
Ao-senXiong Dec 31, 2024
592bbc1
Merge branch 'master' into pico-move
Ao-senXiong Dec 31, 2024
a9851d4
Fix errors for JDK 11
Ao-senXiong Dec 31, 2024
71685bb
Merge branch 'master' into pico-move
Ao-senXiong Jan 3, 2025
736e78c
Merge branch 'master' into pico-move
Ao-senXiong Jan 3, 2025
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ allprojects {

googleJavaFormat().aosp()
importOrder('com', 'jdk', 'lib', 'lombok', 'org', 'java', 'javax')
formatAnnotations().addTypeAnnotation("PolyInitialized").addTypeAnnotation("PolyVP").addTypeAnnotation("ReceiverDependentQual")
formatAnnotations().addTypeAnnotation("PolyInitialized").addTypeAnnotation("PolyVP").addTypeAnnotation("ReceiverDependentQual").addTypeAnnotation("Immutable").addTypeAnnotation("Readonly").addTypeAnnotation("Mutable").addTypeAnnotation("ReceiverDependentMutable").addTypeAnnotation("PolyMutable")
}

groovyGradle {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.checkerframework.checker.pico.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;

/**
* This annotation is used to exclude the field from the abstract state and means the field can be
* reassigned after initialization. It should only annotate on field, not class or method.
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
@HoldsForDefaultValue
public @interface Assignable {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package org.checkerframework.checker.pico.qual;

import org.checkerframework.checker.initialization.qual.HoldsForDefaultValue;
import org.checkerframework.framework.qual.DefaultFor;
import org.checkerframework.framework.qual.DefaultQualifierInHierarchy;
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.TypeUseLocation;
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;

/**
* {@code @Immutable} is a type qualifier that indicates that the fields of annotated reference
* cannot be mutated.
*
* <p>For usage in PICO, there are three ways to use this annotation: Object creation: the object
* created will always be immutable; Annotation on a reference: the object that reference points to
* is immutable; Annotation on a class: all instances of that class are immutable.
*/
@SubtypeOf({Readonly.class})
@Documented
@DefaultQualifierInHierarchy
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@DefaultFor(
value = {TypeUseLocation.EXCEPTION_PARAMETER},
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
})
@HoldsForDefaultValue
public @interface Immutable {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.checkerframework.checker.pico.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;

/**
* {@code @Mutable} is a type qualifier that indicates that the fields of annotated reference can be
* mutated through this reference. This is default behavior for all references in Java.
*
* <p>For usage in PICO, there are three ways to use this annotation: Object creation: the object
* created will always be mutable; Annotation on a reference: the object that reference points to is
* mutable; Annotation on a class: all instances of that class are mutable.
*/
@SubtypeOf({Readonly.class})
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
// @DefaultFor({ TypeUseLocation.EXCEPTION_PARAMETER })
@HoldsForDefaultValue
public @interface Mutable {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.checkerframework.checker.pico.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;

/**
* Indicates that the annotated method is an object identity method. An object identity method is a
* method that returns the identity of the object it is called on.
*
* <p>For example, the {@code hashCode} method is an object identity method, because it returns the
* identity of the object it is called on.
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface ObjectIdentityMethod {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.checkerframework.checker.pico.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 @PICOBottom} can only be annotated before a type parameter (For example, {@code class
* C<@Bottom T extends MutableBox>{}}). This means {@code @PICOBottom} is the lower bound for this
* type parameter.
*
* <p>User can explicitly write {@code @PICOBottom} 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, ReceiverDependentMutable.class, PICOLost.class})
@DefaultFor(typeKinds = {TypeKind.NULL})
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_PARAMETER})
@TargetLocations({TypeUseLocation.LOWER_BOUND})
public @interface PICOBottom {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.checkerframework.checker.pico.qual;

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;

/** Lost means the mutability type of this reference is unknown. This is a subtype of Readonly. */
@SubtypeOf({Readonly.class})
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
public @interface PICOLost {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.checkerframework.checker.pico.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;

/**
* The polymorphic qualifier {@code @PolyMutable} indicates that the mutability type of this
* reference can be substituted to {@code @Mutable} or {@code @Immutable} or {@code @RDM}. This is a
* polymorphic qualifier that can be used in the type hierarchy.
*
* <p>{@code @PolyMutable} applies to method parameters, method return type and receiver.
*/
@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,23 @@
package org.checkerframework.checker.pico.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;

/**
* The top qualifier in the mutability type hierarchy that indicates that the fields of annotated
* reference cannot be mutated through this reference but can be mutated through other Aliasing.
* This is the default qualifier for local variables and subject to flow-sensitive type refinement.
*/
@SubtypeOf({})
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@DefaultFor({TypeUseLocation.LOCAL_VARIABLE, TypeUseLocation.IMPLICIT_UPPER_BOUND})
public @interface Readonly {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.checkerframework.checker.pico.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;

/**
* {@code @ReceiverDependentMutable} is a type qualifier that indicates that mutability type depends
* on the receiver type.
*
* <p>For usage in PICO, there are three ways to use this annotation: Object creation: the object
* created depends on the lhs type; Annotation on a reference: the object that reference depends on
* the receiver type; Annotation on a class: the instances can be mutable or immutable.
*/
@SubtypeOf(Readonly.class)
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
// @DefaultFor({ TypeUseLocation.FIELD })
@HoldsForDefaultValue
public @interface ReceiverDependentMutable {}
Loading
Loading