aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlana <none@none>2014-03-05 15:34:27 -0800
committerlana <none@none>2014-03-05 15:34:27 -0800
commitb55be653f9a77404d6168d466f2df8292f7c290c (patch)
tree36c79fea8ba3e04fbf03a9d91d99f34d11beb28d
parent8a2d75e491b48731e3fc74c2a280ec8d7f1e9221 (diff)
parent76a9d7157b86c2fb25292c2a811d3c59ac07189d (diff)
-rw-r--r--make/mapfiles/libjava/mapfile-vers6
-rw-r--r--make/mapfiles/libjfr/mapfile-vers1
-rw-r--r--src/macosx/classes/com/apple/laf/AquaImageFactory.java23
-rw-r--r--src/macosx/classes/com/apple/laf/AquaUtils.java8
-rw-r--r--src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java13
-rw-r--r--src/macosx/native/sun/awt/CDataTransferer.m12
-rw-r--r--src/macosx/native/sun/awt/LWCToolkit.m15
-rw-r--r--src/share/classes/java/io/FileInputStream.java16
-rw-r--r--src/share/classes/java/io/FileOutputStream.java10
-rw-r--r--src/share/classes/java/io/RandomAccessFile.java21
-rw-r--r--src/share/classes/sun/awt/image/MultiResolutionBufferedImage.java71
-rw-r--r--src/share/classes/sun/nio/ch/FileChannelImpl.java31
-rw-r--r--src/share/classes/sun/nio/ch/NativeThreadSet.java22
-rw-r--r--src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java1
-rw-r--r--src/share/instrument/Reentrancy.c2
-rw-r--r--src/share/native/com/sun/java/util/jar/pack/coding.cpp4
-rw-r--r--src/share/native/com/sun/java/util/jar/pack/defines.h4
-rw-r--r--src/share/native/common/jni_util.h17
-rw-r--r--src/share/native/java/io/FileInputStream.c2
-rw-r--r--src/share/native/java/io/RandomAccessFile.c4
-rw-r--r--src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java4
-rw-r--r--src/solaris/classes/sun/nio/fs/UnixChannelFactory.java6
-rw-r--r--src/solaris/native/java/net/PlainDatagramSocketImpl.c20
-rw-r--r--src/solaris/native/java/net/PlainSocketImpl.c3
-rw-r--r--src/solaris/native/java/net/SocketInputStream.c2
-rw-r--r--src/solaris/native/java/net/bsd_close.c29
-rw-r--r--src/solaris/native/java/net/linux_close.c1
-rw-r--r--src/solaris/native/sun/awt/gtk2_interface.c7
-rw-r--r--src/solaris/native/sun/nio/ch/NativeThread.c45
-rw-r--r--src/windows/classes/sun/nio/fs/WindowsChannelFactory.java15
-rw-r--r--test/ProblemList.txt5
-rw-r--r--test/java/awt/Frame/ExceptionOnSetExtendedStateTest/ExceptionOnSetExtendedStateTest.java103
-rw-r--r--test/java/lang/instrument/DaemonThread/DummyAgent.java46
-rw-r--r--test/java/lang/instrument/DaemonThread/DummyClass.java27
-rw-r--r--test/java/lang/instrument/DaemonThread/TestDaemonThread.java72
-rw-r--r--test/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java44
-rw-r--r--test/java/net/ServerSocket/AnotherSelectFdsLimit.java78
-rw-r--r--test/java/nio/channels/Selector/ByteServer.java68
-rw-r--r--test/java/nio/channels/Selector/ReadAfterConnect.java34
-rw-r--r--test/java/nio/channels/Selector/SelectAfterRead.java92
-rw-r--r--test/java/nio/channels/Selector/SelectWrite.java43
-rw-r--r--test/javax/swing/JMenuItem/8031573/bug8031573.html40
-rw-r--r--test/javax/swing/JMenuItem/8031573/bug8031573.java60
-rw-r--r--test/javax/xml/jaxp/transform/8004476/TestBase.java21
-rw-r--r--test/sun/management/jmxremote/bootstrap/LocalManagementTest.java7
45 files changed, 932 insertions, 223 deletions
diff --git a/make/mapfiles/libjava/mapfile-vers b/make/mapfiles/libjava/mapfile-vers
index d2d806739..e6fd0f53f 100644
--- a/make/mapfiles/libjava/mapfile-vers
+++ b/make/mapfiles/libjava/mapfile-vers
@@ -79,7 +79,7 @@ SUNWprivate_1.1 {
Java_java_io_FileInputStream_close0;
Java_java_io_FileInputStream_initIDs;
Java_java_io_FileInputStream_open;
- Java_java_io_FileInputStream_read;
+ Java_java_io_FileInputStream_read0;
Java_java_io_FileInputStream_readBytes;
Java_java_io_FileInputStream_skip;
Java_java_io_FileOutputStream_close0;
@@ -98,11 +98,11 @@ SUNWprivate_1.1 {
Java_java_io_RandomAccessFile_initIDs;
Java_java_io_RandomAccessFile_length;
Java_java_io_RandomAccessFile_open;
- Java_java_io_RandomAccessFile_read;
+ Java_java_io_RandomAccessFile_read0;
Java_java_io_RandomAccessFile_readBytes;
Java_java_io_RandomAccessFile_seek0;
Java_java_io_RandomAccessFile_setLength;
- Java_java_io_RandomAccessFile_write;
+ Java_java_io_RandomAccessFile_write0;
Java_java_io_RandomAccessFile_writeBytes;
Java_java_io_UnixFileSystem_canonicalize0;
Java_java_io_UnixFileSystem_checkAccess;
diff --git a/make/mapfiles/libjfr/mapfile-vers b/make/mapfiles/libjfr/mapfile-vers
index 8031edc9d..dea13dd98 100644
--- a/make/mapfiles/libjfr/mapfile-vers
+++ b/make/mapfiles/libjfr/mapfile-vers
@@ -34,6 +34,7 @@ SUNWprivate_1.1 {
Java_oracle_jrockit_jfr_VMJFR_getPeriod;
Java_oracle_jrockit_jfr_VMJFR_descriptors;
Java_oracle_jrockit_jfr_VMJFR_redefineClass0;
+ Java_oracle_jrockit_jfr_VMJFR_retransformClasses0;
JNI_OnLoad;
local:
*;
diff --git a/src/macosx/classes/com/apple/laf/AquaImageFactory.java b/src/macosx/classes/com/apple/laf/AquaImageFactory.java
index 7343ae3c4..5451abd5d 100644
--- a/src/macosx/classes/com/apple/laf/AquaImageFactory.java
+++ b/src/macosx/classes/com/apple/laf/AquaImageFactory.java
@@ -48,6 +48,7 @@ import com.apple.laf.AquaUtils.RecyclableObject;
import com.apple.laf.AquaUtils.RecyclableSingleton;
import java.util.Arrays;
import java.util.List;
+import sun.awt.image.MultiResolutionBufferedImage;
import sun.awt.image.MultiResolutionImage;
public class AquaImageFactory {
@@ -230,7 +231,7 @@ public class AquaImageFactory {
@Override
protected Image getInstance() {
- return Toolkit.getDefaultToolkit().getImage("NSImage://" + namedImage);
+ return getNSIcon(namedImage);
}
}
@@ -294,11 +295,27 @@ public class AquaImageFactory {
}
public static Icon getMenuItemCheckIcon() {
- return new InvertableImageIcon(AquaUtils.generateLightenedImage(Toolkit.getDefaultToolkit().getImage("NSImage://NSMenuItemSelection"), 25));
+ return new InvertableImageIcon(AquaUtils.generateLightenedImage(
+ getNSIcon("NSMenuItemSelection"), 25));
}
public static Icon getMenuItemDashIcon() {
- return new InvertableImageIcon(AquaUtils.generateLightenedImage(Toolkit.getDefaultToolkit().getImage("NSImage://NSMenuMixedState"), 25));
+ return new InvertableImageIcon(AquaUtils.generateLightenedImage(
+ getNSIcon("NSMenuMixedState"), 25));
+ }
+
+ private static Image getNSIcon(String imageName) {
+ Image icon = Toolkit.getDefaultToolkit()
+ .getImage("NSImage://" + imageName);
+
+ if (icon instanceof MultiResolutionImage) {
+ return icon;
+ }
+
+ Image icon2x = AquaUtils.getCImageCreator().createImageFromName(
+ imageName, 2 * icon.getWidth(null), 2 * icon.getHeight(null));
+ return new MultiResolutionBufferedImage(
+ BufferedImage.TYPE_INT_ARGB_PRE, 0, icon, icon2x);
}
public static class NineSliceMetrics {
diff --git a/src/macosx/classes/com/apple/laf/AquaUtils.java b/src/macosx/classes/com/apple/laf/AquaUtils.java
index a5f5501cb..6a5228391 100644
--- a/src/macosx/classes/com/apple/laf/AquaUtils.java
+++ b/src/macosx/classes/com/apple/laf/AquaUtils.java
@@ -48,6 +48,7 @@ import sun.security.action.GetPropertyAction;
import sun.swing.SwingUtilities2;
import com.apple.laf.AquaImageFactory.SlicedImageControl;
+import sun.awt.image.MultiResolutionBufferedImage;
final class AquaUtils {
@@ -123,6 +124,13 @@ final class AquaUtils {
static Image generateLightenedImage(final Image image, final int percent) {
final GrayFilter filter = new GrayFilter(true, percent);
+ return (image instanceof MultiResolutionBufferedImage)
+ ? ((MultiResolutionBufferedImage) image).map(
+ rv -> generateLightenedImage(rv, filter))
+ : generateLightenedImage(image, filter);
+ }
+
+ static Image generateLightenedImage(Image image, ImageFilter filter) {
final ImageProducer prod = new FilteredImageSource(image.getSource(), filter);
return Toolkit.getDefaultToolkit().createImage(prod);
}
diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
index f0eebfcdc..50703d40a 100644
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -583,7 +583,12 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
// setVisible could have changed the native maximized state
deliverZoom(true);
} else {
- switch (((Frame)target).getExtendedState()) {
+ int frameState = ((Frame)target).getExtendedState();
+ if ((frameState & Frame.ICONIFIED) != 0) {
+ // Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
+ frameState = Frame.ICONIFIED;
+ }
+ switch (frameState) {
case Frame.ICONIFIED:
CWrapper.NSWindow.miniaturize(nsWindowPtr);
break;
@@ -788,6 +793,10 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
if (prevWindowState == windowState) return;
final long nsWindowPtr = getNSWindowPtr();
+ if ((windowState & Frame.ICONIFIED) != 0) {
+ // Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
+ windowState = Frame.ICONIFIED;
+ }
switch (windowState) {
case Frame.ICONIFIED:
if (prevWindowState == Frame.MAXIMIZED_BOTH) {
diff --git a/src/macosx/native/sun/awt/CDataTransferer.m b/src/macosx/native/sun/awt/CDataTransferer.m
index 5e997bf7a..09a7e5c3a 100644
--- a/src/macosx/native/sun/awt/CDataTransferer.m
+++ b/src/macosx/native/sun/awt/CDataTransferer.m
@@ -28,6 +28,7 @@
#import <AppKit/AppKit.h>
#import <JavaNativeFoundation/JavaNativeFoundation.h>
+#import "jni_util.h"
#include "ThreadUtilities.h"
@@ -172,7 +173,9 @@ JNF_COCOA_ENTER(env);
NSData *tiffImage = [imageRep TIFFRepresentation];
jsize tiffSize = (jsize)[tiffImage length]; // #warning 64-bit: -length returns NSUInteger, but NewByteArray takes jsize
returnValue = (*env)->NewByteArray(env, tiffSize);
+ CHECK_NULL_RETURN(returnValue, nil);
jbyte *tiffData = (jbyte *)(*env)->GetPrimitiveArrayCritical(env, returnValue, 0);
+ CHECK_NULL_RETURN(tiffData, nil);
[tiffImage getBytes:tiffData];
(*env)->ReleasePrimitiveArrayCritical(env, returnValue, tiffData, 0); // Do not use JNI_COMMIT, as that will not free the buffer copy when +ProtectJavaHeap is on.
[imageRep release];
@@ -184,12 +187,13 @@ JNF_COCOA_EXIT(env);
static jobject getImageForByteStream(JNIEnv *env, jbyteArray sourceData)
{
- if (sourceData == NULL) return NULL;
+ CHECK_NULL_RETURN(sourceData, NULL);
jsize sourceSize = (*env)->GetArrayLength(env, sourceData);
if (sourceSize == 0) return NULL;
jbyte *sourceBytes = (*env)->GetPrimitiveArrayCritical(env, sourceData, NULL);
+ CHECK_NULL_RETURN(sourceBytes, NULL);
NSData *rawData = [NSData dataWithBytes:sourceBytes length:sourceSize];
NSImage *newImage = [[NSImage alloc] initWithData:rawData];
@@ -197,8 +201,7 @@ static jobject getImageForByteStream(JNIEnv *env, jbyteArray sourceData)
[newImage release];
(*env)->ReleasePrimitiveArrayCritical(env, sourceData, sourceBytes, JNI_ABORT);
-
- if (newImage == nil) return NULL;
+ CHECK_NULL_RETURN(newImage, NULL);
// The ownership of the NSImage is passed to the new CImage jobject. No need to release it.
static JNF_CLASS_CACHE(jc_CImage, "sun/lwawt/macosx/CImage");
@@ -231,7 +234,8 @@ static jobjectArray CreateJavaFilenameArray(JNIEnv *env, NSArray *filenameArray)
if (filenameCount == 0) return nil;
// Get the java.lang.String class object:
- jclass stringClazz = (*env)->FindClass(env, "java/lang/String"); // can't be null
+ jclass stringClazz = (*env)->FindClass(env, "java/lang/String");
+ CHECK_NULL_RETURN(stringClazz, nil);
jobject jfilenameArray = (*env)->NewObjectArray(env, filenameCount, stringClazz, NULL); // AWT_THREADING Safe (known object)
if ((*env)->ExceptionOccurred(env)) {
(*env)->ExceptionDescribe(env);
diff --git a/src/macosx/native/sun/awt/LWCToolkit.m b/src/macosx/native/sun/awt/LWCToolkit.m
index 3300e2ddc..5e2dd6cb4 100644
--- a/src/macosx/native/sun/awt/LWCToolkit.m
+++ b/src/macosx/native/sun/awt/LWCToolkit.m
@@ -200,13 +200,17 @@ Java_sun_lwawt_macosx_LWCToolkit_initIDs
gNumberOfButtons = sun_lwawt_macosx_LWCToolkit_BUTTONS;
jclass inputEventClazz = (*env)->FindClass(env, "java/awt/event/InputEvent");
+ CHECK_NULL(inputEventClazz);
jmethodID getButtonDownMasksID = (*env)->GetStaticMethodID(env, inputEventClazz, "getButtonDownMasks", "()[I");
+ CHECK_NULL(getButtonDownMasksID);
jintArray obj = (jintArray)(*env)->CallStaticObjectMethod(env, inputEventClazz, getButtonDownMasksID);
jint * tmp = (*env)->GetIntArrayElements(env, obj, JNI_FALSE);
+ CHECK_NULL(tmp);
gButtonDownMasks = (jint*)SAFE_SIZE_ARRAY_ALLOC(malloc, sizeof(jint), gNumberOfButtons);
if (gButtonDownMasks == NULL) {
gNumberOfButtons = 0;
+ (*env)->ReleaseIntArrayElements(env, obj, tmp, JNI_ABORT);
JNU_ThrowOutOfMemoryError(env, NULL);
return;
}
@@ -240,7 +244,7 @@ static UInt32 RGB(NSColor *c) {
return ((ia & 0xFF) << 24) | ((ir & 0xFF) << 16) | ((ig & 0xFF) << 8) | ((ib & 0xFF) << 0);
}
-void doLoadNativeColors(JNIEnv *env, jintArray jColors, BOOL useAppleColors) {
+BOOL doLoadNativeColors(JNIEnv *env, jintArray jColors, BOOL useAppleColors) {
jint len = (*env)->GetArrayLength(env, jColors);
UInt32 colorsArray[len];
@@ -254,8 +258,12 @@ void doLoadNativeColors(JNIEnv *env, jintArray jColors, BOOL useAppleColors) {
}];
jint *_colors = (*env)->GetPrimitiveArrayCritical(env, jColors, 0);
+ if (_colors == NULL) {
+ return NO;
+ }
memcpy(_colors, colors, len * sizeof(UInt32));
(*env)->ReleasePrimitiveArrayCritical(env, jColors, _colors, 0);
+ return YES;
}
/**
@@ -267,8 +275,9 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_loadNativeColors
(JNIEnv *env, jobject peer, jintArray jSystemColors, jintArray jAppleColors)
{
JNF_COCOA_ENTER(env);
- doLoadNativeColors(env, jSystemColors, NO);
- doLoadNativeColors(env, jAppleColors, YES);
+ if (doLoadNativeColors(env, jSystemColors, NO)) {
+ doLoadNativeColors(env, jAppleColors, YES);
+ }
JNF_COCOA_EXIT(env);
}
diff --git a/src/share/classes/java/io/FileInputStream.java b/src/share/classes/java/io/FileInputStream.java
index 3e67fb855..cc6710e8f 100644
--- a/src/share/classes/java/io/FileInputStream.java
+++ b/src/share/classes/java/io/FileInputStream.java
@@ -51,6 +51,12 @@ class FileInputStream extends InputStream
/* File Descriptor - handle to the open file */
private final FileDescriptor fd;
+ /**
+ * The path of the referenced file
+ * (null if the stream is created with a file descriptor)
+ */
+ private final String path;
+
private FileChannel channel = null;
private final Object closeLock = new Object();
@@ -128,6 +134,7 @@ class FileInputStream extends InputStream
}
fd = new FileDescriptor();
fd.attach(this);
+ path = name;
open(name);
}
@@ -164,6 +171,7 @@ class FileInputStream extends InputStream
security.checkRead(fdObj);
}
fd = fdObj;
+ path = null;
/*
* FileDescriptor is being shared by streams.
@@ -186,7 +194,11 @@ class FileInputStream extends InputStream
* file is reached.
* @exception IOException if an I/O error occurs.
*/
- public native int read() throws IOException;
+ public int read() throws IOException {
+ return read0();
+ }
+
+ private native int read0() throws IOException;
/**
* Reads a subarray as a sequence of bytes.
@@ -345,7 +357,7 @@ class FileInputStream extends InputStream
public FileChannel getChannel() {
synchronized (this) {
if (channel == null) {
- channel = FileChannelImpl.open(fd, true, false, this);
+ channel = FileChannelImpl.open(fd, path, true, false, this);
}
return channel;
}
diff --git a/src/share/classes/java/io/FileOutputStream.java b/src/share/classes/java/io/FileOutputStream.java
index 44f472870..8377261b4 100644
--- a/src/share/classes/java/io/FileOutputStream.java
+++ b/src/share/classes/java/io/FileOutputStream.java
@@ -67,6 +67,12 @@ class FileOutputStream extends OutputStream
*/
private FileChannel channel;
+ /**
+ * The path of the referenced file
+ * (null if the stream is created with a file descriptor)
+ */
+ private final String path;
+
private final Object closeLock = new Object();
private volatile boolean closed = false;
@@ -202,6 +208,7 @@ class FileOutputStream extends OutputStream
this.fd = new FileDescriptor();
fd.attach(this);
this.append = append;
+ this.path = name;
open(name, append);
}
@@ -239,6 +246,7 @@ class FileOutputStream extends OutputStream
}
this.fd = fdObj;
this.append = false;
+ this.path = null;
fd.attach(this);
}
@@ -376,7 +384,7 @@ class FileOutputStream extends OutputStream
public FileChannel getChannel() {
synchronized (this) {
if (channel == null) {
- channel = FileChannelImpl.open(fd, false, true, append, this);
+ channel = FileChannelImpl.open(fd, path, false, true, append, this);
}
return channel;
}
diff --git a/src/share/classes/java/io/RandomAccessFile.java b/src/share/classes/java/io/RandomAccessFile.java
index c48aa99b3..58d8c89cd 100644
--- a/src/share/classes/java/io/RandomAccessFile.java
+++ b/src/share/classes/java/io/RandomAccessFile.java
@@ -62,6 +62,12 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
private FileChannel channel = null;
private boolean rw;
+ /**
+ * The path of the referenced file
+ * (null if the stream is created with a file descriptor)
+ */
+ private final String path;
+
private Object closeLock = new Object();
private volatile boolean closed = false;
@@ -233,6 +239,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
}
fd = new FileDescriptor();
fd.attach(this);
+ path = name;
open(name, imode);
}
@@ -272,7 +279,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
public final FileChannel getChannel() {
synchronized (this) {
if (channel == null) {
- channel = FileChannelImpl.open(fd, true, rw, this);
+ channel = FileChannelImpl.open(fd, path, true, rw, this);
}
return channel;
}
@@ -309,7 +316,11 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* @exception IOException if an I/O error occurs. Not thrown if
* end-of-file has been reached.
*/
- public native int read() throws IOException;
+ public int read() throws IOException {
+ return read0();
+ }
+
+ private native int read0() throws IOException;
/**
* Reads a sub array as a sequence of bytes.
@@ -457,7 +468,11 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* @param b the {@code byte} to be written.
* @exception IOException if an I/O error occurs.
*/
- public native void write(int b) throws IOException;
+ public void write(int b) throws IOException {
+ write0(b);
+ }
+
+ private native void write0(int b) throws IOException;
/**
* Writes a sub array as a sequence of bytes.
diff --git a/src/share/classes/sun/awt/image/MultiResolutionBufferedImage.java b/src/share/classes/sun/awt/image/MultiResolutionBufferedImage.java
new file mode 100644
index 000000000..79f7a3b4d
--- /dev/null
+++ b/src/share/classes/sun/awt/image/MultiResolutionBufferedImage.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2014, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 sun.awt.image;
+
+import java.awt.Image;
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Function;
+
+public class MultiResolutionBufferedImage extends BufferedImage
+ implements MultiResolutionImage {
+
+ Image[] resolutionVariants;
+ int baseIndex;
+
+ public MultiResolutionBufferedImage(int imageType, int baseIndex, Image... images) {
+ super(images[baseIndex].getWidth(null), images[baseIndex].getHeight(null),
+ imageType);
+ this.baseIndex = baseIndex;
+ this.resolutionVariants = images;
+ Graphics g = getGraphics();
+ g.drawImage(images[baseIndex], 0, 0, null);
+ g.dispose();
+ images[baseIndex] = this;
+ }
+
+ @Override
+ public Image getResolutionVariant(int width, int height) {
+ for (Image image : resolutionVariants) {
+ if (width <= image.getWidth(null) && height <= image.getHeight(null)) {
+ return image;
+ }
+ }
+ return this;
+ }
+
+ @Override
+ public List<Image> getResolutionVariants() {
+ return Arrays.asList(resolutionVariants);
+ }
+
+ public MultiResolutionBufferedImage map(Function<Image, Image> mapper) {
+ return new MultiResolutionBufferedImage(getType(), baseIndex,
+ Arrays.stream(resolutionVariants).map(mapper)
+ .toArray(length -> new Image[length]));
+ }
+}
diff --git a/src/share/classes/sun/nio/ch/FileChannelImpl.java b/src/share/classes/sun/nio/ch/FileChannelImpl.java
index 703f59826..bb127e8a5 100644
--- a/src/share/classes/sun/nio/ch/FileChannelImpl.java
+++ b/src/share/classes/sun/nio/ch/FileChannelImpl.java
@@ -29,10 +29,20 @@ import java.io.FileDescriptor;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
-import java.nio.channels.*;
+import java.nio.channels.ClosedByInterruptException;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
+import java.nio.channels.FileLockInterruptionException;
+import java.nio.channels.NonReadableChannelException;
+import java.nio.channels.NonWritableChannelException;
+import java.nio.channels.OverlappingFileLockException;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.WritableByteChannel;
+import java.security.AccessController;
import java.util.ArrayList;
import java.util.List;
-import java.security.AccessController;
+
import sun.misc.Cleaner;
import sun.security.action.GetPropertyAction;
@@ -56,13 +66,17 @@ public class FileChannelImpl
// Required to prevent finalization of creating stream (immutable)
private final Object parent;
+ // The path of the referenced file
+ // (null if the parent stream is created with a file descriptor)
+ private final String path;
+
// Thread-safe set of IDs of native threads, for signalling
private final NativeThreadSet threads = new NativeThreadSet(2);
// Lock for operations involving position and size
private final Object positionLock = new Object();
- private FileChannelImpl(FileDescriptor fd, boolean readable,
+ private FileChannelImpl(FileDescriptor fd, String path, boolean readable,
boolean writable, boolean append, Object parent)
{
this.fd = fd;
@@ -70,23 +84,24 @@ public class FileChannelImpl
this.writable = writable;
this.append = append;
this.parent = parent;
+ this.path = path;
this.nd = new FileDispatcherImpl(append);
}
// Used by FileInputStream.getChannel() and RandomAccessFile.getChannel()
- public static FileChannel open(FileDescriptor fd,
+ public static FileChannel open(FileDescriptor fd, String path,
boolean readable, boolean writable,
Object parent)
{
- return new FileChannelImpl(fd, readable, writable, false, parent);
+ return new FileChannelImpl(fd, path, readable, writable, false, parent);
}
// Used by FileOutputStream.getChannel
- public static FileChannel open(FileDescriptor fd,
+ public static FileChannel open(FileDescriptor fd, String path,
boolean readable, boolean writable,
boolean append, Object parent)
{
- return new FileChannelImpl(fd, readable, writable, append, parent);
+ return new FileChannelImpl(fd, path, readable, writable, append, parent);
}
private void ensureOpen() throws IOException {
@@ -110,7 +125,7 @@ public class FileChannelImpl
}
}
- nd.preClose(fd);
+ // signal any threads blocked on this channel
threads.signalAndWait();
if (parent != null) {
diff --git a/src/share/classes/sun/nio/ch/NativeThreadSet.java b/src/share/classes/sun/nio/ch/NativeThreadSet.java
index d6d4c5c9a..5eb90af87 100644
--- a/src/share/classes/sun/nio/ch/NativeThreadSet.java
+++ b/src/share/classes/sun/nio/ch/NativeThreadSet.java
@@ -82,8 +82,9 @@ class NativeThreadSet {
// Signals all threads in this set.
//
- void signalAndWait() {
- synchronized (this) {
+ synchronized void signalAndWait() {
+ boolean interrupted = false;
+ while (used > 0) {
int u = used;
int n = elts.length;
for (int i = 0; i < n; i++) {
@@ -96,16 +97,15 @@ class NativeThreadSet {
break;
}
waitingToEmpty = true;
- boolean interrupted = false;
- while (used > 0) {
- try {
- wait();
- } catch (InterruptedException e) {
- interrupted = true;
- }
+ try {
+ wait(50);
+ } catch (InterruptedException e) {
+ interrupted = true;
+ } finally {
+ waitingToEmpty = false;
}
- if (interrupted)
- Thread.currentThread().interrupt();
}
+ if (interrupted)
+ Thread.currentThread().interrupt();
}
}
diff --git a/src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java b/src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java
index d0813390a..565848055 100644
--- a/src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java
+++ b/src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java
@@ -88,7 +88,6 @@ public class SimpleAsynchronousFileChannelImpl
invalidateAllLocks();
// signal any threads blocked on this channel
- nd.preClose(fdObj);
threads.signalAndWait();
// wait until all async I/O operations have completely gracefully
diff --git a/src/share/instrument/Reentrancy.c b/src/share/instrument/Reentrancy.c
index 58cbfdd1b..0b526c10a 100644
--- a/src/share/instrument/Reentrancy.c
+++ b/src/share/instrument/Reentrancy.c
@@ -130,6 +130,7 @@ tryToAcquireReentrancyToken( jvmtiEnv * jvmtienv,
error = confirmingTLSSet ( jvmtienv,
thread,
JPLIS_CURRENTLY_INSIDE_TOKEN);
+ check_phase_ret_false(error);
jplis_assert(error == JVMTI_ERROR_NONE);
if ( error != JVMTI_ERROR_NONE ) {
result = JNI_FALSE;
@@ -158,6 +159,7 @@ releaseReentrancyToken( jvmtiEnv * jvmtienv,
error = confirmingTLSSet( jvmtienv,
thread,
JPLIS_CURRENTLY_OUTSIDE_TOKEN);
+ check_phase_ret(error);
jplis_assert(error == JVMTI_ERROR_NONE);
}
diff --git a/src/share/native/com/sun/java/util/jar/pack/coding.cpp b/src/share/native/com/sun/java/util/jar/pack/coding.cpp
index 6cedfd80d..66ecc1bff 100644
--- a/src/share/native/com/sun/java/util/jar/pack/coding.cpp
+++ b/src/share/native/com/sun/java/util/jar/pack/coding.cpp
@@ -32,6 +32,8 @@
#include <stdlib.h>
#include <stdarg.h>
+#include "jni_util.h"
+
#include "defines.h"
#include "bytes.h"
#include "utils.h"
@@ -147,7 +149,7 @@ coding* coding::findBySpec(int spec) {
break;
}
coding* ptr = NEW(coding, 1);
- CHECK_NULL_0(ptr);
+ CHECK_NULL_RETURN(ptr, 0);
coding* c = ptr->initFrom(spec);
if (c == null) {
mtrace('f', ptr, 0);
diff --git a/src/share/native/com/sun/java/util/jar/pack/defines.h b/src/share/native/com/sun/java/util/jar/pack/defines.h
index b202892fa..644b9ca9a 100644
--- a/src/share/native/com/sun/java/util/jar/pack/defines.h
+++ b/src/share/native/com/sun/java/util/jar/pack/defines.h
@@ -158,10 +158,6 @@ enum { false, true };
#define CHECK_(y) _CHECK_DO(aborting(), return y)
#define CHECK_0 _CHECK_DO(aborting(), return 0)
-#define CHECK_NULL(p) _CHECK_DO((p)==null, return)
-#define CHECK_NULL_(y,p) _CHECK_DO((p)==null, return y)
-#define CHECK_NULL_0(p) _CHECK_DO((p)==null, return 0)
-
#define CHECK_COUNT(t) if (t < 0){abort("bad value count");} CHECK
#define STR_TRUE "true"
diff --git a/src/share/native/common/jni_util.h b/src/share/native/common/jni_util.h
index b8d23cd1c..0242d71f4 100644
--- a/src/share/native/common/jni_util.h
+++ b/src/share/native/common/jni_util.h
@@ -297,6 +297,21 @@ JNU_NotifyAll(JNIEnv *env, jobject object);
} \
} while (0) \
+#ifdef __cplusplus
+#define JNU_CHECK_EXCEPTION(env) \
+ do { \
+ if ((env)->ExceptionCheck()) { \
+ return; \
+ } \
+ } while (0) \
+
+#define JNU_CHECK_EXCEPTION_RETURN(env, y) \
+ do { \
+ if ((env)->ExceptionCheck()) { \
+ return (y); \
+ } \
+ } while (0)
+#else
#define JNU_CHECK_EXCEPTION(env) \
do { \
if ((*env)->ExceptionCheck(env)) { \
@@ -310,7 +325,7 @@ JNU_NotifyAll(JNIEnv *env, jobject object);
return (y); \
} \
} while (0)
-
+#endif /* __cplusplus */
/************************************************************************
* Debugging utilities
*/
diff --git a/src/share/native/java/io/FileInputStream.c b/src/share/native/java/io/FileInputStream.c
index 52e2cdd8e..092ddbf6f 100644
--- a/src/share/native/java/io/FileInputStream.c
+++ b/src/share/native/java/io/FileInputStream.c
@@ -62,7 +62,7 @@ Java_java_io_FileInputStream_open(JNIEnv *env, jobject this, jstring path) {
}
JNIEXPORT jint JNICALL
-Java_java_io_FileInputStream_read(JNIEnv *env, jobject this) {
+Java_java_io_FileInputStream_read0(JNIEnv *env, jobject this) {
return readSingle(env, this, fis_fd);
}
diff --git a/src/share/native/java/io/RandomAccessFile.c b/src/share/native/java/io/RandomAccessFile.c
index 3251db87f..53b5f1aac 100644
--- a/src/share/native/java/io/RandomAccessFile.c
+++ b/src/share/native/java/io/RandomAccessFile.c
@@ -64,7 +64,7 @@ Java_java_io_RandomAccessFile_open(JNIEnv *env,
}
JNIEXPORT jint JNICALL
-Java_java_io_RandomAccessFile_read(JNIEnv *env, jobject this) {
+Java_java_io_RandomAccessFile_read0(JNIEnv *env, jobject this) {
return readSingle(env, this, raf_fd);
}
@@ -75,7 +75,7 @@ Java_java_io_RandomAccessFile_readBytes(JNIEnv *env,
}
JNIEXPORT void JNICALL
-Java_java_io_RandomAccessFile_write(JNIEnv *env, jobject this, jint byte) {
+Java_java_io_RandomAccessFile_write0(JNIEnv *env, jobject this, jint byte) {
writeSingle(env, this, byte, JNI_FALSE, raf_fd);
}
diff --git a/src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java b/src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java
index e8e756c28..d5edf3f39 100644
--- a/src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java
+++ b/src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java
@@ -149,7 +149,7 @@ class SolarisUserDefinedFileAttributeView
int afd = openat(fd, nameAsBytes(file,name), (O_RDONLY|O_XATTR), 0);
// wrap with channel
- FileChannel fc = UnixChannelFactory.newFileChannel(afd, true, false);
+ FileChannel fc = UnixChannelFactory.newFileChannel(afd, file.toString(), true, false);
// read to EOF (nothing we can do if I/O error occurs)
try {
@@ -190,7 +190,7 @@ class SolarisUserDefinedFileAttributeView
UnixFileModeAttribute.ALL_PERMISSIONS);
// wrap with channel
- FileChannel fc = UnixChannelFactory.newFileChannel(afd, false, true);
+ FileChannel fc = UnixChannelFactory.newFileChannel(afd, file.toString(), false, true);
// write value (nothing we can do if I/O error occurs)
try {
diff --git a/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java b/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java
index d18a466e5..c6f074e59 100644
--- a/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java
+++ b/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java
@@ -100,10 +100,10 @@ class UnixChannelFactory {
/**
* Constructs a file channel from an existing (open) file descriptor
*/
- static FileChannel newFileChannel(int fd, boolean reading, boolean writing) {
+ static FileChannel newFileChannel(int fd, String path, boolean reading, boolean writing) {
FileDescriptor fdObj = new FileDescriptor();
fdAccess.set(fdObj, fd);
- return FileChannelImpl.open(fdObj, reading, writing, null);
+ return FileChannelImpl.open(fdObj, path, reading, writing, null);
}
/**
@@ -134,7 +134,7 @@ class UnixChannelFactory {
throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed");
FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode);
- return FileChannelImpl.open(fdObj, flags.read, flags.write, flags.append, null);
+ return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write, flags.append, null);
}
/**
diff --git a/src/solaris/native/java/net/PlainDatagramSocketImpl.c b/src/solaris/native/java/net/PlainDatagramSocketImpl.c
index 356875600..86c3a7040 100644
--- a/src/solaris/native/java/net/PlainDatagramSocketImpl.c
+++ b/src/solaris/native/java/net/PlainDatagramSocketImpl.c
@@ -517,6 +517,8 @@ Java_java_net_PlainDatagramSocketImpl_peek(JNIEnv *env, jobject this,
} else if (ret == JVM_IO_ERR) {
if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
+ } else if (errno == ENOMEM) {
+ JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Peek failed");
}
@@ -617,15 +619,18 @@ Java_java_net_PlainDatagramSocketImpl_peekData(JNIEnv *env, jobject this,
"Receive timed out");
return -1;
} else if (ret == JVM_IO_ERR) {
+ if (errno == ENOMEM) {
+ JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
#ifdef __linux__
- if (errno == EBADF) {
+ } else if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
- }
#else
- JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
+ } else {
+ JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
#endif
+ }
return -1;
} else if (ret == JVM_IO_INTR) {
JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
@@ -835,15 +840,18 @@ Java_java_net_PlainDatagramSocketImpl_receive0(JNIEnv *env, jobject this,
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
"Receive timed out");
} else if (ret == JVM_IO_ERR) {
+ if (errno == ENOMEM) {
+ JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
#ifdef __linux__
- if (errno == EBADF) {
+ } else if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
- }
#else
- JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
+ } else {
+ JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
#endif
+ }
} else if (ret == JVM_IO_INTR) {
JNU_ThrowByName(env, JNU_JAVAIOPKG "InterruptedIOException",
"operation interrupted");
diff --git a/src/solaris/native/java/net/PlainSocketImpl.c b/src/solaris/native/java/net/PlainSocketImpl.c
index b6f78b9c1..5fed0700c 100644
--- a/src/solaris/native/java/net/PlainSocketImpl.c
+++ b/src/solaris/native/java/net/PlainSocketImpl.c
@@ -708,7 +708,6 @@ Java_java_net_PlainSocketImpl_socketAccept(JNIEnv *env, jobject this,
} else {
ret = NET_Timeout(fd, timeout);
}
-
if (ret == 0) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
"Accept timed out");
@@ -716,6 +715,8 @@ Java_java_net_PlainSocketImpl_socketAccept(JNIEnv *env, jobject this,
} else if (ret == JVM_IO_ERR) {
if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
+ } else if (errno == ENOMEM) {
+ JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Accept failed");
}
diff --git a/src/solaris/native/java/net/SocketInputStream.c b/src/solaris/native/java/net/SocketInputStream.c
index ccee03c9e..864326295 100644
--- a/src/solaris/native/java/net/SocketInputStream.c
+++ b/src/solaris/native/java/net/SocketInputStream.c
@@ -108,6 +108,8 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
} else if (nread == JVM_IO_ERR) {
if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
+ } else if (errno == ENOMEM) {
+ JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"select/poll failed");
diff --git a/src/solaris/native/java/net/bsd_close.c b/src/solaris/native/java/net/bsd_close.c
index f314357e8..5ec3bea43 100644
--- a/src/solaris/native/java/net/bsd_close.c
+++ b/src/solaris/native/java/net/bsd_close.c
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <sys/param.h>
#include <signal.h>
#include <pthread.h>
#include <sys/types.h>
@@ -35,7 +36,6 @@
#include <sys/uio.h>
#include <unistd.h>
#include <errno.h>
-
#include <sys/poll.h>
/*
@@ -347,6 +347,10 @@ int NET_Select(int s, fd_set *readfds, fd_set *writefds,
int NET_Timeout(int s, long timeout) {
long prevtime = 0, newtime;
struct timeval t, *tp = &t;
+ fd_set fds;
+ fd_set* fdsp = NULL;
+ int allocated = 0;
+ threadEntry_t self;
fdEntry_t *fdEntry = getFdEntry(s);
/*
@@ -376,20 +380,29 @@ int NET_Timeout(int s, long timeout) {
t.tv_usec = 0;
}
+ if (s < FD_SETSIZE) {
+ fdsp = &fds;
+ FD_ZERO(fdsp);
+ } else {
+ int length = (howmany(s+1, NFDBITS)) * sizeof(int);
+ fdsp = (fd_set *) calloc(1, length);
+ if (fdsp == NULL) {
+ return -1; // errno will be set to ENOMEM
+ }
+ allocated = 1;
+ }
+ FD_SET(s, fdsp);
+
for(;;) {
- fd_set rfds;
int rv;
- threadEntry_t self;
/*
* call select on the fd. If interrupted by our wakeup signal
* errno will be set to EBADF.
*/
- FD_ZERO(&rfds);
- FD_SET(s, &rfds);
startOp(fdEntry, &self);
- rv = select(s+1, &rfds, 0, 0, tp);
+ rv = select(s+1, fdsp, 0, 0, tp);
endOp(fdEntry, &self);
/*
@@ -403,6 +416,8 @@ int NET_Timeout(int s, long timeout) {
newtime = now.tv_sec * 1000 + now.tv_usec / 1000;
timeout -= newtime - prevtime;
if (timeout <= 0) {
+ if (allocated != 0)
+ free(fdsp);
return 0;
}
prevtime = newtime;
@@ -410,6 +425,8 @@ int NET_Timeout(int s, long timeout) {
t.tv_usec = (timeout % 1000) * 1000;
}
} else {
+ if (allocated != 0)
+ free(fdsp);
return rv;
}
diff --git a/src/solaris/native/java/net/linux_close.c b/src/solaris/native/java/net/linux_close.c
index 38d998658..2d3dfe2fb 100644
--- a/src/solaris/native/java/net/linux_close.c
+++ b/src/solaris/native/java/net/linux_close.c
@@ -34,7 +34,6 @@
#include <sys/uio.h>
#include <unistd.h>
#include <errno.h>
-
#include <sys/poll.h>
/*
diff --git a/src/solaris/native/sun/awt/gtk2_interface.c b/src/solaris/native/sun/awt/gtk2_interface.c
index efe079794..cfcef70fe 100644
--- a/src/solaris/native/sun/awt/gtk2_interface.c
+++ b/src/solaris/native/sun/awt/gtk2_interface.c
@@ -32,6 +32,7 @@
#include "java_awt_Transparency.h"
#include "jvm_md.h"
#include "sizecalc.h"
+#include <jni_util.h>
#define GTK2_LIB_VERSIONED VERSIONED_JNI_LIB_NAME("gtk-x11-2.0", "0")
#define GTK2_LIB JNI_LIB_NAME("gtk-x11-2.0")
@@ -456,13 +457,19 @@ void update_supported_actions(JNIEnv *env) {
const gchar * const * schemes = NULL;
jclass cls_action = (*env)->FindClass(env, "java/awt/Desktop$Action");
+ CHECK_NULL(cls_action);
jclass cls_xDesktopPeer = (*env)->FindClass(env, "sun/awt/X11/XDesktopPeer");
+ CHECK_NULL(cls_xDesktopPeer);
jfieldID fld_supportedActions = (*env)->GetStaticFieldID(env, cls_xDesktopPeer, "supportedActions", "Ljava/util/List;");
+ CHECK_NULL(fld_supportedActions);
jobject supportedActions = (*env)->GetStaticObjectField(env, cls_xDesktopPeer, fld_supportedActions);
jclass cls_arrayList = (*env)->FindClass(env, "java/util/ArrayList");
+ CHECK_NULL(cls_arrayList);
jmethodID mid_arrayListAdd = (*env)->GetMethodID(env, cls_arrayList, "add", "(Ljava/lang/Object;)Z");
+ CHECK_NULL(mid_arrayListAdd);
jmethodID mid_arrayListClear = (*env)->GetMethodID(env, cls_arrayList, "clear", "()V");
+ CHECK_NULL(mid_arrayListClear);
(*env)->CallVoidMethod(env, supportedActions, mid_arrayListClear);
diff --git a/src/solaris/native/sun/nio/ch/NativeThread.c b/src/solaris/native/sun/nio/ch/NativeThread.c
index 79a91a068..5e2a78b7a 100644
--- a/src/solaris/native/sun/nio/ch/NativeThread.c
+++ b/src/solaris/native/sun/nio/ch/NativeThread.c
@@ -32,27 +32,32 @@
#include "sun_nio_ch_NativeThread.h"
#include "nio_util.h"
-
#ifdef __linux__
-#include <pthread.h>
-#include <sys/signal.h>
-
-/* Also defined in src/solaris/native/java/net/linux_close.c */
-#define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
+ #include <pthread.h>
+ #include <sys/signal.h>
+ /* Also defined in net/linux_close.c */
+ #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
+#elif __solaris__
+ #include <thread.h>
+ #include <signal.h>
+ #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+#elif _ALLBSD_SOURCE
+ #include <pthread.h>
+ #include <signal.h>
+ /* Also defined in net/bsd_close.c */
+ #define INTERRUPT_SIGNAL SIGIO
+#else
+ #error "missing platform-specific definition here"
+#endif
static void
nullHandler(int sig)
{
}
-#endif
-
-
JNIEXPORT void JNICALL
Java_sun_nio_ch_NativeThread_init(JNIEnv *env, jclass cl)
{
-#ifdef __linux__
-
/* Install the null handler for INTERRUPT_SIGNAL. This might overwrite the
* handler previously installed by java/net/linux_close.c, but that's okay
* since neither handler actually does anything. We install our own
@@ -67,25 +72,27 @@ Java_sun_nio_ch_NativeThread_init(JNIEnv *env, jclass cl)
sigemptyset(&sa.sa_mask);
if (sigaction(INTERRUPT_SIGNAL, &sa, &osa) < 0)
JNU_ThrowIOExceptionWithLastError(env, "sigaction");
-
-#endif
}
JNIEXPORT jlong JNICALL
Java_sun_nio_ch_NativeThread_current(JNIEnv *env, jclass cl)
{
-#ifdef __linux__
- return (long)pthread_self();
+#ifdef __solaris__
+ return (jlong)thr_self();
#else
- return -1;
+ return (jlong)pthread_self();
#endif
}
JNIEXPORT void JNICALL
Java_sun_nio_ch_NativeThread_signal(JNIEnv *env, jclass cl, jlong thread)
{
-#ifdef __linux__
- if (pthread_kill((pthread_t)thread, INTERRUPT_SIGNAL))
- JNU_ThrowIOExceptionWithLastError(env, "Thread signal failed");
+ int ret;
+#ifdef __solaris__
+ ret = thr_kill((thread_t)thread, INTERRUPT_SIGNAL);
+#else
+ ret = pthread_kill((pthread_t)thread, INTERRUPT_SIGNAL);
#endif
+ if (ret != 0)
+ JNU_ThrowIOExceptionWithLastError(env, "Thread signal failed");
}
diff --git a/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java b/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java
index d9b1489c3..46d063ca1 100644
--- a/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java
+++ b/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java
@@ -25,19 +25,22 @@
package sun.nio.fs;
-import java.nio.file.*;
-import java.nio.channels.*;
import java.io.FileDescriptor;
import java.io.IOException;
-import java.util.*;
+import java.nio.channels.AsynchronousFileChannel;
+import java.nio.channels.FileChannel;
+import java.nio.file.LinkOption;
+import java.nio.file.OpenOption;
+import java.nio.file.StandardOpenOption;
+import java.util.Set;
import com.sun.nio.file.ExtendedOpenOption;
+import sun.misc.JavaIOFileDescriptorAccess;
+import sun.misc.SharedSecrets;
import sun.nio.ch.FileChannelImpl;
import sun.nio.ch.ThreadPool;
import sun.nio.ch.WindowsAsynchronousFileChannelImpl;
-import sun.misc.SharedSecrets;
-import sun.misc.JavaIOFileDescriptorAccess;
import static sun.nio.fs.WindowsNativeDispatcher.*;
import static sun.nio.fs.WindowsConstants.*;
@@ -157,7 +160,7 @@ class WindowsChannelFactory {
throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed");
FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor);
- return FileChannelImpl.open(fdObj, flags.read, flags.write, flags.append, null);
+ return FileChannelImpl.open(fdObj, pathForWindows, flags.read, flags.write, flags.append, null);
}
/**
diff --git a/test/ProblemList.txt b/test/ProblemList.txt
index e7c3ecd0f..1d9efbc98 100644
--- a/test/ProblemList.txt
+++ b/test/ProblemList.txt
@@ -183,11 +183,6 @@ java/net/DatagramSocket/SendDatagramToBadAddress.java macosx-all
# 6963118
java/nio/channels/Selector/Wakeup.java windows-all
-# 7133499, 7133497
-java/nio/channels/AsyncCloseAndInterrupt.java macosx-all
-java/nio/channels/AsynchronousFileChannel/Lock.java macosx-all
-java/nio/channels/FileChannel/Transfer.java macosx-all
-
# 7141822
java/nio/channels/DatagramChannel/ChangingAddress.java macosx-all
diff --git a/test/java/awt/Frame/ExceptionOnSetExtendedStateTest/ExceptionOnSetExtendedStateTest.java b/test/java/awt/Frame/ExceptionOnSetExtendedStateTest/ExceptionOnSetExtendedStateTest.java
new file mode 100644
index 000000000..b0f3c63b0
--- /dev/null
+++ b/test/java/awt/Frame/ExceptionOnSetExtendedStateTest/ExceptionOnSetExtendedStateTest.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2014, 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 8032078
+ @summary Frame.setExtendedState throws RuntimeException, if
+ windowState=ICONIFIED|MAXIMIZED_BOTH, on OS X
+ @author Anton Litvinov
+*/
+
+import java.awt.*;
+
+import sun.awt.SunToolkit;
+
+public class ExceptionOnSetExtendedStateTest {
+ private static final int[] frameStates = { Frame.NORMAL, Frame.ICONIFIED, Frame.MAXIMIZED_BOTH };
+ private static final SunToolkit toolkit = (SunToolkit)Toolkit.getDefaultToolkit();
+
+ private static boolean validatePlatform() {
+ String osName = System.getProperty("os.name");
+ if (osName == null) {
+ throw new RuntimeException("Name of the current OS could not be retrieved.");
+ }
+ return osName.startsWith("Mac");
+ }
+
+ private static void testStateChange(int oldState, int newState, boolean decoratedFrame) {
+ System.out.println(String.format(
+ "testStateChange: oldState='%d', newState='%d', decoratedFrame='%b'",
+ oldState, newState, decoratedFrame));
+
+ Frame frame = new Frame("ExceptionOnSetExtendedStateTest");
+ frame.setSize(200, 200);
+ frame.setUndecorated(!decoratedFrame);
+ frame.setVisible(true);
+ toolkit.realSync();
+
+ frame.setExtendedState(oldState);
+ sleep(1000);
+ frame.setExtendedState(newState);
+
+ boolean stateWasNotChanged = true;
+ int currentState = 0;
+ for (int i = 0; (i < 3) && stateWasNotChanged; i++) {
+ sleep(1000);
+ currentState = frame.getExtendedState();
+ if ((currentState == newState) ||
+ (((newState & Frame.ICONIFIED) != 0) && ((currentState & Frame.ICONIFIED) != 0))) {
+ stateWasNotChanged = false;
+ }
+ }
+ frame.dispose();
+
+ if (stateWasNotChanged) {
+ throw new RuntimeException(String.format(
+ "Frame state was not changed. currentState='%d'", currentState));
+ }
+ }
+
+ private static void sleep(int millis) {
+ try {
+ Thread.sleep(millis);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void main(String[] args) {
+ if (!validatePlatform()) {
+ System.out.println("This test is only for OS X.");
+ return;
+ }
+
+ // Verify that changing states of decorated/undecorated frame to/from supported states
+ // and the state bit mask ICONIFIED | MAXIMIZED_BOTH does not raise RuntimeException.
+ for (int i = 0; i < frameStates.length; i++) {
+ testStateChange(frameStates[i], Frame.ICONIFIED | Frame.MAXIMIZED_BOTH, true);
+ testStateChange(frameStates[i], Frame.ICONIFIED | Frame.MAXIMIZED_BOTH, false);
+ testStateChange(Frame.ICONIFIED | Frame.MAXIMIZED_BOTH, frameStates[i], true);
+ testStateChange(Frame.ICONIFIED | Frame.MAXIMIZED_BOTH, frameStates[i], false);
+ }
+ }
+}
diff --git a/test/java/lang/instrument/DaemonThread/DummyAgent.java b/test/java/lang/instrument/DaemonThread/DummyAgent.java
new file mode 100644
index 000000000..64b4d59cf
--- /dev/null
+++ b/test/java/lang/instrument/DaemonThread/DummyAgent.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2014 Goldman Sachs.
+ * Copyright (c) 2014, 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 java.lang.instrument.ClassFileTransformer;
+import java.lang.instrument.IllegalClassFormatException;
+import java.lang.instrument.Instrumentation;
+import java.security.ProtectionDomain;
+
+public class DummyAgent implements ClassFileTransformer {
+ @Override
+ public byte[] transform(ClassLoader loader, String className,
+ Class<?> classBeingRedefined, ProtectionDomain protectionDomain,
+ byte[] classfileBuffer) throws IllegalClassFormatException {
+
+ /* The Daemon Thread bug is timing dependent and you want the transform method
+ * to return ASAP - so just return the buffer will be fine
+ */
+ return classfileBuffer;
+ }
+
+ public static void premain(String agentArgs, Instrumentation inst) {
+ inst.addTransformer(new DummyAgent(), false);
+ }
+
+}
diff --git a/test/java/lang/instrument/DaemonThread/DummyClass.java b/test/java/lang/instrument/DaemonThread/DummyClass.java
new file mode 100644
index 000000000..18d671afc
--- /dev/null
+++ b/test/java/lang/instrument/DaemonThread/DummyClass.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2014 Goldman Sachs.
+ * Copyright (c) 2014, 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.
+ */
+
+/* Just a dummy class for loading */
+public class DummyClass {
+}
diff --git a/test/java/lang/instrument/DaemonThread/TestDaemonThread.java b/test/java/lang/instrument/DaemonThread/TestDaemonThread.java
new file mode 100644
index 000000000..20c9077d0
--- /dev/null
+++ b/test/java/lang/instrument/DaemonThread/TestDaemonThread.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2014 Goldman Sachs.
+ * Copyright (c) 2014, 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 7142035
+ * @summary Assert in java.lang.instrument agents during shutdown when classloading occurs after shutdown
+ * @library /lib/testlibrary
+ *
+ * @build DummyAgent DummyClass TestDaemonThreadLauncher TestDaemonThread
+ * @run shell ../MakeJAR3.sh DummyAgent
+ * @run main TestDaemonThreadLauncher /timeout=240
+ *
+ */
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+public class TestDaemonThread implements Runnable{
+ File classpath;
+
+ public TestDaemonThread(File classpath) {
+ this.classpath = classpath;
+ }
+
+ @Override
+ public void run() {
+
+
+ try {
+ URL u = this.getClass().getClassLoader().getResource("DummyClass.class");
+ String path = u.getPath();
+ String parent = u.getPath().substring(0, path.lastIndexOf('/')+1);
+ URL parentURL = new URL(u, parent);
+ System.out.println(parentURL);
+ /* Load lots of class by creating multiple classloaders */
+ for(;;) {
+ ClassLoader cl = new URLClassLoader(new URL[] {parentURL}, null);
+ cl.loadClass("DummyClass");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ Thread t = new Thread(new TestDaemonThread(new File(args[0])));
+ /* The important part of the bug is that a Daemon thread can continue to load classes after shutdown */
+ t.setDaemon(true);
+ t.start();
+ Thread.sleep(200);
+ }
+}
diff --git a/test/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java b/test/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java
new file mode 100644
index 000000000..9660bbfa9
--- /dev/null
+++ b/test/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2014 Goldman Sachs.
+ * Copyright (c) 2014, 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 jdk.testlibrary.JDKToolLauncher;
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.ProcessTools;
+
+import java.io.IOException;
+import java.nio.file.Path;
+
+public class TestDaemonThreadLauncher {
+
+ private static ProcessBuilder processBuilder = new ProcessBuilder();
+
+ public static void main(String args[]) throws Exception {
+ for(int i=0; i<50; i++) {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-javaagent:DummyAgent.jar", "TestDaemonThread", ".");
+ OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
+ analyzer.shouldNotContain("ASSERTION FAILED");
+ }
+ }
+}
diff --git a/test/java/net/ServerSocket/AnotherSelectFdsLimit.java b/test/java/net/ServerSocket/AnotherSelectFdsLimit.java
new file mode 100644
index 000000000..391c5fb00
--- /dev/null
+++ b/test/java/net/ServerSocket/AnotherSelectFdsLimit.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2014, 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 8035897
+ * @summary FD_SETSIZE should be set on macosx
+ * @run main/othervm AnotherSelectFdsLimit 1023
+ * @run main/othervm AnotherSelectFdsLimit 1024
+ * @run main/othervm AnotherSelectFdsLimit 1025
+ * @run main/othervm AnotherSelectFdsLimit 1600
+ */
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.SocketTimeoutException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class AnotherSelectFdsLimit {
+ static final int DEFAULT_FDS_TO_USE = 1600;
+
+ public static void main(String [] args) throws Exception {
+ if (!System.getProperty("os.name").contains("OS X")) {
+ System.out.println("Test only run on MAC. Exiting.");
+ return;
+ }
+
+ int fdsToUse = DEFAULT_FDS_TO_USE;
+ if (args.length == 1)
+ fdsToUse = Integer.parseInt(args[0]);
+
+ System.out.println("Using " + fdsToUse + " fds.");
+
+ List<Thread> threads = new ArrayList<>();
+ for (int i=0; i<fdsToUse; i++)
+ threads.add(new WorkerThread());
+
+ for (Thread t : threads)
+ t.start();
+
+ for (Thread t : threads)
+ t.join();
+ }
+
+ static class WorkerThread extends Thread {
+ public void run() {
+ try (ServerSocket ss = new ServerSocket(0)) {
+ ss.setSoTimeout(2000);
+ ss.accept();
+ } catch (SocketTimeoutException x) {
+ // expected
+ } catch (IOException x) {
+ throw new java.io.UncheckedIOException(x);
+ }
+ }
+ }
+}
diff --git a/test/java/nio/channels/Selector/ByteServer.java b/test/java/nio/channels/Selector/ByteServer.java
index eefd1fb17..40d8adfb8 100644
--- a/test/java/nio/channels/Selector/ByteServer.java
+++ b/test/java/nio/channels/Selector/ByteServer.java
@@ -22,52 +22,54 @@
*/
/**
- *
- * Utility class for tests. A simple server, which waits for a connection,
- * writes out n bytes and waits.
+ * Utility class for tests. A simple "in-thread" server to accept connections
+ * and write bytes.
* @author kladko
*/
import java.net.Socket;
import java.net.ServerSocket;
+import java.net.SocketAddress;
+import java.net.InetSocketAddress;
+import java.io.IOException;
+import java.io.Closeable;
+
+public class ByteServer implements Closeable {
-public class ByteServer {
+ private final ServerSocket ss;
+ private Socket s;
- public static final String LOCALHOST = "localhost";
- private int bytecount;
- private Socket socket;
- private ServerSocket serversocket;
- private Thread serverthread;
- volatile Exception savedException;
+ ByteServer() throws IOException {
+ this.ss = new ServerSocket(0);
+ }
+
+ SocketAddress address() {
+ return new InetSocketAddress(ss.getInetAddress(), ss.getLocalPort());
+ }
- public ByteServer(int bytecount) throws Exception{
- this.bytecount = bytecount;
- serversocket = new ServerSocket(0);
+ void acceptConnection() throws IOException {
+ if (s != null)
+ throw new IllegalStateException("already connected");
+ this.s = ss.accept();
}
- public int port() {
- return serversocket.getLocalPort();
+ void closeConnection() throws IOException {
+ Socket s = this.s;
+ if (s != null) {
+ this.s = null;
+ s.close();
+ }
}
- public void start() {
- serverthread = new Thread() {
- public void run() {
- try {
- socket = serversocket.accept();
- socket.getOutputStream().write(new byte[bytecount]);
- socket.getOutputStream().flush();
- } catch (Exception e) {
- System.err.println("Exception in ByteServer: " + e);
- System.exit(1);
- }
- }
- };
- serverthread.start();
+ void write(int count) throws IOException {
+ if (s == null)
+ throw new IllegalStateException("no connection");
+ s.getOutputStream().write(new byte[count]);
}
- public void exit() throws Exception {
- serverthread.join();
- socket.close();
- serversocket.close();
+ public void close() throws IOException {
+ if (s != null)
+ s.close();
+ ss.close();
}
}
diff --git a/test/java/nio/channels/Selector/ReadAfterConnect.java b/test/java/nio/channels/Selector/ReadAfterConnect.java
index e5d0b091b..93318fb64 100644
--- a/test/java/nio/channels/Selector/ReadAfterConnect.java
+++ b/test/java/nio/channels/Selector/ReadAfterConnect.java
@@ -27,27 +27,25 @@
* @author kladko
*/
-import java.net.*;
-import java.nio.*;
-import java.nio.channels.*;
+import java.nio.channels.Selector;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.SocketChannel;
public class ReadAfterConnect {
-
public static void main(String[] argv) throws Exception {
- ByteServer server = new ByteServer(0); // server: accept connection and do nothing
- server.start();
- InetSocketAddress isa = new InetSocketAddress(
- InetAddress.getByName(ByteServer.LOCALHOST), server.port());
- Selector sel = Selector.open();
- SocketChannel sc = SocketChannel.open();
- sc.connect(isa);
- sc.configureBlocking(false);
- sc.register(sel, SelectionKey.OP_READ);
- // Previously channel would get selected here, although there is nothing to read
- if (sel.selectNow() != 0)
- throw new Exception("Select returned nonzero value");
- sc.close();
- server.exit();
+ try (ByteServer server = new ByteServer();
+ SocketChannel sc = SocketChannel.open(server.address())) {
+
+ server.acceptConnection();
+
+ try (Selector sel = Selector.open()) {
+ sc.configureBlocking(false);
+ sc.register(sel, SelectionKey.OP_READ);
+ // Previously channel would get selected here, although there is nothing to read
+ if (sel.selectNow() != 0)
+ throw new Exception("Select returned nonzero value");
+ }
+ }
}
}
diff --git a/test/java/nio/channels/Selector/SelectAfterRead.java b/test/java/nio/channels/Selector/SelectAfterRead.java
index fccd9ddb5..356314652 100644
--- a/test/java/nio/channels/Selector/SelectAfterRead.java
+++ b/test/java/nio/channels/Selector/SelectAfterRead.java
@@ -28,60 +28,62 @@
* @author kladko
*/
-import java.net.*;
-import java.nio.*;
-import java.nio.channels.*;
+import java.nio.ByteBuffer;
+import java.nio.channels.Selector;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.SocketChannel;
public class SelectAfterRead {
- final static int TIMEOUT = 1000;
+ private static final int TIMEOUT = 1000;
public static void main(String[] argv) throws Exception {
- InetAddress lh = InetAddress.getByName(ByteServer.LOCALHOST);
// server: accept connection and write one byte
- ByteServer server = new ByteServer(1);
- server.start();
- Selector sel = Selector.open();
- SocketChannel sc = SocketChannel.open();
- sc.connect(new InetSocketAddress(lh, server.port()));
- sc.read(ByteBuffer.allocate(1));
- sc.configureBlocking(false);
- sc.register(sel, SelectionKey.OP_READ);
- // previously on Windows select would select channel here, although there was
- // nothing to read
- if (sel.selectNow() != 0)
- throw new Exception("Select returned nonzero value");
- sc.close();
- sel.close();
- server.exit();
+ try (ByteServer server = new ByteServer();
+ SocketChannel sc = SocketChannel.open(server.address())) {
+
+ server.acceptConnection();
+ server.write(1);
+
+ try (Selector sel = Selector.open()) {
+ sc.read(ByteBuffer.allocate(1));
+ sc.configureBlocking(false);
+ sc.register(sel, SelectionKey.OP_READ);
+ // previously on Windows select would select channel here, although there was
+ // nothing to read
+ if (sel.selectNow() != 0)
+ throw new Exception("Select returned nonzero value");
+ }
+ }
// Now we will test a two reads combination
// server: accept connection and write two bytes
- server = new ByteServer(2);
- server.start();
- sc = SocketChannel.open();
- sc.connect(new InetSocketAddress(lh, server.port()));
- sc.configureBlocking(false);
- sel = Selector.open();
- sc.register(sel, SelectionKey.OP_READ);
- if (sel.select(TIMEOUT) != 1)
- throw new Exception("One selected key expected");
- sel.selectedKeys().clear();
- // previously on Windows a channel would get selected only once
- if (sel.selectNow() != 1)
- throw new Exception("One selected key expected");
- // Previously on Windows two consequent reads would cause select()
- // to select a channel, although there was nothing remaining to
- // read in the channel
- if (sc.read(ByteBuffer.allocate(1)) != 1)
- throw new Exception("One byte expected");
- if (sc.read(ByteBuffer.allocate(1)) != 1)
- throw new Exception("One byte expected");
- if (sel.selectNow() != 0)
- throw new Exception("Select returned nonzero value");
- sc.close();
- sel.close();
- server.exit();
+ try (ByteServer server = new ByteServer();
+ SocketChannel sc = SocketChannel.open(server.address())) {
+
+ server.acceptConnection();
+ server.write(2);
+
+ try (Selector sel = Selector.open()) {
+ sc.configureBlocking(false);
+ sc.register(sel, SelectionKey.OP_READ);
+ if (sel.select(TIMEOUT) != 1)
+ throw new Exception("One selected key expected");
+ sel.selectedKeys().clear();
+ // previously on Windows a channel would get selected only once
+ if (sel.selectNow() != 1)
+ throw new Exception("One selected key expected");
+ // Previously on Windows two consequent reads would cause select()
+ // to select a channel, although there was nothing remaining to
+ // read in the channel
+ if (sc.read(ByteBuffer.allocate(1)) != 1)
+ throw new Exception("One byte expected");
+ if (sc.read(ByteBuffer.allocate(1)) != 1)
+ throw new Exception("One byte expected");
+ if (sel.selectNow() != 0)
+ throw new Exception("Select returned nonzero value");
+ }
+ }
}
}
diff --git a/test/java/nio/channels/Selector/SelectWrite.java b/test/java/nio/channels/Selector/SelectWrite.java
index 3c2d3d887..ab305edd1 100644
--- a/test/java/nio/channels/Selector/SelectWrite.java
+++ b/test/java/nio/channels/Selector/SelectWrite.java
@@ -22,36 +22,33 @@
*/
/* @test
- @bug 4645302
- @summary Socket with OP_WRITE would get selected only once
- @author kladko
+ * @bug 4645302
+ * @summary Socket with OP_WRITE would get selected only once
+ * @author kladko
*/
-import java.net.*;
-import java.nio.*;
-import java.nio.channels.*;
-
+import java.nio.channels.Selector;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.SocketChannel;
public class SelectWrite {
public static void main(String[] argv) throws Exception {
- ByteServer server = new ByteServer(0);
- // server: accept connection and do nothing
- server.start();
- InetSocketAddress isa = new InetSocketAddress(
- InetAddress.getByName(ByteServer.LOCALHOST), server.port());
- Selector sel = Selector.open();
- SocketChannel sc = SocketChannel.open();
- sc.connect(isa);
- sc.configureBlocking(false);
- sc.register(sel, SelectionKey.OP_WRITE);
- sel.select();
- sel.selectedKeys().clear();
- if (sel.select() == 0) {
- throw new Exception("Select returned zero");
+ try (ByteServer server = new ByteServer();
+ SocketChannel sc = SocketChannel.open(server.address())) {
+
+ server.acceptConnection();
+
+ try (Selector sel = Selector.open()) {
+ sc.configureBlocking(false);
+ sc.register(sel, SelectionKey.OP_WRITE);
+ sel.select();
+ sel.selectedKeys().clear();
+ if (sel.select() == 0) {
+ throw new Exception("Select returned zero");
+ }
+ }
}
- sc.close();
- sel.close();
}
}
diff --git a/test/javax/swing/JMenuItem/8031573/bug8031573.html b/test/javax/swing/JMenuItem/8031573/bug8031573.html
new file mode 100644
index 000000000..b61bbf86e
--- /dev/null
+++ b/test/javax/swing/JMenuItem/8031573/bug8031573.html
@@ -0,0 +1,40 @@
+<!--
+ Copyright (c) 2014, 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.
+-->
+
+<html>
+<body>
+
+Verify that high resolution system icons are used JCheckBoxMenuItem
+on HiDPI displays.
+
+If the display does not support HiDPI mode press PASS.
+
+1. Run the test on HiDPI Display.
+2. Press the Menu in the applet
+3. Check that the icon on the JCheckBoxMenuItem is smooth
+If so, press PASS, else press FAIL.
+
+<applet code="bug8031573.class" width=250 height=250></applet>
+
+</body>
+</html>
diff --git a/test/javax/swing/JMenuItem/8031573/bug8031573.java b/test/javax/swing/JMenuItem/8031573/bug8031573.java
new file mode 100644
index 000000000..5cb1dc504
--- /dev/null
+++ b/test/javax/swing/JMenuItem/8031573/bug8031573.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2014, 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 java.awt.FlowLayout;
+import javax.swing.JApplet;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.SwingUtilities;
+
+/* @test
+ * @bug 8031573
+ * @summary [macosx] Checkmarks of JCheckBoxMenuItems aren't rendered
+ * in high resolution on Retina
+ * @author Alexander Scherbatiy
+ * @run applet/manual=yesno bug8031573.html
+ */
+public class bug8031573 extends JApplet {
+
+ @Override
+ public void init() {
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ JMenuBar bar = new JMenuBar();
+ JMenu menu = new JMenu("Menu");
+ JCheckBoxMenuItem checkBoxMenuItem
+ = new JCheckBoxMenuItem("JCheckBoxMenuItem");
+ checkBoxMenuItem.setSelected(true);
+ menu.add(checkBoxMenuItem);
+ bar.add(menu);
+ setJMenuBar(bar);
+ }
+ });
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/test/javax/xml/jaxp/transform/8004476/TestBase.java b/test/javax/xml/jaxp/transform/8004476/TestBase.java
index 4b6ea705e..11333faa3 100644
--- a/test/javax/xml/jaxp/transform/8004476/TestBase.java
+++ b/test/javax/xml/jaxp/transform/8004476/TestBase.java
@@ -1,7 +1,26 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ * 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 java.security.Policy;
/**
diff --git a/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java b/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java
index efe2a3171..1d4bbb1fb 100644
--- a/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java
+++ b/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java
@@ -32,6 +32,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
+import jdk.testlibrary.ProcessTools;
/**
* @test
@@ -43,11 +44,9 @@ import java.util.concurrent.atomic.AtomicReference;
* both agent properties and jvmstat buffer.
* @build jdk.testlibrary.ProcessTools
* @build TestManager TestApplication
- * @run main/othervm/timeout=300 LocalManagementTest
+ * @run main/othervm/timeout=300 -XX:+UsePerfData LocalManagementTest
*/
-import jdk.testlibrary.ProcessTools;
-
public class LocalManagementTest {
private static final String TEST_CLASSPATH = System.getProperty("test.class.path");
private static final String TEST_JDK = System.getProperty("test.jdk");
@@ -240,4 +239,4 @@ public class LocalManagementTest {
}
}
}
-} \ No newline at end of file
+}