提交 86daca7f 编写于 作者: A asaha

Merge

...@@ -700,6 +700,8 @@ c0091a673d766ce2e76a945bab6de325fe78dd88 jdk8u131-b10 ...@@ -700,6 +700,8 @@ c0091a673d766ce2e76a945bab6de325fe78dd88 jdk8u131-b10
3ab471c4760a808e39406303ff33a25a542b9c75 jdk8u131-b11 3ab471c4760a808e39406303ff33a25a542b9c75 jdk8u131-b11
d50ccb38def5968145fd3f6e0579416bb027e85c jdk8u131-b31 d50ccb38def5968145fd3f6e0579416bb027e85c jdk8u131-b31
e54624a8ebe3639d3b2360adb9ae0fa32f1bef57 jdk8u131-b32 e54624a8ebe3639d3b2360adb9ae0fa32f1bef57 jdk8u131-b32
15006e8dc79bd0005d264bff0b1677a109cf5a02 jdk8u131-b33
e6e35f065443533c81db69022a272927b0b20f69 jdk8u131-b34
a160009bbe1417d85f1c0eec890fdb17391b3637 jdk8u141-b00 a160009bbe1417d85f1c0eec890fdb17391b3637 jdk8u141-b00
e95a13de2d36050302a1af422967f5260fc8eabd jdk8u141-b01 e95a13de2d36050302a1af422967f5260fc8eabd jdk8u141-b01
936085d9aff0554a3bdab2fcbbec1d1864e656a2 jdk8u141-b02 936085d9aff0554a3bdab2fcbbec1d1864e656a2 jdk8u141-b02
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
# questions. # questions.
# #
# Include custom extensions if available.
-include $(CUSTOM_MAKE_DIR)/lib/CoreLibraries.gmk
WIN_VERIFY_LIB := $(JDK_OUTPUTDIR)/objs/libverify/verify.lib WIN_VERIFY_LIB := $(JDK_OUTPUTDIR)/objs/libverify/verify.lib
########################################################################################## ##########################################################################################
...@@ -114,7 +117,8 @@ BUILD_LIBRARIES += $(BUILD_LIBVERIFY) ...@@ -114,7 +117,8 @@ BUILD_LIBRARIES += $(BUILD_LIBVERIFY)
########################################################################################## ##########################################################################################
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 \
$(JDK_TOPDIR)/src/share/native/java/lang/reflect \ $(JDK_TOPDIR)/src/share/native/java/lang/reflect \
$(JDK_TOPDIR)/src/share/native/java/io \ $(JDK_TOPDIR)/src/share/native/java/io \
...@@ -140,6 +144,9 @@ ifeq ($(OPENJDK_TARGET_OS), windows) ...@@ -140,6 +144,9 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/io $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/io
endif 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)) \ LIBJAVA_CFLAGS := $(foreach dir, $(LIBJAVA_SRC_DIRS), -I$(dir)) \
-I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include \ -I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include \
-DARCHPROPNAME='"$(OPENJDK_TARGET_CPU_OSARCH)"' -DARCHPROPNAME='"$(OPENJDK_TARGET_CPU_OSARCH)"'
...@@ -193,7 +200,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA, \ ...@@ -193,7 +200,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA, \
OPTIMIZATION := HIGH, \ OPTIMIZATION := HIGH, \
CFLAGS := $(CFLAGS_JDKLIB) \ CFLAGS := $(CFLAGS_JDKLIB) \
$(LIBJAVA_CFLAGS), \ $(LIBJAVA_CFLAGS), \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjava/mapfile-vers, \ MAPFILE := $(LIBJAVA_MAPFILE), \
LDFLAGS := $(LDFLAGS_JDKLIB) \ LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \ $(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_SUFFIX_posix := -ljvm -lverify, \ LDFLAGS_SUFFIX_posix := -ljvm -lverify, \
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -328,6 +329,10 @@ int NET_Read(int s, void* buf, size_t len) { ...@@ -328,6 +329,10 @@ int NET_Read(int s, void* buf, size_t len) {
BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) ); 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) { int NET_ReadV(int s, const struct iovec * vector, int count) {
BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) ); BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) );
} }
...@@ -429,8 +434,8 @@ int NET_Select(int s, fd_set *readfds, fd_set *writefds, ...@@ -429,8 +434,8 @@ int NET_Select(int s, fd_set *readfds, fd_set *writefds,
* Auto restarts with adjusted timeout if interrupted by * Auto restarts with adjusted timeout if interrupted by
* signal other than our wakeup signal. * signal other than our wakeup signal.
*/ */
int NET_Timeout(int s, long timeout) { int NET_Timeout0(int s, long timeout, long currentTime) {
long prevtime = 0, newtime; long prevtime = currentTime, newtime;
struct timeval t; struct timeval t;
fdEntry_t *fdEntry = getFdEntry(s); fdEntry_t *fdEntry = getFdEntry(s);
...@@ -442,14 +447,6 @@ int NET_Timeout(int s, long timeout) { ...@@ -442,14 +447,6 @@ int NET_Timeout(int s, long timeout) {
return -1; 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(;;) { for(;;) {
struct pollfd pfd; struct pollfd pfd;
int rv; int rv;
......
...@@ -365,7 +365,7 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj ...@@ -365,7 +365,7 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj
static JNF_MEMBER_CACHE(jm_getMaxPage, sjc_CPrinterJob, "getMaxPageAttrib", "()I"); 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_getSelectAttrib, sjc_CPrinterJob, "getSelectAttrib", "()I");
static JNF_MEMBER_CACHE(jm_getNumberOfPages, jc_Pageable, "getNumberOfPages", "()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]; NSMutableDictionary* printingDictionary = [dst dictionary];
...@@ -401,7 +401,7 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj ...@@ -401,7 +401,7 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj
[printingDictionary setObject:[NSNumber numberWithInteger:fromPage] forKey:NSPrintFirstPage]; [printingDictionary setObject:[NSNumber numberWithInteger:fromPage] forKey:NSPrintFirstPage];
[printingDictionary setObject:[NSNumber numberWithInteger:toPage] forKey:NSPrintLastPage]; [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) { if (page != NULL) {
javaPageFormatToNSPrintInfo(env, NULL, page, dst); javaPageFormatToNSPrintInfo(env, NULL, page, dst);
} }
......
...@@ -1089,17 +1089,18 @@ public class Container extends Component { ...@@ -1089,17 +1089,18 @@ public class Container extends Component {
} }
checkAddToSelf(comp); checkAddToSelf(comp);
checkNotAWindow(comp); checkNotAWindow(comp);
if (thisGC != null) {
comp.checkGD(thisGC.getDevice().getIDstring());
}
/* Reparent the component and tidy up the tree's state. */ /* Reparent the component and tidy up the tree's state. */
if (comp.parent != null) { if (comp.parent != null) {
comp.parent.remove(comp); comp.parent.remove(comp);
if (index > component.size()) { if (index > component.size()) {
throw new IllegalArgumentException("illegal component position"); throw new IllegalArgumentException("illegal component position");
} }
} }
if (thisGC != null) {
comp.checkGD(thisGC.getDevice().getIDstring());
}
//index == -1 means add to the end. //index == -1 means add to the end.
if (index == -1) { if (index == -1) {
......
...@@ -818,6 +818,14 @@ public abstract class RasterPrinterJob extends PrinterJob { ...@@ -818,6 +818,14 @@ public abstract class RasterPrinterJob extends PrinterJob {
} }
} }
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 * Presents the user a dialog for changing properties of the
* print job interactively. * print job interactively.
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -52,6 +52,42 @@ Java_java_net_SocketInputStream_init(JNIEnv *env, jclass cls) { ...@@ -52,6 +52,42 @@ Java_java_net_SocketInputStream_init(JNIEnv *env, jclass cls) {
IO_fd_fdID = NET_GetFileDescriptorID(env); 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 * Class: java_net_SocketInputStream
* Method: socketRead0 * Method: socketRead0
...@@ -99,6 +135,7 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this, ...@@ -99,6 +135,7 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
bufP = BUF; bufP = BUF;
} }
#if defined(__solaris__)
if (timeout) { if (timeout) {
nread = NET_Timeout(fd, timeout); nread = NET_Timeout(fd, timeout);
if (nread <= 0) { if (nread <= 0) {
...@@ -126,7 +163,19 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this, ...@@ -126,7 +163,19 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
} }
nread = NET_Read(fd, bufP, len); 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) {
if (nread < 0) { if (nread < 0) {
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -292,6 +292,10 @@ int NET_Read(int s, void* buf, size_t len) { ...@@ -292,6 +292,10 @@ int NET_Read(int s, void* buf, size_t len) {
BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) ); 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) { int NET_ReadV(int s, const struct iovec * vector, int count) {
BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) ); BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) );
} }
...@@ -344,8 +348,8 @@ int NET_Select(int s, fd_set *readfds, fd_set *writefds, ...@@ -344,8 +348,8 @@ int NET_Select(int s, fd_set *readfds, fd_set *writefds,
* Auto restarts with adjusted timeout if interrupted by * Auto restarts with adjusted timeout if interrupted by
* signal other than our wakeup signal. * signal other than our wakeup signal.
*/ */
int NET_Timeout(int s, long timeout) { int NET_Timeout0(int s, long timeout, long currentTime) {
long prevtime = 0, newtime; long prevtime = currentTime, newtime;
struct timeval t, *tp = &t; struct timeval t, *tp = &t;
fd_set fds; fd_set fds;
fd_set* fdsp = NULL; fd_set* fdsp = NULL;
...@@ -366,9 +370,6 @@ int NET_Timeout(int s, long timeout) { ...@@ -366,9 +370,6 @@ int NET_Timeout(int s, long timeout) {
*/ */
if (timeout > 0) { if (timeout > 0) {
/* Timed */ /* Timed */
struct timeval now;
gettimeofday(&now, NULL);
prevtime = now.tv_sec * 1000 + now.tv_usec / 1000;
t.tv_sec = timeout / 1000; t.tv_sec = timeout / 1000;
t.tv_usec = (timeout % 1000) * 1000; t.tv_usec = (timeout % 1000) * 1000;
} else if (timeout < 0) { } else if (timeout < 0) {
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -273,6 +273,10 @@ int NET_Read(int s, void* buf, size_t len) { ...@@ -273,6 +273,10 @@ int NET_Read(int s, void* buf, size_t len) {
BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) ); 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) { int NET_ReadV(int s, const struct iovec * vector, int count) {
BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) ); BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) );
} }
...@@ -324,8 +328,8 @@ int NET_Select(int s, fd_set *readfds, fd_set *writefds, ...@@ -324,8 +328,8 @@ int NET_Select(int s, fd_set *readfds, fd_set *writefds,
* Auto restarts with adjusted timeout if interrupted by * Auto restarts with adjusted timeout if interrupted by
* signal other than our wakeup signal. * signal other than our wakeup signal.
*/ */
int NET_Timeout(int s, long timeout) { int NET_Timeout0(int s, long timeout, long currentTime) {
long prevtime = 0, newtime; long prevtime = currentTime, newtime;
struct timeval t; struct timeval t;
fdEntry_t *fdEntry = getFdEntry(s); fdEntry_t *fdEntry = getFdEntry(s);
...@@ -337,14 +341,6 @@ int NET_Timeout(int s, long timeout) { ...@@ -337,14 +341,6 @@ int NET_Timeout(int s, long timeout) {
return -1; 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(;;) { for(;;) {
struct pollfd pfd; struct pollfd pfd;
int rv; int rv;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <netdb.h> #include <netdb.h>
#include <stdlib.h> #include <stdlib.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <sys/time.h>
#ifndef _ALLBSD_SOURCE #ifndef _ALLBSD_SOURCE
#include <values.h> #include <values.h>
...@@ -1661,3 +1662,20 @@ NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout) ...@@ -1661,3 +1662,20 @@ NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout)
return timeout; 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
...@@ -47,9 +47,13 @@ ...@@ -47,9 +47,13 @@
close subroutine does not return until the select call returns. 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_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_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, extern int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
struct sockaddr *from, int *fromlen); struct sockaddr *from, int *fromlen);
extern int NET_ReadV(int s, const struct iovec * vector, int count); extern int NET_ReadV(int s, const struct iovec * vector, int count);
......
/*
* 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();
}
}
}
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
/* @test /* @test
@bug 8167102 @bug 8167102
@summary PrintRequestAttributeSet breaks page size set using PageFormat @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 @run main/manual WrongPaperPrintingTest
*/ */
......
/*
* 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);
}
}
}
}
/*
* 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);
}
/*
* 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;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册