Skip to content

Commit d0101b8

Browse files
committed
Merge commit '3272c8497ba4c364c49c253095423d495207a6a6' of https://github.com/typetools/jdk into typetools-3.38.0-fixes
2 parents 11a1c44 + 3272c84 commit d0101b8

File tree

10 files changed

+44
-38
lines changed

10 files changed

+44
-38
lines changed

src/java.base/share/classes/java/lang/Byte.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private ByteCache() {}
166166
@Pure
167167
@StaticallyExecutable
168168
@IntrinsicCandidate
169-
public static @Interned @NewObject @PolyIndex @PolyValue @PolySigned Byte valueOf(@PolyIndex @PolyValue @PolySigned byte b) {
169+
public static @Interned @NewObject @PolyIndex @PolySigned @PolyValue Byte valueOf(@PolyIndex @PolySigned @PolyValue byte b) {
170170
final int offset = 128;
171171
return ByteCache.cache[(int)b + offset];
172172
}
@@ -380,7 +380,7 @@ public static byte parseByte(String s) throws NumberFormatException {
380380
*/
381381
@StaticallyExecutable
382382
@Deprecated(since="9", forRemoval = true)
383-
public @PolyIndex @PolyValue @PolySigned Byte(@PolyIndex @PolyValue @PolySigned byte value) {
383+
public @PolyIndex @PolySigned @PolyValue Byte(@PolyIndex @PolySigned @PolyValue byte value) {
384384
this.value = value;
385385
}
386386

@@ -415,7 +415,7 @@ public Byte(String s) throws NumberFormatException {
415415
@Pure
416416
@StaticallyExecutable
417417
@IntrinsicCandidate
418-
public @PolyIndex @PolyValue @PolySigned byte byteValue(@PolyIndex @PolyValue @PolySigned Byte this) {
418+
public @PolyIndex @PolySigned @PolyValue byte byteValue(@PolyIndex @PolySigned @PolyValue Byte this) {
419419
return value;
420420
}
421421

@@ -426,7 +426,7 @@ public Byte(String s) throws NumberFormatException {
426426
*/
427427
@Pure
428428
@StaticallyExecutable
429-
public @PolyIndex @PolyValue @PolySigned short shortValue(@PolyIndex @PolyValue @PolySigned Byte this) {
429+
public @PolyIndex @PolySigned @PolyValue short shortValue(@PolyIndex @PolySigned @PolyValue Byte this) {
430430
return (short)value;
431431
}
432432

@@ -437,7 +437,7 @@ public Byte(String s) throws NumberFormatException {
437437
*/
438438
@Pure
439439
@StaticallyExecutable
440-
public @PolyIndex @PolyValue @PolySigned int intValue(@PolyIndex @PolyValue @PolySigned Byte this) {
440+
public @PolyIndex @PolySigned @PolyValue int intValue(@PolyIndex @PolySigned @PolyValue Byte this) {
441441
return (int)value;
442442
}
443443

@@ -448,7 +448,7 @@ public Byte(String s) throws NumberFormatException {
448448
*/
449449
@Pure
450450
@StaticallyExecutable
451-
public @PolyIndex @PolyValue @PolySigned long longValue(@PolyIndex @PolyValue @PolySigned Byte this) {
451+
public @PolyIndex @PolySigned @PolyValue long longValue(@PolyIndex @PolySigned @PolyValue Byte this) {
452452
return (long)value;
453453
}
454454

src/java.base/share/classes/java/lang/Class.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.checkerframework.checker.signature.qual.ClassGetName;
3737
import org.checkerframework.checker.signature.qual.ClassGetSimpleName;
3838
import org.checkerframework.checker.signature.qual.DotSeparatedIdentifiers;
39+
import org.checkerframework.checker.signedness.qual.Signed;
3940
import org.checkerframework.common.reflection.qual.ForName;
4041
import org.checkerframework.common.reflection.qual.GetConstructor;
4142
import org.checkerframework.common.reflection.qual.GetMethod;
@@ -3947,7 +3948,7 @@ public Void run() {
39473948
*/
39483949
@SuppressWarnings("unchecked")
39493950
@IntrinsicCandidate
3950-
public @PolyNull T cast(@PolyNull Object obj) {
3951+
public @PolyNull @Signed T cast(@PolyNull Object obj) {
39513952
if (obj != null && !isInstance(obj))
39523953
throw new ClassCastException(cannotCastMsg(obj));
39533954
return (T) obj;

src/java.base/share/classes/java/lang/Enum.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@
2727

2828
import org.checkerframework.checker.index.qual.NonNegative;
2929
import org.checkerframework.checker.initialization.qual.UnknownInitialization;
30+
import org.checkerframework.checker.nullness.qual.UnknownKeyFor;
3031
import org.checkerframework.checker.lock.qual.GuardSatisfied;
3132
import org.checkerframework.checker.lock.qual.GuardedByUnknown;
3233
import org.checkerframework.checker.nullness.qual.Nullable;
34+
import org.checkerframework.checker.tainting.qual.Tainted;
3335
import org.checkerframework.common.value.qual.PolyValue;
3436
import org.checkerframework.dataflow.qual.Pure;
3537
import org.checkerframework.dataflow.qual.SideEffectFree;
3638
import org.checkerframework.framework.qual.AnnotatedFor;
39+
import org.checkerframework.framework.qual.Covariant;
3740

3841
import java.io.IOException;
3942
import java.io.InvalidObjectException;
@@ -80,7 +83,8 @@
8083
* @jls 8.9.3 Enum Members
8184
* @since 1.5
8285
*/
83-
@AnnotatedFor({"lock", "nullness", "index", "value"})
86+
@AnnotatedFor({"lock", "nullness", "index", "value", "tainting"})
87+
@Covariant(0)
8488
@SuppressWarnings("serial") // No serialVersionUID needed due to
8589
// special-casing of enum classes.
8690
public abstract class Enum<E extends Enum<E>>
@@ -208,7 +212,7 @@ protected final Object clone(@GuardSatisfied Enum<E> this) throws CloneNotSuppor
208212
* method is the order in which the constants are declared.
209213
*/
210214
@SuppressWarnings({"rawtypes"})
211-
public final int compareTo(E o) {
215+
public final int compareTo(@UnknownKeyFor @Tainted E o) {
212216
Enum<?> other = (Enum<?>)o;
213217
Enum<E> self = this;
214218
if (self.getClass() != other.getClass() && // optimization
@@ -230,7 +234,7 @@ public final int compareTo(E o) {
230234
* enum type
231235
*/
232236
@SuppressWarnings("unchecked")
233-
public final Class<E> getDeclaringClass() {
237+
public final Class<@Tainted E> getDeclaringClass() {
234238
Class<?> clazz = getClass();
235239
Class<?> zuper = clazz.getSuperclass();
236240
return (zuper == Enum.class) ? (Class<E>)clazz : (Class<E>)zuper;

src/java.base/share/classes/java/lang/Integer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ private IntegerCache() {}
11341134
@SideEffectFree
11351135
@StaticallyExecutable
11361136
@IntrinsicCandidate
1137-
public static @NewObject @PolyIndex @PolyValue @PolySigned Integer valueOf(@PolyIndex @PolyValue @PolySigned int i) {
1137+
public static @NewObject @PolyIndex @PolySigned @PolyValue Integer valueOf(@PolyIndex @PolySigned @PolyValue int i) {
11381138
if (i >= IntegerCache.low && i <= IntegerCache.high)
11391139
return IntegerCache.cache[i + (-IntegerCache.low)];
11401140
return new Integer(i);
@@ -1162,7 +1162,7 @@ private IntegerCache() {}
11621162
@SideEffectFree
11631163
@StaticallyExecutable
11641164
@Deprecated(since="9", forRemoval = true)
1165-
public @PolyIndex @PolyValue @PolySigned Integer(@PolyIndex @PolyValue @PolySigned int value) {
1165+
public @PolyIndex @PolySigned @PolyValue Integer(@PolyIndex @PolySigned @PolyValue int value) {
11661166
this.value = value;
11671167
}
11681168

@@ -1219,7 +1219,7 @@ public Integer(String s) throws NumberFormatException {
12191219
@Pure
12201220
@StaticallyExecutable
12211221
@IntrinsicCandidate
1222-
public @PolyIndex @PolyValue @PolySigned int intValue(@PolyIndex @PolyValue @PolySigned Integer this) {
1222+
public @PolyIndex @PolySigned @PolyValue int intValue(@PolyIndex @PolySigned @PolyValue Integer this) {
12231223
return value;
12241224
}
12251225

@@ -1231,7 +1231,7 @@ public Integer(String s) throws NumberFormatException {
12311231
*/
12321232
@Pure
12331233
@StaticallyExecutable
1234-
public @PolyIndex @PolyValue @PolySigned long longValue(@PolyIndex @PolyValue @PolySigned Integer this) {
1234+
public @PolyIndex @PolySigned @PolyValue long longValue(@PolyIndex @PolySigned @PolyValue Integer this) {
12351235
return (long)value;
12361236
}
12371237

src/java.base/share/classes/java/lang/Long.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ private LongCache() {}
12581258
@SideEffectFree
12591259
@StaticallyExecutable
12601260
@IntrinsicCandidate
1261-
public static @NewObject @PolyValue @PolySigned Long valueOf(@PolyValue @PolySigned long l) {
1261+
public static @NewObject @PolySigned @PolyValue Long valueOf(@PolySigned @PolyValue long l) {
12621262
final int offset = 128;
12631263
if (l >= -128 && l <= 127) { // will cache
12641264
return LongCache.cache[(int)l + offset];
@@ -1380,7 +1380,7 @@ else if (nm.startsWith("0", index) && nm.length() > 1 + index) {
13801380
@SideEffectFree
13811381
@StaticallyExecutable
13821382
@Deprecated(since="9", forRemoval = true)
1383-
public @PolyIndex @PolyValue @PolySigned Long(@PolyIndex @PolyValue @PolySigned long value) {
1383+
public @PolyIndex @PolySigned @PolyValue Long(@PolyIndex @PolySigned @PolyValue long value) {
13841384
this.value = value;
13851385
}
13861386

@@ -1449,7 +1449,7 @@ public Long(String s) throws NumberFormatException {
14491449
@Pure
14501450
@StaticallyExecutable
14511451
@IntrinsicCandidate
1452-
public @PolyIndex @PolyValue @PolySigned long longValue(@PolyIndex @PolyValue @PolySigned Long this) {
1452+
public @PolyIndex @PolySigned @PolyValue long longValue(@PolyIndex @PolySigned @PolyValue Long this) {
14531453
return value;
14541454
}
14551455

src/java.base/share/classes/java/lang/Short.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ private ShortCache() {}
302302
@SideEffectFree
303303
@StaticallyExecutable
304304
@IntrinsicCandidate
305-
public static @NewObject @PolyIndex @PolyValue @PolySigned Short valueOf(@PolyIndex @PolyValue @PolySigned short s) {
305+
public static @NewObject @PolyIndex @PolySigned @PolyValue Short valueOf(@PolyIndex @PolySigned @PolyValue short s) {
306306
final int offset = 128;
307307
int sAsInt = s;
308308
if (sAsInt >= -128 && sAsInt <= 127) { // must cache
@@ -385,7 +385,7 @@ private ShortCache() {}
385385
@SideEffectFree
386386
@StaticallyExecutable
387387
@Deprecated(since="9", forRemoval = true)
388-
public @PolyIndex @PolyValue @PolySigned Short(@PolyIndex @PolyValue @PolySigned short value) {
388+
public @PolyIndex @PolySigned @PolyValue Short(@PolyIndex @PolySigned @PolyValue short value) {
389389
this.value = value;
390390
}
391391

@@ -432,7 +432,7 @@ public Short(String s) throws NumberFormatException {
432432
@Pure
433433
@StaticallyExecutable
434434
@IntrinsicCandidate
435-
public @PolyIndex @PolyValue @PolySigned short shortValue(@PolyIndex @PolyValue @PolySigned Short this) {
435+
public @PolyIndex @PolySigned @PolyValue short shortValue(@PolyIndex @PolySigned @PolyValue Short this) {
436436
return value;
437437
}
438438

@@ -443,7 +443,7 @@ public Short(String s) throws NumberFormatException {
443443
*/
444444
@Pure
445445
@StaticallyExecutable
446-
public @PolyIndex @PolyValue @PolySigned int intValue(@PolyIndex @PolyValue @PolySigned Short this) {
446+
public @PolyIndex @PolySigned @PolyValue int intValue(@PolyIndex @PolySigned @PolyValue Short this) {
447447
return (int)value;
448448
}
449449

@@ -454,7 +454,7 @@ public Short(String s) throws NumberFormatException {
454454
*/
455455
@Pure
456456
@StaticallyExecutable
457-
public @PolyIndex @PolyValue @PolySigned long longValue(@PolyIndex @PolyValue @PolySigned Short this) {
457+
public @PolyIndex @PolySigned @PolyValue long longValue(@PolyIndex @PolySigned @PolyValue Short this) {
458458
return (long)value;
459459
}
460460

src/java.base/share/classes/java/lang/String.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.checkerframework.checker.regex.qual.Regex;
4646
import org.checkerframework.checker.signature.qual.PolySignature;
4747
import org.checkerframework.checker.signedness.qual.PolySigned;
48+
import org.checkerframework.common.aliasing.qual.Unique;
4849
import org.checkerframework.common.value.qual.ArrayLen;
4950
import org.checkerframework.common.value.qual.ArrayLenRange;
5051
import org.checkerframework.common.value.qual.EnsuresMinLenIf;
@@ -56,7 +57,6 @@
5657
import org.checkerframework.dataflow.qual.SideEffectFree;
5758
import org.checkerframework.framework.qual.AnnotatedFor;
5859
import org.checkerframework.framework.qual.CFComment;
59-
import org.checkerframework.common.aliasing.qual.Unique;
6060

6161
import java.io.ObjectStreamField;
6262
import java.io.UnsupportedEncodingException;
@@ -4603,7 +4603,7 @@ public static String copyValueOf(char data @GuardSatisfied [], @IndexOrHigh({"#1
46034603
*/
46044604
@Pure
46054605
@StaticallyExecutable
4606-
public native @Interned @SameLen({"this"}) @PolySignature @PolyRegex @PolyValue String intern(@PolySignature @PolyRegex @PolyValue String this);
4606+
public native @Interned @SameLen({"this"}) @PolyRegex @PolySignature @PolyValue String intern(@PolyRegex @PolySignature @PolyValue String this);
46074607

46084608
/**
46094609
* Returns a string whose value is the concatenation of this

src/java.base/share/classes/java/util/Arrays.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2994,7 +2994,7 @@ public static boolean equals(float[] a, int aFromIndex, int aToIndex,
29942994
* @return {@code true} if the two arrays are equal
29952995
*/
29962996
@Pure
2997-
public static boolean equals(@PolyNull @PolySigned @PolyInterned Object @GuardSatisfied @Nullable [] a, @PolyNull @PolySigned @PolyInterned Object @GuardSatisfied @Nullable [] a2) {
2997+
public static boolean equals(@PolyInterned @PolyNull @PolySigned Object @GuardSatisfied @Nullable [] a, @PolyInterned @PolyNull @PolySigned Object @GuardSatisfied @Nullable [] a2) {
29982998
if (a==a2)
29992999
return true;
30003000
if (a==null || a2==null)
@@ -3454,7 +3454,7 @@ public static void fill(float[] a, @IndexOrHigh({"#1"}) int fromIndex, @IndexOrH
34543454
* @throws ArrayStoreException if the specified value is not of a
34553455
* runtime type that can be stored in the specified array
34563456
*/
3457-
public static void fill(@PolyNull @PolySigned @PolyInterned Object[] a, @PolyNull @PolySigned @PolyInterned Object val) {
3457+
public static void fill(@PolyInterned @PolyNull @PolySigned Object[] a, @PolyInterned @PolyNull @PolySigned Object val) {
34583458
for (int i = 0, len = a.length; i < len; i++)
34593459
a[i] = val;
34603460
}
@@ -3478,7 +3478,7 @@ public static void fill(@PolyNull @PolySigned @PolyInterned Object[] a, @PolyNul
34783478
* @throws ArrayStoreException if the specified value is not of a
34793479
* runtime type that can be stored in the specified array
34803480
*/
3481-
public static void fill(@PolyNull @PolySigned @PolyInterned Object[] a, @IndexOrHigh({"#1"}) int fromIndex, @IndexOrHigh({"#1"}) int toIndex, @PolyNull @PolySigned @PolyInterned Object val) {
3481+
public static void fill(@PolyInterned @PolyNull @PolySigned Object[] a, @IndexOrHigh({"#1"}) int fromIndex, @IndexOrHigh({"#1"}) int toIndex, @PolyInterned @PolyNull @PolySigned Object val) {
34823482
rangeCheck(a.length, fromIndex, toIndex);
34833483
for (int i = fromIndex; i < toIndex; i++)
34843484
a[i] = val;
@@ -4552,7 +4552,7 @@ public static int hashCode(double a @Nullable []) {
45524552
* @since 1.5
45534553
*/
45544554
@Pure
4555-
public static int hashCode(@PolyNull @PolySigned @PolyInterned Object a @GuardSatisfied @Nullable []) {
4555+
public static int hashCode(@PolyInterned @PolyNull @PolySigned Object a @GuardSatisfied @Nullable []) {
45564556
if (a == null)
45574557
return 0;
45584558

@@ -4594,7 +4594,7 @@ public static int hashCode(@PolyNull @PolySigned @PolyInterned Object a @GuardSa
45944594
* @since 1.5
45954595
*/
45964596
@Pure
4597-
public static int deepHashCode(@PolyNull @PolySigned @PolyInterned Object a @GuardSatisfied @Nullable []) {
4597+
public static int deepHashCode(@PolyInterned @PolyNull @PolySigned Object a @GuardSatisfied @Nullable []) {
45984598
if (a == null)
45994599
return 0;
46004600

@@ -4668,7 +4668,7 @@ private static int primitiveArrayHashCode(Object a, Class<?> cl) {
46684668
* @since 1.5
46694669
*/
46704670
@Pure
4671-
public static boolean deepEquals(@PolyNull @PolySigned @PolyInterned Object @GuardSatisfied @Nullable [] a1, @PolyNull @PolySigned @PolyInterned Object @GuardSatisfied @Nullable [] a2) {
4671+
public static boolean deepEquals(@PolyInterned @PolyNull @PolySigned Object @GuardSatisfied @Nullable [] a1, @PolyInterned @PolyNull @PolySigned Object @GuardSatisfied @Nullable [] a2) {
46724672
if (a1 == a2)
46734673
return true;
46744674
if (a1 == null || a2==null)
@@ -4990,7 +4990,7 @@ else if (e1 instanceof boolean[] && e2 instanceof boolean[])
49904990
@CFComment({"The @PolyMustCall annotations don't make sense, because toString",
49914991
"shouldn't care about MustCall types, especially of the array. However,",
49924992
"without these annotations, calls to Arrays.toString yield a MustCall error."})
4993-
public static @MinLen(2) String toString(@PolyMustCall @PolyNull @PolySigned @PolyInterned Object @PolyMustCall @Nullable [] a) {
4993+
public static @MinLen(2) String toString(@PolyInterned @PolyMustCall @PolyNull @PolySigned Object @PolyMustCall @Nullable [] a) {
49944994
if (a == null)
49954995
return "null";
49964996

@@ -5042,7 +5042,7 @@ else if (e1 instanceof boolean[] && e2 instanceof boolean[])
50425042
* @since 1.5
50435043
*/
50445044
@SideEffectFree
5045-
public static @MinLen(2) String deepToString(@PolyMustCall @PolyNull @PolySigned @PolyInterned Object @PolyMustCall @Nullable [] a) {
5045+
public static @MinLen(2) String deepToString(@PolyInterned @PolyMustCall @PolyNull @PolySigned Object @PolyMustCall @Nullable [] a) {
50465046
if (a == null)
50475047
return "null";
50485048

src/java.base/share/classes/java/util/List.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.checkerframework.checker.lock.qual.ReleasesNoLocks;
3434
import org.checkerframework.checker.nullness.qual.Nullable;
3535
import org.checkerframework.checker.nullness.qual.PolyNull;
36+
import org.checkerframework.checker.signedness.qual.PolySigned;
3637
import org.checkerframework.checker.signedness.qual.UnknownSignedness;
3738
import org.checkerframework.dataflow.qual.Pure;
3839
import org.checkerframework.dataflow.qual.SideEffectFree;
@@ -219,7 +220,7 @@ public interface List<E> extends Collection<E> {
219220
* @see Arrays#asList(Object[])
220221
*/
221222
@SideEffectFree
222-
@PolyNull Object[] toArray(List<@PolyNull E> this);
223+
@PolyNull @PolySigned Object[] toArray(List<@PolyNull @PolySigned E> this);
223224

224225
/**
225226
* Returns an array containing all of the elements in this list in
@@ -261,7 +262,7 @@ public interface List<E> extends Collection<E> {
261262
* @throws NullPointerException if the specified array is null
262263
*/
263264
@SideEffectFree
264-
<T> @Nullable T[] toArray(@PolyNull T[] a);
265+
<T extends @UnknownSignedness Object> @Nullable T[] toArray(@PolyNull T[] a);
265266

266267

267268
// Modification Operations

src/java.base/share/classes/java/util/stream/Stream.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
288288
* @return the new stream
289289
* @see #mapMulti
290290
*/
291-
<R> Stream<R> flatMap(Function<? super T, ? extends Stream<? extends R>> mapper);
291+
<R> Stream<R> flatMap(Function<? super T, ? extends @Nullable Stream<? extends R>> mapper);
292292

293293
/**
294294
* Returns an {@code IntStream} consisting of the results of replacing each
@@ -308,7 +308,7 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
308308
* @return the new stream
309309
* @see #flatMap(Function)
310310
*/
311-
IntStream flatMapToInt(Function<? super T, ? extends IntStream> mapper);
311+
IntStream flatMapToInt(Function<? super T, ? extends @Nullable IntStream> mapper);
312312

313313
/**
314314
* Returns an {@code LongStream} consisting of the results of replacing each
@@ -328,7 +328,7 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
328328
* @return the new stream
329329
* @see #flatMap(Function)
330330
*/
331-
LongStream flatMapToLong(Function<? super T, ? extends LongStream> mapper);
331+
LongStream flatMapToLong(Function<? super T, ? extends @Nullable LongStream> mapper);
332332

333333
/**
334334
* Returns an {@code DoubleStream} consisting of the results of replacing
@@ -348,7 +348,7 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
348348
* @return the new stream
349349
* @see #flatMap(Function)
350350
*/
351-
DoubleStream flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper);
351+
DoubleStream flatMapToDouble(Function<? super T, ? extends @Nullable DoubleStream> mapper);
352352

353353
// THE EXAMPLES USED IN THE JAVADOC MUST BE IN SYNC WITH THEIR CORRESPONDING
354354
// TEST IN test/jdk/java/util/stream/examples/JavadocExamples.java.

0 commit comments

Comments
 (0)