8154238: Drop code to support Windows XP in windows socket impl
Reviewed-by: chegar
--- a/jdk/src/java.base/windows/classes/java/net/PlainSocketImpl.java Sat Apr 16 13:14:38 2016 +0100
+++ b/jdk/src/java.base/windows/classes/java/net/PlainSocketImpl.java Mon Apr 18 12:36:41 2016 +0200
@@ -25,7 +25,9 @@
package java.net;
import java.io.*;
+import java.security.AccessController;
import java.security.PrivilegedAction;
+import sun.security.action.GetPropertyAction;
/*
* This class PlainSocketImpl simply delegates to the appropriate real
@@ -45,55 +47,29 @@
{
private AbstractPlainSocketImpl impl;
- /* the windows version. */
- private static float version;
-
/* java.net.preferIPv4Stack */
- private static boolean preferIPv4Stack = false;
-
- /* If the version supports a dual stack TCP implementation */
- private static boolean useDualStackImpl = false;
-
- /* sun.net.useExclusiveBind */
- private static String exclBindProp;
+ private static final boolean preferIPv4Stack;
/* True if exclusive binding is on for Windows */
- private static boolean exclusiveBind = true;
+ private static final boolean exclusiveBind;
static {
- java.security.AccessController.doPrivileged( new PrivilegedAction<Object>() {
- public Object run() {
- version = 0;
- try {
- version = Float.parseFloat(System.getProperties().getProperty("os.version"));
- preferIPv4Stack = Boolean.parseBoolean(
- System.getProperties().getProperty("java.net.preferIPv4Stack"));
- exclBindProp = System.getProperty("sun.net.useExclusiveBind");
- } catch (NumberFormatException e ) {
- assert false : e;
- }
- return null; // nothing to return
- } });
+ preferIPv4Stack = Boolean.parseBoolean(
+ AccessController.doPrivileged(
+ new GetPropertyAction("java.net.preferIPv4Stack")));
- // (version >= 6.0) implies Vista or greater.
- if (version >= 6.0 && !preferIPv4Stack) {
- useDualStackImpl = true;
- }
-
- if (exclBindProp != null) {
- // sun.net.useExclusiveBind is true
- exclusiveBind = exclBindProp.length() == 0 ? true
- : Boolean.parseBoolean(exclBindProp);
- } else if (version < 6.0) {
- exclusiveBind = false;
- }
+ String exclBindProp = AccessController.doPrivileged(
+ new GetPropertyAction("sun.net.useExclusiveBind", ""));
+ exclusiveBind = (exclBindProp.isEmpty())
+ ? true
+ : Boolean.parseBoolean(exclBindProp);
}
/**
* Constructs an empty instance.
*/
PlainSocketImpl() {
- if (useDualStackImpl) {
+ if (!preferIPv4Stack) {
impl = new DualStackPlainSocketImpl(exclusiveBind);
} else {
impl = new TwoStacksPlainSocketImpl(exclusiveBind);