src/java.base/share/classes/java/lang/String.java
changeset 57956 e0b8b019d2f5
parent 57783 a0257f1458aa
child 58109 ee07de0d2c16
child 58242 94bb65cb37d3
equal deleted inserted replaced
57955:18863bf3501f 57956:e0b8b019d2f5
   170      * us to avoid recalculating this.
   170      * us to avoid recalculating this.
   171      */
   171      */
   172     private boolean hashIsZero; // Default to false;
   172     private boolean hashIsZero; // Default to false;
   173 
   173 
   174     /** use serialVersionUID from JDK 1.0.2 for interoperability */
   174     /** use serialVersionUID from JDK 1.0.2 for interoperability */
       
   175     @java.io.Serial
   175     private static final long serialVersionUID = -6849794470754667710L;
   176     private static final long serialVersionUID = -6849794470754667710L;
   176 
   177 
   177     /**
   178     /**
   178      * If String compaction is disabled, the bytes in {@code value} are
   179      * If String compaction is disabled, the bytes in {@code value} are
   179      * always encoded in UTF16.
   180      * always encoded in UTF16.
   222      *
   223      *
   223      * A String instance is written into an ObjectOutputStream according to
   224      * A String instance is written into an ObjectOutputStream according to
   224      * <a href="{@docRoot}/../specs/serialization/protocol.html#stream-elements">
   225      * <a href="{@docRoot}/../specs/serialization/protocol.html#stream-elements">
   225      * Object Serialization Specification, Section 6.2, "Stream Elements"</a>
   226      * Object Serialization Specification, Section 6.2, "Stream Elements"</a>
   226      */
   227      */
       
   228     @java.io.Serial
   227     private static final ObjectStreamField[] serialPersistentFields =
   229     private static final ObjectStreamField[] serialPersistentFields =
   228         new ObjectStreamField[0];
   230         new ObjectStreamField[0];
   229 
   231 
   230     /**
   232     /**
   231      * Initializes a newly created {@code String} object so that it represents
   233      * Initializes a newly created {@code String} object so that it represents
  1233     public static final Comparator<String> CASE_INSENSITIVE_ORDER
  1235     public static final Comparator<String> CASE_INSENSITIVE_ORDER
  1234                                          = new CaseInsensitiveComparator();
  1236                                          = new CaseInsensitiveComparator();
  1235     private static class CaseInsensitiveComparator
  1237     private static class CaseInsensitiveComparator
  1236             implements Comparator<String>, java.io.Serializable {
  1238             implements Comparator<String>, java.io.Serializable {
  1237         // use serialVersionUID from JDK 1.2.2 for interoperability
  1239         // use serialVersionUID from JDK 1.2.2 for interoperability
       
  1240         @java.io.Serial
  1238         private static final long serialVersionUID = 8575799808933029326L;
  1241         private static final long serialVersionUID = 8575799808933029326L;
  1239 
  1242 
  1240         public int compare(String s1, String s2) {
  1243         public int compare(String s1, String s2) {
  1241             byte v1[] = s1.value;
  1244             byte v1[] = s1.value;
  1242             byte v2[] = s2.value;
  1245             byte v2[] = s2.value;
  1248             return coder == LATIN1 ? StringLatin1.compareToCI_UTF16(v1, v2)
  1251             return coder == LATIN1 ? StringLatin1.compareToCI_UTF16(v1, v2)
  1249                                    : StringUTF16.compareToCI_Latin1(v1, v2);
  1252                                    : StringUTF16.compareToCI_Latin1(v1, v2);
  1250         }
  1253         }
  1251 
  1254 
  1252         /** Replaces the de-serialized object. */
  1255         /** Replaces the de-serialized object. */
       
  1256         @java.io.Serial
  1253         private Object readResolve() { return CASE_INSENSITIVE_ORDER; }
  1257         private Object readResolve() { return CASE_INSENSITIVE_ORDER; }
  1254     }
  1258     }
  1255 
  1259 
  1256     /**
  1260     /**
  1257      * Compares two strings lexicographically, ignoring case
  1261      * Compares two strings lexicographically, ignoring case