src/java.base/share/classes/java/net/InetAddress.java
changeset 57956 e0b8b019d2f5
parent 55693 9a97b1393e72
child 58242 94bb65cb37d3
equal deleted inserted replaced
57955:18863bf3501f 57956:e0b8b019d2f5
   297      * Lazily initialized via a data race; safe because Strings are immutable.
   297      * Lazily initialized via a data race; safe because Strings are immutable.
   298      */
   298      */
   299     private transient String canonicalHostName = null;
   299     private transient String canonicalHostName = null;
   300 
   300 
   301     /** use serialVersionUID from JDK 1.0.2 for interoperability */
   301     /** use serialVersionUID from JDK 1.0.2 for interoperability */
       
   302     @java.io.Serial
   302     private static final long serialVersionUID = 3286316764910316507L;
   303     private static final long serialVersionUID = 3286316764910316507L;
   303 
   304 
   304     /*
   305     /*
   305      * Load net library into runtime, and perform initializations.
   306      * Load net library into runtime, and perform initializations.
   306      */
   307      */
   351      * @return the alternate object to the de-serialized object.
   352      * @return the alternate object to the de-serialized object.
   352      *
   353      *
   353      * @throws ObjectStreamException if a new object replacing this
   354      * @throws ObjectStreamException if a new object replacing this
   354      * object could not be created
   355      * object could not be created
   355      */
   356      */
       
   357     @java.io.Serial
   356     private Object readResolve() throws ObjectStreamException {
   358     private Object readResolve() throws ObjectStreamException {
   357         // will replace the deserialized 'this' object
   359         // will replace the deserialized 'this' object
   358         return new Inet4Address(holder().getHostName(), holder().getAddress());
   360         return new Inet4Address(holder().getHostName(), holder().getAddress());
   359     }
   361     }
   360 
   362 
  1685         }
  1687         }
  1686 
  1688 
  1687         return (InetAddressImpl) impl;
  1689         return (InetAddressImpl) impl;
  1688     }
  1690     }
  1689 
  1691 
       
  1692     @java.io.Serial
  1690     private void readObjectNoData () {
  1693     private void readObjectNoData () {
  1691         if (getClass().getClassLoader() != null) {
  1694         if (getClass().getClassLoader() != null) {
  1692             throw new SecurityException ("invalid address type");
  1695             throw new SecurityException ("invalid address type");
  1693         }
  1696         }
  1694     }
  1697     }
  1696     private static final jdk.internal.misc.Unsafe UNSAFE
  1699     private static final jdk.internal.misc.Unsafe UNSAFE
  1697             = jdk.internal.misc.Unsafe.getUnsafe();
  1700             = jdk.internal.misc.Unsafe.getUnsafe();
  1698     private static final long FIELDS_OFFSET
  1701     private static final long FIELDS_OFFSET
  1699             = UNSAFE.objectFieldOffset(InetAddress.class, "holder");
  1702             = UNSAFE.objectFieldOffset(InetAddress.class, "holder");
  1700 
  1703 
       
  1704     @java.io.Serial
  1701     private void readObject (ObjectInputStream s) throws
  1705     private void readObject (ObjectInputStream s) throws
  1702                          IOException, ClassNotFoundException {
  1706                          IOException, ClassNotFoundException {
  1703         if (getClass().getClassLoader() != null) {
  1707         if (getClass().getClassLoader() != null) {
  1704             throw new SecurityException ("invalid address type");
  1708             throw new SecurityException ("invalid address type");
  1705         }
  1709         }
  1719     /**
  1723     /**
  1720      * @serialField hostName String
  1724      * @serialField hostName String
  1721      * @serialField address int
  1725      * @serialField address int
  1722      * @serialField family int
  1726      * @serialField family int
  1723      */
  1727      */
       
  1728     @java.io.Serial
  1724     private static final ObjectStreamField[] serialPersistentFields = {
  1729     private static final ObjectStreamField[] serialPersistentFields = {
  1725         new ObjectStreamField("hostName", String.class),
  1730         new ObjectStreamField("hostName", String.class),
  1726         new ObjectStreamField("address", int.class),
  1731         new ObjectStreamField("address", int.class),
  1727         new ObjectStreamField("family", int.class),
  1732         new ObjectStreamField("family", int.class),
  1728     };
  1733     };
  1729 
  1734 
       
  1735     @java.io.Serial
  1730     private void writeObject (ObjectOutputStream s) throws
  1736     private void writeObject (ObjectOutputStream s) throws
  1731                         IOException {
  1737                         IOException {
  1732         if (getClass().getClassLoader() != null) {
  1738         if (getClass().getClassLoader() != null) {
  1733             throw new SecurityException ("invalid address type");
  1739             throw new SecurityException ("invalid address type");
  1734         }
  1740         }