< prev index next >

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

Print this page
*** 26,10 ***
--- 26,11 ---
  package java.lang;
  
  import jdk.internal.misc.CDS;
  import jdk.internal.misc.VM;
  import jdk.internal.util.DecimalDigits;
+ import jdk.internal.value.DeserializeConstructor;
  import jdk.internal.vm.annotation.ForceInline;
  import jdk.internal.vm.annotation.IntrinsicCandidate;
  import jdk.internal.vm.annotation.Stable;
  
  import java.lang.annotation.Native;

*** 54,14 ***
   * an {@code int} to a {@code String} and a {@code String} to an
   * {@code int}, as well as other constants and methods useful when
   * dealing with an {@code int}.
   *
   * <p>This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
!  * class; programmers should treat instances that are
!  * {@linkplain #equals(Object) equal} as interchangeable and should not
!  * use instances for synchronization, or unpredictable behavior may
!  * occur. For example, in a future release, synchronization may fail.
   *
   * <p>Implementation note: The implementations of the "bit twiddling"
   * methods (such as {@link #highestOneBit(int) highestOneBit} and
   * {@link #numberOfTrailingZeros(int) numberOfTrailingZeros}) are
   * based on material from Henry S. Warren, Jr.'s <cite>Hacker's
--- 55,22 ---
   * an {@code int} to a {@code String} and a {@code String} to an
   * {@code int}, as well as other constants and methods useful when
   * dealing with an {@code int}.
   *
   * <p>This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
!  * class; programmers should treat instances that are {@linkplain #equals(Object) equal}
!  * as interchangeable and should not use instances for synchronization, mutexes, or
!  * with {@linkplain java.lang.ref.Reference object references}.
!  *
+  * <div class="preview-block">
+  *      <div class="preview-comment">
+  *          When preview features are enabled, {@code Integer} is a {@linkplain Class#isValue value class}.
+  *          Use of value class instances for synchronization, mutexes, or with
+  *          {@linkplain java.lang.ref.Reference object references} result in
+  *          {@link IdentityException}.
+  *      </div>
+  * </div>
   *
   * <p>Implementation note: The implementations of the "bit twiddling"
   * methods (such as {@link #highestOneBit(int) highestOneBit} and
   * {@link #numberOfTrailingZeros(int) numberOfTrailingZeros}) are
   * based on material from Henry S. Warren, Jr.'s <cite>Hacker's

*** 72,10 ***
--- 81,11 ---
   * @author  Arthur van Hoff
   * @author  Josh Bloch
   * @author  Joseph D. Darcy
   * @since 1.0
   */
+ @jdk.internal.MigratedValueClass
  @jdk.internal.ValueBased
  public final class Integer extends Number
          implements Comparable<Integer>, Constable, ConstantDesc {
      /**
       * A constant holding the minimum value an {@code int} can

*** 997,10 ***
--- 1007,11 ---
       * @param  i an {@code int} value.
       * @return an {@code Integer} instance representing {@code i}.
       * @since  1.5
       */
      @IntrinsicCandidate
+     @DeserializeConstructor
      public static Integer valueOf(int i) {
          if (i >= IntegerCache.low && i <= IntegerCache.high)
              return IntegerCache.cache[i + (-IntegerCache.low)];
          return new Integer(i);
      }
< prev index next >