< prev index next >

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

Print this page
*** 59,21 ***
   */
  @jdk.internal.ValueBased
  public final class Boolean implements java.io.Serializable,
                                        Comparable<Boolean>, Constable
  {
      /**
       * The {@code Boolean} object corresponding to the primitive
       * value {@code true}.
       */
!     public static final Boolean TRUE = new Boolean(true);
  
      /**
       * The {@code Boolean} object corresponding to the primitive
       * value {@code false}.
       */
!     public static final Boolean FALSE = new Boolean(false);
  
      /**
       * The Class object representing the primitive type boolean.
       *
       * @since   1.1
--- 59,28 ---
   */
  @jdk.internal.ValueBased
  public final class Boolean implements java.io.Serializable,
                                        Comparable<Boolean>, Constable
  {
+     // AOT cache support - there are references to these fields by other cached Java objects. We need
+     // to preserve their identity across AOT cache assembly phase and production runs.
+     static class AOTHolder {
+         private static final Boolean TRUE  = new Boolean(true);
+         private static final Boolean FALSE = new Boolean(false);
+     }
+ 
      /**
       * The {@code Boolean} object corresponding to the primitive
       * value {@code true}.
       */
!     public static final Boolean TRUE = AOTHolder.TRUE;
  
      /**
       * The {@code Boolean} object corresponding to the primitive
       * value {@code false}.
       */
!     public static final Boolean FALSE = AOTHolder.FALSE;
  
      /**
       * The Class object representing the primitive type boolean.
       *
       * @since   1.1
< prev index next >