< prev index next >

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

Print this page
rev 17358 : 8182487: Add Unsafe.objectFieldOffset(Class, String)
Reviewed-by: dsimms


 563     /**
 564      * @serialField ipaddress byte[]
 565      * @serialField scope_id int
 566      * @serialField scope_id_set boolean
 567      * @serialField scope_ifname_set boolean
 568      * @serialField ifname String
 569      */
 570 
 571     private static final ObjectStreamField[] serialPersistentFields = {
 572          new ObjectStreamField("ipaddress", byte[].class),
 573          new ObjectStreamField("scope_id", int.class),
 574          new ObjectStreamField("scope_id_set", boolean.class),
 575          new ObjectStreamField("scope_ifname_set", boolean.class),
 576          new ObjectStreamField("ifname", String.class)
 577     };
 578 
 579     private static final long FIELDS_OFFSET;
 580     private static final jdk.internal.misc.Unsafe UNSAFE;
 581 
 582     static {
 583         try {
 584             jdk.internal.misc.Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe();
 585             FIELDS_OFFSET = unsafe.objectFieldOffset(
 586                     Inet6Address.class.getDeclaredField("holder6"));
 587             UNSAFE = unsafe;
 588         } catch (ReflectiveOperationException e) {
 589             throw new Error(e);
 590         }
 591     }
 592 
 593     /**
 594      * restore the state of this object from stream
 595      * including the scope information, only if the
 596      * scoped interface name is valid on this system
 597      */
 598     private void readObject(ObjectInputStream s)
 599         throws IOException, ClassNotFoundException {
 600         NetworkInterface scope_ifname = null;
 601 
 602         if (getClass().getClassLoader() != null) {
 603             throw new SecurityException ("invalid address type");
 604         }
 605 
 606         ObjectInputStream.GetField gf = s.readFields();
 607         byte[] ipaddress = (byte[])gf.get("ipaddress", null);
 608         int scope_id = gf.get("scope_id", -1);
 609         boolean scope_id_set = gf.get("scope_id_set", false);
 610         boolean scope_ifname_set = gf.get("scope_ifname_set", false);




 563     /**
 564      * @serialField ipaddress byte[]
 565      * @serialField scope_id int
 566      * @serialField scope_id_set boolean
 567      * @serialField scope_ifname_set boolean
 568      * @serialField ifname String
 569      */
 570 
 571     private static final ObjectStreamField[] serialPersistentFields = {
 572          new ObjectStreamField("ipaddress", byte[].class),
 573          new ObjectStreamField("scope_id", int.class),
 574          new ObjectStreamField("scope_id_set", boolean.class),
 575          new ObjectStreamField("scope_ifname_set", boolean.class),
 576          new ObjectStreamField("ifname", String.class)
 577     };
 578 
 579     private static final long FIELDS_OFFSET;
 580     private static final jdk.internal.misc.Unsafe UNSAFE;
 581 
 582     static {

 583         jdk.internal.misc.Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe();
 584         FIELDS_OFFSET = unsafe.objectFieldOffset(
 585                 Inet6Address.class, "holder6");
 586         UNSAFE = unsafe;



 587     }
 588 
 589     /**
 590      * restore the state of this object from stream
 591      * including the scope information, only if the
 592      * scoped interface name is valid on this system
 593      */
 594     private void readObject(ObjectInputStream s)
 595         throws IOException, ClassNotFoundException {
 596         NetworkInterface scope_ifname = null;
 597 
 598         if (getClass().getClassLoader() != null) {
 599             throw new SecurityException ("invalid address type");
 600         }
 601 
 602         ObjectInputStream.GetField gf = s.readFields();
 603         byte[] ipaddress = (byte[])gf.get("ipaddress", null);
 604         int scope_id = gf.get("scope_id", -1);
 605         boolean scope_id_set = gf.get("scope_id_set", false);
 606         boolean scope_ifname_set = gf.get("scope_ifname_set", false);


< prev index next >