< prev index next >

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

Print this page




1628      */
1629     static InetAddress anyLocalAddress() {
1630         return impl.anyLocalAddress();
1631     }
1632 
1633     /*
1634      * Load and instantiate an underlying impl class
1635      */
1636     static InetAddressImpl loadImpl(String implName) {
1637         Object impl = null;
1638 
1639         /*
1640          * Property "impl.prefix" will be prepended to the classname
1641          * of the implementation object we instantiate, to which we
1642          * delegate the real work (like native methods).  This
1643          * property can vary across implementations of the java.
1644          * classes.  The default is an empty String "".
1645          */
1646         String prefix = GetPropertyAction.getProperty("impl.prefix", "");
1647         try {
1648             impl = Class.forName("java.net." + prefix + implName).newInstance();


1649         } catch (ClassNotFoundException e) {
1650             System.err.println("Class not found: java.net." + prefix +
1651                                implName + ":\ncheck impl.prefix property " +
1652                                "in your properties file.");
1653         } catch (InstantiationException e) {
1654             System.err.println("Could not instantiate: java.net." + prefix +
1655                                implName + ":\ncheck impl.prefix property " +
1656                                "in your properties file.");
1657         } catch (IllegalAccessException e) {
1658             System.err.println("Cannot access class: java.net." + prefix +
1659                                implName + ":\ncheck impl.prefix property " +
1660                                "in your properties file.");
1661         }
1662 
1663         if (impl == null) {
1664             try {
1665                 impl = Class.forName(implName).newInstance();


1666             } catch (Exception e) {
1667                 throw new Error("System property impl.prefix incorrect");
1668             }
1669         }
1670 
1671         return (InetAddressImpl) impl;
1672     }
1673 
1674     private void readObjectNoData (ObjectInputStream s) throws
1675                          IOException, ClassNotFoundException {
1676         if (getClass().getClassLoader() != null) {
1677             throw new SecurityException ("invalid address type");
1678         }
1679     }
1680 
1681     private static final long FIELDS_OFFSET;
1682     private static final jdk.internal.misc.Unsafe UNSAFE;
1683 
1684     static {
1685         try {




1628      */
1629     static InetAddress anyLocalAddress() {
1630         return impl.anyLocalAddress();
1631     }
1632 
1633     /*
1634      * Load and instantiate an underlying impl class
1635      */
1636     static InetAddressImpl loadImpl(String implName) {
1637         Object impl = null;
1638 
1639         /*
1640          * Property "impl.prefix" will be prepended to the classname
1641          * of the implementation object we instantiate, to which we
1642          * delegate the real work (like native methods).  This
1643          * property can vary across implementations of the java.
1644          * classes.  The default is an empty String "".
1645          */
1646         String prefix = GetPropertyAction.getProperty("impl.prefix", "");
1647         try {
1648             @SuppressWarnings("deprecation")
1649             Object tmp = Class.forName("java.net." + prefix + implName).newInstance();
1650             impl = tmp;
1651         } catch (ClassNotFoundException e) {
1652             System.err.println("Class not found: java.net." + prefix +
1653                                implName + ":\ncheck impl.prefix property " +
1654                                "in your properties file.");
1655         } catch (InstantiationException e) {
1656             System.err.println("Could not instantiate: java.net." + prefix +
1657                                implName + ":\ncheck impl.prefix property " +
1658                                "in your properties file.");
1659         } catch (IllegalAccessException e) {
1660             System.err.println("Cannot access class: java.net." + prefix +
1661                                implName + ":\ncheck impl.prefix property " +
1662                                "in your properties file.");
1663         }
1664 
1665         if (impl == null) {
1666             try {
1667                 @SuppressWarnings("deprecation")
1668                 Object tmp = Class.forName(implName).newInstance();
1669                 impl = tmp;
1670             } catch (Exception e) {
1671                 throw new Error("System property impl.prefix incorrect");
1672             }
1673         }
1674 
1675         return (InetAddressImpl) impl;
1676     }
1677 
1678     private void readObjectNoData (ObjectInputStream s) throws
1679                          IOException, ClassNotFoundException {
1680         if (getClass().getClassLoader() != null) {
1681             throw new SecurityException ("invalid address type");
1682         }
1683     }
1684 
1685     private static final long FIELDS_OFFSET;
1686     private static final jdk.internal.misc.Unsafe UNSAFE;
1687 
1688     static {
1689         try {


< prev index next >