changeset 12741:c4ad4e7a509f

Merge
author asaha
date Mon, 26 Jun 2017 22:34:00 -0700
parents 24364089455f c874f91b603b
children 6dd62a5c70bf 360dc434ba24
files .hgtags make/lib/CoreLibraries.gmk
diffstat 16 files changed, 448 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Mon Jun 26 22:23:36 2017 -0700
+++ b/.hgtags	Mon Jun 26 22:34:00 2017 -0700
@@ -700,6 +700,8 @@
 3ab471c4760a808e39406303ff33a25a542b9c75 jdk8u131-b11
 d50ccb38def5968145fd3f6e0579416bb027e85c jdk8u131-b31
 e54624a8ebe3639d3b2360adb9ae0fa32f1bef57 jdk8u131-b32
+15006e8dc79bd0005d264bff0b1677a109cf5a02 jdk8u131-b33
+e6e35f065443533c81db69022a272927b0b20f69 jdk8u131-b34
 a160009bbe1417d85f1c0eec890fdb17391b3637 jdk8u141-b00
 e95a13de2d36050302a1af422967f5260fc8eabd jdk8u141-b01
 936085d9aff0554a3bdab2fcbbec1d1864e656a2 jdk8u141-b02
--- a/make/lib/CoreLibraries.gmk	Mon Jun 26 22:23:36 2017 -0700
+++ b/make/lib/CoreLibraries.gmk	Mon Jun 26 22:34:00 2017 -0700
@@ -23,6 +23,9 @@
 # questions.
 #
 
+# Include custom extensions if available.
+-include $(CUSTOM_MAKE_DIR)/lib/CoreLibraries.gmk
+
 WIN_VERIFY_LIB := $(JDK_OUTPUTDIR)/objs/libverify/verify.lib
 
 ##########################################################################################
@@ -114,7 +117,8 @@
 
 ##########################################################################################
 
-LIBJAVA_SRC_DIRS := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/lang \
+# Allow a custom makefile to add extra src dirs
+LIBJAVA_SRC_DIRS += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/lang \
     $(JDK_TOPDIR)/src/share/native/java/lang \
     $(JDK_TOPDIR)/src/share/native/java/lang/reflect \
     $(JDK_TOPDIR)/src/share/native/java/io \
@@ -140,6 +144,9 @@
       $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/io
 endif
 
+# Make it possible to override this variable
+LIBJAVA_MAPFILE ?= $(JDK_TOPDIR)/make/mapfiles/libjava/mapfile-vers
+
 LIBJAVA_CFLAGS := $(foreach dir, $(LIBJAVA_SRC_DIRS), -I$(dir)) \
     -I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include \
     -DARCHPROPNAME='"$(OPENJDK_TARGET_CPU_OSARCH)"'
@@ -193,7 +200,7 @@
     OPTIMIZATION := HIGH, \
     CFLAGS := $(CFLAGS_JDKLIB) \
         $(LIBJAVA_CFLAGS), \
-    MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjava/mapfile-vers, \
+    MAPFILE := $(LIBJAVA_MAPFILE), \
     LDFLAGS := $(LDFLAGS_JDKLIB) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LDFLAGS_SUFFIX_posix := -ljvm -lverify, \
--- a/src/aix/native/java/net/aix_close.c	Mon Jun 26 22:23:36 2017 -0700
+++ b/src/aix/native/java/net/aix_close.c	Mon Jun 26 22:34:00 2017 -0700
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, SAP SE and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -328,6 +329,10 @@
     BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) );
 }
 
+int NET_NonBlockingRead(int s, void* buf, size_t len) {
+    BLOCKING_IO_RETURN_INT(s, recv(s, buf, len, MSG_NONBLOCK));
+}
+
 int NET_ReadV(int s, const struct iovec * vector, int count) {
     BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) );
 }
@@ -429,8 +434,8 @@
  * Auto restarts with adjusted timeout if interrupted by
  * signal other than our wakeup signal.
  */
