< prev index next >

src/java.base/share/classes/java/net/InetAddress.java

Print this page




1713         if (getClass().getClassLoader() != null) {
1714             throw new SecurityException ("invalid address type");
1715         }
1716     }
1717 
1718     private static final jdk.internal.misc.Unsafe UNSAFE
1719             = jdk.internal.misc.Unsafe.getUnsafe();
1720     private static final long FIELDS_OFFSET
1721             = UNSAFE.objectFieldOffset(InetAddress.class, "holder");
1722 
1723     private void readObject (ObjectInputStream s) throws
1724                          IOException, ClassNotFoundException {
1725         if (getClass().getClassLoader() != null) {
1726             throw new SecurityException ("invalid address type");
1727         }
1728         GetField gf = s.readFields();
1729         String host = (String)gf.get("hostName", null);
1730         int address= gf.get("address", 0);
1731         int family= gf.get("family", 0);
1732         InetAddressHolder h = new InetAddressHolder(host, address, family);
1733         UNSAFE.putObject(this, FIELDS_OFFSET, h);
1734     }
1735 
1736     /* needed because the serializable fields no longer exist */
1737 
1738     /**
1739      * @serialField hostName String
1740      * @serialField address int
1741      * @serialField family int
1742      */
1743     private static final ObjectStreamField[] serialPersistentFields = {
1744         new ObjectStreamField("hostName", String.class),
1745         new ObjectStreamField("address", int.class),
1746         new ObjectStreamField("family", int.class),
1747     };
1748 
1749     private void writeObject (ObjectOutputStream s) throws
1750                         IOException {
1751         if (getClass().getClassLoader() != null) {
1752             throw new SecurityException ("invalid address type");
1753         }


1713         if (getClass().getClassLoader() != null) {
1714             throw new SecurityException ("invalid address type");
1715         }
1716     }
1717 
1718     private static final jdk.internal.misc.Unsafe UNSAFE
1719             = jdk.internal.misc.Unsafe.getUnsafe();
1720     private static final long FIELDS_OFFSET
1721             = UNSAFE.objectFieldOffset(InetAddress.class, "holder");
1722 
1723     private void readObject (ObjectInputStream s) throws
1724                          IOException, ClassNotFoundException {
1725         if (getClass().getClassLoader() != null) {
1726             throw new SecurityException ("invalid address type");
1727         }
1728         GetField gf = s.readFields();
1729         String host = (String)gf.get("hostName", null);
1730         int address= gf.get("address", 0);
1731         int family= gf.get("family", 0);
1732         InetAddressHolder h = new InetAddressHolder(host, address, family);
1733         UNSAFE.putReference(this, FIELDS_OFFSET, h);
1734     }
1735 
1736     /* needed because the serializable fields no longer exist */
1737 
1738     /**
1739      * @serialField hostName String
1740      * @serialField address int
1741      * @serialField family int
1742      */
1743     private static final ObjectStreamField[] serialPersistentFields = {
1744         new ObjectStreamField("hostName", String.class),
1745         new ObjectStreamField("address", int.class),
1746         new ObjectStreamField("family", int.class),
1747     };
1748 
1749     private void writeObject (ObjectOutputStream s) throws
1750                         IOException {
1751         if (getClass().getClassLoader() != null) {
1752             throw new SecurityException ("invalid address type");
1753         }
< prev index next >