22 * or visit www.oracle.com if you need additional information or have any |
22 * or visit www.oracle.com if you need additional information or have any |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 package java.net; |
25 package java.net; |
26 |
26 |
27 import java.security.AccessController; |
27 import java.util.Properties; |
28 import java.security.PrivilegedAction; |
|
29 import sun.security.action.GetPropertyAction; |
28 import sun.security.action.GetPropertyAction; |
30 |
29 |
31 /** |
30 /** |
32 * This class defines a factory for creating DatagramSocketImpls. It defaults |
31 * This class defines a factory for creating DatagramSocketImpls. It defaults |
33 * to creating plain DatagramSocketImpls, but may create other DatagramSocketImpls |
32 * to creating plain DatagramSocketImpls, but may create other DatagramSocketImpls |
55 private static final boolean exclusiveBind; |
54 private static final boolean exclusiveBind; |
56 |
55 |
57 static { |
56 static { |
58 Class<?> prefixImplClassLocal = null; |
57 Class<?> prefixImplClassLocal = null; |
59 |
58 |
|
59 Properties props = GetPropertyAction.getProperties(); |
60 preferIPv4Stack = Boolean.parseBoolean( |
60 preferIPv4Stack = Boolean.parseBoolean( |
61 AccessController.doPrivileged( |
61 props.getProperty("java.net.preferIPv4Stack")); |
62 new GetPropertyAction("java.net.preferIPv4Stack"))); |
|
63 |
62 |
64 String exclBindProp = AccessController.doPrivileged( |
63 String exclBindProp = props.getProperty("sun.net.useExclusiveBind", ""); |
65 new GetPropertyAction("sun.net.useExclusiveBind", "")); |
|
66 exclusiveBind = (exclBindProp.isEmpty()) |
64 exclusiveBind = (exclBindProp.isEmpty()) |
67 ? true |
65 ? true |
68 : Boolean.parseBoolean(exclBindProp); |
66 : Boolean.parseBoolean(exclBindProp); |
69 |
67 |
70 // impl.prefix |
68 // impl.prefix |
71 String prefix = null; |
69 String prefix = null; |
72 try { |
70 try { |
73 prefix = AccessController.doPrivileged( |
71 prefix = props.getProperty("impl.prefix"); |
74 new GetPropertyAction("impl.prefix", null)); |
|
75 if (prefix != null) |
72 if (prefix != null) |
76 prefixImplClassLocal = Class.forName("java.net."+prefix+"DatagramSocketImpl"); |
73 prefixImplClassLocal = Class.forName("java.net."+prefix+"DatagramSocketImpl"); |
77 } catch (Exception e) { |
74 } catch (Exception e) { |
78 System.err.println("Can't find class: java.net." + |
75 System.err.println("Can't find class: java.net." + |
79 prefix + |
76 prefix + |