Skip to content
Open
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
4ac32c6
Add all annotations from PICO
Dec 28, 2024
2d4b59a
Annotate `Object`
Dec 28, 2024
8d05b23
Annotate `Serializable`
Dec 29, 2024
db869cc
Annotate `Date`
Dec 29, 2024
3466455
Annotate `FileInputStream` and `ObjectOutputStream`
Dec 29, 2024
50c2952
Annotate `Iterator`
Dec 29, 2024
1d6408f
Annotate `Throwable`
Dec 29, 2024
de05b72
Annotate `IndexOutOfBoundsException`
Dec 29, 2024
3936f73
Annotate `StringBuilder`
Dec 29, 2024
8156957
Annotate `CharSequence`
Dec 29, 2024
22347f4
Annotate `String`
Dec 29, 2024
9cd9d17
Annotate `RuntimeException`
Dec 29, 2024
1d8b0c0
Annotate `Cloneable`
Dec 29, 2024
8be60b7
Annotate `Comparable`
Dec 29, 2024
ca9f48d
Annotate `Collection`
Dec 29, 2024
31387f6
Annotate `AbstractCollection`
Dec 29, 2024
d7e5a00
More annotations for `Iterator`
Dec 29, 2024
5504162
Annotate `List`
Dec 29, 2024
e282eb2
Import PICO in `List`
Dec 29, 2024
c5a0af6
Annotate `Collections`
Dec 29, 2024
c5f61b9
Annotate `AbstractList`
Dec 29, 2024
2d57c20
Annotate `Map`
Dec 29, 2024
a153821
Annotate `AbstractMap`
Dec 29, 2024
89d2c16
Annotate `HashMap`
Dec 29, 2024
26047b9
Annotate `Set`
Dec 29, 2024
43324c0
Annotate `AbstractSet`
Dec 29, 2024
2bf56b1
Annotate `HashSet`
Dec 29, 2024
b1d7ea2
Annotate `ArrayList`
Dec 29, 2024
4aca645
Annotate `File`
Dec 29, 2024
30ee3e5
Annotate `StringBuffer`
Dec 29, 2024
a45538d
Annotate `AbstractStringBuilder`
Dec 29, 2024
111fe02
Annotate `Array`
Dec 29, 2024
5e51849
More annotations for `Arrays`
Dec 29, 2024
b9ac1fc
Annotate `Stack`
Dec 29, 2024
adfe794
Annotate `Vector`
Dec 29, 2024
7bb4912
Import Readonly in `Logger`
Dec 29, 2024
552b2a5
Annotate `HashTable`
Dec 29, 2024
0dccf15
Annotate `PrintStream`
Dec 29, 2024
50fdf29
Annotate `PrintWriter`
Dec 29, 2024
ce93b81
Annotate `Container`
Dec 29, 2024
3be97ae
Annotate `AnnotationMirror`
Dec 29, 2024
d8d42c9
Annotate `ExecutionException`
Dec 29, 2024
50bbc71
Export PICO in `module-info.java`
Dec 30, 2024
733b538
Fix typos and reorder qualifier
Dec 30, 2024
d452318
Fix import
Dec 30, 2024
02f104d
Fix import
Dec 30, 2024
52c8a4a
A few mutable annotations for setters
Dec 30, 2024
852ec54
A few mutable annotations for setters
Dec 30, 2024
85b5275
A few mutable annotations for setters in Map
Dec 30, 2024
fef7277
Entryset's receiver should be readonly
Dec 30, 2024
61f55da
Allow constructor to take any take arraylist
aosen-xiong Jan 8, 2025
a32a288
Add import
aosen-xiong Jan 8, 2025
c5777c3
Annotate getter as Readonly
aosen-xiong Jan 8, 2025
1360278
Annotate util method in Object
aosen-xiong Jan 11, 2025
e4fbd15
Annotate util method in Object
aosen-xiong Jan 11, 2025
dfa3348
A few more annotations
aosen-xiong Jan 14, 2025
7101885
More annotations
aosen-xiong Jan 14, 2025
ec1d6c3
Make copyof polymutable
aosen-xiong Jan 12, 2025
bbea90a
Make arraycopy polymutable
aosen-xiong Jan 12, 2025
af50f17
Annotation for `AtomicInteger`
aosen-xiong Jan 12, 2025
852dfff
Correct array annotations
aosen-xiong Jan 24, 2025
19a2c57
More annotations
aosen-xiong Jan 24, 2025
e771edd
More annotations
aosen-xiong Jan 24, 2025
14410e2
A large update
aosen-xiong Apr 15, 2025
df801bd
Merge remote-tracking branch 'origin/master' into pico-move
aosen-xiong Apr 15, 2025
0bb59f1
Remove sideeffectsonly annotations because of merge errors
aosen-xiong Apr 15, 2025
eea9cf1
Fix DefaultQualifier because of merge error
aosen-xiong Apr 15, 2025
cabab35
Undo error in treemap because of merge
aosen-xiong Apr 15, 2025
457007f
Commit PICO annotation
aosen-xiong Apr 15, 2025
de61bde
Commit PICO annotation
aosen-xiong Apr 15, 2025
6245543
Commit PICO annotation
aosen-xiong Apr 15, 2025
bf4e90d
Commit PICO annotation
aosen-xiong Apr 15, 2025
f4cf00f
All good!
aosen-xiong Apr 16, 2025
5b4485e
Fix a few errors and remove redundant mutable
aosen-xiong May 6, 2025
5587b8f
Continue suppress warnings on Date
aosen-xiong May 11, 2025
1f9600e
Add a few Initialization annotations
aosen-xiong May 11, 2025
13593db
Remove unused import
aosen-xiong May 11, 2025
ff52d6b
Try lazyfinal
aosen-xiong Oct 4, 2025
95d59ee
Fix package issue
aosen-xiong Oct 4, 2025
0cdb340
Add lazyfinal annotations
aosen-xiong Oct 4, 2025
1f2cd40
Merge branch 'master' into pico-move
aosen-xiong Oct 6, 2025
5daf90f
Another round and some format
aosen-xiong Oct 19, 2025
4779e30
Add annotations
aosen-xiong Oct 20, 2025
5d97d87
Add annotations
aosen-xiong Oct 20, 2025
5dbd81a
Add annotations
aosen-xiong Oct 25, 2025
a098ebb
Add annotations
aosen-xiong Oct 26, 2025
1c7b4a1
Add annotations
aosen-xiong Oct 28, 2025
30ea111
Add annotations
aosen-xiong Oct 28, 2025
11da63b
Add annotations
aosen-xiong Oct 29, 2025
6f84799
Add annotations
aosen-xiong Oct 29, 2025
adb58cc
Add annotations
aosen-xiong Oct 29, 2025
7a4a0cd
Add annotations
aosen-xiong Oct 29, 2025
1acde16
Add annotations
aosen-xiong Oct 29, 2025
61c16eb
Add annotations
aosen-xiong Oct 29, 2025
33d9ae1
Add annotations
aosen-xiong Oct 30, 2025
9bdb806
Add annotations
aosen-xiong Oct 30, 2025
e1d766e
Add annotations
aosen-xiong Oct 30, 2025
06782f9
Update comment
aosen-xiong Nov 5, 2025
d0a5439
WIP
aosen-xiong Feb 2, 2026
9d7df7d
WIP
aosen-xiong Feb 3, 2026
54c49fb
WIP
aosen-xiong Feb 3, 2026
4826034
WIP
aosen-xiong Feb 3, 2026
ecf465c
WIP
aosen-xiong Feb 3, 2026
7c5f060
Hack on JDK to remove strange errors
aosen-xiong Feb 3, 2026
5a8addc
WIP
aosen-xiong Feb 4, 2026
de3b7d6
Merge branch 'master' into final-case-study
aosen-xiong Feb 4, 2026
60470fd
Empty commit for CI
aosen-xiong Feb 4, 2026
c613344
Remove LazyFinal
aosen-xiong Mar 4, 2026
a1ebb99
Merge branch 'master' into pico-move
aosen-xiong Jun 16, 2026
71ce588
Merge pico-artifact into pico-move
aosen-xiong Jun 16, 2026
b6085ce
Remove stale PICO qualifier definitions
aosen-xiong Jun 16, 2026
b56178f
Revert class file gitignore entry
aosen-xiong Jun 16, 2026
00bdd7a
Trigger JDK CI
aosen-xiong Jun 16, 2026
a587387
Remove initialization annotations from pico move
aosen-xiong Jun 17, 2026
e66daf7
Restore existing initialization annotations
aosen-xiong Jun 17, 2026
6fb403e
Rename PICO annotations to Mutability annotations
aosen-xiong Jul 4, 2026
411ee3d
Sync mutability qualifiers with Checker Framework
aosen-xiong Jul 4, 2026
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
6 changes: 5 additions & 1 deletion src/java.base/share/classes/java/io/File.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@
import org.checkerframework.checker.lock.qual.GuardSatisfied;
import org.checkerframework.checker.lock.qual.ReleasesNoLocks;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.pico.qual.ReceiverDependentMutable;
import org.checkerframework.checker.pico.qual.Readonly;
import org.checkerframework.checker.regex.qual.Regex;
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.framework.qual.AnnotatedFor;
import org.checkerframework.framework.qual.CFComment;
import org.checkerframework.framework.qual.DefaultQualifierForUse;

