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.misc.CDS;
import jdk.internal.vm.annotation.IntrinsicCandidate; import jdk.internal.vm.annotation.IntrinsicCandidate;
import jdk.internal.vm.annotation.Stable;
import java.lang.constant.Constable; import java.lang.constant.Constable;
import java.lang.constant.DynamicConstantDesc; 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())); return Optional.of(DynamicConstantDesc.ofNamed(BSM_EXPLICIT_CAST, DEFAULT_NAME, CD_byte, intValue()));
} }
private static class ByteCache { private static final class ByteCache {
private ByteCache() {} private ByteCache() {}
@Stable
static final Byte[] cache; static final Byte[] cache;
static Byte[] archivedCache; static Byte[] archivedCache;

View file

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

View file

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

View file

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

View file

@ -27,6 +27,7 @@ package java.lang;
import jdk.internal.misc.CDS; import jdk.internal.misc.CDS;
import jdk.internal.vm.annotation.IntrinsicCandidate; import jdk.internal.vm.annotation.IntrinsicCandidate;
import jdk.internal.vm.annotation.Stable;
import java.lang.constant.Constable; import java.lang.constant.Constable;
import java.lang.constant.DynamicConstantDesc; 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())); return Optional.of(DynamicConstantDesc.ofNamed(BSM_EXPLICIT_CAST, DEFAULT_NAME, CD_short, intValue()));
} }
private static class ShortCache { private static final class ShortCache {
private ShortCache() {} private ShortCache() {}
@Stable
static final Short[] cache; static final Short[] cache;
static Short[] archivedCache; static Short[] archivedCache;