Skip to content

Move PICO to EISOP #1013

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

Open
wants to merge 82 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 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
6a7fb65
Remove unused override
Ao-senXiong Jan 3, 2025
44a70e6
Correct the test cases
Ao-senXiong Jan 7, 2025
3735fbe
Merge branch 'master' into pico-move
Ao-senXiong Jan 7, 2025
861d5c8
Undo debug
Ao-senXiong Jan 7, 2025
17c11e6
Test array as field in class
Ao-senXiong Jan 8, 2025
b0ed675
Delete jdk.astub
Ao-senXiong Jan 8, 2025
5cc6842
Correct code and refine example
Ao-senXiong Jan 8, 2025
38a547a
Partially fixed override rule
Ao-senXiong Jan 9, 2025
aa42c42
Merge branch 'master' into pico-move
Ao-senXiong Jan 9, 2025
3b97db2
Remove hack for adding annotation for toString and other methods
Ao-senXiong Jan 10, 2025
4f6236a
Apply suggestions from code review
Ao-senXiong Jan 10, 2025
e347eb2
Remove super clause annotator
Ao-senXiong Jan 11, 2025
999750a
Remove used code
Ao-senXiong Jan 11, 2025
e97245d
Apply spotless
Ao-senXiong Jan 11, 2025
e2827d9
Fixes PolyMutable factory pattern
Ao-senXiong Jan 12, 2025
3fccd21
Compute Varargs before calling setParameterTypes
Ao-senXiong Aug 19, 2024
da92fa8
Merge branch 'master' into pico-move
Ao-senXiong Jan 16, 2025
e3db549
Doc cleanup
Ao-senXiong Jan 25, 2025
586433e
Clean up duplicate code for constructor invocation
Ao-senXiong Jan 26, 2025
c3a6cea
Fixed crash bugs and a few more cleanups
Ao-senXiong Jan 26, 2025
dcfde22
Clean up code and default method receiver to its class bound
Ao-senXiong Jan 26, 2025
1cc754f
Merge branch 'master' into pico-move
Ao-senXiong Jan 30, 2025
e31d2f7
Fix behavior in transitive mutable field
Ao-senXiong Feb 1, 2025
ffb39ee
Fixes array component type
Ao-senXiong Feb 1, 2025
2f9f082
Merge branch 'master' into pico-move
Ao-senXiong Feb 15, 2025
958f36a
Merge branch 'master' into pico-move
Ao-senXiong Feb 19, 2025
e6c21c2
Adapt framework change
Ao-senXiong Feb 19, 2025
698dfc9
Fixing newest change
Ao-senXiong Feb 19, 2025
58c78d9
Allow underinit receiver to do assignment
Ao-senXiong Feb 20, 2025
87a8ca1
Add test case
Ao-senXiong Feb 20, 2025
4c35416
Add Circular initialization test case
Ao-senXiong Feb 20, 2025
c79959b
Allow static class be annotated as RDM
Ao-senXiong Feb 20, 2025
5f76aaa
Merge branch 'master' into pico-move
Ao-senXiong Feb 23, 2025
2ba3033
Add `assumeInitialized` option
Ao-senXiong Mar 13, 2025
59367a2
Merge branch 'master' into pico-move
Ao-senXiong Mar 13, 2025
3f22ec2
Add suppress warning string
Ao-senXiong Mar 13, 2025
3fdc6b3
Merge branch 'master' into pico-move
Ao-senXiong Apr 15, 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
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,14 @@ allprojects { currentProj ->
}
targetExclude doNotFormat


if (eisopFormatting) {
googleJavaFormat(versions.googleJavaFormat).aosp()
importOrder('com', 'jdk', 'lib', 'lombok', 'org', 'java', 'javax')
} else {
googleJavaFormat(versions.googleJavaFormat) // the formatter to apply to Java files
}
formatAnnotations().addTypeAnnotation("PolyInitialized").addTypeAnnotation("PolyVP").addTypeAnnotation("ReceiverDependentQual")
formatAnnotations().addTypeAnnotation("PolyInitialized").addTypeAnnotation("PolyVP").addTypeAnnotation("ReceiverDependentQual").addTypeAnnotation("Immutable").addTypeAnnotation("Readonly").addTypeAnnotation("Mutable").addTypeAnnotation("ReceiverDependentMutable").addTypeAnnotation("PolyMutable")
}

// Only define a groovyGradle task on the root project, for simplicity in setting the target pattern
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,25 @@
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})
@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,25 @@
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})
@HoldsForDefaultValue
public @interface ReceiverDependentMutable {}
Loading
Loading