8295555: Primitive wrapper caches could be @Stable

Reviewed-by: rriggs
This commit is contained in:
Per Minborg 2023-06-13 08:39:00 +00:00
parent 5d716121c1
commit f7de726bd3
5 changed files with 16 additions and 5 deletions

View File

@ -27,6 +27,7 @@ package java.lang;
import jdk.internal.misc.CDS;
import jdk.internal.vm.annotation.IntrinsicCandidate;
import jdk.internal.vm.annotation.Stable;
import java.lang.constant.Constable;
import java.lang.constant.DynamicConstantDesc;
@ -105,9 +106,10 @@ public final class Byte extends Number implements Comparable<Byte>, Constable {
return Optional.of(DynamicConstantDesc.ofNamed(BSM_EXPLICIT_CAST, DEFAULT_NAME, CD_byte, intValue()));
}
private static class ByteCache {
private static final class ByteCache {
private ByteCache() {}
@Stable
static final Byte[] cache;
static Byte[] archivedCache;

View File

@ -27,6 +27,7 @@ package java.lang;
import jdk.internal.misc.CDS;
import jdk.internal.vm.annotation.IntrinsicCandidate;
import jdk.internal.vm.annotation.Stable;
import java.lang.constant.Constable;
import java.lang.constant.DynamicConstantDesc;
@ -8956,9 +8957,10 @@ class Character implements java.io.Serializable, Comparable<Character>, Constabl
this.value = value;
}
private static class CharacterCache {
private static final class CharacterCache {
private CharacterCache(){}
@Stable
static final Character[] cache;
static Character[] archivedCache;

View File

@ -29,6 +29,7 @@ import jdk.internal.misc.CDS;
import jdk.internal.misc.VM;
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.vm.annotation.IntrinsicCandidate;
import jdk.internal.vm.annotation.Stable;
import java.lang.annotation.Native;
import java.lang.constant.Constable;
@ -1005,9 +1006,11 @@ public final class Integer extends Number
* with new Integer object(s) after initialization.
*/
private static class IntegerCache {
private static final class IntegerCache {
static final int low = -128;
static final int high;
@Stable
static final Integer[] cache;
static Integer[] archivedCache;

View File

@ -36,6 +36,7 @@ import java.util.Optional;
import jdk.internal.misc.CDS;
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.vm.annotation.IntrinsicCandidate;
import jdk.internal.vm.annotation.Stable;
import static java.lang.String.COMPACT_STRINGS;
import static java.lang.String.LATIN1;
@ -1156,9 +1157,10 @@ public final class Long extends Number
return Long.valueOf(parseLong(s, 10));
}
private static class LongCache {
private static final class LongCache {
private LongCache() {}
@Stable
static final Long[] cache;
static Long[] archivedCache;

View File

@ -27,6 +27,7 @@ package java.lang;
import jdk.internal.misc.CDS;
import jdk.internal.vm.annotation.IntrinsicCandidate;
import jdk.internal.vm.annotation.Stable;
import java.lang.constant.Constable;
import java.lang.constant.DynamicConstantDesc;
@ -231,9 +232,10 @@ public final class Short extends Number implements Comparable<Short>, Constable
return Optional.of(DynamicConstantDesc.ofNamed(BSM_EXPLICIT_CAST, DEFAULT_NAME, CD_short, intValue()));
}
private static class ShortCache {
private static final class ShortCache {
private ShortCache() {}
@Stable
static final Short[] cache;
static Short[] archivedCache;