Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
4c348b7
Added Confidential annotations for JDK
iywang2016 Oct 30, 2024
7e5c991
Added poly annotation for Throwable.getMessage
iywang2016 Jan 6, 2025
de7a3e3
Added poly annotation for Throwable.getMessage
iywang2016 Jan 6, 2025
a7c4ce5
Added poly annotation for Throwable.getMessage
iywang2016 Jan 6, 2025
609e7f9
Removed poly annotation for Throwable.getMessage
iywang2016 Jan 6, 2025
6571e19
Added unknown annotation for Throwable.getMessage
iywang2016 Jan 6, 2025
c4446dd
Removed poly annotation for Throwable.getMessage
iywang2016 Jan 6, 2025
ba581d7
Removed annotations for Throwable.getMessage
iywang2016 Jan 6, 2025
44a7f6f
Added annotations for Throwable.getMessage
iywang2016 Jan 6, 2025
fcf2f72
Make return type of `Throwable.getMessage()` explicit
mernst Jan 7, 2025
a0cb29e
Added UnknownConfidential annotation to Stream.collect()
iywang2016 Jan 13, 2025
efff74e
Added UnknownConfidential annotation to String.java
iywang2016 Feb 18, 2025
cc3be97
Added PolyConfidential annotation to String.format
iywang2016 Feb 18, 2025
241b62a
Added UnknownConfidential annotation to String.equals
iywang2016 Feb 18, 2025
a185307
Added PolyConfidential annotation to String.equals, Stream.collect, O…
iywang2016 Feb 25, 2025
99f8297
Added PolyConfidential annotation to Exception constructors and Throw…
iywang2016 Feb 25, 2025
7c225e5
Added PolyConfidential annotations
iywang2016 Mar 3, 2025
4b26da2
Merge ../jdk-branch-master into iywang
mernst Mar 3, 2025
6552483
Confidential overloads of toString
iywang2016 Mar 10, 2025
184a9d9
Merge remote-tracking branch 'origin/iywang' into iywang
iywang2016 Mar 10, 2025
20ac8d6
Add missing import
mernst Mar 11, 2025
15bd2ee
Sort imports
mernst Mar 11, 2025
b708411
Add export
mernst Mar 11, 2025
7e5fea0
Sort imports
mernst Mar 11, 2025
fc1e64a
Removed wildcard import and added missing import
iywang2016 Mar 11, 2025
c24d49e
Merge ../jdk-branch-master into iywang
mernst Apr 1, 2025
e6bc011
Export SQL Quotes qualifiers
mernst Apr 1, 2025
8a46e4e
Add qualifiers
mernst Apr 1, 2025
582cabe
Merge ../jdk-branch-master into iywang
mernst Apr 1, 2025
fc39596
Add `import` statement
mernst Apr 4, 2025
0b0b8ec
Revised Object.toString to use poly annotations
iywang2016 Apr 7, 2025
a8445da
Added qualifiers
iywang2016 Apr 7, 2025
46a544e
Merge remote-tracking branch 'origin/iywang' into iywang
iywang2016 Apr 7, 2025
1a0eb4a
Revised Object toString to use PolyConfidential
iywang2016 Apr 7, 2025
e4905a0
Revised Object toString to use PolyConfidential parameter and Confide…
iywang2016 Apr 7, 2025
923d35e
Revised typo
iywang2016 Apr 10, 2025
c00cd20
Revising generics default
iywang2016 May 5, 2025
c0dbab2
Added NonConfidential to getClass return
iywang2016 May 5, 2025
10311d6
Added DefaultFor to NonConfidential
iywang2016 May 5, 2025
d2aaf4f
Revised DefaultFor in NonConfidential
iywang2016 May 5, 2025
6a5df67
Removed PolyConfidential receiver annotation for toString
iywang2016 May 15, 2025
e6ac40f
Added back PolyConfidential receiver annotation for toString
iywang2016 May 19, 2025
be75381
Added PolyConfidential annotation to Optional type
iywang2016 May 19, 2025
92d3af5
Changed PolyConfidential to top type
iywang2016 Jun 17, 2025
eb7ea2f
Merge ../jdk-branch-master into iywang
mernst Jul 16, 2025
13f944c
Merge ../jdk-branch-master into iywang
mernst Aug 8, 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
39 changes: 20 additions & 19 deletions src/java.base/share/classes/java/io/PrintStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package java.io;

