Skip to content

Commit

Permalink
8295555: Primitive wrapper caches could be @Stable
Browse files Browse the repository at this point in the history
Reviewed-by: rriggs
  • Loading branch information
minborg committed Jun 13, 2023
1 parent 5d71612 commit f7de726
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/java.base/share/classes/java/lang/Byte.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

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;
Expand Down Expand Up @@ -105,9 +106,10 @@ public Optional<DynamicConstantDesc<Byte>> describeConstable() {
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;

Expand Down
4 changes: 3 additions & 1 deletion src/java.base/share/classes/java/lang/Character.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

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;
Expand Down Expand Up @@ -8956,9 +8957,10 @@ public Character(char value) {
this.value = value;
}

private static class CharacterCache {
private static final class CharacterCache {
private CharacterCache(){}

@Stable
static final Character[] cache;
static Character[] archivedCache;

Expand Down
5 changes: 4 additions & 1 deletion src/java.base/share/classes/java/lang/Integer.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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;
Expand Down Expand Up @@ -1005,9 +1006,11 @@ public static Integer valueOf(String s) throws NumberFormatException {
* 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;

Expand Down
4 changes: 3 additions & 1 deletion src/java.base/share/classes/java/lang/Long.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
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;
Expand Down Expand Up @@ -1156,9 +1157,10 @@ public static Long valueOf(String s) throws NumberFormatException
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;

Expand Down
4 changes: 3 additions & 1 deletion src/java.base/share/classes/java/lang/Short.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

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;
Expand Down Expand Up @@ -231,9 +232,10 @@ public Optional<DynamicConstantDesc<Short>> describeConstable() {
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;

Expand Down

1 comment on commit f7de726

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.