import java.net.URI;
import java.net.URL;
Expand Down Expand Up @@ -162,7 +165,8 @@
"EnsuresNonNullIf(expression={\"list()\",\"list(FilenameFilter)\",\"listFiles()\",\"listFiles(FilenameFilter)\",\"listFiles(FileFilter)\"}, result=true)\""
})
@AnnotatedFor({"index", "initialization", "interning", "lock", "nullness"})
public class File
@DefaultQualifierForUse(Readonly.class)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should all files have this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I am still thinking. At least for most usage in @RDM class, this make sense because we need to make the most method can be used for both @Immutable and @Mutable class like getters. Some methods can only be used by @Mutable receiver like add(...).

I am wondering should we default the defaultqualifierforuse to RDM for RDM class?

public @ReceiverDependentMutable class File
Comment thread
aosen-xiong marked this conversation as resolved.
Outdated
implements Serializable, Comparable<File>
{

Expand Down
5 changes: 4 additions & 1 deletion src/java.base/share/classes/java/io/FileInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import org.checkerframework.checker.index.qual.LTLengthOf;
import org.checkerframework.checker.index.qual.NonNegative;
import org.checkerframework.checker.mustcall.qual.MustCallAlias;
import org.checkerframework.checker.pico.qual.ReceiverDependentMutable;
import org.checkerframework.checker.pico.qual.Readonly;
import org.checkerframework.framework.qual.AnnotatedFor;

import java.nio.channels.FileChannel;
Expand Down Expand Up @@ -70,6 +72,7 @@
* @since 1.0
*/
@AnnotatedFor({"index", "initialization", "mustcall", "nullness"})
@ReceiverDependentMutable
public class FileInputStream extends InputStream
{
private static final int DEFAULT_BUFFER_SIZE = 8192;
Expand Down Expand Up @@ -147,7 +150,7 @@ public FileInputStream(String name) throws FileNotFoundException {
* @see java.io.File#getPath()
* @see java.lang.SecurityManager#checkRead(java.lang.String)
*/
public FileInputStream(File file) throws FileNotFoundException {
public @ReceiverDependentMutable FileInputStream(@Readonly File file) throws FileNotFoundException {
String name = (file != null ? file.getPath() : null);
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
Expand Down
3 changes: 2 additions & 1 deletion src/java.base/share/classes/java/io/ObjectOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.checkerframework.checker.index.qual.NonNegative;
import org.checkerframework.checker.mustcall.qual.MustCallAlias;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.pico.qual.Readonly;
import org.checkerframework.checker.signedness.qual.PolySigned;
import org.checkerframework.framework.qual.AnnotatedFor;

Expand Down Expand Up @@ -354,7 +355,7 @@ public void useProtocolVersion(int version) throws IOException {
* @throws IOException Any exception thrown by the underlying
* OutputStream.
*/
public final void writeObject(@Nullable Object obj) throws IOException {
public final void writeObject(@Readonly @Nullable Object obj) throws IOException {
if (enableOverride) {
writeObjectOverride(obj);
return;
Expand Down
14 changes: 8 additions & 6 deletions src/java.base/share/classes/java/io/PrintStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import org.checkerframework.checker.mustcall.qual.MustCallAlias;
import org.checkerframework.checker.mustcall.qual.NotOwning;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.pico.qual.Readonly;
import org.checkerframework.checker.pico.qual.ReceiverDependentMutable;
import org.checkerframework.checker.signedness.qual.PolySigned;
import org.checkerframework.framework.qual.AnnotatedFor;
import org.checkerframework.framework.qual.CFComment;
Expand Down Expand Up @@ -75,7 +77,7 @@

@CFComment({"lock: TODO: Should parameters be @GuardSatisfied, or is the default of @GuardedBy({}) appropriate? (@GuardedBy({}) is more conservative.)"})
@AnnotatedFor({"formatter", "i18n", "index", "initialization", "lock", "mustcall", "nullness", "signedness"})
public class PrintStream extends FilterOutputStream
public @ReceiverDependentMutable class PrintStream extends FilterOutputStream
implements Appendable, Closeable
{

Expand Down Expand Up @@ -888,7 +890,7 @@ public void print(@GuardSatisfied PrintStream this, @Nullable String s) {
* @param obj The {@code Object} to be printed
* @see java.lang.Object#toString()
*/
public void print(@GuardSatisfied PrintStream this, @Nullable Object obj) {
public void print(@GuardSatisfied PrintStream this, @Nullable @Readonly Object obj) {
write(String.valueOf(obj));
}

Expand Down Expand Up @@ -1058,7 +1060,7 @@ public void println(@GuardSatisfied PrintStream this, @Nullable @Localized Strin
*
* @param x The {@code Object} to be printed.
*/
public void println(@GuardSatisfied PrintStream this, @Nullable Object x) {
public void println(@GuardSatisfied PrintStream this, @Nullable @Readonly Object x) {
String s = String.valueOf(x);
if (getClass() == PrintStream.class) {
// need to apply String.valueOf again since first invocation
Expand Down Expand Up @@ -1118,7 +1120,7 @@ public void println(@GuardSatisfied PrintStream this, @Nullable Object x) {
*/
@CFComment({"lock/nullness: The vararg arrays can actually be null, but let's not annotate them because passing null is bad style; see whether this annotation is useful."})
@FormatMethod
public @NotOwning PrintStream printf(@GuardSatisfied PrintStream this, String format, @Nullable Object ... args) {
public @NotOwning PrintStream printf(@GuardSatisfied PrintStream this, String format, @Nullable @Readonly Object ... args) {
return format(format, args);
}

Expand Down Expand Up @@ -1171,7 +1173,7 @@ public void println(@GuardSatisfied PrintStream this, @Nullable Object x) {
* @since 1.5
*/
@FormatMethod
public @NotOwning PrintStream printf(@GuardSatisfied PrintStream this, @Nullable Locale l, String format, @Nullable Object ... args) {
public @NotOwning PrintStream printf(@GuardSatisfied PrintStream this, @Nullable Locale l, String format, @Nullable @Readonly Object ... args) {
return format(l, format, args);
}

Expand Down Expand Up @@ -1277,7 +1279,7 @@ public void println(@GuardSatisfied PrintStream this, @Nullable Object x) {
* @since 1.5
*/
@FormatMethod
public @NotOwning PrintStream format(@GuardSatisfied PrintStream this, @Nullable Locale l, String format, @Nullable Object ... args) {
public @NotOwning PrintStream format(@GuardSatisfied PrintStream this, @Nullable Locale l, String format, @Nullable @Readonly Object ... args) {
try {
synchronized (this) {
ensureOpen();
Expand Down
17 changes: 10 additions & 7 deletions src/java.base/share/classes/java/io/PrintWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
import org.checkerframework.checker.lock.qual.GuardSatisfied;
import org.checkerframework.checker.mustcall.qual.MustCallAlias;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.pico.qual.Readonly;
import org.checkerframework.checker.pico.qual.ReceiverDependentMutable;

import org.checkerframework.framework.qual.AnnotatedFor;

import java.util.Objects;
Expand Down Expand Up @@ -68,7 +71,7 @@
*/

@AnnotatedFor({"formatter", "index", "initialization", "lock", "mustcall", "nullness"})
public class PrintWriter extends Writer {
public @ReceiverDependentMutable class PrintWriter extends Writer {

/**
* The underlying character-output stream of this
Expand Down Expand Up @@ -705,7 +708,7 @@ public void print(@GuardSatisfied PrintWriter this, @Nullable String s) {
* @param obj The {@code Object} to be printed
* @see java.lang.Object#toString()
*/
public void print(@GuardSatisfied PrintWriter this, @Nullable Object obj) {
public void print(@GuardSatisfied PrintWriter this, @Nullable @Readonly Object obj) {
write(String.valueOf(obj));
}

Expand Down Expand Up @@ -841,7 +844,7 @@ public void println(@GuardSatisfied PrintWriter this, @Nullable String x) {
*
* @param x The {@code Object} to be printed.
*/
public void println(@GuardSatisfied PrintWriter this, @Nullable Object x) {
public void println(@GuardSatisfied PrintWriter this, @Nullable @Readonly Object x) {
String s = String.valueOf(x);
synchronized (lock) {
print(s);
Expand Down Expand Up @@ -894,7 +897,7 @@ public void println(@GuardSatisfied PrintWriter this, @Nullable Object x) {
* @since 1.5
*/
@FormatMethod
public @MustCallAlias PrintWriter printf(@GuardSatisfied @MustCallAlias PrintWriter this, String format, @Nullable Object ... args) {
public @MustCallAlias PrintWriter printf(@GuardSatisfied @MustCallAlias PrintWriter this, String format, @Nullable @Readonly Object ... args) {
return format(format, args);
}

Expand Down Expand Up @@ -948,7 +951,7 @@ public void println(@GuardSatisfied PrintWriter this, @Nullable Object x) {
* @since 1.5
*/
@FormatMethod
public @MustCallAlias PrintWriter printf(@GuardSatisfied @MustCallAlias PrintWriter this, @Nullable Locale l, String format, @Nullable Object ... args) {
public @MustCallAlias PrintWriter printf(@GuardSatisfied @MustCallAlias PrintWriter this, @Nullable Locale l, String format, @Nullable @Readonly Object ... args) {
return format(l, format, args);
}

Expand Down Expand Up @@ -993,7 +996,7 @@ public void println(@GuardSatisfied PrintWriter this, @Nullable Object x) {
* @since 1.5
*/
@FormatMethod
public @MustCallAlias PrintWriter format(@GuardSatisfied @MustCallAlias PrintWriter this, String format, @Nullable Object ... args) {
public @MustCallAlias PrintWriter format(@GuardSatisfied @MustCallAlias PrintWriter this, String format, @Nullable @Readonly Object ... args) {
try {
synchronized (lock) {
ensureOpen();
Expand Down Expand Up @@ -1054,7 +1057,7 @@ public void println(@GuardSatisfied PrintWriter this, @Nullable Object x) {
* @since 1.5
*/
@FormatMethod
public @MustCallAlias PrintWriter format(@GuardSatisfied @MustCallAlias PrintWriter this, @Nullable Locale l, String format, @Nullable Object ... args) {
public @MustCallAlias PrintWriter format(@GuardSatisfied @MustCallAlias PrintWriter this, @Nullable Locale l, String format, @Nullable @Readonly Object ... args) {
try {
synchronized (lock) {
ensureOpen();
Expand Down
2 changes: 2 additions & 0 deletions src/java.base/share/classes/java/io/Serializable.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/

package java.io;
import org.checkerframework.checker.pico.qual.ReceiverDependentMutable;

/**
* Serializability of a class is enabled by the class implementing the
Expand Down Expand Up @@ -190,5 +191,6 @@
* <cite>Java Object Serialization Specification</cite></a>
* @since 1.1
*/
@ReceiverDependentMutable
public interface Serializable {
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.checkerframework.checker.interning.qual.UsesObjectEquals;
import org.checkerframework.checker.lock.qual.GuardSatisfied;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.pico.qual.Mutable;
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.framework.qual.AnnotatedFor;
Expand Down Expand Up @@ -68,7 +69,7 @@
* @since 1.5
*/
@AnnotatedFor({"index", "initialization", "interning", "lock", "nullness"})
abstract @UsesObjectEquals class AbstractStringBuilder implements Appendable, CharSequence {
abstract @UsesObjectEquals @Mutable class AbstractStringBuilder implements Appendable, CharSequence {
/**
* The value is used for character storage.
*/
Expand Down
6 changes: 5 additions & 1 deletion src/java.base/share/classes/java/lang/CharSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@
import org.checkerframework.checker.lock.qual.GuardSatisfied;
import org.checkerframework.checker.nonempty.qual.EnsuresNonEmptyIf;
import org.checkerframework.checker.nonempty.qual.NonEmpty;
import org.checkerframework.checker.pico.qual.ReceiverDependentMutable;
import org.checkerframework.checker.pico.qual.Readonly;
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.dataflow.qual.SideEffectsOnly;
import org.checkerframework.framework.qual.AnnotatedFor;
import org.checkerframework.framework.qual.DefaultQualifierForUse;

import java.util.NoSuchElementException;
import java.util.Objects;
Expand Down Expand Up @@ -69,7 +72,8 @@
*/

@AnnotatedFor({"lock", "nullness", "index"})
public interface CharSequence {
@DefaultQualifierForUse(Readonly.class)
public @ReceiverDependentMutable interface CharSequence {

/**
* Returns the length of this character sequence. The length is the number
Expand Down
3 changes: 2 additions & 1 deletion src/java.base/share/classes/java/lang/Cloneable.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package java.lang;

import org.checkerframework.checker.pico.qual.ReceiverDependentMutable;
import org.checkerframework.framework.qual.AnnotatedFor;

/**
Expand Down Expand Up @@ -52,5 +53,5 @@
* @since 1.0
*/
@AnnotatedFor({"nullness"})
public interface Cloneable {
public @ReceiverDependentMutable interface Cloneable {
}
6 changes: 4 additions & 2 deletions src/java.base/share/classes/java/lang/Comparable.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

import org.checkerframework.checker.lock.qual.GuardSatisfied;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.pico.qual.ReceiverDependentMutable;
import org.checkerframework.checker.pico.qual.Readonly;
import org.checkerframework.dataflow.qual.Pure;
import org.checkerframework.framework.qual.AnnotatedFor;
import org.checkerframework.framework.qual.CFComment;
Expand Down Expand Up @@ -110,7 +112,7 @@
* @since 1.2
*/
@AnnotatedFor({"lock", "nullness", "index"})
public interface Comparable<T extends @NonNull Object> {
public @ReceiverDependentMutable interface Comparable<T extends @NonNull Object> {
/**
* Compares this object with the specified object for order. Returns a
* negative integer, zero, or a positive integer as this object is less
Expand Down Expand Up @@ -148,5 +150,5 @@ public interface Comparable<T extends @NonNull Object> {
*/
@CFComment("nullness: arguments may NOT be null")
@Pure
public int compareTo(@GuardSatisfied Comparable<T> this, @NonNull T o);
public int compareTo(@Readonly @GuardSatisfied Comparable<T> this, @NonNull T o);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package java.lang;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.pico.qual.ReceiverDependentMutable;
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.framework.qual.AnnotatedFor;

Expand All @@ -39,7 +40,7 @@
* @since 1.0
*/
@AnnotatedFor({"nullness"})
public class IndexOutOfBoundsException extends RuntimeException {
public @ReceiverDependentMutable class IndexOutOfBoundsException extends RuntimeException {
@java.io.Serial
private static final long serialVersionUID = 234122996006267687L;

Expand Down
14 changes: 9 additions & 5 deletions src/java.base/share/classes/java/lang/Object.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import org.checkerframework.checker.mustcall.qual.MustCall;
import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.pico.qual.Readonly;
import org.checkerframework.checker.pico.qual.ReceiverDependentMutable;
import org.checkerframework.checker.signedness.qual.UnknownSignedness;
import org.checkerframework.checker.tainting.qual.Untainted;
import org.checkerframework.common.aliasing.qual.Unique;
Expand All @@ -55,13 +57,15 @@
*/
@AnnotatedFor({"aliasing", "guieffect", "index", "lock", "nullness"})
@PolyUIType
@ReceiverDependentMutable
public class Object {

/**
* Constructs a new object.
*/
@Pure
@IntrinsicCandidate
@ReceiverDependentMutable
public @Unique @Untainted Object() {}

/**
Expand All @@ -87,7 +91,7 @@ public class Object {
@SafeEffect
@Pure
@IntrinsicCandidate
public final native Class<? extends @MustCall() Object> getClass(@PolyUI @GuardSatisfied @UnknownInitialization @UnknownSignedness Object this);
public final native Class<? extends @MustCall() Object> getClass(@Readonly @PolyUI @GuardSatisfied @UnknownInitialization @UnknownSignedness Object this);

/**
* Returns a hash code value for the object. This method is
Expand Down Expand Up @@ -124,7 +128,7 @@ public class Object {
*/
@Pure
@IntrinsicCandidate
public native int hashCode(@GuardSatisfied @UnknownSignedness Object this);
public native int hashCode(@Readonly @GuardSatisfied @UnknownSignedness Object this);

/**
* Indicates whether some other object is "equal to" this one.
Expand Down Expand Up @@ -186,7 +190,7 @@ public class Object {
*/
@Pure
@EnsuresNonNullIf(expression="#1", result=true)
public boolean equals(@GuardSatisfied Object this, @GuardSatisfied @Nullable Object obj) {
public boolean equals(@Readonly @GuardSatisfied Object this, @Readonly @GuardSatisfied @Nullable Object obj) {
return (this == obj);
}

Expand Down Expand Up @@ -253,7 +257,7 @@ public boolean equals(@GuardSatisfied Object this, @GuardSatisfied @Nullable Obj
*/
@SideEffectFree
@IntrinsicCandidate
protected native Object clone(@GuardSatisfied Object this) throws CloneNotSupportedException;
protected native @ReceiverDependentMutable Object clone(@ReceiverDependentMutable @GuardSatisfied Object this) throws CloneNotSupportedException;

/**
* Returns a string representation of the object.
Expand Down Expand Up @@ -284,7 +288,7 @@ public boolean equals(@GuardSatisfied Object this, @GuardSatisfied @Nullable Obj
"that differs according to ==, and @Deterministic requires that the results of",
"two calls of the method are ==."})
@SideEffectFree
public String toString(@GuardSatisfied Object this) {
public String toString(@Readonly @GuardSatisfied Object this) {
return getClass().getName() + "@" + Integer.toHexString(hashCode());
}

Expand Down
Loading