-int NET_Timeout(int s, long timeout) {
-    long prevtime = 0, newtime;
+int NET_Timeout0(int s, long timeout, long currentTime) {
+    long prevtime = currentTime, newtime;
     struct timeval t;
     fdEntry_t *fdEntry = getFdEntry(s);
 
@@ -442,14 +447,6 @@
         return -1;
     }
 
-    /*
-     * Pick up current time as may need to adjust timeout
-     */
-    if (timeout > 0) {
-        gettimeofday(&t, NULL);
-        prevtime = t.tv_sec * 1000  +  t.tv_usec / 1000;
-    }
-
     for(;;) {
         struct pollfd pfd;
         int rv;
--- a/src/macosx/native/sun/awt/CPrinterJob.m	Mon Jun 26 22:23:36 2017 -0700
+++ b/src/macosx/native/sun/awt/CPrinterJob.m	Mon Jun 26 22:34:00 2017 -0700
@@ -365,7 +365,7 @@
     static JNF_MEMBER_CACHE(jm_getMaxPage, sjc_CPrinterJob, "getMaxPageAttrib", "()I");
     static JNF_MEMBER_CACHE(jm_getSelectAttrib, sjc_CPrinterJob, "getSelectAttrib", "()I");
     static JNF_MEMBER_CACHE(jm_getNumberOfPages, jc_Pageable, "getNumberOfPages", "()I");
-    static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormat", "(I)Ljava/awt/print/PageFormat;");
+    static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormatFromAttributes", "()Ljava/awt/print/PageFormat;");
 
     NSMutableDictionary* printingDictionary = [dst dictionary];
 
@@ -401,7 +401,7 @@
     [printingDictionary setObject:[NSNumber numberWithInteger:fromPage] forKey:NSPrintFirstPage];
     [printingDictionary setObject:[NSNumber numberWithInteger:toPage] forKey:NSPrintLastPage];
 
-    jobject page = JNFCallObjectMethod(env, srcPrinterJob, jm_getPageFormat, (jint)0);
+    jobject page = JNFCallObjectMethod(env, srcPrinterJob, jm_getPageFormat); 
     if (page != NULL) {
         javaPageFormatToNSPrintInfo(env, NULL, page, dst);
     }
--- a/src/share/classes/java/awt/Container.java	Mon Jun 26 22:23:36 2017 -0700
+++ b/src/share/classes/java/awt/Container.java	Mon Jun 26 22:34:00 2017 -0700
@@ -1089,17 +1089,18 @@
             }
             checkAddToSelf(comp);
             checkNotAWindow(comp);
+            /* Reparent the component and tidy up the tree's state. */
+            if (comp.parent != null) {
+                comp.parent.remove(comp);
+                if (index > component.size()) {
+                    throw new IllegalArgumentException("illegal component position");
+                }
+            }
             if (thisGC != null) {
                 comp.checkGD(thisGC.getDevice().getIDstring());
             }
 
-            /* Reparent the component and tidy up the tree's state. */
-            if (comp.parent != null) {
-                comp.parent.remove(comp);
-                    if (index > component.size()) {
-                        throw new IllegalArgumentException("illegal component position");
-                    }
-            }
+
 
             //index == -1 means add to the end.
             if (index == -1) {
--- a/src/share/classes/sun/print/RasterPrinterJob.java	Mon Jun 26 22:23:36 2017 -0700
+++ b/src/share/classes/sun/print/RasterPrinterJob.java	Mon Jun 26 22:34:00 2017 -0700
@@ -818,6 +818,14 @@
         }
    }
 
