< 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, twisti, bchristi, mgerdin


 559         }
 560         throw new UnknownHostException ("No matching address found for interface : " +ifname);
 561     }
 562 
 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);
 611         String ifname = (String)gf.get("ifname", null);




 559         }
 560         throw new UnknownHostException ("No matching address found for interface : " +ifname);
 561     }
 562 
 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 jdk.internal.misc.Unsafe UNSAFE
 580             = jdk.internal.misc.Unsafe.getUnsafe();
 581     private static final long FIELDS_OFFSET = UNSAFE.objectFieldOffset(
 582                 Inet6Address.class, "holder6");









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


< prev index next >