import org.checkerframework.checker.confidential.qual.NonConfidential;
import org.checkerframework.checker.formatter.qual.FormatMethod;
import org.checkerframework.checker.i18n.qual.Localized;
import org.checkerframework.checker.index.qual.IndexOrHigh;
Expand Down Expand Up @@ -74,7 +75,7 @@
*/

@CFComment({"lock: TODO: Should parameters be @GuardSatisfied, or is the default of @GuardedBy({}) appropriate? (@GuardedBy({}) is more conservative.)"})
@AnnotatedFor({"formatter", "i18n", "index", "lock", "mustcall", "nullness", "signedness"})
@AnnotatedFor({"formatter", "i18n", "index", "lock", "mustcall", "nullness", "signedness", "confidential"})
public class PrintStream extends FilterOutputStream
implements Appendable, Closeable
{
Expand Down Expand Up @@ -790,7 +791,7 @@ public void print(@GuardSatisfied PrintStream this, boolean b) {
*
* @param c The {@code char} to be printed
*/
public void print(@GuardSatisfied PrintStream this, char c) {
public void print(@GuardSatisfied PrintStream this, @NonConfidential char c) {
write(String.valueOf(c));
}

Expand All @@ -804,7 +805,7 @@ public void print(@GuardSatisfied PrintStream this, char c) {
* @param i The {@code int} to be printed
* @see java.lang.Integer#toString(int)
*/
public void print(@GuardSatisfied PrintStream this, int i) {
public void print(@GuardSatisfied PrintStream this, @NonConfidential int i) {
write(String.valueOf(i));
}

Expand All @@ -818,7 +819,7 @@ public void print(@GuardSatisfied PrintStream this, int i) {
* @param l The {@code long} to be printed
* @see java.lang.Long#toString(long)
*/
public void print(@GuardSatisfied PrintStream this, long l) {
public void print(@GuardSatisfied PrintStream this, @NonConfidential long l) {
write(String.valueOf(l));
}

Expand All @@ -832,7 +833,7 @@ public void print(@GuardSatisfied PrintStream this, long l) {
* @param f The {@code float} to be printed
* @see java.lang.Float#toString(float)
*/
public void print(@GuardSatisfied PrintStream this, float f) {
public void print(@GuardSatisfied PrintStream this, @NonConfidential float f) {
write(String.valueOf(f));
}

Expand All @@ -846,7 +847,7 @@ public void print(@GuardSatisfied PrintStream this, float f) {
* @param d The {@code double} to be printed
* @see java.lang.Double#toString(double)
*/
public void print(@GuardSatisfied PrintStream this, double d) {
public void print(@GuardSatisfied PrintStream this, @NonConfidential double d) {
write(String.valueOf(d));
}

Expand All @@ -860,7 +861,7 @@ public void print(@GuardSatisfied PrintStream this, double d) {
*
* @throws NullPointerException If {@code s} is {@code null}
*/
public void print(@GuardSatisfied PrintStream this, @PolySigned char s[]) {
public void print(@GuardSatisfied PrintStream this, @NonConfidential @PolySigned char s[]) {
write(s);
}

Expand All @@ -874,7 +875,7 @@ public void print(@GuardSatisfied PrintStream this, @PolySigned char s[]) {
*
* @param s The {@code String} to be printed
*/
public void print(@GuardSatisfied PrintStream this, @Nullable String s) {
public void print(@GuardSatisfied PrintStream this, @NonConfidential @Nullable String s) {
write(String.valueOf(s));
}

Expand All @@ -888,7 +889,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, @NonConfidential @Nullable Object obj) {
write(String.valueOf(obj));
}

Expand Down Expand Up @@ -930,7 +931,7 @@ public void println(@GuardSatisfied PrintStream this, boolean x) {
*
* @param x The {@code char} to be printed.
*/
public void println(@GuardSatisfied PrintStream this, char x) {
public void println(@GuardSatisfied PrintStream this, @NonConfidential char x) {
if (getClass() == PrintStream.class) {
writeln(String.valueOf(x));
} else {
Expand All @@ -948,7 +949,7 @@ public void println(@GuardSatisfied PrintStream this, char x) {
*
* @param x The {@code int} to be printed.
*/
public void println(@GuardSatisfied PrintStream this, int x) {
public void println(@GuardSatisfied PrintStream this, @NonConfidential int x) {
if (getClass() == PrintStream.class) {
writeln(String.valueOf(x));
} else {
Expand All @@ -966,7 +967,7 @@ public void println(@GuardSatisfied PrintStream this, int x) {
*
* @param x a The {@code long} to be printed.
*/
public void println(@GuardSatisfied PrintStream this, long x) {
public void println(@GuardSatisfied PrintStream this, @NonConfidential long x) {
if (getClass() == PrintStream.class) {
writeln(String.valueOf(x));
} else {
Expand All @@ -984,7 +985,7 @@ public void println(@GuardSatisfied PrintStream this, long x) {
*
* @param x The {@code float} to be printed.
*/
public void println(@GuardSatisfied PrintStream this, float x) {
public void println(@GuardSatisfied PrintStream this, @NonConfidential float x) {
if (getClass() == PrintStream.class) {
writeln(String.valueOf(x));
} else {
Expand All @@ -1002,7 +1003,7 @@ public void println(@GuardSatisfied PrintStream this, float x) {
*
* @param x The {@code double} to be printed.
*/
public void println(@GuardSatisfied PrintStream this, double x) {
public void println(@GuardSatisfied PrintStream this, @NonConfidential double x) {
if (getClass() == PrintStream.class) {
writeln(String.valueOf(x));
} else {
Expand All @@ -1020,7 +1021,7 @@ public void println(@GuardSatisfied PrintStream this, double x) {
*
* @param x an array of chars to print.
*/
public void println(@GuardSatisfied PrintStream this, char[] x) {
public void println(@GuardSatisfied PrintStream this, @NonConfidential char[] x) {
if (getClass() == PrintStream.class) {
writeln(x);
} else {
Expand All @@ -1038,7 +1039,7 @@ public void println(@GuardSatisfied PrintStream this, char[] x) {
*
* @param x The {@code String} to be printed.
*/
public void println(@GuardSatisfied PrintStream this, @Nullable @Localized String x) {
public void println(@GuardSatisfied PrintStream this, @NonConfidential @Nullable @Localized String x) {
if (getClass() == PrintStream.class) {
writeln(String.valueOf(x));
} else {
Expand All @@ -1058,7 +1059,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, @NonConfidential @Nullable 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 +1119,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 @NonConfidential PrintStream printf(@GuardSatisfied PrintStream this, @NonConfidential String format, @NonConfidential @Nullable Object ... args) {
return format(format, args);
}

Expand Down Expand Up @@ -1171,7 +1172,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 @NonConfidential PrintStream printf(@GuardSatisfied PrintStream this, @Nullable Locale l, @NonConfidential String format, @NonConfidential @Nullable Object ... args) {
return format(l, format, args);
}

Expand Down
13 changes: 7 additions & 6 deletions src/java.base/share/classes/java/lang/Exception.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@

package java.lang;

import org.checkerframework.checker.confidential.qual.PolyConfidential;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.common.aliasing.qual.Unique;
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.framework.qual.AnnotatedFor;
import org.checkerframework.common.aliasing.qual.Unique;

/**
* The class {@code Exception} and its subclasses are a form of
Expand All @@ -47,7 +48,7 @@
* @jls 11.2 Compile-Time Checking of Exceptions
* @since 1.0
*/
@AnnotatedFor({"aliasing", "nullness"})
@AnnotatedFor({"aliasing", "nullness", "confidential"})
public class Exception extends Throwable {
@java.io.Serial
static final long serialVersionUID = -3387516993124229948L;
Expand All @@ -71,7 +72,7 @@ public class Exception extends Throwable {
* later retrieval by the {@link #getMessage()} method.
*/
@SideEffectFree
public @Unique Exception(@Nullable String message) {
public @Unique Exception(@Nullable @PolyConfidential String message) {
super(message);
}

Expand All @@ -90,7 +91,7 @@ public class Exception extends Throwable {
* @since 1.4
*/
@SideEffectFree
public @Unique Exception(@Nullable String message, @Nullable Throwable cause) {
public @Unique Exception(@Nullable @PolyConfidential String message, @Nullable @PolyConfidential Throwable cause) {
super(message, cause);
}

Expand All @@ -109,7 +110,7 @@ public class Exception extends Throwable {
* @since 1.4
*/
@SideEffectFree
public @Unique Exception(@Nullable Throwable cause) {
public @Unique Exception(@Nullable @PolyConfidential Throwable cause) {
super(cause);
}

Expand All @@ -127,7 +128,7 @@ public class Exception extends Throwable {
* be writable
* @since 1.7
*/
protected @Unique Exception(@Nullable String message, @Nullable Throwable cause,
protected @Unique Exception(@Nullable @PolyConfidential String message, @Nullable @PolyConfidential Throwable cause,
boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
Expand Down
7 changes: 4 additions & 3 deletions src/java.base/share/classes/java/lang/Object.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package java.lang;

import org.checkerframework.checker.confidential.qual.PolyConfidential;
import org.checkerframework.checker.guieffect.qual.PolyUI;
import org.checkerframework.checker.guieffect.qual.PolyUIType;
import org.checkerframework.checker.guieffect.qual.SafeEffect;
Expand Down Expand Up @@ -53,7 +54,7 @@
* @see java.lang.Class
* @since 1.0
*/
@AnnotatedFor({"aliasing", "guieffect", "index", "lock", "nullness"})
@AnnotatedFor({"aliasing", "guieffect", "index", "lock", "nullness", "confidential"})
@PolyUIType
public class Object {

Expand Down Expand Up @@ -186,7 +187,7 @@ public class Object {
*/
@Pure
@EnsuresNonNullIf(expression="#1", result=true)
public boolean equals(@GuardSatisfied Object this, @GuardSatisfied @Nullable Object obj) {
public boolean equals(@GuardSatisfied @PolyConfidential Object this, @GuardSatisfied @Nullable @PolyConfidential Object obj) {
return (this == obj);
}

Expand Down Expand Up @@ -284,7 +285,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 @Confidential String toString(@PolyConfidential @GuardSatisfied Object this) {
return getClass().getName() + "@" + Integer.toHexString(hashCode());
}

Expand Down
11 changes: 6 additions & 5 deletions src/java.base/share/classes/java/lang/RuntimeException.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package java.lang;

import org.checkerframework.checker.confidential.qual.PolyConfidential;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.dataflow.qual.SideEffectFree;
import org.checkerframework.framework.qual.AnnotatedFor;
Expand All @@ -44,7 +45,7 @@
* @jls 11.2 Compile-Time Checking of Exceptions
* @since 1.0
*/
@AnnotatedFor({"nullness"})
@AnnotatedFor({"nullness", "confidential"})
public class RuntimeException extends Exception {
@java.io.Serial
static final long serialVersionUID = -7034897190745766939L;
Expand All @@ -66,7 +67,7 @@ public RuntimeException() {
* later retrieval by the {@link #getMessage()} method.
*/
@SideEffectFree
public RuntimeException(@Nullable String message) {
public RuntimeException(@Nullable @PolyConfidential String message) {
super(message);
}

Expand All @@ -85,7 +86,7 @@ public RuntimeException(@Nullable String message) {
* @since 1.4
*/
@SideEffectFree
public RuntimeException(@Nullable String message, @Nullable Throwable cause) {
public RuntimeException(@Nullable @PolyConfidential String message, @Nullable @PolyConfidential Throwable cause) {
super(message, cause);
}

Expand All @@ -102,7 +103,7 @@ public RuntimeException(@Nullable String message, @Nullable Throwable cause) {
* @since 1.4
*/
@SideEffectFree
public RuntimeException(@Nullable Throwable cause) {
public RuntimeException(@Nullable @PolyConfidential Throwable cause) {
super(cause);
}

Expand All @@ -121,7 +122,7 @@ public RuntimeException(@Nullable Throwable cause) {
*
* @since 1.7
*/
protected RuntimeException(@Nullable String message, @Nullable Throwable cause,
protected RuntimeException(@Nullable @PolyConfidential String message, @Nullable @PolyConfidential Throwable cause,
boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
Expand Down
7 changes: 4 additions & 3 deletions src/java.base/share/classes/java/lang/String.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package java.lang;

import org.checkerframework.checker.confidential.qual.PolyConfidential;
import org.checkerframework.checker.formatter.qual.FormatMethod;
import org.checkerframework.checker.index.qual.IndexFor;
import org.checkerframework.checker.index.qual.IndexOrHigh;
Expand Down Expand Up @@ -171,7 +172,7 @@
* @jls 15.18.1 String Concatenation Operator +
*/

@AnnotatedFor({"aliasing", "formatter", "index", "interning", "lock", "nullness", "regex", "signature", "signedness"})
@AnnotatedFor({"aliasing", "formatter", "index", "interning", "lock", "nullness", "regex", "signature", "signedness", "confidential"})
public final class String
implements java.io.Serializable, Comparable<String>, CharSequence,
Constable, ConstantDesc {
Expand Down Expand Up @@ -1910,7 +1911,7 @@ public void getBytes(@IndexOrHigh({"this"}) int srcBegin, @IndexOrHigh({"this"})
@EnsuresNonNullIf(expression={"#1"}, result=true)
@Pure
@StaticallyExecutable
public boolean equals(@GuardSatisfied @Nullable Object anObject) {
public boolean equals(@PolyConfidential String this, @GuardSatisfied @Nullable @PolyConfidential Object anObject) {
if (this == anObject) {
return true;
}
Expand Down Expand Up @@ -4327,7 +4328,7 @@ public IntStream codePoints() {
@SideEffectFree
@StaticallyExecutable
@FormatMethod
public static String format(String format, @GuardSatisfied @Nullable Object @GuardSatisfied ... args) {
public static @PolyConfidential String format(String format, @PolyConfidential @GuardSatisfied @Nullable Object @GuardSatisfied ... args) {
return new Formatter().format(format, args).toString();
}

Expand Down
7 changes: 5 additions & 2 deletions src/java.base/share/classes/java/lang/Throwable.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

package java.lang;

import org.checkerframework.checker.confidential.qual.NonConfidential;
import org.checkerframework.checker.confidential.qual.PolyConfidential;
import org.checkerframework.checker.initialization.qual.UnknownInitialization;
import org.checkerframework.checker.interning.qual.UsesObjectEquals;
import org.checkerframework.checker.lock.qual.GuardSatisfied;
Expand Down Expand Up @@ -119,7 +121,7 @@
* @jls 11.2 Compile-Time Checking of Exceptions
* @since 1.0
*/
@AnnotatedFor({"interning", "lock", "nullness"})
@AnnotatedFor({"interning", "lock", "nullness", "confidential"})
public @UsesObjectEquals class Throwable implements Serializable {
/** use serialVersionUID from JDK 1.0.2 for interoperability */
@java.io.Serial
Expand Down Expand Up @@ -394,7 +396,8 @@ protected Throwable(@Nullable String message, @Nullable Throwable cause,
* (which may be {@code null}).
*/
@Pure
public @Nullable String getMessage(@GuardSatisfied Throwable this) {
// TODO: The type should be @Poly. Change it later.
public @Nullable @NonConfidential String getMessage(@PolyConfidential @GuardSatisfied Throwable this) {
return detailMessage;
}

Expand Down
Loading
Loading