+   protected PageFormat getPageFormatFromAttributes() {
+       if (attributes == null || attributes.isEmpty()) {
+            return null;
+        }
+        return attributeToPageFormat(getPrintService(), this.attributes);
+   }
+
+
    /**
      * Presents the user a dialog for changing properties of the
      * print job interactively.
--- a/src/solaris/native/java/net/SocketInputStream.c	Mon Jun 26 22:23:36 2017 -0700
+++ b/src/solaris/native/java/net/SocketInputStream.c	Mon Jun 26 22:34:00 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,6 +52,42 @@
     IO_fd_fdID = NET_GetFileDescriptorID(env);
 }
 
+#if !defined(__solaris__)
+static int NET_ReadWithTimeout(JNIEnv *env, int fd, char *bufP, int len, long timeout) {
+    int result = 0;
+    long prevtime = NET_GetCurrentTime(), newtime;
+    while (timeout > 0) {
+        result = NET_TimeoutWithCurrentTime(fd, timeout, prevtime);
+        if (result <= 0) {
+            if (result == 0) {
+                JNU_ThrowByName(env, "java/net/SocketTimeoutException", "Read timed out");
+            } else if (result == -1) {
+                if (errno == EBADF) {
+                    JNU_ThrowByName(env, "java/net/SocketException", "Socket closed");
+                } else if (errno == ENOMEM) {
+                    JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
+                } else {
+                    JNU_ThrowByNameWithMessageAndLastError
+                            (env, "java/net/SocketException", "select/poll failed");
+                }
+            }
+            return -1;
+        }
+        result = NET_NonBlockingRead(fd, bufP, len);
+        if (result == -1 && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) {
+            newtime = NET_GetCurrentTime();
+            timeout -= newtime - prevtime;
+            if (timeout > 0) {
+                prevtime = newtime;
+            }
+        } else {
+            break;
+        }
+    }
+    return result;
+}
+#endif
+
 /*
  * Class:     java_net_SocketInputStream
  * Method:    socketRead0
@@ -99,6 +135,7 @@
         bufP = BUF;
     }
 
+#if defined(__solaris__)
     if (timeout) {
         nread = NET_Timeout(fd, timeout);
         if (nread <= 0) {
@@ -126,7 +163,19 @@
     }
 
     nread = NET_Read(fd, bufP, len);
-
+#else
+    if (timeout) {
+        nread = NET_ReadWithTimeout(env, fd, bufP, len, timeout);
+        if ((*env)->ExceptionCheck(env)) {
+            if (bufP != BUF) {
+                free(bufP);
+            }
+            return nread;
+        }
+    } else {
+        nread = NET_Read(fd, bufP, len);
+    }
+#endif
     if (nread <= 0) {
         if (nread < 0) {
 
--- a/src/solaris/native/java/net/bsd_close.c	Mon Jun 26 22:23:36 2017 -0700
+++ b/src/solaris/native/java/net/bsd_close.c	Mon Jun 26 22:34:00 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -292,6 +292,10 @@
     BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) );
 }
 
+int NET_NonBlockingRead(int s, void* buf, size_t len) {
+    BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT));
+}
+
 int NET_ReadV(int s, const struct iovec * vector, int count) {
     BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) );
 }
@@ -344,8 +348,8 @@
  * Auto restarts with adjusted timeout if interrupted by
  * signal other than our wakeup signal.
  */
-int NET_Timeout(int s, long timeout) {
-    long prevtime = 0, newtime;
+int NET_Timeout0(int s, long timeout, long currentTime) {
+    long prevtime = currentTime, newtime;
     struct timeval t, *tp = &t;
     fd_set fds;
     fd_set* fdsp = NULL;
@@ -366,9 +370,6 @@
      */
     if (timeout > 0) {
         /* Timed */
-        struct timeval now;
-        gettimeofday(&now, NULL);
-        prevtime = now.tv_sec * 1000  +  now.tv_usec / 1000;
         t.tv_sec = timeout / 1000;
         t.tv_usec = (timeout % 1000) * 1000;
     } else if (timeout < 0) {
--- a/src/solaris/native/java/net/linux_close.c	Mon Jun 26 22:23:36 2017 -0700
+++ b/src/solaris/native/java/net/linux_close.c	Mon Jun 26 22:34:00 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -273,6 +273,10 @@
     BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) );
 }
 
+int NET_NonBlockingRead(int s, void* buf, size_t len) {
+    BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT) );
+}
+
 int NET_ReadV(int s, const struct iovec * vector, int count) {
     BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) );
 }
@@ -324,8 +328,8 @@
  * Auto restarts with adjusted timeout if interrupted by
  * signal other than our wakeup signal.
  */
-int NET_Timeout(int s, long timeout) {
-    long prevtime = 0, newtime;
+int NET_Timeout0(int s, long timeout, long currentTime) {
+    long prevtime = currentTime, newtime;
     struct timeval t;
     fdEntry_t *fdEntry = getFdEntry(s);
 
@@ -337,14 +341,6 @@
         return -1;
     }
 
-    /*
-     * Pick up current time as may need to adjust timeout
-     */
-    if (timeout > 0) {
-        gettimeofday(&t, NULL);
-        prevtime = t.tv_sec * 1000  +  t.tv_usec / 1000;
-    }
-
     for(;;) {
         struct pollfd pfd;
         int rv;
--- a/src/solaris/native/java/net/net_util_md.c	Mon Jun 26 22:23:36 2017 -0700
+++ b/src/solaris/native/java/net/net_util_md.c	Mon Jun 26 22:34:00 2017 -0700
@@ -33,6 +33,7 @@
 #include <netdb.h>
 #include <stdlib.h>
 #include <dlfcn.h>
+#include <sys/time.h>
 
 #ifndef _ALLBSD_SOURCE
 #include <values.h>
@@ -1661,3 +1662,20 @@
 
     return timeout;
 }
+
+#if !defined(__solaris__)
+long NET_GetCurrentTime() {
+    struct timeval time;
+    gettimeofday(&time, NULL);
+    return (time.tv_sec * 1000 + time.tv_usec / 1000);
+}
+
+int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime) {
+    return NET_Timeout0(s, timeout, currentTime);
+}
+
+int NET_Timeout(int s, long timeout) {
+    long currentTime = (timeout > 0) ? NET_GetCurrentTime() : 0;
+    return NET_Timeout0(s, timeout, currentTime);
+}
+#endif
--- a/src/solaris/native/java/net/net_util_md.h	Mon Jun 26 22:23:36 2017 -0700
+++ b/src/solaris/native/java/net/net_util_md.h	Mon Jun 26 22:34:00 2017 -0700
@@ -47,9 +47,13 @@
    close subroutine does not return until the select call returns.
    ...
 */
