aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorasaha <none@none>2014-11-19 12:54:52 -0800
committerasaha <none@none>2014-11-19 12:54:52 -0800
commit1d5f03b5e3abc70cd7829aa7a6bb7b35f3e51263 (patch)
tree07e24fc4d683ecf03118c7912b44c3f7409385d0
parent5d64177043cf0ed1d7187c8788fa01a016c89ef6 (diff)
parent64bfb81abca2537742e7627f94367afad50a9c52 (diff)
Merge
-rw-r--r--.hgtags2
-rw-r--r--make/mapfiles/libjava/mapfile-vers5
-rw-r--r--make/mapfiles/libsplashscreen/mapfile-vers1
-rw-r--r--src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java2
-rw-r--r--src/macosx/native/apple/security/KeystoreImpl.m36
-rw-r--r--src/macosx/native/java/util/MacOSXPreferencesFile.m106
-rw-r--r--src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m50
-rw-r--r--src/share/bin/java.c40
-rw-r--r--src/share/bin/splashscreen.h3
-rw-r--r--src/share/bin/splashscreen_stubs.c16
-rw-r--r--src/share/classes/java/awt/SplashScreen.java25
-rw-r--r--src/share/classes/java/awt/Window.java13
-rw-r--r--src/share/classes/java/io/SequenceInputStream.java28
-rw-r--r--src/share/classes/java/lang/invoke/MethodType.java12
-rw-r--r--src/share/classes/java/lang/ref/ReferenceQueue.java8
-rw-r--r--src/share/classes/java/util/BitSet.java11
-rw-r--r--src/share/classes/java/util/IdentityHashMap.java129
-rw-r--r--src/share/classes/javax/swing/JComboBox.java3
-rw-r--r--src/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java18
-rw-r--r--src/share/classes/jdk/internal/org/objectweb/asm/TypePath.java7
-rw-r--r--src/share/classes/jdk/internal/org/objectweb/asm/commons/GeneratorAdapter.java14
-rw-r--r--src/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java8
-rw-r--r--src/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java3
-rw-r--r--src/share/classes/jdk/internal/org/objectweb/asm/tree/AnnotationNode.java10
-rw-r--r--src/share/classes/jdk/internal/org/objectweb/asm/tree/LookupSwitchInsnNode.java2
-rw-r--r--src/share/classes/jdk/internal/org/objectweb/asm/tree/MethodInsnNode.java1
-rw-r--r--src/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java2
-rw-r--r--src/share/classes/jdk/internal/org/objectweb/asm/util/Textifier.java2
-rw-r--r--src/share/classes/jdk/internal/org/objectweb/asm/version.txt10
-rw-r--r--src/share/classes/jdk/net/Sockets.java1
-rw-r--r--src/share/classes/sun/invoke/util/Wrapper.java22
-rw-r--r--src/share/classes/sun/misc/Launcher.java26
-rw-r--r--src/share/classes/sun/misc/URLClassPath.java180
-rw-r--r--src/share/classes/sun/misc/VM.java5
-rw-r--r--src/share/classes/sun/nio/fs/AbstractPoller.java16
-rw-r--r--src/share/classes/sun/nio/fs/PollingWatchService.java6
-rw-r--r--src/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java4
-rw-r--r--src/share/classes/sun/reflect/generics/reflectiveObjects/LazyReflectiveObjectGenerator.java2
-rw-r--r--src/share/classes/sun/reflect/generics/repository/AbstractRepository.java4
-rw-r--r--src/share/classes/sun/reflect/generics/repository/ClassRepository.java8
-rw-r--r--src/share/classes/sun/reflect/generics/repository/GenericDeclRepository.java4
-rw-r--r--src/share/classes/sun/reflect/generics/scope/AbstractScope.java10
-rw-r--r--src/share/classes/sun/reflect/generics/tree/ClassSignature.java6
-rw-r--r--src/share/javavm/export/jvm.h25
-rw-r--r--src/share/native/java/lang/ClassLoader.c4
-rw-r--r--src/share/native/sun/awt/splashscreen/java_awt_SplashScreen.c15
-rw-r--r--src/share/native/sun/awt/splashscreen/splashscreen_impl.c8
-rw-r--r--src/share/native/sun/awt/splashscreen/splashscreen_impl.h7
-rw-r--r--src/share/native/sun/misc/URLClassPath.c109
-rw-r--r--src/share/native/sun/security/ec/impl/mpi.c2
-rw-r--r--src/share/native/sun/security/pkcs11/wrapper/p11_crypt.c12
-rw-r--r--src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c8
-rw-r--r--src/solaris/native/sun/nio/ch/FileDispatcherImpl.c17
-rw-r--r--src/windows/classes/sun/awt/windows/WPathGraphics.java4
-rw-r--r--src/windows/native/sun/awt/splashscreen/splashscreen_sys.c8
-rw-r--r--src/windows/native/sun/java2d/d3d/D3DBadHardware.h127
-rw-r--r--test/com/sun/jndi/ldap/LdapTimeoutTest.java27
-rw-r--r--test/java/awt/Frame/DisposeStressTest/DisposeStressTest.html21
-rw-r--r--test/java/awt/Frame/DisposeStressTest/DisposeStressTest.java247
-rw-r--r--test/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java161
-rw-r--r--test/java/awt/Window/AlwaysOnTop/SyncAlwaysOnTopFieldTest.java62
-rw-r--r--test/java/awt/print/PrinterJob/ImagePrinting/NullClipARGB.java74
-rw-r--r--test/java/io/SequenceInputStream/LotsOfStreams.java66
-rw-r--r--test/java/lang/invoke/ExplicitCastArgumentsTest.java86
-rw-r--r--test/java/lang/ref/EarlyTimeout.java104
-rw-r--r--test/java/nio/channels/FileChannel/BlockDeviceSize.java62
-rw-r--r--test/java/nio/file/WatchService/Basic.java46
-rw-r--r--test/java/util/BitSet/BSMethods.java20
-rw-r--r--test/java/util/IdentityHashMap/Capacity.java226
-rw-r--r--test/java/util/logging/LoggingDeadlock2.java2
-rw-r--r--test/javax/swing/JComboBox/8057893/bug8057893.java84
-rw-r--r--test/javax/xml/jaxp/testng/TEST.properties3
-rw-r--r--test/javax/xml/jaxp/testng/parse/XMLEntityScannerLoad.java75
-rw-r--r--test/jdk/net/Sockets/SupportedOptions.java45
-rw-r--r--test/sun/jvmstat/monitor/MonitoredVm/CR6672135.java1
-rw-r--r--test/sun/misc/URLClassPath/EnableLookupCache.java66
-rw-r--r--test/sun/security/pkcs11/Cipher/JNICheck.java64
77 files changed, 2362 insertions, 387 deletions
diff --git a/.hgtags b/.hgtags
index e671fd094..f100d686c 100644
--- a/.hgtags
+++ b/.hgtags
@@ -359,3 +359,5 @@ c3a4729c70fa29d79ad77e0643ad7715ebbc96b5 jdk8u40-b10
693da296b395139f2fe6d7131eb0b0d85f6015f6 jdk8u40-b11
fb8db13639204e37388904bb6e57778c5d762631 jdk8u40-b12
ba80109a9b3eb92b56012c9ec3aafd9aee2efa69 jdk8u40-b13
+ffc348308de2e872f5d510d440604c3726a67a18 jdk8u40-b14
+31dac938108da722c56a0526fba7f6ae84773056 jdk8u40-b15
diff --git a/make/mapfiles/libjava/mapfile-vers b/make/mapfiles/libjava/mapfile-vers
index 0dc76bf02..152053c8a 100644
--- a/make/mapfiles/libjava/mapfile-vers
+++ b/make/mapfiles/libjava/mapfile-vers
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 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
@@ -269,6 +269,9 @@ SUNWprivate_1.1 {
Java_sun_reflect_Reflection_getCallerClass__;
Java_sun_reflect_Reflection_getCallerClass__I;
Java_sun_reflect_Reflection_getClassAccessFlags;
+ Java_sun_misc_URLClassPath_knownToNotExist0;
+ Java_sun_misc_URLClassPath_getLookupCacheURLs;
+ Java_sun_misc_URLClassPath_getLookupCacheForClassLoader;
Java_sun_misc_Version_getJdkVersionInfo;
Java_sun_misc_Version_getJdkSpecialVersion;
Java_sun_misc_Version_getJvmVersionInfo;
diff --git a/make/mapfiles/libsplashscreen/mapfile-vers b/make/mapfiles/libsplashscreen/mapfile-vers
index b9507326c..2be756be1 100644
--- a/make/mapfiles/libsplashscreen/mapfile-vers
+++ b/make/mapfiles/libsplashscreen/mapfile-vers
@@ -35,6 +35,7 @@ SUNWprivate_1.1 {
Java_java_awt_SplashScreen__1getImageFileName;
Java_java_awt_SplashScreen__1getImageJarName;
Java_java_awt_SplashScreen__1setImageData;
+ Java_java_awt_SplashScreen__1getScaleFactor;
SplashLoadMemory;
SplashLoadFile;
diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
index 57dd241fd..a055acfea 100644
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
@@ -676,7 +676,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
final long nsWindowPtr = getNSWindowPtr();
LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit();
Window w = DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
- if( w != null
+ if( w != null && w.getPeer() != null
&& ((LWWindowPeer)w.getPeer()).getPeerType() == LWWindowPeer.PeerType.EMBEDDED_FRAME
&& !lwcToolkit.isApplicationActive()) {
lwcToolkit.activateApplicationIgnoringOtherApps();
diff --git a/src/macosx/native/apple/security/KeystoreImpl.m b/src/macosx/native/apple/security/KeystoreImpl.m
index 1e26771eb..30cff2ed5 100644
--- a/src/macosx/native/apple/security/KeystoreImpl.m
+++ b/src/macosx/native/apple/security/KeystoreImpl.m
@@ -299,11 +299,21 @@ static void addIdentitiesToKeystore(JNIEnv *env, jobject keyStore)
// Make a java array of certificate data from the chain.
jclass byteArrayClass = (*env)->FindClass(env, "[B");
+ if (byteArrayClass == NULL) {
+ goto errOut;
+ }
jobjectArray javaCertArray = (*env)->NewObjectArray(env, certCount, byteArrayClass, NULL);
+ // Cleanup first then check for a NULL return code
(*env)->DeleteLocalRef(env, byteArrayClass);
+ if (javaCertArray == NULL) {
+ goto errOut;
+ }
// And, make an array of the certificate refs.
jlongArray certRefArray = (*env)->NewLongArray(env, certCount);
+ if (certRefArray == NULL) {
+ goto errOut;
+ }
SecCertificateRef currCertRef = NULL;
@@ -318,6 +328,9 @@ static void addIdentitiesToKeystore(JNIEnv *env, jobject keyStore)
bzero(&currCertData, sizeof(CSSM_DATA));
err = SecCertificateGetData(currCertRef, &currCertData);
jbyteArray encodedCertData = (*env)->NewByteArray(env, currCertData.Length);
+ if (encodedCertData == NULL) {
+ goto errOut;
+ }
(*env)->SetByteArrayRegion(env, encodedCertData, 0, currCertData.Length, (jbyte *)currCertData.Data);
(*env)->SetObjectArrayElement(env, javaCertArray, i, encodedCertData);
jlong certRefElement = ptr_to_jlong(currCertRef);
@@ -330,6 +343,9 @@ static void addIdentitiesToKeystore(JNIEnv *env, jobject keyStore)
// Find the label. It's a 'blob', but we interpret as characters.
jstring alias = getLabelFromItem(env, (SecKeychainItemRef)certificate);
+ if (alias == NULL) {
+ goto errOut;
+ }
// Find the creation date.
jlong creationDate = getModDateFromItem(env, (SecKeychainItemRef)certificate);
@@ -340,6 +356,7 @@ static void addIdentitiesToKeystore(JNIEnv *env, jobject keyStore)
}
} while (searchResult == noErr);
+errOut:
if (identitySearch != NULL) {
CFRelease(identitySearch);
}
@@ -362,10 +379,16 @@ static void addCertificatesToKeystore(JNIEnv *env, jobject keyStore)
CSSM_DATA currCertificate;
err = SecCertificateGetData(certRef, &currCertificate);
jbyteArray certData = (*env)->NewByteArray(env, currCertificate.Length);
+ if (certData == NULL) {
+ goto errOut;
+ }
(*env)->SetByteArrayRegion(env, certData, 0, currCertificate.Length, (jbyte *)currCertificate.Data);
// Find the label. It's a 'blob', but we interpret as characters.
jstring alias = getLabelFromItem(env, theItem);
+ if (alias == NULL) {
+ goto errOut;
+ }
// Find the creation date.
jlong creationDate = getModDateFromItem(env, theItem);
@@ -376,6 +399,7 @@ static void addCertificatesToKeystore(JNIEnv *env, jobject keyStore)
}
} while (searchResult == noErr);
+errOut:
if (keychainItemSearch != NULL) {
CFRelease(keychainItemSearch);
}
@@ -404,6 +428,9 @@ JNIEXPORT jbyteArray JNICALL Java_apple_security_KeychainStore__1getEncodedKeyDa
if (passwordLen > 0) {
passwordChars = (*env)->GetCharArrayElements(env, passwordObj, NULL);
+ if (passwordChars == NULL) {
+ goto errOut;
+ }
passwordStrRef = CFStringCreateWithCharacters(kCFAllocatorDefault, passwordChars, passwordLen);
}
}
@@ -423,9 +450,13 @@ JNIEXPORT jbyteArray JNICALL Java_apple_security_KeychainStore__1getEncodedKeyDa
if (err == noErr) {
CFIndex size = CFDataGetLength(exportedData);
returnValue = (*env)->NewByteArray(env, size);
+ if (returnValue == NULL) {
+ goto errOut;
+ }
(*env)->SetByteArrayRegion(env, returnValue, 0, size, (jbyte *)CFDataGetBytePtr(exportedData));
}
+errOut:
if (exportedData) CFRelease(exportedData);
if (passwordStrRef) CFRelease(passwordStrRef);
@@ -466,6 +497,9 @@ JNF_COCOA_ENTER(env);
jsize dataSize = (*env)->GetArrayLength(env, rawDataObj);
jbyte *rawData = (*env)->GetByteArrayElements(env, rawDataObj, NULL);
+ if (rawData == NULL) {
+ goto errOut;
+ }
CFDataRef cfDataToImport = CFDataCreate(kCFAllocatorDefault, (UInt8 *)rawData, dataSize);
CFArrayRef createdItems = NULL;
@@ -522,6 +556,8 @@ JNF_COCOA_ENTER(env);
CFRelease(createdItems);
}
+errOut: ;
+
JNF_COCOA_EXIT(env);
return returnValue;
diff --git a/src/macosx/native/java/util/MacOSXPreferencesFile.m b/src/macosx/native/java/util/MacOSXPreferencesFile.m
index e2212fc2e..f25f8684d 100644
--- a/src/macosx/native/java/util/MacOSXPreferencesFile.m
+++ b/src/macosx/native/java/util/MacOSXPreferencesFile.m
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, 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
@@ -71,6 +71,8 @@ static void throwOutOfMemoryError(JNIEnv *env, const char *msg)
static jclass exceptionClass = NULL;
jclass c;
+ (*env)->ExceptionClear(env); // If an exception is pending, clear it before
+ // calling FindClass() and/or ThrowNew().
if (exceptionClass) {
c = exceptionClass;
} else {
@@ -534,8 +536,13 @@ Java_java_util_prefs_MacOSXPreferencesFile_addNode
(JNIEnv *env, jobject klass, jobject jpath,
jobject jname, jlong juser, jlong jhost)
{
- CFStringRef path = toCF(env, jpath);
- CFStringRef name = toCF(env, jname);
+ CFStringRef path = NULL;
+ CFStringRef name = NULL;
+
+ path = toCF(env, jpath);
+ if (path != NULL) {
+ name = toCF(env, jname);
+ }
CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
CFDictionaryRef node = NULL;
@@ -579,8 +586,13 @@ Java_java_util_prefs_MacOSXPreferencesFile_removeNode
(JNIEnv *env, jobject klass, jobject jpath,
jobject jname, jlong juser, jlong jhost)
{
- CFStringRef path = toCF(env, jpath);
- CFStringRef name = toCF(env, jname);
+ CFStringRef path = NULL;
+ CFStringRef name = NULL;
+
+ path = toCF(env, jpath);
+ if (path != NULL) {
+ name = toCF(env, jname);
+ }
CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
CFStringRef parentName;
@@ -647,9 +659,17 @@ Java_java_util_prefs_MacOSXPreferencesFile_addChildToNode
jobject jname, jlong juser, jlong jhost)
{
// like addNode, but can put a three-level-deep dict into the root file
- CFStringRef path = toCF(env, jpath);
- CFStringRef child = toCF(env, jchild);
- CFStringRef name = toCF(env, jname);
+ CFStringRef path = NULL;
+ CFStringRef child = NULL;
+ CFStringRef name = NULL;
+
+ path = toCF(env, jpath);
+ if (path != NULL) {
+ child = toCF(env, jchild);
+ }
+ if (child != NULL) {
+ name = toCF(env, jname);
+ }
CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
CFMutableDictionaryRef parent;
@@ -693,9 +713,17 @@ Java_java_util_prefs_MacOSXPreferencesFile_removeChildFromNode
(JNIEnv *env, jobject klass, jobject jpath, jobject jchild,
jobject jname, jlong juser, jlong jhost)
{
- CFStringRef path = toCF(env, jpath);
- CFStringRef child = toCF(env, jchild);
- CFStringRef name = toCF(env, jname);
+ CFStringRef path = NULL;
+ CFStringRef child = NULL;
+ CFStringRef name = NULL;
+
+ path = toCF(env, jpath);
+ if (path != NULL) {
+ child = toCF(env, jchild);
+ }
+ if (child != NULL) {
+ name = toCF(env, jname);
+ }
CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
CFDictionaryRef constParent;
@@ -734,10 +762,21 @@ Java_java_util_prefs_MacOSXPreferencesFile_addKeyToNode
(JNIEnv *env, jobject klass, jobject jpath, jobject jkey, jobject jvalue,
jobject jname, jlong juser, jlong jhost)
{
- CFStringRef path = toCF(env, jpath);
- CFStringRef key = toCF(env, jkey);
- CFStringRef value = toCF(env, jvalue);
- CFStringRef name = toCF(env, jname);
+ CFStringRef path = NULL;
+ CFStringRef key = NULL;
+ CFStringRef value = NULL;
+ CFStringRef name = NULL;
+
+ path = toCF(env, jpath);
+ if (path != NULL) {
+ key = toCF(env, jkey);
+ }
+ if (key != NULL) {
+ value = toCF(env, jvalue);
+ }
+ if (value != NULL) {
+ name = toCF(env, jname);
+ }
CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
CFMutableDictionaryRef node = NULL;
@@ -771,9 +810,17 @@ Java_java_util_prefs_MacOSXPreferencesFile_removeKeyFromNode
(JNIEnv *env, jobject klass, jobject jpath, jobject jkey,
jobject jname, jlong juser, jlong jhost)
{
- CFStringRef path = toCF(env, jpath);
- CFStringRef key = toCF(env, jkey);
- CFStringRef name = toCF(env, jname);
+ CFStringRef path = NULL;
+ CFStringRef key = NULL;
+ CFStringRef name = NULL;
+
+ path = toCF(env, jpath);
+ if (path != NULL) {
+ key = toCF(env, jkey);
+ }
+ if (key != NULL) {
+ name = toCF(env, jname);
+ }
CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
CFDictionaryRef constNode;
@@ -812,9 +859,17 @@ Java_java_util_prefs_MacOSXPreferencesFile_getKeyFromNode
(JNIEnv *env, jobject klass, jobject jpath, jobject jkey,
jobject jname, jlong juser, jlong jhost)
{
- CFStringRef path = toCF(env, jpath);
- CFStringRef key = toCF(env, jkey);
- CFStringRef name = toCF(env, jname);
+ CFStringRef path = NULL;
+ CFStringRef key = NULL;
+ CFStringRef name = NULL;
+
+ path = toCF(env, jpath);
+ if (path != NULL) {
+ key = toCF(env, jkey);
+ }
+ if (key != NULL) {
+ name = toCF(env, jname);
+ }
CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
CFPropertyListRef value;
@@ -914,8 +969,13 @@ static jarray getStringsForNode(JNIEnv *env, jobject klass, jobject jpath,
jobject jname, jlong juser, jlong jhost,
Boolean allowSlash)
{
- CFStringRef path = toCF(env, jpath);
- CFStringRef name = toCF(env, jname);
+ CFStringRef path = NULL;
+ CFStringRef name = NULL;
+
+ path = toCF(env, jpath);
+ if (path != NULL) {
+ name = toCF(env, jname);
+ }
CFStringRef user = (CFStringRef)jlong_to_ptr(juser);
CFStringRef host = (CFStringRef)jlong_to_ptr(jhost);
CFDictionaryRef node;
diff --git a/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m b/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m
index 40f380bde..0eaf688ca 100644
--- a/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m
+++ b/src/macosx/native/sun/awt/splashscreen/splashscreen_sys.m
@@ -45,6 +45,7 @@
#include <dlfcn.h>
#include <sizecalc.h>
+#import "ThreadUtilities.h"
static NSScreen* SplashNSScreen()
{
@@ -125,6 +126,43 @@ done:
return buf;
}
+char* SplashGetScaledImageName(const char* jar, const char* file,
+ float *scaleFactor) {
+ NSAutoreleasePool *pool = [NSAutoreleasePool new];
+ *scaleFactor = 1;
+ char* scaledFile = nil;
+ __block float screenScaleFactor = 1;
+
+ [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
+ screenScaleFactor = [SplashNSScreen() backingScaleFactor];
+ }];
+
+ if (screenScaleFactor > 1) {
+ NSString *fileName = [NSString stringWithUTF8String: file];
+ NSUInteger length = [fileName length];
+ NSRange range = [fileName rangeOfString: @"."
+ options:NSBackwardsSearch];
+ NSUInteger dotIndex = range.location;
+ NSString *fileName2x = nil;
+
+ if (dotIndex == NSNotFound) {
+ fileName2x = [fileName stringByAppendingString: @"@2x"];
+ } else {
+ fileName2x = [fileName substringToIndex: dotIndex];
+ fileName2x = [fileName2x stringByAppendingString: @"@2x"];
+ fileName2x = [fileName2x stringByAppendingString:
+ [fileName substringFromIndex: dotIndex]];
+ }
+
+ if ((fileName2x != nil) && (jar || [[NSFileManager defaultManager]
+ fileExistsAtPath: fileName2x])){
+ *scaleFactor = 2;
+ scaledFile = strdup([fileName2x UTF8String]);
+ }
+ }
+ [pool drain];
+ return scaledFile;
+}
void
SplashInitPlatform(Splash * splash) {
@@ -132,7 +170,7 @@ SplashInitPlatform(Splash * splash) {
splash->maskRequired = 0;
-
+
//TODO: the following is too much of a hack but should work in 90% cases.
// besides we don't use device-dependant drawing, so probably
// that's very fine indeed
@@ -218,7 +256,15 @@ SplashRedrawWindow(Splash * splash) {
[image setBackgroundColor: [NSColor clearColor]];
[image addRepresentation: rep];
-
+ float scaleFactor = splash->scaleFactor;
+ if (scaleFactor > 0 && scaleFactor != 1) {
+ [image setScalesWhenResized:YES];
+ NSSize size = [image size];
+ size.width /= scaleFactor;
+ size.height /= scaleFactor;
+ [image setSize: size];
+ }
+
NSImageView * view = [[NSImageView alloc] init];
[view setImage: image];
diff --git a/src/share/bin/java.c b/src/share/bin/java.c
index cc354ebaf..4b16e8b5c 100644
--- a/src/share/bin/java.c
+++ b/src/share/bin/java.c
@@ -1874,20 +1874,48 @@ ShowSplashScreen()
const char *jar_name = getenv(SPLASH_JAR_ENV_ENTRY);
const char *file_name = getenv(SPLASH_FILE_ENV_ENTRY);
int data_size;
- void *image_data;
+ void *image_data = NULL;
+ float scale_factor = 1;
+ char *scaled_splash_name = NULL;
+
+ if (file_name == NULL){
+ return;
+ }
+
+ scaled_splash_name = DoSplashGetScaledImageName(
+ jar_name, file_name, &scale_factor);
if (jar_name) {
- image_data = JLI_JarUnpackFile(jar_name, file_name, &data_size);
+
+ if (scaled_splash_name) {
+ image_data = JLI_JarUnpackFile(
+ jar_name, scaled_splash_name, &data_size);
+ }
+
+ if (!image_data) {
+ scale_factor = 1;
+ image_data = JLI_JarUnpackFile(
+ jar_name, file_name, &data_size);
+ }
if (image_data) {
DoSplashInit();
+ DoSplashSetScaleFactor(scale_factor);
DoSplashLoadMemory(image_data, data_size);
JLI_MemFree(image_data);
}
- } else if (file_name) {
- DoSplashInit();
- DoSplashLoadFile(file_name);
} else {
- return;
+ DoSplashInit();
+ if (scaled_splash_name) {
+ DoSplashSetScaleFactor(scale_factor);
+ DoSplashLoadFile(scaled_splash_name);
+ } else {
+ DoSplashLoadFile(file_name);
+ }
+ }
+
+ if (scaled_splash_name) {
+ JLI_MemFree(scaled_splash_name);
}
+
DoSplashSetFileJarName(file_name, jar_name);
/*
diff --git a/src/share/bin/splashscreen.h b/src/share/bin/splashscreen.h
index da64bf651..3afd68c71 100644
--- a/src/share/bin/splashscreen.h
+++ b/src/share/bin/splashscreen.h
@@ -29,3 +29,6 @@ int DoSplashLoadFile(const char* filename);
void DoSplashInit(void);
void DoSplashClose(void);
void DoSplashSetFileJarName(const char* fileName, const char* jarName);
+void DoSplashSetScaleFactor(float scaleFactor);
+char* DoSplashGetScaledImageName(const char* jarName, const char* fileName,
+ float* scaleFactor);
diff --git a/src/share/bin/splashscreen_stubs.c b/src/share/bin/splashscreen_stubs.c
index 1ceee65ef..9c1f5148c 100644
--- a/src/share/bin/splashscreen_stubs.c
+++ b/src/share/bin/splashscreen_stubs.c
@@ -37,6 +37,9 @@ typedef void (*SplashInit_t)(void);
typedef void (*SplashClose_t)(void);
typedef void (*SplashSetFileJarName_t)(const char* fileName,
const char* jarName);
+typedef void (*SplashSetScaleFactor_t)(float scaleFactor);
+typedef char* (*SplashGetScaledImageName_t)(const char* fileName,
+ const char* jarName, float* scaleFactor);
/*
* This macro invokes a function from the shared lib.
@@ -58,11 +61,11 @@ typedef void (*SplashSetFileJarName_t)(const char* fileName,
#define INVOKEV(name) _INVOKE(name, ,;)
int DoSplashLoadMemory(void* pdata, int size) {
- INVOKE(SplashLoadMemory,0)(pdata, size);
+ INVOKE(SplashLoadMemory, NULL)(pdata, size);
}
int DoSplashLoadFile(const char* filename) {
- INVOKE(SplashLoadFile,0)(filename);
+ INVOKE(SplashLoadFile, NULL)(filename);
}
void DoSplashInit(void) {
@@ -76,3 +79,12 @@ void DoSplashClose(void) {
void DoSplashSetFileJarName(const char* fileName, const char* jarName) {
INVOKEV(SplashSetFileJarName)(fileName, jarName);
}
+
+void DoSplashSetScaleFactor(float scaleFactor) {
+ INVOKEV(SplashSetScaleFactor)(scaleFactor);
+}
+
+char* DoSplashGetScaledImageName(const char* fileName, const char* jarName,
+ float* scaleFactor) {
+ INVOKE(SplashGetScaledImageName, NULL)(fileName, jarName, scaleFactor);
+} \ No newline at end of file
diff --git a/src/share/classes/java/awt/SplashScreen.java b/src/share/classes/java/awt/SplashScreen.java
index a1d4b6f9a..9ec56251a 100644
--- a/src/share/classes/java/awt/SplashScreen.java
+++ b/src/share/classes/java/awt/SplashScreen.java
@@ -245,7 +245,14 @@ public final class SplashScreen {
public Rectangle getBounds() throws IllegalStateException {
synchronized (SplashScreen.class) {
checkVisible();
- return _getBounds(splashPtr);
+ float scale = _getScaleFactor(splashPtr);
+ Rectangle bounds = _getBounds(splashPtr);
+ assert scale > 0;
+ if (scale > 0 && scale != 1) {
+ bounds.setSize((int) (bounds.getWidth() / scale),
+ (int) (bounds.getWidth() / scale));
+ }
+ return bounds;
}
}
@@ -287,10 +294,19 @@ public final class SplashScreen {
public Graphics2D createGraphics() throws IllegalStateException {
synchronized (SplashScreen.class) {
if (image==null) {
- Dimension dim = getSize();
- image = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB);
+ // get unscaled splash image size
+ Dimension dim = _getBounds(splashPtr).getSize();
+ image = new BufferedImage(dim.width, dim.height,
+ BufferedImage.TYPE_INT_ARGB);
+ }
+ float scale = _getScaleFactor(splashPtr);
+ Graphics2D g = image.createGraphics();
+ assert (scale > 0);
+ if (scale <= 0) {
+ scale = 1;
}
- return image.createGraphics();
+ g.scale(scale, scale);
+ return g;
}
}
@@ -401,5 +417,6 @@ public final class SplashScreen {
private native static String _getImageFileName(long splashPtr);
private native static String _getImageJarName(long SplashPtr);
private native static boolean _setImageData(long SplashPtr, byte[] data);
+ private native static float _getScaleFactor(long SplashPtr);
};
diff --git a/src/share/classes/java/awt/Window.java b/src/share/classes/java/awt/Window.java
index 13779fd41..1052a200c 100644
--- a/src/share/classes/java/awt/Window.java
+++ b/src/share/classes/java/awt/Window.java
@@ -2247,7 +2247,18 @@ public class Window extends Container implements Accessible {
}
firePropertyChange("alwaysOnTop", oldAlwaysOnTop, alwaysOnTop);
}
- for (WeakReference<Window> ref : ownedWindowList) {
+ setOwnedWindowsAlwaysOnTop(alwaysOnTop);
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ private void setOwnedWindowsAlwaysOnTop(boolean alwaysOnTop) {
+ WeakReference<Window>[] ownedWindowArray;
+ synchronized (ownedWindowList) {
+ ownedWindowArray = new WeakReference[ownedWindowList.size()];
+ ownedWindowList.copyInto(ownedWindowArray);
+ }
+
+ for (WeakReference<Window> ref : ownedWindowArray) {
Window window = ref.get();
if (window != null) {
try {
diff --git a/src/share/classes/java/io/SequenceInputStream.java b/src/share/classes/java/io/SequenceInputStream.java
index 1a2858423..01da7f66b 100644
--- a/src/share/classes/java/io/SequenceInputStream.java
+++ b/src/share/classes/java/io/SequenceInputStream.java
@@ -135,7 +135,7 @@ class SequenceInputStream extends InputStream {
* @since JDK1.1
*/
public int available() throws IOException {
- if(in == null) {
+ if (in == null) {
return 0; // no way to signal EOF from available()
}
return in.available();
@@ -160,15 +160,14 @@ class SequenceInputStream extends InputStream {
* @exception IOException if an I/O error occurs.
*/
public int read() throws IOException {
- if (in == null) {
- return -1;
- }
- int c = in.read();
- if (c == -1) {
+ while (in != null) {
+ int c = in.read();
+ if (c != -1) {
+ return c;
+ }
nextStream();
- return read();
}
- return c;
+ return -1;
}
/**
@@ -204,13 +203,14 @@ class SequenceInputStream extends InputStream {
} else if (len == 0) {
return 0;
}
-
- int n = in.read(b, off, len);
- if (n <= 0) {
+ do {
+ int n = in.read(b, off, len);
+ if (n > 0) {
+ return n;
+ }
nextStream();
- return read(b, off, len);
- }
- return n;
+ } while (in != null);
+ return -1;
}
/**
diff --git a/src/share/classes/java/lang/invoke/MethodType.java b/src/share/classes/java/lang/invoke/MethodType.java
index 96d692f7d..c1b984856 100644
--- a/src/share/classes/java/lang/invoke/MethodType.java
+++ b/src/share/classes/java/lang/invoke/MethodType.java
@@ -891,11 +891,6 @@ class MethodType implements java.io.Serializable {
* with MHs.eCE.
* 3a. unboxing conversions can be followed by the full matrix of primitive conversions
* 3b. unboxing of null is permitted (creates a zero primitive value)
- * Most unboxing conversions, like {@code Object->int}, has potentially
- * different behaviors for asType vs. MHs.eCE, because the dynamic value
- * might be a wrapper of a type that requires narrowing, like {@code (Object)1L->byte}.
- * The equivalence is only certain if the static src type is a wrapper,
- * and the conversion will be a widening one.
* Other than interfaces, reference-to-reference conversions are the same.
* Boxing primitives to references is the same for both operators.
*/
@@ -906,11 +901,8 @@ class MethodType implements java.io.Serializable {
// Or a boxing conversion, which is always to an exact wrapper class.
return canConvert(src, dst);
} else if (dst.isPrimitive()) {
- Wrapper dw = Wrapper.forPrimitiveType(dst);
- // Watch out: If src is Number or Object, we could get dynamic narrowing conversion.
- // The conversion is known to be widening only if the wrapper type is statically visible.
- return (Wrapper.isWrapperType(src) &&
- dw.isConvertibleFrom(Wrapper.forWrapperType(src)));
+ // Unboxing behavior is different between MHs.eCA & MH.asType (see 3b).
+ return false;
} else {
// R->R always works, but we have to avoid a check-cast to an interface.
return !dst.isInterface() || dst.isAssignableFrom(src);
diff --git a/src/share/classes/java/lang/ref/ReferenceQueue.java b/src/share/classes/java/lang/ref/ReferenceQueue.java
index 61eaccbc6..534d21c7b 100644
--- a/src/share/classes/java/lang/ref/ReferenceQueue.java
+++ b/src/share/classes/java/lang/ref/ReferenceQueue.java
@@ -138,11 +138,17 @@ public class ReferenceQueue<T> {
synchronized (lock) {
Reference<? extends T> r = reallyPoll();
if (r != null) return r;
+ long start = (timeout == 0) ? 0 : System.nanoTime();
for (;;) {
lock.wait(timeout);
r = reallyPoll();
if (r != null) return r;
- if (timeout != 0) return null;
+ if (timeout != 0) {
+ long end = System.nanoTime();
+ timeout -= (end - start) / 1000_000;
+ if (timeout <= 0) return null;
+ start = end;
+ }
}
}
}
diff --git a/src/share/classes/java/util/BitSet.java b/src/share/classes/java/util/BitSet.java
index ae95b8e43..261a77c12 100644
--- a/src/share/classes/java/util/BitSet.java
+++ b/src/share/classes/java/util/BitSet.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -696,6 +696,9 @@ public class BitSet implements Cloneable, java.io.Serializable {
* <pre> {@code
* for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i+1)) {
* // operate on index i here
+ * if (i == Integer.MAX_VALUE) {
+ * break; // or (i+1) would overflow
+ * }
* }}</pre>
*
* @param fromIndex the index to start checking from (inclusive)
@@ -1186,10 +1189,12 @@ public class BitSet implements Cloneable, java.io.Serializable {
int i = nextSetBit(0);
if (i != -1) {
b.append(i);
- for (i = nextSetBit(i+1); i >= 0; i = nextSetBit(i+1)) {
+ while (true) {
+ if (++i < 0) break;
+ if ((i = nextSetBit(i)) < 0) break;
int endOfRun = nextClearBit(i);
do { b.append(", ").append(i); }
- while (++i < endOfRun);
+ while (++i != endOfRun);
}
}
diff --git a/src/share/classes/java/util/IdentityHashMap.java b/src/share/classes/java/util/IdentityHashMap.java
index 6e50f8a46..d40ad341b 100644
--- a/src/share/classes/java/util/IdentityHashMap.java
+++ b/src/share/classes/java/util/IdentityHashMap.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -25,7 +25,6 @@
package java.util;
-import java.io.*;
import java.lang.reflect.Array;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
@@ -74,7 +73,7 @@ import java.util.function.Consumer;
* maximum size and the number of buckets is unspecified.
*
* <p>If the size of the map (the number of key-value mappings) sufficiently
- * exceeds the expected maximum size, the number of buckets is increased
+ * exceeds the expected maximum size, the number of buckets is increased.
* Increasing the number of buckets ("rehashing") may be fairly expensive, so
* it pays to create identity hash maps with a sufficiently large expected
* maximum size. On the other hand, iteration over collection views requires
@@ -160,6 +159,10 @@ public class IdentityHashMap<K,V>
* The maximum capacity, used if a higher value is implicitly specified
* by either of the constructors with arguments.
* MUST be a power of two <= 1<<29.
+ *
+ * In fact, the map can hold no more than MAXIMUM_CAPACITY-1 items
+ * because it has to have at least one slot with the key == null
+ * in order to avoid infinite loops in get(), put(), remove()
*/
private static final int MAXIMUM_CAPACITY = 1 << 29;
@@ -181,11 +184,6 @@ public class IdentityHashMap<K,V>
transient int modCount;
/**
- * The next size value at which to resize (capacity * load factor).
- */
- private transient int threshold;
-
- /**
* Value representing null keys inside tables.
*/
static final Object NULL_KEY = new Object();
@@ -229,27 +227,18 @@ public class IdentityHashMap<K,V>
}
/**
- * Returns the appropriate capacity for the specified expected maximum
- * size. Returns the smallest power of two between MINIMUM_CAPACITY
- * and MAXIMUM_CAPACITY, inclusive, that is greater than
- * (3 * expectedMaxSize)/2, if such a number exists. Otherwise
- * returns MAXIMUM_CAPACITY. If (3 * expectedMaxSize)/2 is negative, it
- * is assumed that overflow has occurred, and MAXIMUM_CAPACITY is returned.
+ * Returns the appropriate capacity for the given expected maximum size.
+ * Returns the smallest power of two between MINIMUM_CAPACITY and
+ * MAXIMUM_CAPACITY, inclusive, that is greater than (3 *
+ * expectedMaxSize)/2, if such a number exists. Otherwise returns
+ * MAXIMUM_CAPACITY.
*/
- private int capacity(int expectedMaxSize) {
- // Compute min capacity for expectedMaxSize given a load factor of 2/3
- int minCapacity = (3 * expectedMaxSize)/2;
-
- // Compute the appropriate capacity
- int result;
- if (minCapacity > MAXIMUM_CAPACITY || minCapacity < 0) {
- result = MAXIMUM_CAPACITY;
- } else {
- result = MINIMUM_CAPACITY;
- while (result < minCapacity)
- result <<= 1;
- }
- return result;
+ private static int capacity(int expectedMaxSize) {
+ // assert expectedMaxSize >= 0;
+ return
+ (expectedMaxSize > MAXIMUM_CAPACITY / 3) ? MAXIMUM_CAPACITY :
+ (expectedMaxSize <= 2 * MINIMUM_CAPACITY / 3) ? MINIMUM_CAPACITY :
+ Integer.highestOneBit(expectedMaxSize + (expectedMaxSize << 1));
}
/**
@@ -262,7 +251,6 @@ public class IdentityHashMap<K,V>
// assert initCapacity >= MINIMUM_CAPACITY;
// assert initCapacity <= MAXIMUM_CAPACITY;
- threshold = (initCapacity * 2)/3;
table = new Object[2 * initCapacity];
}
@@ -429,52 +417,58 @@ public class IdentityHashMap<K,V>
* @see #containsKey(Object)
*/
public V put(K key, V value) {
- Object k = maskNull(key);
- Object[] tab = table;
- int len = tab.length;
- int i = hash(k, len);
+ final Object k = maskNull(key);
- Object item;
- while ( (item = tab[i]) != null) {
- if (item == k) {
- @SuppressWarnings("unchecked")
- V oldValue = (V) tab[i + 1];
- tab[i + 1] = value;
- return oldValue;
+ retryAfterResize: for (;;) {
+ final Object[] tab = table;
+ final int len = tab.length;
+ int i = hash(k, len);
+
+ for (Object item; (item = tab[i]) != null;
+ i = nextKeyIndex(i, len)) {
+ if (item == k) {
+ @SuppressWarnings("unchecked")
+ V oldValue = (V) tab[i + 1];
+ tab[i + 1] = value;
+ return oldValue;
+ }
}
- i = nextKeyIndex(i, len);
- }
- modCount++;
- tab[i] = k;
- tab[i + 1] = value;
- if (++size >= threshold)
- resize(len); // len == 2 * current capacity.
- return null;
+ final int s = size + 1;
+ // Use optimized form of 3 * s.
+ // Next capacity is len, 2 * current capacity.
+ if (s + (s << 1) > len && resize(len))
+ continue retryAfterResize;
+
+ modCount++;
+ tab[i] = k;
+ tab[i + 1] = value;
+ size = s;
+ return null;
+ }
}
/**
- * Resize the table to hold given capacity.
+ * Resizes the table if necessary to hold given capacity.
*
* @param newCapacity the new capacity, must be a power of two.
+ * @return whether a resize did in fact take place
*/
- private void resize(int newCapacity) {
+ private boolean resize(int newCapacity) {
// assert (newCapacity & -newCapacity) == newCapacity; // power of 2
int newLength = newCapacity * 2;
Object[] oldTable = table;
int oldLength = oldTable.length;
- if (oldLength == 2*MAXIMUM_CAPACITY) { // can't expand any further
- if (threshold == MAXIMUM_CAPACITY-1)
+ if (oldLength == 2 * MAXIMUM_CAPACITY) { // can't expand any further
+ if (size == MAXIMUM_CAPACITY - 1)
throw new IllegalStateException("Capacity exhausted.");
- threshold = MAXIMUM_CAPACITY-1; // Gigantic map!
- return;
+ return false;
}
if (oldLength >= newLength)
- return;
+ return false;
Object[] newTable = new Object[newLength];
- threshold = newLength / 3;
for (int j = 0; j < oldLength; j += 2) {
Object key = oldTable[j];
@@ -490,6 +484,7 @@ public class IdentityHashMap<K,V>
}
}
table = newTable;
+ return true;
}
/**
@@ -504,8 +499,8 @@ public class IdentityHashMap<K,V>
int n = m.size();
if (n == 0)
return;
- if (n > threshold) // conservatively pre-expand
- resize(capacity(n));
+ if (n > size)
+ resize(capacity(n)); // conservatively pre-expand
for (Entry<? extends K, ? extends V> e : m.entrySet())
put(e.getKey(), e.getValue());
@@ -542,7 +537,6 @@ public class IdentityHashMap<K,V>
return null;
i = nextKeyIndex(i, len);
}
-
}
/**
@@ -1266,8 +1260,8 @@ public class IdentityHashMap<K,V>
private static final long serialVersionUID = 8188218128353913216L;
/**
- * Save the state of the <tt>IdentityHashMap</tt> instance to a stream
- * (i.e., serialize it).
+ * Saves the state of the <tt>IdentityHashMap</tt> instance to a stream
+ * (i.e., serializes it).
*
* @serialData The <i>size</i> of the HashMap (the number of key-value
* mappings) (<tt>int</tt>), followed by the key (Object) and
@@ -1295,8 +1289,8 @@ public class IdentityHashMap<K,V>
}
/**
- * Reconstitute the <tt>IdentityHashMap</tt> instance from a stream (i.e.,
- * deserialize it).
+ * Reconstitutes the <tt>IdentityHashMap</tt> instance from a stream (i.e.,
+ * deserializes it).
*/
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException {
@@ -1305,9 +1299,10 @@ public class IdentityHashMap<K,V>
// Read in size (number of Mappings)
int size = s.readInt();
-
- // Allow for 33% growth (i.e., capacity is >= 2* size()).
- init(capacity((size*4)/3));
+ if (size < 0)
+ throw new java.io.StreamCorruptedException
+ ("Illegal mappings count: " + size);
+ init(capacity(size));
// Read the keys and values, and put the mappings in the table
for (int i=0; i<size; i++) {
@@ -1324,7 +1319,7 @@ public class IdentityHashMap<K,V>
* update modCount, etc.
*/
private void putForCreate(K key, V value)
- throws IOException
+ throws java.io.StreamCorruptedException
{
Object k = maskNull(key);
Object[] tab = table;
diff --git a/src/share/classes/javax/swing/JComboBox.java b/src/share/classes/javax/swing/JComboBox.java
index 1e0be3c8f..6e71c43cb 100644
--- a/src/share/classes/javax/swing/JComboBox.java
+++ b/src/share/classes/javax/swing/JComboBox.java
@@ -1308,7 +1308,8 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible {
*/
public void actionPerformed(ActionEvent e) {
ComboBoxEditor editor = getEditor();
- if ((editor != null) && (e != null) && (editor == e.getSource())) {
+ if ((editor != null) && (e != null)
+ && (editor.getEditorComponent() == e.getSource())) {
setPopupVisible(false);
getModel().setSelectedItem(editor.getItem());
String oldCommand = getActionCommand();
diff --git a/src/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java b/src/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java
index 4f842157a..c9bf9d302 100644
--- a/src/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java
+++ b/src/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java
@@ -1858,7 +1858,7 @@ public class ClassReader {
break;
case 'B': // pointer to CONSTANT_Byte
av.visit(name,
- new Byte((byte) readInt(items[readUnsignedShort(v)])));
+ (byte) readInt(items[readUnsignedShort(v)]));
v += 2;
break;
case 'Z': // pointer to CONSTANT_Boolean
@@ -1868,13 +1868,13 @@ public class ClassReader {
v += 2;
break;
case 'S': // pointer to CONSTANT_Short
- av.visit(name, new Short(
- (short) readInt(items[readUnsignedShort(v)])));
+ av.visit(name,
+ (short) readInt(items[readUnsignedShort(v)]));
v += 2;
break;
case 'C': // pointer to CONSTANT_Char
- av.visit(name, new Character(
- (char) readInt(items[readUnsignedShort(v)])));
+ av.visit(name,
+ (char) readInt(items[readUnsignedShort(v)]));
v += 2;
break;
case 's': // pointer to CONSTANT_Utf8
@@ -2498,13 +2498,13 @@ public class ClassReader {
int index = items[item];
switch (b[index - 1]) {
case ClassWriter.INT:
- return new Integer(readInt(index));
+ return readInt(index);
case ClassWriter.FLOAT:
- return new Float(Float.intBitsToFloat(readInt(index)));
+ return Float.intBitsToFloat(readInt(index));
case ClassWriter.LONG:
- return new Long(readLong(index));
+ return readLong(index);
case ClassWriter.DOUBLE:
- return new Double(Double.longBitsToDouble(readLong(index)));
+ return Double.longBitsToDouble(readLong(index));
case ClassWriter.CLASS:
return Type.getObjectType(readUTF8(index, buf));
case ClassWriter.STR:
diff --git a/src/share/classes/jdk/internal/org/objectweb/asm/TypePath.java b/src/share/classes/jdk/internal/org/objectweb/asm/TypePath.java
index b43a11d5a..31fe2bc68 100644
--- a/src/share/classes/jdk/internal/org/objectweb/asm/TypePath.java
+++ b/src/share/classes/jdk/internal/org/objectweb/asm/TypePath.java
@@ -181,6 +181,9 @@ public class TypePath {
typeArg = typeArg * 10 + c - '0';
i += 1;
}
+ if (i < n && typePath.charAt(i) == ';') {
+ i += 1;
+ }
out.put11(TYPE_ARGUMENT, typeArg);
}
}
@@ -193,7 +196,7 @@ public class TypePath {
* ARRAY_ELEMENT} steps are represented with '[', {@link #INNER_TYPE
* INNER_TYPE} steps with '.', {@link #WILDCARD_BOUND WILDCARD_BOUND} steps
* with '*' and {@link #TYPE_ARGUMENT TYPE_ARGUMENT} steps with their type
- * argument index in decimal form.
+ * argument index in decimal form followed by ';'.
*/
@Override
public String toString() {
@@ -211,7 +214,7 @@ public class TypePath {
result.append('*');
break;
case TYPE_ARGUMENT:
- result.append(getStepArgument(i));
+ result.append(getStepArgument(i)).append(';');
break;
default:
result.append('_');
diff --git a/src/share/classes/jdk/internal/org/objectweb/asm/commons/GeneratorAdapter.java b/src/share/classes/jdk/internal/org/objectweb/asm/commons/GeneratorAdapter.java
index 786a5b536..e198de78c 100644
--- a/src/share/classes/jdk/internal/org/objectweb/asm/commons/GeneratorAdapter.java
+++ b/src/share/classes/jdk/internal/org/objectweb/asm/commons/GeneratorAdapter.java
@@ -408,7 +408,7 @@ public class GeneratorAdapter extends LocalVariablesSorter {
} else if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE) {
mv.visitIntInsn(Opcodes.SIPUSH, value);
} else {
- mv.visitLdcInsn(new Integer(value));
+ mv.visitLdcInsn(value);
}
}
@@ -422,7 +422,7 @@ public class GeneratorAdapter extends LocalVariablesSorter {
if (value == 0L || value == 1L) {
mv.visitInsn(Opcodes.LCONST_0 + (int) value);
} else {
- mv.visitLdcInsn(new Long(value));
+ mv.visitLdcInsn(value);
}
}
@@ -437,7 +437,7 @@ public class GeneratorAdapter extends LocalVariablesSorter {
if (bits == 0L || bits == 0x3f800000 || bits == 0x40000000) { // 0..2
mv.visitInsn(Opcodes.FCONST_0 + (int) value);
} else {
- mv.visitLdcInsn(new Float(value));
+ mv.visitLdcInsn(value);
}
}
@@ -452,7 +452,7 @@ public class GeneratorAdapter extends LocalVariablesSorter {
if (bits == 0L || bits == 0x3ff0000000000000L) { // +0.0d and 1.0d
mv.visitInsn(Opcodes.DCONST_0 + (int) value);
} else {
- mv.visitLdcInsn(new Double(value));
+ mv.visitLdcInsn(value);
}
}
@@ -1647,11 +1647,13 @@ public class GeneratorAdapter extends LocalVariablesSorter {
*/
public void catchException(final Label start, final Label end,
final Type exception) {
+ Label doCatch = new Label();
if (exception == null) {
- mv.visitTryCatchBlock(start, end, mark(), null);
+ mv.visitTryCatchBlock(start, end, doCatch, null);
} else {
- mv.visitTryCatchBlock(start, end, mark(),
+ mv.visitTryCatchBlock(start, end, doCatch,
exception.getInternalName());
}
+ mark(doCatch);
}
}
diff --git a/src/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java b/src/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java
index 2c54ea475..2df144ef7 100644
--- a/src/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java
+++ b/src/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java
@@ -737,7 +737,7 @@ public class InstructionAdapter extends MethodVisitor {
} else if (cst >= Short.MIN_VALUE && cst <= Short.MAX_VALUE) {
mv.visitIntInsn(Opcodes.SIPUSH, cst);
} else {
- mv.visitLdcInsn(new Integer(cst));
+ mv.visitLdcInsn(cst);
}
}
@@ -745,7 +745,7 @@ public class InstructionAdapter extends MethodVisitor {
if (cst == 0L || cst == 1L) {
mv.visitInsn(Opcodes.LCONST_0 + (int) cst);
} else {
- mv.visitLdcInsn(new Long(cst));
+ mv.visitLdcInsn(cst);
}
}
@@ -754,7 +754,7 @@ public class InstructionAdapter extends MethodVisitor {
if (bits == 0L || bits == 0x3f800000 || bits == 0x40000000) { // 0..2
mv.visitInsn(Opcodes.FCONST_0 + (int) cst);
} else {
- mv.visitLdcInsn(new Float(cst));
+ mv.visitLdcInsn(cst);
}
}
@@ -763,7 +763,7 @@ public class InstructionAdapter extends MethodVisitor {
if (bits == 0L || bits == 0x3ff0000000000000L) { // +0.0d and 1.0d
mv.visitInsn(Opcodes.DCONST_0 + (int) cst);
} else {
- mv.visitLdcInsn(new Double(cst));
+ mv.visitLdcInsn(cst);
}
}
diff --git a/src/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java b/src/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java
index 51fcb4c46..cd407fd80 100644
--- a/src/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java
+++ b/src/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java
@@ -366,8 +366,7 @@ public class SerialVersionUIDAdder extends ClassVisitor {
protected void addSVUID(long svuid) {
FieldVisitor fv = super.visitField(Opcodes.ACC_FINAL
- + Opcodes.ACC_STATIC, "serialVersionUID", "J", null, new Long(
- svuid));
+ + Opcodes.ACC_STATIC, "serialVersionUID", "J", null, svuid);
if (fv != null) {
fv.visitEnd();
}
diff --git a/src/share/classes/jdk/internal/org/objectweb/asm/tree/AnnotationNode.java b/src/share/classes/jdk/internal/org/objectweb/asm/tree/AnnotationNode.java
index b67ea3859..1bb9925df 100644
--- a/src/share/classes/jdk/internal/org/objectweb/asm/tree/AnnotationNode.java
+++ b/src/share/classes/jdk/internal/org/objectweb/asm/tree/AnnotationNode.java
@@ -247,11 +247,13 @@ public class AnnotationNode extends AnnotationVisitor {
an.accept(av.visitAnnotation(name, an.desc));
} else if (value instanceof List) {
AnnotationVisitor v = av.visitArray(name);
- List<?> array = (List<?>) value;
- for (int j = 0; j < array.size(); ++j) {
- accept(v, null, array.get(j));
+ if (v != null) {
+ List<?> array = (List<?>) value;
+ for (int j = 0; j < array.size(); ++j) {
+ accept(v, null, array.get(j));
+ }
+ v.visitEnd();
}
- v.visitEnd();
} else {
av.visit(name, value);
}
diff --git a/src/share/classes/jdk/internal/org/objectweb/asm/tree/LookupSwitchInsnNode.java b/src/share/classes/jdk/internal/org/objectweb/asm/tree/LookupSwitchInsnNode.java
index b1daa382f..ab408b748 100644
--- a/src/share/classes/jdk/internal/org/objectweb/asm/tree/LookupSwitchInsnNode.java
+++ b/src/share/classes/jdk/internal/org/objectweb/asm/tree/LookupSwitchInsnNode.java
@@ -110,7 +110,7 @@ public class LookupSwitchInsnNode extends AbstractInsnNode {
: labels.length);
if (keys != null) {
for (int i = 0; i < keys.length; ++i) {
- this.keys.add(new Integer(keys[i]));
+ this.keys.add(keys[i]);
}
}
if (labels != null) {
diff --git a/src/share/classes/jdk/internal/org/objectweb/asm/tree/MethodInsnNode.java b/src/share/classes/jdk/internal/org/objectweb/asm/tree/MethodInsnNode.java
index 2f61df3b5..cb84d4262 100644
--- a/src/share/classes/jdk/internal/org/objectweb/asm/tree/MethodInsnNode.java
+++ b/src/share/classes/jdk/internal/org/objectweb/asm/tree/MethodInsnNode.java
@@ -160,6 +160,7 @@ public class MethodInsnNode extends AbstractInsnNode {
@Override
public void accept(final MethodVisitor mv) {
mv.visitMethodInsn(opcode, owner, name, desc, itf);
+ acceptAnnotations(mv);
}
@Override
diff --git a/src/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java b/src/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java
index 0716debae..25673195f 100644
--- a/src/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java
+++ b/src/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java
@@ -802,7 +802,7 @@ public class CheckMethodAdapter extends MethodVisitor {
if (labels.get(label) != null) {
throw new IllegalArgumentException("Already visited label");
}
- labels.put(label, new Integer(insnCount));
+ labels.put(label, insnCount);
super.visitLabel(label);
}
diff --git a/src/share/classes/jdk/internal/org/objectweb/asm/util/Textifier.java b/src/share/classes/jdk/internal/org/objectweb/asm/util/Textifier.java
index c210e2c40..b8e1cd1f1 100644
--- a/src/share/classes/jdk/internal/org/objectweb/asm/util/Textifier.java
+++ b/src/share/classes/jdk/internal/org/objectweb/asm/util/Textifier.java
@@ -732,7 +732,7 @@ public class Textifier extends Printer {
Textifier t = createTextifier();
text.add(t.getText());
text.add(visible ? ") // parameter " : ") // invisible, parameter ");
- text.add(new Integer(parameter));
+ text.add(parameter);
text.add("\n");
return t;
}
diff --git a/src/share/classes/jdk/internal/org/objectweb/asm/version.txt b/src/share/classes/jdk/internal/org/objectweb/asm/version.txt
index d93a6c4b4..5ba3a332b 100644
--- a/src/share/classes/jdk/internal/org/objectweb/asm/version.txt
+++ b/src/share/classes/jdk/internal/org/objectweb/asm/version.txt
@@ -1,12 +1,12 @@
Path: .
-Working Copy Root Path: /hudson/jobs/objectweb-pull/workspace/asm-svn-2014-06-19
+Working Copy Root Path: /hudson/jobs/objectweb-init/workspace/asm-svn-2014-10-15
URL: file:///svnroot/asm/trunk/asm
Repository Root: file:///svnroot/asm
Repository UUID: 271bd773-ee82-43a6-9b2b-1890ed8ce7f9
-Revision: 1750
+Revision: 1772
Node Kind: directory
Schedule: normal
-Last Changed Author: forax
-Last Changed Rev: 1750
-Last Changed Date: 2014-06-06 00:31:02 +0200 (Fri, 06 Jun 2014)
+Last Changed Author: ebruneton
+Last Changed Rev: 1772
+Last Changed Date: 2014-09-06 09:13:07 +0200 (Sat, 06 Sep 2014)
diff --git a/src/share/classes/jdk/net/Sockets.java b/src/share/classes/jdk/net/Sockets.java
index 2b31a1d57..7b6f8dbbd 100644
--- a/src/share/classes/jdk/net/Sockets.java
+++ b/src/share/classes/jdk/net/Sockets.java
@@ -371,6 +371,7 @@ public class Sockets {
set = new HashSet<>();
set.add(StandardSocketOptions.SO_RCVBUF);
set.add(StandardSocketOptions.SO_REUSEADDR);
+ set.add(StandardSocketOptions.IP_TOS);
set = Collections.unmodifiableSet(set);
options.put(ServerSocket.class, set);
diff --git a/src/share/classes/sun/invoke/util/Wrapper.java b/src/share/classes/sun/invoke/util/Wrapper.java
index 2732e28c8..0a0d04b3c 100644
--- a/src/share/classes/sun/invoke/util/Wrapper.java
+++ b/src/share/classes/sun/invoke/util/Wrapper.java
@@ -26,19 +26,19 @@
package sun.invoke.util;
public enum Wrapper {
- BOOLEAN(Boolean.class, boolean.class, 'Z', (Boolean)false, new boolean[0], Format.unsigned(1)),
+ // wrapperType primitiveType char zero emptyArray format
+ BOOLEAN( Boolean.class, boolean.class, 'Z', (Boolean)false, new boolean[0], Format.unsigned( 1)),
// These must be in the order defined for widening primitive conversions in JLS 5.1.2
- BYTE(Byte.class, byte.class, 'B', (Byte)(byte)0, new byte[0], Format.signed(8)),
- SHORT(Short.class, short.class, 'S', (Short)(short)0, new short[0], Format.signed(16)),
- CHAR(Character.class, char.class, 'C', (Character)(char)0, new char[0], Format.unsigned(16)),
- INT(Integer.class, int.class, 'I', (Integer)/*(int)*/0, new int[0], Format.signed(32)),
- LONG(Long.class, long.class, 'J', (Long)(long)0, new long[0], Format.signed(64)),
- FLOAT(Float.class, float.class, 'F', (Float)(float)0, new float[0], Format.floating(32)),
- DOUBLE(Double.class, double.class, 'D', (Double)(double)0, new double[0], Format.floating(64)),
- //NULL(Null.class, null.class, 'N', null, null, Format.other(1)),
- OBJECT(Object.class, Object.class, 'L', null, new Object[0], Format.other(1)),
+ BYTE ( Byte.class, byte.class, 'B', (Byte)(byte)0, new byte[0], Format.signed( 8)),
+ SHORT ( Short.class, short.class, 'S', (Short)(short)0, new short[0], Format.signed( 16)),
+ CHAR (Character.class, char.class, 'C', (Character)(char)0, new char[0], Format.unsigned(16)),
+ INT ( Integer.class, int.class, 'I', (Integer)/*(int)*/0, new int[0], Format.signed( 32)),
+ LONG ( Long.class, long.class, 'J', (Long)(long)0, new long[0], Format.signed( 64)),
+ FLOAT ( Float.class, float.class, 'F', (Float)(float)0, new float[0], Format.floating(32)),
+ DOUBLE ( Double.class, double.class, 'D', (Double)(double)0, new double[0], Format.floating(64)),
+ OBJECT ( Object.class, Object.class, 'L', null, new Object[0], Format.other( 1)),
// VOID must be the last type, since it is "assignable" from any other type:
- VOID(Void.class, void.class, 'V', null, null, Format.other(0)),
+ VOID ( Void.class, void.class, 'V', null, null, Format.other( 0)),
;
private final Class<?> wrapperType;
diff --git a/src/share/classes/sun/misc/Launcher.java b/src/share/classes/sun/misc/Launcher.java
index 71b3d3bbc..f72f60e85 100644
--- a/src/share/classes/sun/misc/Launcher.java
+++ b/src/share/classes/sun/misc/Launcher.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -162,6 +162,8 @@ public class Launcher {
*/
public ExtClassLoader(File[] dirs) throws IOException {
super(getExtURLs(dirs), null, factory);
+ SharedSecrets.getJavaNetAccess().
+ getURLClassPath(this).initLookupCache(this);
}
private static File[] getExtDirs() {
@@ -285,11 +287,15 @@ public class Launcher {
});
}
+ final URLClassPath ucp;
+
/*
* Creates a new AppClassLoader
*/
AppClassLoader(URL[] urls, ClassLoader parent) {
super(urls, parent, factory);
+ ucp = SharedSecrets.getJavaNetAccess().getURLClassPath(this);
+ ucp.initLookupCache(this);
}
/**
@@ -305,6 +311,23 @@ public class Launcher {
sm.checkPackageAccess(name.substring(0, i));
}
}
+
+ if (ucp.knownToNotExist(name)) {
+ // The class of the given name is not found in the parent
+ // class loader as well as its local URLClassPath.
+ // Check if this class has already been defined dynamically;
+ // if so, return the loaded class; otherwise, skip the parent
+ // delegation and findClass.
+ Class<?> c = findLoadedClass(name);
+ if (c != null) {
+ if (resolve) {
+ resolveClass(c);
+ }
+ return c;
+ }
+ throw new ClassNotFoundException(name);
+ }
+
return (super.loadClass(name, resolve));
}
@@ -386,6 +409,7 @@ public class Launcher {
urls = new URL[0];
}
bcp = new URLClassPath(urls, factory);
+ bcp.initLookupCache(null);
}
}
diff --git a/src/share/classes/sun/misc/URLClassPath.java b/src/share/classes/sun/misc/URLClassPath.java
index 11dae8197..f92b1ded0 100644
--- a/src/share/classes/sun/misc/URLClassPath.java
+++ b/src/share/classes/sun/misc/URLClassPath.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -38,6 +38,7 @@ import java.util.jar.Attributes.Name;
import java.net.JarURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
+import java.net.URLClassLoader;
import java.net.URLConnection;
import java.net.HttpURLConnection;
import java.net.URLStreamHandler;
@@ -52,6 +53,7 @@ import java.security.PrivilegedExceptionAction;
import java.security.cert.Certificate;
import sun.misc.FileURLMapper;
import sun.net.util.URLUtil;
+import sun.security.action.GetPropertyAction;
/**
* This class is used to maintain a search path of URLs for loading classes
@@ -63,15 +65,18 @@ public class URLClassPath {
final static String USER_AGENT_JAVA_VERSION = "UA-Java-Version";
final static String JAVA_VERSION;
private static final boolean DEBUG;
+ private static final boolean DEBUG_LOOKUP_CACHE;
private static final boolean DISABLE_JAR_CHECKING;
static {
JAVA_VERSION = java.security.AccessController.doPrivileged(
- new sun.security.action.GetPropertyAction("java.version"));
+ new GetPropertyAction("java.version"));
DEBUG = (java.security.AccessController.doPrivileged(
- new sun.security.action.GetPropertyAction("sun.misc.URLClassPath.debug")) != null);
+ new GetPropertyAction("sun.misc.URLClassPath.debug")) != null);
+ DEBUG_LOOKUP_CACHE = (java.security.AccessController.doPrivileged(
+ new GetPropertyAction("sun.misc.URLClassPath.debugLookupCache")) != null);
String p = java.security.AccessController.doPrivileged(
- new sun.security.action.GetPropertyAction("sun.misc.URLClassPath.disableJarChecking"));
+ new GetPropertyAction("sun.misc.URLClassPath.disableJarChecking"));
DISABLE_JAR_CHECKING = p != null ? p.equals("true") || p.equals("") : false;
}
@@ -149,6 +154,12 @@ public class URLClassPath {
urls.add(0, url);
path.add(url);
+
+ if (lookupCacheURLs != null) {
+ // The lookup cache is no longer valid, since getLookupCache()
+ // does not consider the newly added url.
+ disableAllLookupCaches();
+ }
}
}
@@ -172,7 +183,8 @@ public class URLClassPath {
*/
public URL findResource(String name, boolean check) {
Loader loader;
- for (int i = 0; (loader = getLoader(i)) != null; i++) {
+ int[] cache = getLookupCache(name);
+ for (int i = 0; (loader = getNextLoader(cache, i)) != null; i++) {
URL url = loader.findResource(name, check);
if (url != null) {
return url;
@@ -195,7 +207,8 @@ public class URLClassPath {
}
Loader loader;
- for (int i = 0; (loader = getLoader(i)) != null; i++) {
+ int[] cache = getLookupCache(name);
+ for (int i = 0; (loader = getNextLoader(cache, i)) != null; i++) {
Resource res = loader.getResource(name, check);
if (res != null) {
return res;
@@ -215,6 +228,7 @@ public class URLClassPath {
final boolean check) {
return new Enumeration<URL>() {
private int index = 0;
+ private int[] cache = getLookupCache(name);
private URL url = null;
private boolean next() {
@@ -222,7 +236,7 @@ public class URLClassPath {
return true;
} else {
Loader loader;
- while ((loader = getLoader(index++)) != null) {
+ while ((loader = getNextLoader(cache, index++)) != null) {
url = loader.findResource(name, check);
if (url != null) {
return true;
@@ -262,6 +276,7 @@ public class URLClassPath {
final boolean check) {
return new Enumeration<Resource>() {
private int index = 0;
+ private int[] cache = getLookupCache(name);
private Resource res = null;
private boolean next() {
@@ -269,7 +284,7 @@ public class URLClassPath {
return true;
} else {
Loader loader;
- while ((loader = getLoader(index++)) != null) {
+ while ((loader = getNextLoader(cache, index++)) != null) {
res = loader.getResource(name, check);
if (res != null) {
return true;
@@ -298,6 +313,151 @@ public class URLClassPath {
return getResources(name, true);
}
+ private static volatile boolean lookupCacheEnabled
+ = "true".equals(VM.getSavedProperty("sun.cds.enableSharedLookupCache"));
+ private URL[] lookupCacheURLs;
+ private ClassLoader lookupCacheLoader;
+
+ synchronized void initLookupCache(ClassLoader loader) {
+ if ((lookupCacheURLs = getLookupCacheURLs(loader)) != null) {
+ lookupCacheLoader = loader;
+ } else {
+ // This JVM instance does not support lookup cache.
+ disableAllLookupCaches();
+ }
+ }
+
+ static void disableAllLookupCaches() {
+ lookupCacheEnabled = false;
+ }
+
+ private static native URL[] getLookupCacheURLs(ClassLoader loader);
+ private static native int[] getLookupCacheForClassLoader(ClassLoader loader,
+ String name);
+ private static native boolean knownToNotExist0(ClassLoader loader,
+ String className);
+
+ synchronized boolean knownToNotExist(String className) {
+ if (lookupCacheURLs != null && lookupCacheEnabled) {
+ return knownToNotExist0(lookupCacheLoader, className);
+ }
+
+ // Don't know if this class exists or not -- need to do a full search.
+ return false;
+ }
+
+ /**
+ * Returns an array of the index to lookupCacheURLs that may
+ * contain the specified resource. The values in the returned
+ * array are in strictly ascending order and must be a valid index
+ * to lookupCacheURLs array.
+ *
+ * This method returns an empty array if the specified resource
+ * cannot be found in this URLClassPath. If there is no lookup
+ * cache or it's disabled, this method returns null and the lookup
+ * should search the entire classpath.
+ *
+ * Example: if lookupCacheURLs contains {a.jar, b.jar, c.jar, d.jar}
+ * and package "foo" only exists in a.jar and c.jar,
+ * getLookupCache("foo/Bar.class") will return {0, 2}
+ *
+ * @param name the resource name
+ * @return an array of the index to lookupCacheURLs that may contain the
+ * specified resource; or null if no lookup cache is used.
+ */
+ private synchronized int[] getLookupCache(String name) {
+ if (lookupCacheURLs == null || !lookupCacheEnabled) {
+ return null;
+ }
+
+ int[] cache = getLookupCacheForClassLoader(lookupCacheLoader, name);
+ if (cache != null && cache.length > 0) {
+ int maxindex = cache[cache.length - 1]; // cache[] is strictly ascending.
+ if (!ensureLoaderOpened(maxindex)) {
+ if (DEBUG_LOOKUP_CACHE) {
+ System.out.println("Expanded loaders FAILED " +
+ loaders.size() + " for maxindex=" + maxindex);
+ }
+ return null;
+ }
+ }
+
+ return cache;
+ }
+
+ private boolean ensureLoaderOpened(int index) {
+ if (loaders.size() <= index) {
+ // Open all Loaders up to, and including, index
+ if (getLoader(index) == null) {
+ return false;
+ }
+ if (!lookupCacheEnabled) {
+ // cache was invalidated as the result of the above call.
+ return false;
+ }
+ if (DEBUG_LOOKUP_CACHE) {
+ System.out.println("Expanded loaders " + loaders.size() +
+ " to index=" + index);
+ }
+ }
+ return true;
+ }
+
+ /*
+ * The CLASS-PATH attribute was expanded by the VM when building
+ * the resource lookup cache in the same order as the getLoader
+ * method does. This method validates if the URL from the lookup
+ * cache matches the URL of the Loader at the given index;
+ * otherwise, this method disables the lookup cache.
+ */
+ private synchronized void validateLookupCache(int index,
+ String urlNoFragString) {
+ if (lookupCacheURLs != null && lookupCacheEnabled) {
+ if (index < lookupCacheURLs.length &&
+ urlNoFragString.equals(
+ URLUtil.urlNoFragString(lookupCacheURLs[index]))) {
+ return;
+ }
+ if (DEBUG || DEBUG_LOOKUP_CACHE) {
+ System.out.println("WARNING: resource lookup cache invalidated "
+ + "for lookupCacheLoader at " + index);
+ }
+ disableAllLookupCaches();
+ }
+ }
+
+ /**
+ * Returns the next Loader that may contain the resource to
+ * lookup. If the given cache is null, return loaders.get(index)
+ * that may be lazily created; otherwise, cache[index] is the next
+ * Loader that may contain the resource to lookup and so returns
+ * loaders.get(cache[index]).
+ *
+ * If cache is non-null, loaders.get(cache[index]) must be present.
+ *
+ * @param cache lookup cache. If null, search the entire class path
+ * @param index index to the given cache array; or to the loaders list.
+ */
+ private synchronized Loader getNextLoader(int[] cache, int index) {
+ if (closed) {
+ return null;
+ }
+ if (cache != null) {
+ if (index < cache.length) {
+ Loader loader = loaders.get(cache[index]);
+ if (DEBUG_LOOKUP_CACHE) {
+ System.out.println("HASCACHE: Loading from : " + cache[index]
+ + " = " + loader.getBaseURL());
+ }
+ return loader;
+ } else {
+ return null; // finished iterating over cache[]
+ }
+ } else {
+ return getLoader(index);
+ }
+ }
+
/*
* Returns the Loader at the specified position in the URL search
* path. The URLs are opened and expanded as needed. Returns null
@@ -341,9 +501,13 @@ public class URLClassPath {
continue;
}
// Finally, add the Loader to the search path.
+ validateLookupCache(loaders.size(), urlNoFragString);
loaders.add(loader);
lmap.put(urlNoFragString, loader);
}
+ if (DEBUG_LOOKUP_CACHE) {
+ System.out.println("NOCACHE: Loading from : " + index );
+ }
return loaders.get(index);
}
diff --git a/src/share/classes/sun/misc/VM.java b/src/share/classes/sun/misc/VM.java
index f317b5daf..4ae2664b7 100644
--- a/src/share/classes/sun/misc/VM.java
+++ b/src/share/classes/sun/misc/VM.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -313,6 +313,9 @@ public class VM {
// used by sun.launcher.LauncherHelper
props.remove("sun.java.launcher.diag");
+
+ // used by sun.misc.URLClassPath
+ props.remove("sun.cds.enableSharedLookupCache");
}
// Initialize any miscellenous operating system settings that need to be
diff --git a/src/share/classes/sun/nio/fs/AbstractPoller.java b/src/share/classes/sun/nio/fs/AbstractPoller.java
index fd3503ce2..34d4ea4e3 100644
--- a/src/share/classes/sun/nio/fs/AbstractPoller.java
+++ b/src/share/classes/sun/nio/fs/AbstractPoller.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -100,8 +100,6 @@ abstract class AbstractPoller implements Runnable {
// validate arguments before request to poller
if (dir == null)
throw new NullPointerException();
- if (events.length == 0)
- throw new IllegalArgumentException("No events to register");
Set<WatchEvent.Kind<?>> eventSet = new HashSet<>(events.length);
for (WatchEvent.Kind<?> event: events) {
// standard events
@@ -114,17 +112,16 @@ abstract class AbstractPoller implements Runnable {
}
// OVERFLOW is ignored
- if (event == StandardWatchEventKinds.OVERFLOW) {
- if (events.length == 1)
- throw new IllegalArgumentException("No events to register");
+ if (event == StandardWatchEventKinds.OVERFLOW)
continue;
- }
// null/unsupported
if (event == null)
throw new NullPointerException("An element in event set is 'null'");
throw new UnsupportedOperationException(event.name());
}
+ if (eventSet.isEmpty())
+ throw new IllegalArgumentException("No events to register");
return (WatchKey)invoke(RequestType.REGISTER, dir, eventSet, modifiers);
}
@@ -192,14 +189,17 @@ abstract class AbstractPoller implements Runnable {
* the request.
*/
Object awaitResult() {
+ boolean interrupted = false;
synchronized (this) {
while (!completed) {
try {
wait();
} catch (InterruptedException x) {
- // ignore
+ interrupted = true;
}
}
+ if (interrupted)
+ Thread.currentThread().interrupt();
return result;
}
}
diff --git a/src/share/classes/sun/nio/fs/PollingWatchService.java b/src/share/classes/sun/nio/fs/PollingWatchService.java
index 30de2473b..d3d989122 100644
--- a/src/share/classes/sun/nio/fs/PollingWatchService.java
+++ b/src/share/classes/sun/nio/fs/PollingWatchService.java
@@ -74,8 +74,6 @@ class PollingWatchService
throws IOException
{
// check events - CCE will be thrown if there are invalid elements
- if (events.length == 0)
- throw new IllegalArgumentException("No events to register");
final Set<WatchEvent.Kind<?>> eventSet =
new HashSet<WatchEvent.Kind<?>>(events.length);
for (WatchEvent.Kind<?> event: events) {
@@ -90,8 +88,6 @@ class PollingWatchService
// OVERFLOW is ignored
if (event == StandardWatchEventKinds.OVERFLOW) {
- if (events.length == 1)
- throw new IllegalArgumentException("No events to register");
continue;
}
@@ -100,6 +96,8 @@ class PollingWatchService
throw new NullPointerException("An element in event set is 'null'");
throw new UnsupportedOperationException(event.name());
}
+ if (eventSet.isEmpty())
+ throw new IllegalArgumentException("No events to register");
// A modifier may be used to specify the sensitivity level
SensitivityWatchEventModifier sensivity = SensitivityWatchEventModifier.MEDIUM;
diff --git a/src/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java b/src/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java
index 71a34bb6d..fb939f415 100644
--- a/src/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java
+++ b/src/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java
@@ -45,8 +45,8 @@ import sun.reflect.generics.tree.FieldTypeSignature;
* core reflection (java.lang.reflect).
*/
public class CoreReflectionFactory implements GenericsFactory {
- private GenericDeclaration decl;
- private Scope scope;
+ private final GenericDeclaration decl;
+ private final Scope scope;
private CoreReflectionFactory(GenericDeclaration d, Scope s) {
decl = d;
diff --git a/src/share/classes/sun/reflect/generics/reflectiveObjects/LazyReflectiveObjectGenerator.java b/src/share/classes/sun/reflect/generics/reflectiveObjects/LazyReflectiveObjectGenerator.java
index 7cedafd64..0bc6f6088 100644
--- a/src/share/classes/sun/reflect/generics/reflectiveObjects/LazyReflectiveObjectGenerator.java
+++ b/src/share/classes/sun/reflect/generics/reflectiveObjects/LazyReflectiveObjectGenerator.java
@@ -40,7 +40,7 @@ import sun.reflect.generics.visitor.Reifier;
*
*/
public abstract class LazyReflectiveObjectGenerator {
- private GenericsFactory factory; // cached factory
+ private final GenericsFactory factory; // cached factory
protected LazyReflectiveObjectGenerator(GenericsFactory f) {
factory = f;
diff --git a/src/share/classes/sun/reflect/generics/repository/AbstractRepository.java b/src/share/classes/sun/reflect/generics/repository/AbstractRepository.java
index a28d88d3a..42f9446c3 100644
--- a/src/share/classes/sun/reflect/generics/repository/AbstractRepository.java
+++ b/src/share/classes/sun/reflect/generics/repository/AbstractRepository.java
@@ -40,9 +40,9 @@ public abstract class AbstractRepository<T extends Tree> {
// A factory used to produce reflective objects. Provided when the
//repository is created. Will vary across implementations.
- private GenericsFactory factory;
+ private final GenericsFactory factory;
- private T tree; // the AST for the generic type info
+ private final T tree; // the AST for the generic type info
//accessors
private GenericsFactory getFactory() { return factory;}
diff --git a/src/share/classes/sun/reflect/generics/repository/ClassRepository.java b/src/share/classes/sun/reflect/generics/repository/ClassRepository.java
index f60f03346..d3b54514e 100644
--- a/src/share/classes/sun/reflect/generics/repository/ClassRepository.java
+++ b/src/share/classes/sun/reflect/generics/repository/ClassRepository.java
@@ -42,8 +42,8 @@ public class ClassRepository extends GenericDeclRepository<ClassSignature> {
public static final ClassRepository NONE = ClassRepository.make("Ljava/lang/Object;", null);
- private Type superclass; // caches the generic superclass info
- private Type[] superInterfaces; // caches the generic superinterface info
+ private volatile Type superclass; // caches the generic superclass info
+ private volatile Type[] superInterfaces; // caches the generic superinterface info
// private, to enforce use of static factory
private ClassRepository(String rawSig, GenericsFactory f) {
@@ -80,17 +80,20 @@ public class ClassRepository extends GenericDeclRepository<ClassSignature> {
*/
public Type getSuperclass(){
+ Type superclass = this.superclass;
if (superclass == null) { // lazily initialize superclass
Reifier r = getReifier(); // obtain visitor
// Extract superclass subtree from AST and reify
getTree().getSuperclass().accept(r);
// extract result from visitor and cache it
superclass = r.getResult();
+ this.superclass = superclass;
}
return superclass; // return cached result
}
public Type[] getSuperInterfaces(){
+ Type[] superInterfaces = this.superInterfaces;
if (superInterfaces == null) { // lazily initialize super interfaces
// first, extract super interface subtree(s) from AST
TypeTree[] ts = getTree().getSuperInterfaces();
@@ -104,6 +107,7 @@ public class ClassRepository extends GenericDeclRepository<ClassSignature> {
sis[i] = r.getResult();
}
superInterfaces = sis; // cache overall result
+ this.superInterfaces = superInterfaces;
}
return superInterfaces.clone(); // return cached result
}
diff --git a/src/share/classes/sun/reflect/generics/repository/GenericDeclRepository.java b/src/share/classes/sun/reflect/generics/repository/GenericDeclRepository.java
index 28cb4b4c7..38af52030 100644
--- a/src/share/classes/sun/reflect/generics/repository/GenericDeclRepository.java
+++ b/src/share/classes/sun/reflect/generics/repository/GenericDeclRepository.java
@@ -42,7 +42,7 @@ import sun.reflect.generics.visitor.Reifier;
public abstract class GenericDeclRepository<S extends Signature>
extends AbstractRepository<S> {
- private TypeVariable<?>[] typeParams; // caches the formal type parameters
+ private volatile TypeVariable<?>[] typeParams; // caches the formal type parameters
protected GenericDeclRepository(String rawSig, GenericsFactory f) {
super(rawSig, f);
@@ -65,6 +65,7 @@ public abstract class GenericDeclRepository<S extends Signature>
* @return the formal type parameters of this generic declaration
*/
public TypeVariable<?>[] getTypeParameters(){
+ TypeVariable[] typeParams = this.typeParams;
if (typeParams == null) { // lazily initialize type parameters
// first, extract type parameter subtree(s) from AST
FormalTypeParameter[] ftps = getTree().getFormalTypeParameters();
@@ -78,6 +79,7 @@ public abstract class GenericDeclRepository<S extends Signature>
tps[i] = (TypeVariable<?>) r.getResult();
}
typeParams = tps; // cache overall result
+ this.typeParams = typeParams;
}
return typeParams.clone(); // return cached result
}
diff --git a/src/share/classes/sun/reflect/generics/scope/AbstractScope.java b/src/share/classes/sun/reflect/generics/scope/AbstractScope.java
index bc0132eea..872360b80 100644
--- a/src/share/classes/sun/reflect/generics/scope/AbstractScope.java
+++ b/src/share/classes/sun/reflect/generics/scope/AbstractScope.java
@@ -41,8 +41,8 @@ import java.lang.reflect.TypeVariable;
public abstract class AbstractScope<D extends GenericDeclaration>
implements Scope {
- private D recvr; // the declaration whose scope this instance represents
- private Scope enclosingScope; // the enclosing scope of this scope
+ private final D recvr; // the declaration whose scope this instance represents
+ private volatile Scope enclosingScope; // the enclosing scope of this scope
/**
* Constructor. Takes a reflective object whose scope the newly
@@ -71,7 +71,11 @@ public abstract class AbstractScope<D extends GenericDeclaration>
* @return the enclosing scope
*/
protected Scope getEnclosingScope(){
- if (enclosingScope == null) {enclosingScope = computeEnclosingScope();}
+ Scope enclosingScope = this.enclosingScope;
+ if (enclosingScope == null) {
+ enclosingScope = computeEnclosingScope();
+ this.enclosingScope = enclosingScope;
+ }
return enclosingScope;
}
diff --git a/src/share/classes/sun/reflect/generics/tree/ClassSignature.java b/src/share/classes/sun/reflect/generics/tree/ClassSignature.java
index ca77d9f8a..9347f9770 100644
--- a/src/share/classes/sun/reflect/generics/tree/ClassSignature.java
+++ b/src/share/classes/sun/reflect/generics/tree/ClassSignature.java
@@ -28,9 +28,9 @@ package sun.reflect.generics.tree;
import sun.reflect.generics.visitor.Visitor;
public class ClassSignature implements Signature {
- private FormalTypeParameter[] formalTypeParams;
- private ClassTypeSignature superclass;
- private ClassTypeSignature[] superInterfaces;
+ private final FormalTypeParameter[] formalTypeParams;
+ private final ClassTypeSignature superclass;
+ private final ClassTypeSignature[] superInterfaces;
private ClassSignature(FormalTypeParameter[] ftps,
ClassTypeSignature sc,
diff --git a/src/share/javavm/export/jvm.h b/src/share/javavm/export/jvm.h
index 1aaec31c3..611120f25 100644
--- a/src/share/javavm/export/jvm.h
+++ b/src/share/javavm/export/jvm.h
@@ -1391,6 +1391,31 @@ JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState);
JNIEXPORT jobjectArray JNICALL
JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values);
+/*
+ * Returns true if the JVM's lookup cache indicates that this class is
+ * known to NOT exist for the given loader.
+ */
+JNIEXPORT jboolean JNICALL
+JVM_KnownToNotExist(JNIEnv *env, jobject loader, const char *classname);
+
+/*
+ * Returns an array of all URLs that are stored in the JVM's lookup cache
+ * for the given loader. NULL if the lookup cache is unavailable.
+ */
+JNIEXPORT jobjectArray JNICALL
+JVM_GetResourceLookupCacheURLs(JNIEnv *env, jobject loader);
+
+/*
+ * Returns an array of all URLs that *may* contain the resource_name for the
+ * given loader. This function returns an integer array, each element
+ * of which can be used to index into the array returned by
+ * JVM_GetResourceLookupCacheURLs of the same loader to determine the
+ * URLs.
+ */
+JNIEXPORT jintArray JNICALL
+JVM_GetResourceLookupCache(JNIEnv *env, jobject loader, const char *resource_name);
+
+
/* =========================================================================
* The following defines a private JVM interface that the JDK can query
* for the JVM version and capabilities. sun.misc.Version defines
diff --git a/src/share/native/java/lang/ClassLoader.c b/src/share/native/java/lang/ClassLoader.c
index f6d058399..9a4c5db74 100644
--- a/src/share/native/java/lang/ClassLoader.c
+++ b/src/share/native/java/lang/ClassLoader.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -51,7 +51,7 @@ Java_java_lang_ClassLoader_registerNatives(JNIEnv *env, jclass cls)
/* Convert java string to UTF char*. Use local buffer if possible,
otherwise malloc new memory. Returns null IFF malloc failed. */
-static char*
+char*
getUTF(JNIEnv *env, jstring str, char* localBuf, int bufSize)
{
char* utfStr = NULL;
diff --git a/src/share/native/sun/awt/splashscreen/java_awt_SplashScreen.c b/src/share/native/sun/awt/splashscreen/java_awt_SplashScreen.c
index 86f6837a7..eb63c49d6 100644
--- a/src/share/native/sun/awt/splashscreen/java_awt_SplashScreen.c
+++ b/src/share/native/sun/awt/splashscreen/java_awt_SplashScreen.c
@@ -220,3 +220,18 @@ JNIEXPORT jboolean JNICALL Java_java_awt_SplashScreen__1setImageData
(*env)->ReleaseByteArrayElements(env, data, pBytes, JNI_ABORT);
return rc ? JNI_TRUE : JNI_FALSE;
}
+
+/*
+ * Class: java_awt_SplashScreen
+ * Method: _getScaleFactor
+ * Signature: (J)F
+ */
+JNIEXPORT jfloat JNICALL Java_java_awt_SplashScreen__1getScaleFactor
+(JNIEnv *env, jclass thisClass, jlong jsplash)
+{
+ Splash *splash = (Splash *) jlong_to_ptr(jsplash);
+ if (!splash) {
+ return 1;
+ }
+ return splash->scaleFactor;
+} \ No newline at end of file
diff --git a/src/share/native/sun/awt/splashscreen/splashscreen_impl.c b/src/share/native/sun/awt/splashscreen/splashscreen_impl.c
index 021447e28..ad30a9a3f 100644
--- a/src/share/native/sun/awt/splashscreen/splashscreen_impl.c
+++ b/src/share/native/sun/awt/splashscreen/splashscreen_impl.c
@@ -59,6 +59,7 @@ SplashInit()
memset(splash, 0, sizeof(Splash));
splash->currentFrame = -1;
+ splash->scaleFactor = 1;
initFormat(&splash->imageFormat, QUAD_RED_MASK, QUAD_GREEN_MASK,
QUAD_BLUE_MASK, QUAD_ALPHA_MASK);
SplashInitPlatform(splash);
@@ -101,6 +102,13 @@ SplashCleanup(Splash * splash)
SplashSetFileJarName(NULL, NULL);
}
+SPLASHEXPORT void
+SplashSetScaleFactor(float scaleFactor)
+{
+ Splash *splash = SplashGetInstance();
+ splash->scaleFactor = scaleFactor;
+}
+
void
SplashDone(Splash * splash)
{
diff --git a/src/share/native/sun/awt/splashscreen/splashscreen_impl.h b/src/share/native/sun/awt/splashscreen/splashscreen_impl.h
index 21f09cee1..d26a4cb6b 100644
--- a/src/share/native/sun/awt/splashscreen/splashscreen_impl.h
+++ b/src/share/native/sun/awt/splashscreen/splashscreen_impl.h
@@ -35,6 +35,9 @@ SPLASHEXPORT int SplashLoadFile(const char *filename); // FIXME: range checking
SPLASHEXPORT void SplashInit(void);
SPLASHEXPORT void SplashClose(void);
+SPLASHEXPORT void SplashSetScaleFactor(float);
+SPLASHEXPORT char* SplashGetScaledImageName(const char*, const char*, float*);
+
SPLASHEXPORT void
SplashSetFileJarName(const char* fileName, const char* jarName);
@@ -79,6 +82,7 @@ typedef struct Splash
int fileNameLen;
char* jarName; /* stored in 16-bit unicode (jchars) */
int jarNameLen;
+ float scaleFactor;
#if defined(WITH_WIN32)
BOOL isLayered;
HWND hWnd;
@@ -115,6 +119,8 @@ void SplashDonePlatform(Splash * splash);
unsigned SplashTime();
char* SplashConvertStringAlloc(const char* in, int *size);
+char* SplashGetScaledImageName(const char* jarName,
+ const char* fileName, float *scaleFactor);
void SplashLock(Splash * splash);
void SplashUnlock(Splash * splash);
@@ -138,6 +144,7 @@ void SplashDone(Splash * splash);
void SplashUpdateScreenData(Splash * splash);
void SplashCleanup(Splash * splash);
+void SplashSetScaleFactor(float scaleFactor);
typedef struct SplashStream {
diff --git a/src/share/native/sun/misc/URLClassPath.c b/src/share/native/sun/misc/URLClassPath.c
new file mode 100644
index 000000000..16380c9d1
--- /dev/null
+++ b/src/share/native/sun/misc/URLClassPath.c
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ */
+
+#include <string.h>
+
+#include "jni.h"
+#include "jni_util.h"
+#include "jlong.h"
+#include "jvm.h"
+#include "jdk_util.h"
+
+#include "sun_misc_URLClassPath.h"
+
+extern char*
+getUTF(JNIEnv *env, jstring str, char* localBuf, int bufSize);
+
+
+JNIEXPORT jboolean JNICALL
+Java_sun_misc_URLClassPath_knownToNotExist0(JNIEnv *env, jclass cls, jobject loader,
+ jstring classname)
+{
+ char *clname;
+ jboolean result = JNI_FALSE;
+ char buf[128];
+
+ if (classname == NULL) {
+ JNU_ThrowNullPointerException(env, NULL);
+ return result;
+ }
+
+ clname = getUTF(env, classname, buf, sizeof(buf));
+ if (clname == NULL) {
+ JNU_ThrowOutOfMemoryError(env, NULL);
+ return result;
+ }
+ VerifyFixClassname(clname);
+
+ if (!VerifyClassname(clname, JNI_TRUE)) { /* expects slashed name */
+ goto done;
+ }
+
+ result = JVM_KnownToNotExist(env, loader, clname);
+
+ done:
+ if (clname != buf) {
+ free(clname);
+ }
+
+ return result;
+}
+
+JNIEXPORT jobjectArray JNICALL
+Java_sun_misc_URLClassPath_getLookupCacheURLs(JNIEnv *env, jclass cls, jobject loader)
+{
+ return JVM_GetResourceLookupCacheURLs(env, loader);
+}
+
+
+JNIEXPORT jintArray JNICALL
+Java_sun_misc_URLClassPath_getLookupCacheForClassLoader(JNIEnv *env, jclass cls,
+ jobject loader,
+ jstring resource_name)
+{
+ char *resname;
+ jintArray result = NULL;
+ char buf[128];
+
+ if (resource_name == NULL) {
+ JNU_ThrowNullPointerException(env, NULL);
+ return result;
+ }
+
+ resname = getUTF(env, resource_name, buf, sizeof(buf));
+ if (resname == NULL) {
+ JNU_ThrowOutOfMemoryError(env, NULL);
+ return result;
+ }
+ result = JVM_GetResourceLookupCache(env, loader, resname);
+
+ done:
+ if (resname != buf) {
+ free(resname);
+ }
+
+ return result;
+}
+
diff --git a/src/share/native/sun/security/ec/impl/mpi.c b/src/share/native/sun/security/ec/impl/mpi.c
index 3149fa217..496916afd 100644
--- a/src/share/native/sun/security/ec/impl/mpi.c
+++ b/src/share/native/sun/security/ec/impl/mpi.c
@@ -3376,7 +3376,7 @@ mp_err s_mp_div_d(mp_int *mp, mp_digit d, mp_digit *r)
#if !defined(MP_NO_MP_WORD) && !defined(MP_NO_DIV_WORD)
mp_word w = 0, q;
#else
- mp_digit w, q;
+ mp_digit w = 0, q;
#endif
int ix;
mp_err res;
diff --git a/src/share/native/sun/security/pkcs11/wrapper/p11_crypt.c b/src/share/native/sun/security/pkcs11/wrapper/p11_crypt.c
index b56608a8f..2696483f7 100644
--- a/src/share/native/sun/security/pkcs11/wrapper/p11_crypt.c
+++ b/src/share/native/sun/security/pkcs11/wrapper/p11_crypt.c
@@ -141,8 +141,8 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1Encrypt
(CK_BYTE_PTR)(outBufP + jOutOfs),
&ckEncryptedPartLen);
- (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT);
(*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT);
+ (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT);
ckAssertReturnValueOK(env, rv);
return ckEncryptedPartLen;
@@ -214,7 +214,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1EncryptUpdate
}
if (directOut == 0) {
- (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT);
+ (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT);
}
ckAssertReturnValueOK(env, rv);
@@ -266,7 +266,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1EncryptFinal
//printf("EF: ckLastEncryptedPartLen=%i", ckLastEncryptedPartLen);
if (directOut == 0) {
- (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT);
+ (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT);
}
ckAssertReturnValueOK(env, rv);
@@ -361,8 +361,8 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1Decrypt
(CK_BYTE_PTR)(outBufP + jOutOfs),
&ckPartLen);
- (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT);
(*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT);
+ (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT);
ckAssertReturnValueOK(env, rv);
@@ -429,7 +429,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptUpdate
}
if (directOut == 0) {
- (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT);
+ (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT);
}
ckAssertReturnValueOK(env, rv);
@@ -478,7 +478,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptFinal
&ckLastPartLen);
if (directOut == 0) {
- (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT);
+ (*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT);
}
diff --git a/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c b/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c
index 112225812..85a93042f 100644
--- a/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c
+++ b/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c
@@ -794,3 +794,11 @@ void
SplashReconfigure(Splash * splash) {
sendctl(splash, SPLASHCTL_RECONFIGURE);
}
+
+SPLASHEXPORT char*
+SplashGetScaledImageName(const char* jarName, const char* fileName,
+ float *scaleFactor)
+{
+ *scaleFactor = 1;
+ return NULL;
+}
diff --git a/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c b/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c
index c9d201124..403c15cad 100644
--- a/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c
+++ b/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c
@@ -34,6 +34,10 @@
#include <fcntl.h>
#include <sys/uio.h>
#include <unistd.h>
+#if defined(__linux__)
+#include <linux/fs.h>
+#include <sys/ioctl.h>
+#endif
#include "nio.h"
#include "nio_util.h"
@@ -177,10 +181,21 @@ Java_sun_nio_ch_FileDispatcherImpl_truncate0(JNIEnv *env, jobject this,
JNIEXPORT jlong JNICALL
Java_sun_nio_ch_FileDispatcherImpl_size0(JNIEnv *env, jobject this, jobject fdo)
{
+ jint fd = fdval(env, fdo);
struct stat64 fbuf;
- if (fstat64(fdval(env, fdo), &fbuf) < 0)
+ if (fstat64(fd, &fbuf) < 0)
return handle(env, -1, "Size failed");
+
+#ifdef BLKGETSIZE64
+ if (S_ISBLK(fbuf.st_mode)) {
+ uint64_t size;
+ if (ioctl(fd, BLKGETSIZE64, &size) < 0)
+ return handle(env, -1, "Size failed");
+ return (jlong)size;
+ }
+#endif
+
return fbuf.st_size;
}
diff --git a/src/windows/classes/sun/awt/windows/WPathGraphics.java b/src/windows/classes/sun/awt/windows/WPathGraphics.java
index 282d84563..c3410a96b 100644
--- a/src/windows/classes/sun/awt/windows/WPathGraphics.java
+++ b/src/windows/classes/sun/awt/windows/WPathGraphics.java
@@ -1400,7 +1400,9 @@ final class WPathGraphics extends PathGraphics {
* The saved device transform is needed as the current transform
* is not likely to be the same.
*/
- deviceClip(savedClip.getPathIterator(savedTransform));
+ if (savedClip != null) {
+ deviceClip(savedClip.getPathIterator(savedTransform));
+ }
/* Scale the bounding rectangle by the scale transform.
* Because the scaling transform has only x and y
diff --git a/src/windows/native/sun/awt/splashscreen/splashscreen_sys.c b/src/windows/native/sun/awt/splashscreen/splashscreen_sys.c
index 8e02c1869..3c1fe7f50 100644
--- a/src/windows/native/sun/awt/splashscreen/splashscreen_sys.c
+++ b/src/windows/native/sun/awt/splashscreen/splashscreen_sys.c
@@ -568,3 +568,11 @@ SplashReconfigure(Splash * splash)
{
PostMessage(splash->hWnd, WM_SPLASHRECONFIGURE, 0, 0);
}
+
+SPLASHEXPORT char*
+SplashGetScaledImageName(const char* jarName, const char* fileName,
+ float *scaleFactor)
+{
+ *scaleFactor = 1;
+ return NULL;
+}
diff --git a/src/windows/native/sun/java2d/d3d/D3DBadHardware.h b/src/windows/native/sun/java2d/d3d/D3DBadHardware.h
index 91ee7b358..83aedad8f 100644
--- a/src/windows/native/sun/java2d/d3d/D3DBadHardware.h
+++ b/src/windows/native/sun/java2d/d3d/D3DBadHardware.h
@@ -51,131 +51,8 @@ typedef struct ADAPTER_INFO {
static const ADAPTER_INFO badHardware[] = {
- // Intel HD
- // Clarkdale (Desktop) GMA HD Lines
- { 0x8086, 0x0042, NO_VERSION, OS_ALL },
- // Arrandale (Mobile) GMA HD Lines
- { 0x8086, 0x0046, NO_VERSION, OS_ALL },
-
- // Sandy Bridge HD Graphics 3000/2000
- { 0x8086, 0x0102, NO_VERSION, OS_ALL },
- { 0x8086, 0x0106, NO_VERSION, OS_ALL },
- { 0x8086, 0x0112, NO_VERSION, OS_ALL },
- { 0x8086, 0x0116, NO_VERSION, OS_ALL },
- { 0x8086, 0x0122, NO_VERSION, OS_ALL },
- { 0x8086, 0x0126, NO_VERSION, OS_ALL },
- { 0x8086, 0x010A, NO_VERSION, OS_ALL },
-
- // Ivy Bridge
- { 0x8086, 0x0162, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0162, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0166, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0166, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x016A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x016A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0152, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0152, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0156, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0156, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x015A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x015A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-
- // Haswell
- { 0x8086, 0x0402, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0402, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0406, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0406, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0412, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0412, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0416, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0416, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x041E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x041E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x040A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x040A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x041A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x041A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0A06, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0A06, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0A16, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0A16, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0A26, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0A26, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0A2E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0A2E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0A1E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0A1E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0A0E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0A0E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0D26, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0D26, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
- { 0x8086, 0x0D22, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 },
- { 0x8086, 0x0D22, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 },
-
- // Reason: workaround for 6620073, 6612195
- // Intel 740
- { 0x8086, 0x7800, NO_VERSION, OS_ALL },
- { 0x8086, 0x1240, NO_VERSION, OS_ALL },
- { 0x8086, 0x7121, NO_VERSION, OS_ALL },
- { 0x8086, 0x7123, NO_VERSION, OS_ALL },
- { 0x8086, 0x7125, NO_VERSION, OS_ALL },
- { 0x8086, 0x1132, NO_VERSION, OS_ALL },
- // IEG
- { 0x8086, 0x2562, NO_VERSION, OS_ALL },
- { 0x8086, 0x3577, NO_VERSION, OS_ALL },
- { 0x8086, 0x2572, NO_VERSION, OS_ALL },
- { 0x8086, 0x3582, NO_VERSION, OS_ALL },
- { 0x8086, 0x358E, NO_VERSION, OS_ALL },
- // GMA
- { 0x8086, 0x2582, NO_VERSION, OS_ALL },
- { 0x8086, 0x2782, NO_VERSION, OS_ALL },
- { 0x8086, 0x2592, NO_VERSION, OS_ALL },
- { 0x8086, 0x2792, NO_VERSION, OS_ALL },
- { 0x8086, 0x2772, NO_VERSION, OS_ALL },
- { 0x8086, 0x2776, NO_VERSION, OS_ALL },
- { 0x8086, 0x27A2, NO_VERSION, OS_ALL },
- { 0x8086, 0x27A6, NO_VERSION, OS_ALL },
- { 0x8086, 0x27AE, NO_VERSION, OS_ALL },
- { 0x8086, 0x29D2, NO_VERSION, OS_ALL },
- { 0x8086, 0x29D3, NO_VERSION, OS_ALL },
- { 0x8086, 0x29B2, NO_VERSION, OS_ALL },
- { 0x8086, 0x29B3, NO_VERSION, OS_ALL },
- { 0x8086, 0x29C2, NO_VERSION, OS_ALL },
- { 0x8086, 0x29C3, NO_VERSION, OS_ALL },
- { 0x8086, 0xA001, NO_VERSION, OS_ALL },
- { 0x8086, 0xA002, NO_VERSION, OS_ALL },
- { 0x8086, 0xA011, NO_VERSION, OS_ALL },
- { 0x8086, 0xA012, NO_VERSION, OS_ALL },
- // GMA
- { 0x8086, 0x2972, NO_VERSION, OS_ALL },
- { 0x8086, 0x2973, NO_VERSION, OS_ALL },
- { 0x8086, 0x2992, NO_VERSION, OS_ALL },
- { 0x8086, 0x2993, NO_VERSION, OS_ALL },
- { 0x8086, 0x29A2, NO_VERSION, OS_ALL },
- { 0x8086, 0x29A3, NO_VERSION, OS_ALL },
- { 0x8086, 0x2982, NO_VERSION, OS_ALL },
- { 0x8086, 0x2983, NO_VERSION, OS_ALL },
- { 0x8086, 0x2A02, NO_VERSION, OS_ALL },
- { 0x8086, 0x2A03, NO_VERSION, OS_ALL },
- { 0x8086, 0x2A12, NO_VERSION, OS_ALL },
- { 0x8086, 0x2A13, NO_VERSION, OS_ALL },
-
- // Eaglelake (Desktop) GMA 4500 Lines
- { 0x8086, 0x2E42, NO_VERSION, OS_ALL },
- { 0x8086, 0x2E43, NO_VERSION, OS_ALL },
- { 0x8086, 0x2E92, NO_VERSION, OS_ALL },
- { 0x8086, 0x2E93, NO_VERSION, OS_ALL },
- { 0x8086, 0x2E12, NO_VERSION, OS_ALL },
- { 0x8086, 0x2E13, NO_VERSION, OS_ALL },
- // Eaglelake (Desktop) GMA X4500 Lines
- { 0x8086, 0x2E32, NO_VERSION, OS_ALL },
- { 0x8086, 0x2E33, NO_VERSION, OS_ALL },
- { 0x8086, 0x2E22, NO_VERSION, OS_ALL },
- // Eaglelake (Desktop) GMA X4500HD Lines
- { 0x8086, 0x2E23, NO_VERSION, OS_ALL },
- // Cantiga (Mobile) GMA 4500MHD Lines
- { 0x8086, 0x2A42, NO_VERSION, OS_ALL },
- { 0x8086, 0x2A43, NO_VERSION, OS_ALL },
+ // All Intel Chips.
+ { 0x8086, ALL_DEVICEIDS, NO_VERSION, OS_ALL },
// ATI Mobility Radeon X1600, X1400, X1450, X1300, X1350
// Reason: workaround for 6613066, 6687166
diff --git a/test/com/sun/jndi/ldap/LdapTimeoutTest.java b/test/com/sun/jndi/ldap/LdapTimeoutTest.java
index ba507479e..092416eff 100644
--- a/test/com/sun/jndi/ldap/LdapTimeoutTest.java
+++ b/test/com/sun/jndi/ldap/LdapTimeoutTest.java
@@ -46,8 +46,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
public class LdapTimeoutTest {
- private static final ScheduledExecutorService pool =
- Executors.newScheduledThreadPool(1);
+
static volatile int passed = 0, failed = 0;
static void pass() {passed++;}
static void fail() {failed++; Thread.dumpStack();}
@@ -80,7 +79,6 @@ public class LdapTimeoutTest {
new LdapTimeoutTest().simpleAuthConnectTest(env);
} finally {
s.interrupt();
- LdapTimeoutTest.pool.shutdown();
}
System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
@@ -90,7 +88,6 @@ public class LdapTimeoutTest {
void ldapReadTimeoutTest(Hashtable env, boolean ssl) {
InitialContext ctx = null;
if (ssl) env.put(Context.SECURITY_PROTOCOL, "ssl");
- ScheduledFuture killer = killSwitch(5_000);
long start = System.nanoTime();
try {
ctx = new InitialDirContext(env);
@@ -112,13 +109,12 @@ public class LdapTimeoutTest {
pass();
}
} finally {
- if (!shutItDown(killer, ctx)) fail();
+ if (!shutItDown(ctx)) fail();
}
}
void simpleAuthConnectTest(Hashtable env) {
InitialContext ctx = null;
- ScheduledFuture killer = killSwitch(5_000);
long start = System.nanoTime();
try {
ctx = new InitialDirContext(env);
@@ -141,13 +137,12 @@ public class LdapTimeoutTest {
fail();
}
} finally {
- if (!shutItDown(killer, ctx)) fail();
+ if (!shutItDown(ctx)) fail();
}
}
void deadServerNoTimeout(Hashtable env) {
InitialContext ctx = null;
- ScheduledFuture killer = killSwitch(30_000);
long start = System.currentTimeMillis();
try {
ctx = new InitialDirContext(env);
@@ -169,12 +164,11 @@ public class LdapTimeoutTest {
pass();
}
} finally {
- if (!shutItDown(killer, ctx)) fail();
+ if (!shutItDown(ctx)) fail();
}
}
- boolean shutItDown(ScheduledFuture killer, InitialContext ctx) {
- killer.cancel(true);
+ boolean shutItDown(InitialContext ctx) {
try {
if (ctx != null) ctx.close();
return true;
@@ -183,17 +177,6 @@ public class LdapTimeoutTest {
}
}
- ScheduledFuture killSwitch(int ms) {
- final Thread current = Thread.currentThread();
- return LdapTimeoutTest.pool.schedule(new Callable<Void>() {
- public Void call() throws Exception {
- System.err.println("Fail: killSwitch()");
- System.exit(0);
- return null;
- }
- }, ms, MILLISECONDS);
- }
-
static class Server extends Thread {
final ServerSocket serverSock;
diff --git a/test/java/awt/Frame/DisposeStressTest/DisposeStressTest.html b/test/java/awt/Frame/DisposeStressTest/DisposeStressTest.html
new file mode 100644
index 000000000..41944bc31
--- /dev/null
+++ b/test/java/awt/Frame/DisposeStressTest/DisposeStressTest.html
@@ -0,0 +1,21 @@
+<html>
+<!--
+ @test
+ @bug 4051487 4145670
+ @summary Tests that disposing of an empty Frame or a Frame with a MenuBar
+ while it is being created does not crash the VM.
+ @author dpm area=Threads
+ @run applet/timeout=7200 DisposeStressTest.html
+ -->
+<head>
+<title>DisposeStressTest</title>
+</head>
+<body>
+
+<h1>DisposeStressTest<br>Bug ID: 4051487, 4145670</h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="DisposeStressTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
diff --git a/test/java/awt/Frame/DisposeStressTest/DisposeStressTest.java b/test/java/awt/Frame/DisposeStressTest/DisposeStressTest.java
new file mode 100644
index 000000000..7e13bc3e3
--- /dev/null
+++ b/test/java/awt/Frame/DisposeStressTest/DisposeStressTest.java
@@ -0,0 +1,247 @@
+/*
+ * 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 4051487 4145670 8062021
+ @summary Tests that disposing of an empty Frame or a Frame with a MenuBar
+ while it is being created does not crash the VM.
+ @author dpm area=Threads
+ @run applet/timeout=7200 DisposeStressTest.html
+*/
+
+// Note there is no @ in front of test above. This is so that the
+// harness will not mistake this file as a test file. It should
+// only see the html file as a test file. (the harness runs all
+// valid test files, so it would run this test twice if this file
+// were valid as well as the html file.)
+// Also, note the area= after Your Name in the author tag. Here, you
+// should put which functional area the test falls in. See the
+// AWT-core home page -> test areas and/or -> AWT team for a list of
+// areas.
+// Note also the 'DisposeStressTest.html' in the run tag. This should
+// be changed to the name of the test.
+
+
+/**
+ * DisposeStressTest.java
+ *
+ * summary:
+ */
+
+import java.applet.Applet;
+import java.awt.*;
+
+
+//Automated tests should run as applet tests if possible because they
+// get their environments cleaned up, including AWT threads, any
+// test created threads, and any system resources used by the test
+// such as file descriptors. (This is normally not a problem as
+// main tests usually run in a separate VM, however on some platforms
+// such as the Mac, separate VMs are not possible and non-applet
+// tests will cause problems). Also, you don't have to worry about
+// synchronisation stuff in Applet tests they way you do in main
+// tests...
+
+
+public class DisposeStressTest extends Applet
+ {
+ //Declare things used in the test, like buttons and labels here
+
+ public void init()
+ {
+ //Create instructions for the user here, as well as set up
+ // the environment -- set the layout manager, add buttons,
+ // etc.
+
+ this.setLayout (new BorderLayout ());
+
+ String[] instructions =
+ {
+ "This is an AUTOMATIC test",
+ "simply wait until it is done"
+ };
+ Sysout.createDialog( );
+ Sysout.printInstructions( instructions );
+
+ }//End init()
+
+ public void start ()
+ {
+ for (int i = 0; i < 1000; i++) {
+ Frame f = new Frame();
+ f.setBounds(10, 10, 10, 10);
+ f.show();
+ f.dispose();
+
+ Frame f2 = new Frame();
+ f2.setBounds(10, 10, 100, 100);
+ MenuBar bar = new MenuBar();
+ Menu menu = new Menu();
+ menu.add(new MenuItem("foo"));
+ bar.add(menu);
+ f2.setMenuBar(bar);
+ f2.show();
+ f2.dispose();
+ }
+ }// start()
+
+ }// class DisposeStressTest
+
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+ {
+ private static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.show();
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.show();
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ }
+
+ }// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+ {
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("South", messageText);
+
+ pack();
+
+ show();
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ }
+
+ }// TestDialog class
diff --git a/test/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java b/test/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java
new file mode 100644
index 000000000..a13cd8152
--- /dev/null
+++ b/test/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java
@@ -0,0 +1,161 @@
+/*
+ * 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.Color;
+import java.awt.Dialog;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Panel;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.SplashScreen;
+import java.awt.Window;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import javax.imageio.ImageIO;
+import sun.java2d.SunGraphics2D;
+
+/**
+ * @test
+ * @bug 8043869
+ * @author Alexander Scherbatiy
+ * @summary [macosx] java -splash does not honor 2x hi dpi notation for retina
+ * support
+ * @run main MultiResolutionSplashTest GENERATE_IMAGES
+ * @run main/othervm -splash:splash1.png MultiResolutionSplashTest TEST_SPLASH 0
+ * @run main/othervm -splash:splash2 MultiResolutionSplashTest TEST_SPLASH 1
+ * @run main/othervm -splash:splash3. MultiResolutionSplashTest TEST_SPLASH 2
+ */
+public class MultiResolutionSplashTest {
+
+ private static final int IMAGE_WIDTH = 300;
+ private static final int IMAGE_HEIGHT = 200;
+
+ private static final ImageInfo[] tests = {
+ new ImageInfo("splash1.png", "splash1@2x.png", Color.BLUE, Color.GREEN),
+ new ImageInfo("splash2", "splash2@2x", Color.WHITE, Color.BLACK),
+ new ImageInfo("splash3.", "splash3@2x.", Color.YELLOW, Color.RED)
+ };
+
+ public static void main(String[] args) throws Exception {
+
+ String test = args[0];
+
+ switch (test) {
+ case "GENERATE_IMAGES":
+ generateImages();
+ break;
+ case "TEST_SPLASH":
+ int index = Integer.parseInt(args[1]);
+ testSplash(tests[index]);
+ break;
+ default:
+ throw new RuntimeException("Unknown test: " + test);
+ }
+ }
+
+ static void testSplash(ImageInfo test) throws Exception {
+ SplashScreen splashScreen = SplashScreen.getSplashScreen();
+
+ if (splashScreen == null) {
+ throw new RuntimeException("Splash screen is not shown!");
+ }
+
+ Graphics2D g = splashScreen.createGraphics();
+ Rectangle splashBounds = splashScreen.getBounds();
+ int screenX = (int) splashBounds.getCenterX();
+ int screenY = (int) splashBounds.getCenterY();
+
+ Robot robot = new Robot();
+ Color splashScreenColor = robot.getPixelColor(screenX, screenY);
+
+ float scaleFactor = getScaleFactor();
+ Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;
+
+ if (!testColor.equals(splashScreenColor)) {
+ throw new RuntimeException(
+ "Image with wrong resolution is used for splash screen!");
+ }
+ }
+
+ static float getScaleFactor() {
+
+ final Dialog dialog = new Dialog((Window) null);
+ dialog.setSize(100, 100);
+ dialog.setModal(true);
+ final float[] scaleFactors = new float[1];
+ Panel panel = new Panel() {
+
+ @Override
+ public void paint(Graphics g) {
+ float scaleFactor = 1;
+ if (g instanceof SunGraphics2D) {
+ scaleFactor = ((SunGraphics2D) g).surfaceData.getDefaultScale();
+ }
+ scaleFactors[0] = scaleFactor;
+ dialog.setVisible(false);
+ }
+ };
+
+ dialog.add(panel);
+ dialog.setVisible(true);
+ dialog.dispose();
+
+ return scaleFactors[0];
+ }
+
+ static void generateImages() throws Exception {
+ for (ImageInfo test : tests) {
+ generateImage(test.name1x, test.color1x, 1);
+ generateImage(test.name2x, test.color2x, 2);
+ }
+ }
+
+ static void generateImage(String name, Color color, int scale) throws Exception {
+ File file = new File(name);
+ if (file.exists()) {
+ return;
+ }
+ BufferedImage image = new BufferedImage(scale * IMAGE_WIDTH, scale * IMAGE_HEIGHT,
+ BufferedImage.TYPE_INT_RGB);
+ Graphics g = image.getGraphics();
+ g.setColor(color);
+ g.fillRect(0, 0, scale * IMAGE_WIDTH, scale * IMAGE_HEIGHT);
+ ImageIO.write(image, "png", file);
+ }
+
+ static class ImageInfo {
+
+ final String name1x;
+ final String name2x;
+ final Color color1x;
+ final Color color2x;
+
+ public ImageInfo(String name1x, String name2x, Color color1x, Color color2x) {
+ this.name1x = name1x;
+ this.name2x = name2x;
+ this.color1x = color1x;
+ this.color2x = color2x;
+ }
+ }
+}
diff --git a/test/java/awt/Window/AlwaysOnTop/SyncAlwaysOnTopFieldTest.java b/test/java/awt/Window/AlwaysOnTop/SyncAlwaysOnTopFieldTest.java
new file mode 100644
index 000000000..ed76fa8e0
--- /dev/null
+++ b/test/java/awt/Window/AlwaysOnTop/SyncAlwaysOnTopFieldTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.Window;
+
+/**
+ * @test
+ * @bug 8064468
+ * @author Alexander Scherbatiy
+ * @summary ownedWindowList access requires synchronization in
+ * Window.setAlwaysOnTop() method
+ * @run main SyncAlwaysOnTopFieldTest
+ */
+public class SyncAlwaysOnTopFieldTest {
+
+ private static final int WINDOWS_COUNT = 200;
+ private static final int STEPS_COUNT = 20;
+
+ public static void main(String[] args) throws Exception {
+ final Window rootWindow = createWindow(null);
+
+ new Thread(() -> {
+ for (int i = 0; i < WINDOWS_COUNT; i++) {
+ createWindow(rootWindow);
+ }
+ }).start();
+
+ boolean alwaysOnTop = true;
+ for (int i = 0; i < STEPS_COUNT; i++) {
+ Thread.sleep(10);
+ rootWindow.setAlwaysOnTop(alwaysOnTop);
+ alwaysOnTop = !alwaysOnTop;
+ }
+ }
+
+ private static Window createWindow(Window parent) {
+ Window window = new Window(parent);
+ window.setSize(200, 200);
+ window.setVisible(true);
+ return window;
+ }
+} \ No newline at end of file
diff --git a/test/java/awt/print/PrinterJob/ImagePrinting/NullClipARGB.java b/test/java/awt/print/PrinterJob/ImagePrinting/NullClipARGB.java
new file mode 100644
index 000000000..88d4e43cf
--- /dev/null
+++ b/test/java/awt/print/PrinterJob/ImagePrinting/NullClipARGB.java
@@ -0,0 +1,74 @@
+/*
+ * 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 8061392
+ * @summary Test no NPE when printing transparency with null clip.
+ */
+
+import java.awt.*;
+import java.awt.image.*;
+import java.awt.print.*;
+
+public class NullClipARGB implements Printable {
+
+ public static void main( String[] args ) {
+
+ try {
+ PrinterJob pj = PrinterJob.getPrinterJob();
+ pj.setPrintable(new NullClipARGB());
+ pj.print();
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public int print(Graphics g, PageFormat pf, int pageIndex)
+ throws PrinterException{
+
+ if (pageIndex != 0) {
+ return NO_SUCH_PAGE;
+ }
+ Graphics2D g2 = (Graphics2D)g;
+ System.out.println("original clip="+g2.getClip());
+ g2.translate(pf.getImageableX(), pf.getImageableY());
+ g2.rotate(0.2);
+ g2.setClip(null);
+ g2.setColor( Color.BLACK );
+ g2.drawString("This text should be visible through the image", 0, 20);
+ BufferedImage bi = new BufferedImage(100, 100,
+ BufferedImage.TYPE_INT_ARGB );
+ Graphics ig = bi.createGraphics();
+ ig.setColor( new Color( 192, 192, 192, 80 ) );
+ ig.fillRect( 0, 0, 100, 100 );
+ ig.setColor( Color.BLACK );
+ ig.drawRect( 0, 0, 99, 99 );
+ ig.dispose();
+ g2.drawImage(bi, 10, 0, 90, 90, null );
+ g2.translate(100, 100);
+ g2.drawString("This text should also be visible through the image", 0, 20);
+ g2.drawImage(bi, 10, 0, 90, 90, null );
+ return PAGE_EXISTS;
+ }
+}
diff --git a/test/java/io/SequenceInputStream/LotsOfStreams.java b/test/java/io/SequenceInputStream/LotsOfStreams.java
new file mode 100644
index 000000000..3ad0d27f7
--- /dev/null
+++ b/test/java/io/SequenceInputStream/LotsOfStreams.java
@@ -0,0 +1,66 @@
+/*
+ * 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 7011804
+ * @summary SequenceInputStream#read() was implemented recursivly,
+ * which may cause stack overflow
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.SequenceInputStream;
+import java.util.Enumeration;
+
+public class LotsOfStreams {
+
+ static final int MAX_SUBSTREAMS = 32000;
+
+ public static void main(String[] argv) throws Exception {
+ try (InputStream stream =
+ new SequenceInputStream(new LOSEnumeration())) {
+ stream.read();
+ }
+ try (InputStream stream =
+ new SequenceInputStream(new LOSEnumeration())) {
+ byte[] b = new byte[1];
+ stream.read(b, 0, 1);
+ }
+ }
+
+ static class LOSEnumeration
+ implements Enumeration<InputStream> {
+
+ private static InputStream inputStream =
+ new ByteArrayInputStream(new byte[0]);
+ private int left = MAX_SUBSTREAMS;
+
+ public boolean hasMoreElements() {
+ return (left > 0);
+ }
+ public InputStream nextElement() {
+ left--;
+ return inputStream;
+ }
+ }
+}
diff --git a/test/java/lang/invoke/ExplicitCastArgumentsTest.java b/test/java/lang/invoke/ExplicitCastArgumentsTest.java
new file mode 100644
index 000000000..06f7a64aa
--- /dev/null
+++ b/test/java/lang/invoke/ExplicitCastArgumentsTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+package java.lang.invoke;
+
+import sun.invoke.util.Wrapper;
+
+/* @test
+ * @summary unit tests for MethodHandles.explicitCastArguments()
+ *
+ * @run main/bootclasspath java.lang.invoke.ExplicitCastArgumentsTest
+ */
+public class ExplicitCastArgumentsTest {
+ private static final boolean VERBOSE = Boolean.getBoolean("verbose");
+
+ public static void main(String[] args) throws Throwable {
+ for (Wrapper from : Wrapper.values()) {
+ for (Wrapper to : Wrapper.values()) {
+ if (from == Wrapper.VOID || to == Wrapper.VOID) continue;
+ testRef2Prim (from, to);
+ }
+ }
+ System.out.println("TEST PASSED");
+ }
+
+ public static void testRef2Prim(Wrapper from, Wrapper to) throws Throwable {
+ // MHs.eCA javadoc:
+ // If T0 is a reference and T1 a primitive, and if the reference is null at runtime, a zero value is introduced.
+ test(from.wrapperType(), to.primitiveType(), null, false);
+ }
+
+ public static void test(Class<?> from, Class<?> to, Object param, boolean failureExpected) throws Throwable {
+ if (VERBOSE) System.out.printf("%-10s => %-10s: %5s: ", from.getSimpleName(), to.getSimpleName(), param);
+
+ MethodHandle original = MethodHandles.identity(from);
+ MethodType newType = original.type().changeReturnType(to);
+
+ try {
+ MethodHandle target = MethodHandles.explicitCastArguments(original, newType);
+ Object result = target.invokeWithArguments(param);
+
+ if (VERBOSE) {
+ String resultStr;
+ if (result != null) {
+ resultStr = String.format("%10s (%10s)", "'"+result+"'", result.getClass().getSimpleName());
+ } else {
+ resultStr = String.format("%10s", result);
+ }
+ System.out.println(resultStr);
+ }
+
+ if (failureExpected) {
+ String msg = String.format("No exception thrown: %s => %s; parameter: %s", from, to, param);
+ throw new AssertionError(msg);
+ }
+ } catch (AssertionError e) {
+ throw e; // report test failure
+ } catch (Throwable e) {
+ if (VERBOSE) System.out.printf("%s: %s\n", e.getClass(), e.getMessage());
+ if (!failureExpected) {
+ String msg = String.format("Unexpected exception was thrown: %s => %s; parameter: %s", from, to, param);
+ throw new AssertionError(msg, e);
+ }
+ }
+ }
+}
diff --git a/test/java/lang/ref/EarlyTimeout.java b/test/java/lang/ref/EarlyTimeout.java
new file mode 100644
index 000000000..d10372571
--- /dev/null
+++ b/test/java/lang/ref/EarlyTimeout.java
@@ -0,0 +1,104 @@
+/*
+ * 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 6853696
+ * @summary ReferenceQueue#remove(timeout) should not return null before
+ * timeout is elapsed
+ */
+
+import java.lang.InterruptedException;
+import java.lang.System;
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.util.concurrent.CountDownLatch;
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
+
+/**
+ * In order to demonstrate the issue we make several threads (two appears to be sufficient)
+ * to block in ReferenceQueue#remove(timeout) at the same time.
+ * Then, we force a reference to be enqueued by setting its referent to null and calling System.gc().
+ * One of the threads gets the reference returned from the remove().
+ * The other threads get null:
+ * 1) with bug: this may happen before the specified timeout is elapsed,
+ * 2) without bug: this can only happen after the timeout is fully elapsed.
+ */
+
+public class EarlyTimeout extends Thread {
+
+ static final int THREADS_COUNT = 2;
+ static final int TIMEOUT = 1000;
+
+ static Object referent = new Object();
+ static final ReferenceQueue<Object> queue = new ReferenceQueue<Object>();
+ static final WeakReference<Object> weakReference = new WeakReference<Object>(referent, queue);
+ static final CountDownLatch startedSignal = new CountDownLatch(THREADS_COUNT);
+
+ long actual;
+ Reference<?> reference;
+
+ public static void main(String[] args) throws Exception {
+ EarlyTimeout[] threads = new EarlyTimeout[THREADS_COUNT];
+ for (int i = 0; i < THREADS_COUNT; ++i) {
+ threads[i] = new EarlyTimeout();
+ threads[i].start();
+ }
+ // The main thread waits until the threads has started and give it a chance
+ // for the threads to block on the queue.remove(TIMEOUT) call
+ startedSignal.await();
+ Thread.sleep(TIMEOUT / 2);
+ referent = null;
+ System.gc();
+ for (EarlyTimeout thread : threads) {
+ thread.join();
+ }
+ if (weakReference.get() != null) {
+ throw new RuntimeException("weakReference was not cleared");
+ }
+ int nonNullRefCount = 0;
+ for (EarlyTimeout thread : threads) {
+ if (thread.reference == null && thread.actual < TIMEOUT) {
+ throw new RuntimeException("elapsed time " + thread.actual
+ + " is less than timeout " + TIMEOUT);
+ }
+ if (thread.reference != null && thread.reference == weakReference) {
+ nonNullRefCount++;
+ }
+ }
+ if (nonNullRefCount > 1) {
+ throw new RuntimeException("more than one references were removed from queue");
+ }
+ }
+
+ public void run() {
+ try {
+ startedSignal.countDown();
+ long start = System.nanoTime();
+ reference = queue.remove(TIMEOUT);
+ actual = NANOSECONDS.toMillis(System.nanoTime() - start);
+ } catch (InterruptedException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+}
diff --git a/test/java/nio/channels/FileChannel/BlockDeviceSize.java b/test/java/nio/channels/FileChannel/BlockDeviceSize.java
new file mode 100644
index 000000000..aafe4192d
--- /dev/null
+++ b/test/java/nio/channels/FileChannel/BlockDeviceSize.java
@@ -0,0 +1,62 @@
+/*
+ * 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 8054029
+ * @summary Block devices should not report size=0 on Linux
+ */
+
+import java.io.RandomAccessFile;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.channels.FileChannel;
+import java.nio.file.AccessDeniedException;
+import java.nio.file.NoSuchFileException;
+import static java.nio.file.StandardOpenOption.*;
+
+
+public class BlockDeviceSize {
+ private static final String BLK_FNAME = "/dev/sda1";
+ private static final Path BLK_PATH = Paths.get(BLK_FNAME);
+
+ public static void main(String[] args) throws Throwable {
+ try (FileChannel ch = FileChannel.open(BLK_PATH, READ);
+ RandomAccessFile file = new RandomAccessFile(BLK_FNAME, "r")) {
+
+ long size1 = ch.size();
+ long size2 = file.length();
+ if (size1 != size2) {
+ throw new RuntimeException("size differs when retrieved" +
+ " in different ways: " + size1 + " != " + size2);
+ }
+ System.out.println("OK");
+
+ } catch (NoSuchFileException nsfe) {
+ System.err.println("File " + BLK_FNAME + " not found." +
+ " Skipping test");
+ } catch (AccessDeniedException ade) {
+ System.err.println("Access to " + BLK_FNAME + " is denied." +
+ " Run test as root.");
+ }
+ }
+}
diff --git a/test/java/nio/file/WatchService/Basic.java b/test/java/nio/file/WatchService/Basic.java
index 00965e89d..f31a2f5b5 100644
--- a/test/java/nio/file/WatchService/Basic.java
+++ b/test/java/nio/file/WatchService/Basic.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -22,7 +22,7 @@
*/
/* @test
- * @bug 4313887 6838333 7017446
+ * @bug 4313887 6838333 7017446 8011537 8042470
* @summary Unit test for java.nio.file.WatchService
* @library ..
* @run main Basic
@@ -295,24 +295,31 @@ public class Basic {
// IllegalArgumentException
System.out.println("IllegalArgumentException tests...");
try {
- dir.register(watcher, new WatchEvent.Kind<?>[]{ } );
+ dir.register(watcher /*empty event list*/);
throw new RuntimeException("IllegalArgumentException not thrown");
} catch (IllegalArgumentException x) {
}
try {
// OVERFLOW is ignored so this is equivalent to the empty set
- dir.register(watcher, new WatchEvent.Kind<?>[]{ OVERFLOW });
+ dir.register(watcher, OVERFLOW);
+ throw new RuntimeException("IllegalArgumentException not thrown");
+ } catch (IllegalArgumentException x) {
+ }
+ try {
+ // OVERFLOW is ignored even if specified multiple times
+ dir.register(watcher, OVERFLOW, OVERFLOW);
throw new RuntimeException("IllegalArgumentException not thrown");
} catch (IllegalArgumentException x) {
}
// UnsupportedOperationException
try {
- dir.register(watcher, new WatchEvent.Kind<?>[]{
+ dir.register(watcher,
new WatchEvent.Kind<Object>() {
@Override public String name() { return "custom"; }
@Override public Class<Object> type() { return Object.class; }
- }});
+ });
+ throw new RuntimeException("UnsupportedOperationException not thrown");
} catch (UnsupportedOperationException x) {
}
try {
@@ -328,7 +335,7 @@ public class Basic {
// NullPointerException
System.out.println("NullPointerException tests...");
try {
- dir.register(null, new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
+ dir.register(null, ENTRY_CREATE);
throw new RuntimeException("NullPointerException not thrown");
} catch (NullPointerException x) {
}
@@ -380,7 +387,7 @@ public class Basic {
try {
dir.register(watcher, new WatchEvent.Kind<?>[]{ ENTRY_CREATE });
- throw new RuntimeException("ClosedWatchServiceException not thrown");
+ throw new RuntimeException("ClosedWatchServiceException not thrown");
} catch (ClosedWatchServiceException x) {
}
@@ -468,6 +475,28 @@ public class Basic {
}
}
+ /**
+ * Test that thread interruped status is preserved upon a call
+ * to register()
+ */
+ static void testThreadInterrupt(Path dir) throws IOException {
+ System.out.println("-- Thread interrupted status test --");
+
+ FileSystem fs = FileSystems.getDefault();
+ Thread curr = Thread.currentThread();
+ try (WatchService watcher = fs.newWatchService()) {
+ System.out.println("interrupting current thread");
+ curr.interrupt();
+ dir.register(watcher, ENTRY_CREATE);
+ if (!curr.isInterrupted())
+ throw new RuntimeException("thread should remain interrupted");
+ System.out.println("current thread is still interrupted");
+ System.out.println("OKAY");
+ } finally {
+ curr.interrupted();
+ }
+ }
+
public static void main(String[] args) throws IOException {
Path dir = TestUtil.createTemporaryDirectory();
try {
@@ -478,6 +507,7 @@ public class Basic {
testWakeup(dir);
testExceptions(dir);
testTwoWatchers(dir);
+ testThreadInterrupt(dir);
} finally {
TestUtil.removeAll(dir);
diff --git a/test/java/util/BitSet/BSMethods.java b/test/java/util/BitSet/BSMethods.java
index c8f69e93e..86d7499a4 100644
--- a/test/java/util/BitSet/BSMethods.java
+++ b/test/java/util/BitSet/BSMethods.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -23,9 +23,10 @@
/* @test
* @bug 4098239 4107540 4080736 4261102 4274710 4305272
- * 4979017 4979028 4979031 5030267 6222207
+ * 4979017 4979028 4979031 5030267 6222207 8040806
* @summary Test the operation of the methods of BitSet class
* @author Mike McCloskey, Martin Buchholz
+ * @run main/othervm BSMethods
*/
import java.util.*;
@@ -897,6 +898,21 @@ public class BSMethods {
private static void testToString() {
check(new BitSet().toString().equals("{}"));
check(makeSet(2,3,42,43,234).toString().equals("{2, 3, 42, 43, 234}"));
+
+ final long MB = 1024*1024;
+ if (Runtime.getRuntime().maxMemory() >= 512*MB) {
+ // only run it if we have enough memory
+ try {
+ check(makeSet(Integer.MAX_VALUE-1).toString().equals(
+ "{" + (Integer.MAX_VALUE-1) + "}"));
+ check(makeSet(Integer.MAX_VALUE).toString().equals(
+ "{" + Integer.MAX_VALUE + "}"));
+ check(makeSet(0, 1, Integer.MAX_VALUE-1, Integer.MAX_VALUE).toString().equals(
+ "{0, 1, " + (Integer.MAX_VALUE-1) + ", " + Integer.MAX_VALUE + "}"));
+ } catch (IndexOutOfBoundsException exc) {
+ fail("toString() with indices near MAX_VALUE");
+ }
+ }
}
private static void testLogicalIdentities() {
diff --git a/test/java/util/IdentityHashMap/Capacity.java b/test/java/util/IdentityHashMap/Capacity.java
new file mode 100644
index 000000000..3114e6c16
--- /dev/null
+++ b/test/java/util/IdentityHashMap/Capacity.java
@@ -0,0 +1,226 @@
+/*
+ * 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.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Random;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.*;
+
+/*
+ * @test
+ * @bug 6904367
+ * @summary IdentityHashMap reallocates storage when inserting expected
+ * number of elements
+ * @run testng Capacity
+ */
+
+@Test
+public class Capacity {
+ static final Field tableField;
+ static final Random random = new Random();
+ static final Object[][] sizesData;
+
+ @DataProvider(name="sizes", parallel = true)
+ public Object[][] sizesToTest() { return sizesData; }
+
+ static {
+ try {
+ tableField = IdentityHashMap.class.getDeclaredField("table");
+ tableField.setAccessible(true);
+ } catch (NoSuchFieldException e) {
+ throw new LinkageError("table", e);
+ }
+
+ ArrayList<Object[]> sizes = new ArrayList<>();
+ for (int size = 0; size < 200; size++)
+ sizes.add(new Object[] { size });
+
+ // some numbers known to demonstrate bug 6904367
+ for (int size : new int[] {682, 683, 1365, 2730, 2731, 5461})
+ sizes.add(new Object[] { size });
+
+ // a few more random sizes to try
+ for (int i = 0; i != 128; i++)
+ sizes.add(new Object[] { random.nextInt(5000) });
+
+ sizesData = sizes.toArray(new Object[0][]);
+ }
+
+ static int capacity(IdentityHashMap<?,?> map) {
+ try {
+ return ((Object[]) tableField.get(map)).length / 2;
+ } catch (Throwable t) {
+ throw new LinkageError("table", t);
+ }
+ }
+
+ static void assertCapacity(IdentityHashMap<?,?> map,
+ int expectedCapacity) {
+ assertEquals(capacity(map), expectedCapacity);
+ }
+
+ static void growUsingPut(IdentityHashMap<Object,Object> map,
+ int elementsToAdd) {
+ for (int i = 0; i < elementsToAdd; i++)
+ map.put(new Object(), new Object());
+ }
+
+ static void growUsingPutAll(IdentityHashMap<Object,Object> map,
+ int elementsToAdd) {
+ IdentityHashMap<Object,Object> other = new IdentityHashMap<>();
+ growUsingPut(other, elementsToAdd);
+ map.putAll(other);
+ }
+
+ static void growUsingRepeatedPutAll(IdentityHashMap<Object,Object> map,
+ int elementsToAdd) {
+ for (int i = 0; i < elementsToAdd; i++)
+ map.putAll(Collections.singletonMap(new Object(),
+ new Object()));
+ }
+
+ /**
+ * Checks that expected number of items can be inserted into
+ * the map without resizing of the internal storage
+ */
+ @Test(dataProvider = "sizes")
+ public void canInsertExpectedItemsWithoutResizing(int size)
+ throws Throwable {
+ // First try growing using put()
+ IdentityHashMap<Object,Object> m = new IdentityHashMap<>(size);
+ int initialCapacity = capacity(m);
+ growUsingPut(m, size);
+ assertCapacity(m, initialCapacity);
+
+ // Doubling from the expected size will cause exactly one
+ // resize, except near minimum capacity.
+ if (size > 1) {
+ growUsingPut(m, size);
+ assertCapacity(m, 2 * initialCapacity);
+ }
+
+ // Try again, growing with putAll()
+ m = new IdentityHashMap<>(size);
+ initialCapacity = capacity(m);
+ growUsingPutAll(m, size);
+ assertCapacity(m, initialCapacity);
+
+ // Doubling from the expected size will cause exactly one
+ // resize, except near minimum capacity.
+ if (size > 1) {
+ growUsingPutAll(m, size);
+ assertCapacity(m, 2 * initialCapacity);
+ }
+ }
+
+ /**
+ * Given the expected size, computes such a number N of items that
+ * inserting (N+1) items will trigger resizing of the internal storage
+ */
+ static int threshold(int size) throws Throwable {
+ IdentityHashMap<Object,Object> m = new IdentityHashMap<>(size);
+ int initialCapacity = capacity(m);
+ while (capacity(m) == initialCapacity)
+ growUsingPut(m, 1);
+ return m.size() - 1;
+ }
+
+ /**
+ * Checks that inserting (threshold+1) item causes resizing
+ * of the internal storage
+ */
+ @Test(dataProvider = "sizes")
+ public void passingThresholdCausesResize(int size) throws Throwable {
+ final int threshold = threshold(size);
+ IdentityHashMap<Object,Object> m = new IdentityHashMap<>(threshold);
+ int initialCapacity = capacity(m);
+
+ growUsingPut(m, threshold);
+ assertCapacity(m, initialCapacity);
+
+ growUsingPut(m, 1);
+ assertCapacity(m, 2 * initialCapacity);
+ }
+
+ /**
+ * Checks that 4 methods of requiring capacity lead to the same
+ * internal capacity, unless sized below default capacity.
+ */
+ @Test(dataProvider = "sizes")
+ public void differentGrowthPatternsResultInSameCapacity(int size)
+ throws Throwable {
+ if (size < 21) // 21 is default maxExpectedSize
+ return;
+
+ IdentityHashMap<Object,Object> m;
+ m = new IdentityHashMap<Object,Object>(size);
+ int capacity1 = capacity(m);
+
+ m = new IdentityHashMap<>();
+ growUsingPut(m, size);
+ int capacity2 = capacity(m);
+
+ m = new IdentityHashMap<>();
+ growUsingPutAll(m, size);
+ int capacity3 = capacity(m);
+
+ m = new IdentityHashMap<>();
+ growUsingRepeatedPutAll(m, size);
+ int capacity4 = capacity(m);
+
+ if (capacity1 != capacity2 ||
+ capacity2 != capacity3 ||
+ capacity3 != capacity4)
+ throw new AssertionError("Capacities not equal: "
+ + capacity1 + " "
+ + capacity2 + " "
+ + capacity3 + " "
+ + capacity4);
+ }
+
+ public void defaultExpectedMaxSizeIs21() {
+ assertCapacity(new IdentityHashMap<Long,Long>(), 32);
+ assertCapacity(new IdentityHashMap<Long,Long>(21), 32);
+ }
+
+ public void minimumCapacityIs4() {
+ assertCapacity(new IdentityHashMap<Long,Long>(0), 4);
+ assertCapacity(new IdentityHashMap<Long,Long>(1), 4);
+ assertCapacity(new IdentityHashMap<Long,Long>(2), 4);
+ assertCapacity(new IdentityHashMap<Long,Long>(3), 8);
+ }
+
+ @Test(enabled = false)
+ /** needs too much memory to run normally */
+ public void maximumCapacityIs2ToThe29() {
+ assertCapacity(new IdentityHashMap<Long,Long>(Integer.MAX_VALUE),
+ 1 << 29);
+ }
+}
diff --git a/test/java/util/logging/LoggingDeadlock2.java b/test/java/util/logging/LoggingDeadlock2.java
index de328e768..c5b4e8937 100644
--- a/test/java/util/logging/LoggingDeadlock2.java
+++ b/test/java/util/logging/LoggingDeadlock2.java
@@ -28,7 +28,7 @@
* @author Serguei Spitsyn / Hitachi / Martin Buchholz
*
* @build LoggingDeadlock2
- * @run main/timeout=15 LoggingDeadlock2
+ * @run main LoggingDeadlock2
*
* There is a clear deadlock between LogManager.<clinit> and
* Cleaner.run() methods.
diff --git a/test/javax/swing/JComboBox/8057893/bug8057893.java b/test/javax/swing/JComboBox/8057893/bug8057893.java
new file mode 100644
index 000000000..5f58d3dd6
--- /dev/null
+++ b/test/javax/swing/JComboBox/8057893/bug8057893.java
@@ -0,0 +1,84 @@
+/*
+ * 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.EventQueue;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.WindowConstants;
+import sun.awt.SunToolkit;
+
+/**
+ * @test
+ * @bug 8057893
+ * @author Alexander Scherbatiy
+ * @summary JComboBox actionListener never receives "comboBoxEdited"
+ * from getActionCommand
+ * @run main bug8057893
+ */
+public class bug8057893 {
+
+ private static volatile boolean isComboBoxEdited = false;
+
+ public static void main(String[] args) throws Exception {
+ Robot robot = new Robot();
+ robot.setAutoDelay(50);
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+ EventQueue.invokeAndWait(() -> {
+ JFrame frame = new JFrame();
+ frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+ JComboBox<String> comboBox = new JComboBox<>(new String[]{"one", "two"});
+ comboBox.setEditable(true);
+ comboBox.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if ("comboBoxEdited".equals(e.getActionCommand())) {
+ isComboBoxEdited = true;
+ }
+ }
+ });
+ frame.add(comboBox);
+ frame.pack();
+ frame.setVisible(true);
+ comboBox.requestFocusInWindow();
+ });
+
+ toolkit.realSync();
+
+ robot.keyPress(KeyEvent.VK_A);
+ robot.keyRelease(KeyEvent.VK_A);
+ robot.keyPress(KeyEvent.VK_ENTER);
+ robot.keyRelease(KeyEvent.VK_ENTER);
+ toolkit.realSync();
+
+ if(!isComboBoxEdited){
+ throw new RuntimeException("ComboBoxEdited event is not fired!");
+ }
+ }
+}
diff --git a/test/javax/xml/jaxp/testng/TEST.properties b/test/javax/xml/jaxp/testng/TEST.properties
new file mode 100644
index 000000000..4d7d0f90d
--- /dev/null
+++ b/test/javax/xml/jaxp/testng/TEST.properties
@@ -0,0 +1,3 @@
+# This file identifies root(s) of the test-ng hierarchy.
+
+TestNG.dirs = .
diff --git a/test/javax/xml/jaxp/testng/parse/XMLEntityScannerLoad.java b/test/javax/xml/jaxp/testng/parse/XMLEntityScannerLoad.java
new file mode 100644
index 000000000..aac3badd7
--- /dev/null
+++ b/test/javax/xml/jaxp/testng/parse/XMLEntityScannerLoad.java
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+package parse;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+/**
+ * JDK-8059327: XML parser returns corrupt attribute value
+ * https://bugs.openjdk.java.net/browse/JDK-8059327
+ *
+ * Also:
+ * JDK-8061550: XMLEntityScanner can corrupt corrupt content during parsing
+ * https://bugs.openjdk.java.net/browse/JDK-8061550
+ *
+ * @Summary: verify that the character cache in XMLEntityScanner is reset properly
+ */
+
+public class XMLEntityScannerLoad {
+
+ @Test(dataProvider = "xmls")
+ public void test(String xml) throws SAXException, IOException, ParserConfigurationException {
+ Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ChunkInputStream(xml));
+ String value = d.getDocumentElement().getAttribute("a1");
+ assertEquals(value, "w");
+ }
+
+ static class ChunkInputStream extends ByteArrayInputStream {
+ ChunkInputStream(String xml) {
+ super(xml.getBytes());
+ }
+
+ @Override
+ public synchronized int read(byte[] b, int off, int len) {
+ return super.read(b, off, 7);
+ }
+ }
+
+ @DataProvider(name = "xmls")
+ private Object[][] xmls() {
+ return new Object[][] {
+ {"<?xml version=\"1.0\"?><element a1=\"w\" a2=\"&quot;&quot;\"/>"},
+ {"<?xml version=\"1.1\"?><element a1=\"w\" a2=\"&quot;&quot;\"/>"}
+ };
+ }
+}
diff --git a/test/jdk/net/Sockets/SupportedOptions.java b/test/jdk/net/Sockets/SupportedOptions.java
new file mode 100644
index 000000000..cf1d0ceea
--- /dev/null
+++ b/test/jdk/net/Sockets/SupportedOptions.java
@@ -0,0 +1,45 @@
+/*
+ * 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 8062744
+ * @run main SupportedOptions
+ */
+
+import java.net.*;
+import java.io.IOException;
+import jdk.net.*;
+
+public class SupportedOptions {
+
+ public static void main(String[] args) throws Exception {
+ if (!Sockets.supportedOptions(ServerSocket.class)
+ .contains(StandardSocketOptions.IP_TOS)) {
+ throw new RuntimeException("Test failed");
+ }
+ // Now set the option
+ ServerSocket ss = new ServerSocket();
+ Sockets.setOption(ss, java.net.StandardSocketOptions.IP_TOS, 128);
+ }
+}
diff --git a/test/sun/jvmstat/monitor/MonitoredVm/CR6672135.java b/test/sun/jvmstat/monitor/MonitoredVm/CR6672135.java
index 1cd02b50e..604d7dcf7 100644
--- a/test/sun/jvmstat/monitor/MonitoredVm/CR6672135.java
+++ b/test/sun/jvmstat/monitor/MonitoredVm/CR6672135.java
@@ -34,6 +34,7 @@ import sun.jvmstat.monitor.VmIdentifier;
* @bug 6672135
* @summary setInterval() for local MonitoredHost and local MonitoredVm
* @author Tomas Hurka
+ * @run main/othervm -XX:+UsePerfData CR6672135
*/
public class CR6672135 {
diff --git a/test/sun/misc/URLClassPath/EnableLookupCache.java b/test/sun/misc/URLClassPath/EnableLookupCache.java
new file mode 100644
index 000000000..2ff3801ce
--- /dev/null
+++ b/test/sun/misc/URLClassPath/EnableLookupCache.java
@@ -0,0 +1,66 @@
+/*
+ * 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 8061651
+ * @summary -Dsun.cds.enableSharedLookupCache specified on the command-line
+ * should have no effect.
+ * @run main/othervm -Dsun.cds.enableSharedLookupCache=true -Xshare:off -Dfoo.foo.bar=xyz EnableLookupCache
+ */
+
+public class EnableLookupCache {
+ public static void main(String[] args) throws Exception {
+ // If JVM is started with -Xshare:off, the sun.cds.enableSharedLookupCache
+ // should never be true, even if it has been explicitly set in the
+ // command-line.
+ String prop = "sun.cds.enableSharedLookupCache";
+ String value = System.getProperty(prop);
+ System.out.println("System.getProperty(\"" + prop + "\") = \"" + value+ "\"");
+
+ if ("true".equals(value)) {
+ System.out.println("Test FAILED: system property " + prop +
+ " is \"true\" (unexpected)");
+ throw new RuntimeException(prop + " should not be " + value);
+ }
+
+ // Make sure the -D... arguments in the @run tag are indeed used.
+ prop = "foo.foo.bar";
+ value = System.getProperty(prop);
+ System.out.println("System.getProperty(\"" + prop + "\") = \"" + value+ "\"");
+ if (!"xyz".equals(value)) {
+ System.out.println("Test FAILED: system property " + prop +
+ " should be \"xyz\" -- is JTREG set up properly?");
+ throw new RuntimeException(prop + " should not be " + value);
+ }
+
+
+ // We should be able to load the other classes without issue.
+ A.test();
+ B.test();
+ System.out.println("Test PASSED");
+ }
+
+ static class A {static void test() {}}
+ static class B {static void test() {}}
+}
+
diff --git a/test/sun/security/pkcs11/Cipher/JNICheck.java b/test/sun/security/pkcs11/Cipher/JNICheck.java
new file mode 100644
index 000000000..ecb12517a
--- /dev/null
+++ b/test/sun/security/pkcs11/Cipher/JNICheck.java
@@ -0,0 +1,64 @@
+/*
+ * 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 8063700
+ * @run main/othervm -Xcheck:jni JNICheck
+ */
+
+import javax.crypto.Cipher;
+import javax.crypto.SealedObject;
+import javax.crypto.SecretKey;
+import javax.crypto.KeyGenerator;
+import java.security.NoSuchProviderException;
+
+public class JNICheck {
+
+ /* This test is similar to the JCK test that found 8063700. */
+ static class SealedObjectTest {
+ Cipher c;
+
+ SealedObjectTest() throws Exception {
+ try {
+ c = Cipher.getInstance("AES", "SunPKCS11-Solaris");
+ } catch (NoSuchProviderException nspe) {
+ System.out.println("No SunPKCS11-Solaris provider. Test skipped");
+ return;
+ }
+
+ String s = "Test string";
+ SealedObject so;
+ SecretKey key = KeyGenerator.getInstance("AES").generateKey();
+
+ c.init(Cipher.ENCRYPT_MODE, key);
+ so = new SealedObject(s, c);
+
+ so.getObject(key, "SunPKCS11-Solaris");
+ }
+ }
+
+ public static void main(String args[]) throws Exception {
+ new SealedObjectTest();
+ }
+}