-#if defined(__linux__) || defined(MACOSX) || defined (_AIX)
+#if !defined(__solaris__)
 extern int NET_Timeout(int s, long timeout);
+extern int NET_Timeout0(int s, long timeout, long currentTime);
 extern int NET_Read(int s, void* buf, size_t len);
+extern int NET_NonBlockingRead(int s, void* buf, size_t len);
+extern int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime);
+extern long NET_GetCurrentTime();
 extern int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
        struct sockaddr *from, int *fromlen);
 extern int NET_ReadV(int s, const struct iovec * vector, int count);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Container/MoveToOtherScreenTest/MoveToOtherScreenTest.java	Mon Jun 26 22:34:00 2017 -0700
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+import java.awt.Canvas;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.lang.reflect.InvocationTargetException;
+
+
+
+/* @test
+   @bug 8160696
+   @summary IllegalArgumentException: adding a component to a container on a different GraphicsDevice
+   @author Mikhail Cherkasov
+   @run main MoveToOtherScreenTest
+*/
+public class MoveToOtherScreenTest {
+
+    private static volatile boolean twoDisplays = true;
+    private static final Canvas canvas = new Canvas();
+    private static final Frame[] frms = new JFrame[2];
+
+    public static void main(String[] args) throws InterruptedException, InvocationTargetException {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                GraphicsEnvironment ge = GraphicsEnvironment.
+                        getLocalGraphicsEnvironment();
+                GraphicsDevice[] gds = ge.getScreenDevices();
+                if (gds.length < 2) {
+                    System.out.println("Test requires at least 2 displays");
+                    twoDisplays = false;
+                    return;
+                }
+                for (int i = 0; i < 2; i++) {
+                    GraphicsConfiguration conf = gds[i].getConfigurations()[0];
+                    JFrame frm = new JFrame("Frame " + i);
+                    frm.setLocation(conf.getBounds().x, 0); // On first screen
+                    frm.setSize(new Dimension(400, 400));
+                    frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+                    frm.setVisible(true);
+                    frms[i] = frm;
+                }
+                canvas.setBackground(Color.red);
+                frms[0].add(canvas);
+            }
+        });
+        if(!twoDisplays){
+           return;
+        }
+        Thread.sleep(200);
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                frms[1].add(canvas);
+            }
+        });
+        for (Frame frm : frms) {
+            frm.dispose();
+        }
+    }
+}
--- a/test/java/awt/print/PageFormat/WrongPaperPrintingTest.java	Mon Jun 26 22:23:36 2017 -0700
+++ b/test/java/awt/print/PageFormat/WrongPaperPrintingTest.java	Mon Jun 26 22:34:00 2017 -0700
@@ -24,6 +24,7 @@
 /* @test
    @bug 8167102
    @summary PrintRequestAttributeSet breaks page size set using PageFormat
+   @ignore Exclude the test until 8167102 is resolved by a new reassessed fix
    @run main/manual WrongPaperPrintingTest
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/xml/ws/8172297/Main.java	Mon Jun 26 22:34:00 2017 -0700
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8172297
+ * @summary Test that carriage-return and new-line characters
+ * are preserved in webservice parameters
+ * @compile ws/HelloWorld.java ws/HelloWorldImpl.java Main.java
+ * @run testng/othervm Main
+ */
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.URL;
+import java.util.concurrent.CountDownLatch;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Service;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import ws.HelloWorld;
+import ws.HelloWorldImpl;
+
+public class Main {
+
+    @Test
+    public void runTest() throws Exception {
+        //
+        CountDownLatch serverInitSignal = new CountDownLatch(1);
+        CountDownLatch testDoneSignal = new CountDownLatch(1);
+
+        WebserviceRunner serverThread = new WebserviceRunner(serverInitSignal, testDoneSignal);
+        (new Thread(serverThread)).start();
+
+        serverInitSignal.await();
+
+        boolean paramModified = runClientCode(serverThread.getPort());
+
+        testDoneSignal.countDown();
+
+        Assert.assertFalse(paramModified, "WS parameter was modified during round trip.");
+    }
+
+    /*
+     * Connects to launched web service endpoint, sends message with CR/NL symbols and
+     * checks if it was modified during the round trip client/server communication.
+     */
+    private boolean runClientCode(int port) throws Exception {
+        System.out.println("Launching WS client connection on " + port + " port");
+        URL url = new URL("http://localhost:" + port + "/ws/hello?wsdl");
+        QName qname = new QName("http://ws/", "HelloWorldImplService");
+        Service service = Service.create(url, qname);
+
+        HelloWorld hello = (HelloWorld) service.getPort(HelloWorld.class);
+
+        logStringContent("Client input parameter", WS_PARAM_VALUE);
+
+        String response = hello.getHelloWorldAsString(WS_PARAM_VALUE);
+        logStringContent("Client response parameter", response);
+
+        return !WS_PARAM_VALUE.equals(response);
+    }
+
+    /*
+     * Outputs the parameter value with newline and carriage-return symbols
+     * replaced with #CR and #NL text abbreviations.
+     */
+    private static void logStringContent(String description, String parameter) {
+        String readableContent = parameter.replaceAll("\r", "#CR")
+                                          .replaceAll("\n", "#NL");
+        System.out.println(description + ": '" + readableContent + "'");
+    }
+
+    /* Web service parameter value with newline and carriage-return symbols */
+    private final static String WS_PARAM_VALUE = "\r\r\n\r\r CarriageReturn and "
+                                                +"NewLine \r\n\n Test \r\r\r\r";
+
+    /*
+     * Web service server thread that publishes WS on vacant port and waits
+     * for client to finalize testing
+     */
+    class WebserviceRunner implements Runnable {
+        // Latch used to signalize when WS endpoint is initialized
+        private final CountDownLatch initSignal;
+        // Latch used to signalize when client completed testing
+        private final CountDownLatch doneSignal;
+        // Port where WS endpoint is published
+        private volatile int port = 0;
+
+        // Constructor
+        WebserviceRunner(CountDownLatch initSignal, CountDownLatch doneSignal) {
+            this.initSignal = initSignal;
+            this.doneSignal = doneSignal;
+        }
+
+        // Returns port of the published endpoint
+        public int getPort() {
+            return port;
+        }
+
+        /*
+         * Publish web service on vacant port and waits for the client to
+         * complete testing.
+         */
+        public void run() {
+            try {
+                // Find vacant port number
+                ServerSocket ss = new ServerSocket(0);
+                port = ss.getLocalPort();
+                ss.close();
+
+                // Publish WebService
+                System.out.println("Publishing WebService on " + port + " port");
+                Endpoint ep = Endpoint.publish("http://localhost:" + port + "/ws/hello", new HelloWorldImpl());
+
+                // Notify main thread that WS endpoint is published
+                initSignal.countDown();
+
+                // Wait for main thread to complete testing
+                System.out.println("Waiting for done signal from test client.");
+                doneSignal.await();
+
+                // Terminate WS endpoint
+                System.out.println("Got done signal from the client. Stopping WS endpoint.");
+                ep.stop();
+            } catch (IOException ioe) {
+                System.out.println("Failed to get vacant port number:" + ioe);
+            } catch (InterruptedException ie) {
+                System.out.println("Failed to wait for test completion:" + ie);
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/xml/ws/8172297/ws/HelloWorld.java	Mon Jun 26 22:34:00 2017 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package ws;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.Style;
+import javax.jws.soap.SOAPBinding.Use;
+
+//Web service endpoint interface
+@WebService
+@SOAPBinding(style = Style.DOCUMENT, use = Use.LITERAL)
+public interface HelloWorld {
+
+    @WebMethod
+    String getHelloWorldAsString(String name);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/xml/ws/8172297/ws/HelloWorldImpl.java	Mon Jun 26 22:34:00 2017 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package ws;
+
+import javax.jws.WebService;
+
+// Simple web service implementation that echoes its parameter
+@WebService(endpointInterface = "ws.HelloWorld")
+public class HelloWorldImpl implements HelloWorld {
+
+    @Override
+    public String getHelloWorldAsString(String name) {
+        System.out.println("Server-side parameter value: '"
+                + name.replaceAll("\r", "#CR")
+                      .replaceAll("\n", "#NL") + "'");
+        return name;
+    }
+}