From 04edcf722cd71a6c807c57449fb81ec337097e1a Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Fri, 14 Nov 2014 12:32:43 +0300 Subject: [PATCH 01/67] 8004148: NPE in sun.awt.SunToolkit.getWindowDeactivationTime Reviewed-by: serb --- jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java index 29f8c297717..6d179aa4f9f 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java @@ -1882,6 +1882,9 @@ public abstract class SunToolkit extends Toolkit public synchronized void setWindowDeactivationTime(Window w, long time) { AppContext ctx = getAppContext(w); + if (ctx == null) { + return; + } @SuppressWarnings("unchecked") WeakHashMap map = (WeakHashMap)ctx.get(DEACTIVATION_TIMES_MAP_KEY); if (map == null) { @@ -1893,6 +1896,9 @@ public abstract class SunToolkit extends Toolkit public synchronized long getWindowDeactivationTime(Window w) { AppContext ctx = getAppContext(w); + if (ctx == null) { + return -1; + } @SuppressWarnings("unchecked") WeakHashMap map = (WeakHashMap)ctx.get(DEACTIVATION_TIMES_MAP_KEY); if (map == null) { From ea786e7bc7a2f01a712038083cbfbcfda8a47268 Mon Sep 17 00:00:00 2001 From: Vinnie Ryan Date: Fri, 14 Nov 2014 11:41:42 +0000 Subject: [PATCH 02/67] 8034031: [parfait] JNI exception pending in jdk/src/macosx/native/apple/security/KeystoreImpl.m Reviewed-by: alanb --- .../macosx/native/libosx/KeystoreImpl.m | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/jdk/src/jdk.deploy.osx/macosx/native/libosx/KeystoreImpl.m b/jdk/src/jdk.deploy.osx/macosx/native/libosx/KeystoreImpl.m index 2fe5c4bb79e..179151440da 100644 --- a/jdk/src/jdk.deploy.osx/macosx/native/libosx/KeystoreImpl.m +++ b/jdk/src/jdk.deploy.osx/macosx/native/libosx/KeystoreImpl.m @@ -300,11 +300,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; @@ -319,6 +329,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); @@ -331,6 +344,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); @@ -341,6 +357,7 @@ static void addIdentitiesToKeystore(JNIEnv *env, jobject keyStore) } } while (searchResult == noErr); +errOut: if (identitySearch != NULL) { CFRelease(identitySearch); } @@ -363,10 +380,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); @@ -377,6 +400,7 @@ static void addCertificatesToKeystore(JNIEnv *env, jobject keyStore) } } while (searchResult == noErr); +errOut: if (keychainItemSearch != NULL) { CFRelease(keychainItemSearch); } @@ -405,6 +429,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); } } @@ -424,9 +451,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); @@ -467,6 +498,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; @@ -523,6 +557,8 @@ JNF_COCOA_ENTER(env); CFRelease(createdItems); } +errOut: ; + JNF_COCOA_EXIT(env); return returnValue; From 187bacb237a08e66bd2046ae141263b899ac3615 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Fri, 14 Nov 2014 18:15:52 +0000 Subject: [PATCH 03/67] 8050983: Misplaced parentheses in sun.net.www.http.HttpClient break HTTP PUT streaming Reviewed-by: michaelm --- .../classes/sun/net/www/http/HttpClient.java | 14 ++++++++------ .../www/http/HttpClient/StreamingRetry.java | 19 ++++++++++++++----- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/net/www/http/HttpClient.java b/jdk/src/java.base/share/classes/sun/net/www/http/HttpClient.java index 0e07d3ab65c..fcdd50943ab 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/http/HttpClient.java +++ b/jdk/src/java.base/share/classes/sun/net/www/http/HttpClient.java @@ -657,9 +657,10 @@ public class HttpClient extends NetworkClient { cachedHttpClient = false; if (!failedOnce && requests != null) { failedOnce = true; - if (getRequestMethod().equals("CONNECT") || - (httpuc.getRequestMethod().equals("POST") && - (!retryPostProp || streaming))) { + if (getRequestMethod().equals("CONNECT") + || streaming + || (httpuc.getRequestMethod().equals("POST") + && !retryPostProp)) { // do not retry the request } else { // try once more @@ -769,9 +770,10 @@ public class HttpClient extends NetworkClient { } else if (nread != 8) { if (!failedOnce && requests != null) { failedOnce = true; - if (getRequestMethod().equals("CONNECT") || - (httpuc.getRequestMethod().equals("POST") && - (!retryPostProp || streaming))) { + if (getRequestMethod().equals("CONNECT") + || streaming + || (httpuc.getRequestMethod().equals("POST") + && !retryPostProp)) { // do not retry the request } else { closeServer(); diff --git a/jdk/test/sun/net/www/http/HttpClient/StreamingRetry.java b/jdk/test/sun/net/www/http/HttpClient/StreamingRetry.java index 03c5b503e8a..35dbc51d2de 100644 --- a/jdk/test/sun/net/www/http/HttpClient/StreamingRetry.java +++ b/jdk/test/sun/net/www/http/HttpClient/StreamingRetry.java @@ -23,8 +23,8 @@ /* * @test - * @bug 6672144 - * @summary HttpURLConnection.getInputStream sends POST request after failed chunked send + * @bug 6672144 8050983 + * @summary Do not retry failed request with a streaming body. */ import java.net.HttpURLConnection; @@ -33,6 +33,7 @@ import java.net.URL; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import static java.lang.System.out; public class StreamingRetry implements Runnable { static final int ACCEPT_TIMEOUT = 20 * 1000; // 20 seconds @@ -43,11 +44,17 @@ public class StreamingRetry implements Runnable { } void instanceMain() throws IOException { - test(); + out.println("Test with default method"); + test(null); + out.println("Test with POST method"); + test("POST"); + out.println("Test with PUT method"); + test("PUT"); + if (failed > 0) throw new RuntimeException("Some tests failed"); } - void test() throws IOException { + void test(String method) throws IOException { ss = new ServerSocket(0); ss.setSoTimeout(ACCEPT_TIMEOUT); int port = ss.getLocalPort(); @@ -58,6 +65,8 @@ public class StreamingRetry implements Runnable { URL url = new URL("http://localhost:" + port + "/"); HttpURLConnection uc = (HttpURLConnection) url.openConnection(); uc.setDoOutput(true); + if (method != null) + uc.setRequestMethod(method); uc.setChunkedStreamingMode(4096); OutputStream os = uc.getOutputStream(); os.write("Hello there".getBytes()); @@ -79,7 +88,7 @@ public class StreamingRetry implements Runnable { ss.close(); fail("The server shouldn't accept a second connection"); } catch (IOException e) { - //OK, the clien will close the server socket if successfull + //OK, the client will close the server socket if successful } } From 72f7a2a671cd8ef044cf8e7dd10fb547927260ad Mon Sep 17 00:00:00 2001 From: Martin Buchholz Date: Mon, 27 Oct 2014 16:24:43 -0700 Subject: [PATCH 04/67] 8062194: java.util.jar.Attributes should use insertion-ordered iteration S/HashMap/LinkedHashMap/g Reviewed-by: alanb, sherman --- .../classes/java/util/jar/Attributes.java | 9 ++- .../util/jar/Attributes/IterationOrder.java | 74 +++++++++++++++++++ 2 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 jdk/test/java/util/jar/Attributes/IterationOrder.java diff --git a/jdk/src/java.base/share/classes/java/util/jar/Attributes.java b/jdk/src/java.base/share/classes/java/util/jar/Attributes.java index 37efbd47481..1bf9ac170fb 100644 --- a/jdk/src/java.base/share/classes/java/util/jar/Attributes.java +++ b/jdk/src/java.base/share/classes/java/util/jar/Attributes.java @@ -28,7 +28,7 @@ package java.util.jar; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import java.util.Collection; @@ -47,6 +47,9 @@ import sun.misc.ASCIICaseInsensitiveComparator; * JAR File Specification * for more information about valid attribute names and values. * + *

This map and its views have a predictable iteration order, namely the + * order that keys were inserted into the map, as with {@link LinkedHashMap}. + * * @author David Connelly * @see Manifest * @since 1.2 @@ -71,7 +74,7 @@ public class Attributes implements Map, Cloneable { * @param size the initial number of attributes */ public Attributes(int size) { - map = new HashMap<>(size); + map = new LinkedHashMap<>(size); } /** @@ -81,7 +84,7 @@ public class Attributes implements Map, Cloneable { * @param attr the specified Attributes */ public Attributes(Attributes attr) { - map = new HashMap<>(attr); + map = new LinkedHashMap<>(attr); } diff --git a/jdk/test/java/util/jar/Attributes/IterationOrder.java b/jdk/test/java/util/jar/Attributes/IterationOrder.java new file mode 100644 index 00000000000..4028d71e7c4 --- /dev/null +++ b/jdk/test/java/util/jar/Attributes/IterationOrder.java @@ -0,0 +1,74 @@ +/* + * Copyright 2014 Google, Inc. 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 8062194 + * @summary Ensure Attribute iteration order is the insertion order. + */ + +import java.util.Arrays; +import java.util.Map; +import java.util.jar.Attributes; +import java.util.jar.Attributes.Name; + +public class IterationOrder { + static void checkOrder(Attributes.Name k0, String v0, + Attributes.Name k1, String v1, + Attributes.Name k2, String v2) { + Attributes x = new Attributes(); + x.put(k0, v0); + x.put(k1, v1); + x.put(k2, v2); + Map.Entry[] entries + = x.entrySet().toArray(new Map.Entry[3]); + if (!(entries.length == 3 + && entries[0].getKey() == k0 + && entries[0].getValue() == v0 + && entries[1].getKey() == k1 + && entries[1].getValue() == v1 + && entries[2].getKey() == k2 + && entries[2].getValue() == v2)) { + throw new AssertionError(Arrays.toString(entries)); + } + + Object[] keys = x.keySet().toArray(); + if (!(keys.length == 3 + && keys[0] == k0 + && keys[1] == k1 + && keys[2] == k2)) { + throw new AssertionError(Arrays.toString(keys)); + } + } + + public static void main(String[] args) throws Exception { + Attributes.Name k0 = Name.MANIFEST_VERSION; + Attributes.Name k1 = Name.MAIN_CLASS; + Attributes.Name k2 = Name.SEALED; + String v0 = "42.0"; + String v1 = "com.google.Hello"; + String v2 = "yes"; + checkOrder(k0, v0, k1, v1, k2, v2); + checkOrder(k1, v1, k0, v0, k2, v2); + checkOrder(k2, v2, k1, v1, k0, v0); + } +} From 5e65c0f984aa3ce3478e05427cab863d01a1d152 Mon Sep 17 00:00:00 2001 From: Martin Buchholz Date: Thu, 6 Nov 2014 13:29:36 -0800 Subject: [PATCH 05/67] 8063147: Class.getFields spec should state that fields are inherited from superinterfaces Reviewed-by: psandoz, chegar --- .../share/classes/java/lang/Class.java | 3 +- .../java/lang/Class/getFields/Sanity.java | 168 ++++++++++++++++++ 2 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 jdk/test/java/lang/Class/getFields/Sanity.java diff --git a/jdk/src/java.base/share/classes/java/lang/Class.java b/jdk/src/java.base/share/classes/java/lang/Class.java index 5c03b975326..9063450866f 100644 --- a/jdk/src/java.base/share/classes/java/lang/Class.java +++ b/jdk/src/java.base/share/classes/java/lang/Class.java @@ -1533,7 +1533,8 @@ public final class Class implements java.io.Serializable, * 0. * *

If this {@code Class} object represents a class, then this method - * returns the public fields of the class and of all its superclasses. + * returns the public fields of the class and of all its superclasses and + * superinterfaces. * *

If this {@code Class} object represents an interface, then this * method returns the fields of the interface and of all its diff --git a/jdk/test/java/lang/Class/getFields/Sanity.java b/jdk/test/java/lang/Class/getFields/Sanity.java new file mode 100644 index 00000000000..e82ac10521d --- /dev/null +++ b/jdk/test/java/lang/Class/getFields/Sanity.java @@ -0,0 +1,168 @@ +/* + * Copyright 2014 Google, Inc. 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 8063147 + * @summary Tests for Class.getFields(). + * @run testng Sanity + */ + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +public class Sanity { + public interface EmptyInterface {} + class EmptyClass {} + interface BI1 { + public int i = 1; + int j = 2; + } + interface BI2 { + int k = 1; + } + public interface DI extends BI1, BI2, EmptyInterface { + int m = 5; + } + interface DDI extends DI { + int n = 6; + } + + public class D extends EmptyClass { + public int publicDField; + protected int protectedDField; + private int privateDField; + } + + class DD extends D { + public int publicDDField; + protected int protectedDDField; + private int privateDDField; + } + + public class Universe extends DD implements DDI { + public int publicUniverseField; + protected int protectedUniverseField; + private int privateUniverseField; + } + + void assertContainsNoFields(Class clazz) { + assertEquals(clazz.getFields().length, 0); + } + + @Test + public void primitiveTypesHaveNoFields() throws Exception { + assertContainsNoFields(byte.class); + assertContainsNoFields(char.class); + assertContainsNoFields(short.class); + assertContainsNoFields(int.class); + assertContainsNoFields(long.class); + assertContainsNoFields(boolean.class); + assertContainsNoFields(void.class); + assertContainsNoFields(double.class); + assertContainsNoFields(float.class); + } + + @Test + public void arrayTypesHaveNoFields() throws Exception { + assertContainsNoFields(byte[].class); + assertContainsNoFields(Object[].class); + assertContainsNoFields(java.util.Map[].class); + assertContainsNoFields(java.util.HashMap[].class); + } + + @Test + public void emptyInterfacesHaveNoFields() throws Exception { + assertContainsNoFields(EmptyInterface.class); + } + + @Test + public void emptyClassesHaveNoFields() throws Exception { + assertContainsNoFields(EmptyClass.class); + class EmptyLocalClass {} + assertContainsNoFields(EmptyLocalClass.class); + } + + void assertContainsFields(Class clazz, int count) { + assertEquals(clazz.getFields().length, count); + } + + @Test + public void checkFieldCounts() throws Exception { + assertContainsFields(BI1.class, 2); + assertContainsFields(BI2.class, 1); + assertContainsFields(DI.class, 4); + assertContainsFields(DDI.class, 5); + assertContainsFields(D.class, 1); + assertContainsFields(DD.class, 2); + assertContainsFields(Universe.class, 8); + } + + void assertContainsFields(Class derived, Class base) { + List derivedFields = Arrays.asList(derived.getFields()); + List baseFields = Arrays.asList(base.getFields()); + assertTrue(derivedFields.containsAll(baseFields)); + } + + List> directSupers(Class clazz) { + List> directSupers = new ArrayList<>(); + directSupers.addAll(Arrays.asList(clazz.getInterfaces())); + if (clazz.getSuperclass() != null) { + directSupers.add(clazz.getSuperclass()); + } + return directSupers; + } + + void assertContainsSuperFields(Class clazz) { + for (Class directSuper : directSupers(clazz)) { + assertContainsFields(clazz, directSuper); + } + } + + List> testClasses() { + List> testClasses = new ArrayList<>(); + testClasses.add(Sanity.class); + testClasses.addAll(Arrays.asList(Sanity.class.getDeclaredClasses())); + assertEquals(testClasses.size(), 10); + return testClasses; + } + + @Test + public void fieldsAreInheritedFromSupers() throws Exception { + for (Class clazz : testClasses()) { + assertContainsSuperFields(clazz); + } + } + + @Test + public void getFieldIsConsistentWithGetFields() throws Exception { + for (Class clazz : testClasses()) { + for (Field field : clazz.getFields()) { + assertEquals(field, clazz.getField(field.getName())); + } + } + } +} From 05ed094d99a4cc89ab61d4d8ce09b7f77eaeffb3 Mon Sep 17 00:00:00 2001 From: Mark Sheppard Date: Sat, 15 Nov 2014 18:26:29 +0000 Subject: [PATCH 06/67] 8015692: java.net.BindException is thrown on Windows XP when HTTP server is started and stopped in the loop Join the dispatcher thread in the ServerImpl.stop method to ensure Dispatcher is finished prior to exiting stop(). Reviewed-by: chegar --- .../sun/net/httpserver/ServerImpl.java | 13 +++- .../net/httpserver/SimpleHttpServerTest.java | 64 +++++++++++++++++++ 2 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 jdk/test/com/sun/net/httpserver/SimpleHttpServerTest.java diff --git a/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java b/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java index 5b424fb948d..5952c79ee87 100644 --- a/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java +++ b/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -82,6 +82,7 @@ class ServerImpl implements TimeSource { private Timer timer, timer1; private Logger logger; + private Thread dispatcherThread; ServerImpl ( HttpServer wrapper, String protocol, InetSocketAddress addr, int backlog @@ -141,9 +142,9 @@ class ServerImpl implements TimeSource { if (executor == null) { executor = new DefaultExecutor(); } - Thread t = new Thread (dispatcher); + dispatcherThread = new Thread (dispatcher); started = true; - t.start(); + dispatcherThread.start(); } public void setExecutor (Executor executor) { @@ -205,6 +206,12 @@ class ServerImpl implements TimeSource { if (timer1Enabled) { timer1.cancel(); } + try { + dispatcherThread.join(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + logger.log(Level.FINER, "ServerImpl.stop: ", e); + } } Dispatcher dispatcher; diff --git a/jdk/test/com/sun/net/httpserver/SimpleHttpServerTest.java b/jdk/test/com/sun/net/httpserver/SimpleHttpServerTest.java new file mode 100644 index 00000000000..c33ded954b4 --- /dev/null +++ b/jdk/test/com/sun/net/httpserver/SimpleHttpServerTest.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 8015692 + * @summary Test HttpServer instantiation, start, and stop repeated in a loop + * Testing for Bind exception on Windows + */ + +import java.net.InetSocketAddress; +import java.net.ServerSocket; + +import com.sun.net.httpserver.HttpServer; + + +public class SimpleHttpServerTest { + + public static void main(String[] args) throws Exception { + + System.out.println(System.getProperty("java.version")); + InetSocketAddress serverAddr = new InetSocketAddress(0); + HttpServer server = HttpServer.create(serverAddr, 0); + final int serverPort = server.getAddress().getPort(); + server.start(); + server.stop(0); + serverAddr = new InetSocketAddress(serverPort); + int exceptionCount = 0; + System.out.println("Using serverPort == " + serverPort); + for (int i = 0; i < 100; i++) { + try { + server = HttpServer.create(serverAddr, 0); + server.start(); + server.stop(0); + } catch (Exception ex) { + ex.printStackTrace(); + exceptionCount++; + } + } + if (exceptionCount > 0) { + throw new RuntimeException("Test Failed"); + } + } +} From 0d4528c45f76fe5ad05f77e625c78306b49a073f Mon Sep 17 00:00:00 2001 From: Anthony Scarpino Date: Sun, 18 May 2014 23:06:51 +0000 Subject: [PATCH 07/67] 8042480: CipherInputStream.close() throws AEADBadTagException in some cases Reviewed-by: xuelei --- .../share/classes/javax/crypto/CipherInputStream.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java b/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java index 0930f9d6426..37520a1b5ec 100644 --- a/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java +++ b/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.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 @@ -88,6 +88,8 @@ public class CipherInputStream extends FilterInputStream { private int ofinish = 0; // stream status private boolean closed = false; + // The stream has been read from. False if the stream has never been read. + private boolean read = false; /** * private convenience function. @@ -103,6 +105,7 @@ public class CipherInputStream extends FilterInputStream { private int getMoreData() throws IOException { if (done) return -1; int readin = input.read(ibuffer); + read = true; if (readin == -1) { done = true; try { @@ -306,7 +309,11 @@ public class CipherInputStream extends FilterInputStream { } } catch (BadPaddingException | IllegalBlockSizeException ex) { - throw new IOException(ex); + /* If no data has been read from the stream to be en/decrypted, + we supress any exceptions, and close quietly. */ + if (read) { + throw new IOException(ex); + } } ostart = 0; ofinish = 0; From 9c20c6fd5f29e14ed08fdeece7aa5e3df9a73c46 Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Thu, 29 May 2014 04:24:10 +0000 Subject: [PATCH 08/67] 8043200: Decrease the preference mode of RC4 in the enabled cipher suite list Reviewed-by: wetmore, ahgross, asmotrak --- .../classes/sun/security/ssl/CipherSuite.java | 103 +++++++++--------- .../ciphersuites/CipherSuitesInOrder.java | 49 +++++---- 2 files changed, 78 insertions(+), 74 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuite.java b/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuite.java index c29cb69b6f9..6d52cc68435 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuite.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuite.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -968,7 +968,7 @@ final class CipherSuite implements Comparable { * 1. Prefer Suite B compliant cipher suites, see RFC6460 (To be * changed later, see below). * 2. Prefer the stronger bulk cipher, in the order of AES_256(GCM), - * AES_128(GCM), AES_256, AES_128, RC-4, 3DES-EDE. + * AES_128(GCM), AES_256, AES_128, 3DES-EDE, RC-4. * 3. Prefer the stronger MAC algorithm, in the order of SHA384, * SHA256, SHA, MD5. * 4. Prefer the better performance of key exchange and digital @@ -1087,18 +1087,6 @@ final class CipherSuite implements Comparable { add("TLS_DHE_DSS_WITH_AES_128_CBC_SHA", 0x0032, --p, K_DHE_DSS, B_AES_128, T); - // RC-4 - add("TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", - 0xC007, --p, K_ECDHE_ECDSA, B_RC4_128, N); - add("TLS_ECDHE_RSA_WITH_RC4_128_SHA", - 0xC011, --p, K_ECDHE_RSA, B_RC4_128, N); - add("SSL_RSA_WITH_RC4_128_SHA", - 0x0005, --p, K_RSA, B_RC4_128, N); - add("TLS_ECDH_ECDSA_WITH_RC4_128_SHA", - 0xC002, --p, K_ECDH_ECDSA, B_RC4_128, N); - add("TLS_ECDH_RSA_WITH_RC4_128_SHA", - 0xC00C, --p, K_ECDH_RSA, B_RC4_128, N); - // 3DES_EDE add("TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", 0xC008, --p, K_ECDHE_ECDSA, B_3DES, T); @@ -1115,6 +1103,17 @@ final class CipherSuite implements Comparable { add("SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA", 0x0013, --p, K_DHE_DSS, B_3DES, N); + // RC-4 + add("TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", + 0xC007, --p, K_ECDHE_ECDSA, B_RC4_128, N); + add("TLS_ECDHE_RSA_WITH_RC4_128_SHA", + 0xC011, --p, K_ECDHE_RSA, B_RC4_128, N); + add("SSL_RSA_WITH_RC4_128_SHA", + 0x0005, --p, K_RSA, B_RC4_128, N); + add("TLS_ECDH_ECDSA_WITH_RC4_128_SHA", + 0xC002, --p, K_ECDH_ECDSA, B_RC4_128, N); + add("TLS_ECDH_RSA_WITH_RC4_128_SHA", + 0xC00C, --p, K_ECDH_RSA, B_RC4_128, N); add("SSL_RSA_WITH_RC4_128_MD5", 0x0004, --p, K_RSA, B_RC4_128, N); @@ -1134,7 +1133,7 @@ final class CipherSuite implements Comparable { * 2. If a cipher suite has been obsoleted, we put it at the end of * the list. * 3. Prefer the stronger bulk cipher, in the order of AES_256, - * AES_128, RC-4, 3DES-EDE, DES, RC4_40, DES40, NULL. + * AES_128, 3DES-EDE, RC-4, DES, DES40, RC4_40, NULL. * 4. Prefer the stronger MAC algorithm, in the order of SHA384, * SHA256, SHA, MD5. * 5. Prefer the better performance of key exchange and digital @@ -1162,15 +1161,40 @@ final class CipherSuite implements Comparable { add("TLS_DH_anon_WITH_AES_128_CBC_SHA", 0x0034, --p, K_DH_ANON, B_AES_128, N); + add("TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA", + 0xC017, --p, K_ECDH_ANON, B_3DES, N); + add("SSL_DH_anon_WITH_3DES_EDE_CBC_SHA", + 0x001b, --p, K_DH_ANON, B_3DES, N); + add("TLS_ECDH_anon_WITH_RC4_128_SHA", 0xC016, --p, K_ECDH_ANON, B_RC4_128, N); add("SSL_DH_anon_WITH_RC4_128_MD5", 0x0018, --p, K_DH_ANON, B_RC4_128, N); - add("TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA", - 0xC017, --p, K_ECDH_ANON, B_3DES, N); - add("SSL_DH_anon_WITH_3DES_EDE_CBC_SHA", - 0x001b, --p, K_DH_ANON, B_3DES, N); + // weak cipher suites obsoleted in TLS 1.2 + add("SSL_RSA_WITH_DES_CBC_SHA", + 0x0009, --p, K_RSA, B_DES, N, tls12); + add("SSL_DHE_RSA_WITH_DES_CBC_SHA", + 0x0015, --p, K_DHE_RSA, B_DES, N, tls12); + add("SSL_DHE_DSS_WITH_DES_CBC_SHA", + 0x0012, --p, K_DHE_DSS, B_DES, N, tls12); + add("SSL_DH_anon_WITH_DES_CBC_SHA", + 0x001a, --p, K_DH_ANON, B_DES, N, tls12); + + // weak cipher suites obsoleted in TLS 1.1 + add("SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", + 0x0008, --p, K_RSA_EXPORT, B_DES_40, N, tls11); + add("SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", + 0x0014, --p, K_DHE_RSA, B_DES_40, N, tls11); + add("SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", + 0x0011, --p, K_DHE_DSS, B_DES_40, N, tls11); + add("SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", + 0x0019, --p, K_DH_ANON, B_DES_40, N, tls11); + + add("SSL_RSA_EXPORT_WITH_RC4_40_MD5", + 0x0003, --p, K_RSA_EXPORT, B_RC4_40, N, tls11); + add("SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", + 0x0017, --p, K_DH_ANON, B_RC4_40, N, tls11); add("TLS_RSA_WITH_NULL_SHA256", 0x003b, --p, K_RSA, B_NULL, N, max, tls12, P_SHA256); @@ -1189,52 +1213,27 @@ final class CipherSuite implements Comparable { add("SSL_RSA_WITH_NULL_MD5", 0x0001, --p, K_RSA, B_NULL, N); - // weak cipher suites obsoleted in TLS 1.2 - add("SSL_RSA_WITH_DES_CBC_SHA", - 0x0009, --p, K_RSA, B_DES, N, tls12); - add("SSL_DHE_RSA_WITH_DES_CBC_SHA", - 0x0015, --p, K_DHE_RSA, B_DES, N, tls12); - add("SSL_DHE_DSS_WITH_DES_CBC_SHA", - 0x0012, --p, K_DHE_DSS, B_DES, N, tls12); - add("SSL_DH_anon_WITH_DES_CBC_SHA", - 0x001a, --p, K_DH_ANON, B_DES, N, tls12); - - // weak cipher suites obsoleted in TLS 1.1 - add("SSL_RSA_EXPORT_WITH_RC4_40_MD5", - 0x0003, --p, K_RSA_EXPORT, B_RC4_40, N, tls11); - add("SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", - 0x0017, --p, K_DH_ANON, B_RC4_40, N, tls11); - - add("SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", - 0x0008, --p, K_RSA_EXPORT, B_DES_40, N, tls11); - add("SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", - 0x0014, --p, K_DHE_RSA, B_DES_40, N, tls11); - add("SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", - 0x0011, --p, K_DHE_DSS, B_DES_40, N, tls11); - add("SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", - 0x0019, --p, K_DH_ANON, B_DES_40, N, tls11); - // Supported Kerberos ciphersuites from RFC2712 - add("TLS_KRB5_WITH_RC4_128_SHA", - 0x0020, --p, K_KRB5, B_RC4_128, N); - add("TLS_KRB5_WITH_RC4_128_MD5", - 0x0024, --p, K_KRB5, B_RC4_128, N); add("TLS_KRB5_WITH_3DES_EDE_CBC_SHA", 0x001f, --p, K_KRB5, B_3DES, N); add("TLS_KRB5_WITH_3DES_EDE_CBC_MD5", 0x0023, --p, K_KRB5, B_3DES, N); + add("TLS_KRB5_WITH_RC4_128_SHA", + 0x0020, --p, K_KRB5, B_RC4_128, N); + add("TLS_KRB5_WITH_RC4_128_MD5", + 0x0024, --p, K_KRB5, B_RC4_128, N); add("TLS_KRB5_WITH_DES_CBC_SHA", 0x001e, --p, K_KRB5, B_DES, N, tls12); add("TLS_KRB5_WITH_DES_CBC_MD5", 0x0022, --p, K_KRB5, B_DES, N, tls12); - add("TLS_KRB5_EXPORT_WITH_RC4_40_SHA", - 0x0028, --p, K_KRB5_EXPORT, B_RC4_40, N, tls11); - add("TLS_KRB5_EXPORT_WITH_RC4_40_MD5", - 0x002b, --p, K_KRB5_EXPORT, B_RC4_40, N, tls11); add("TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA", 0x0026, --p, K_KRB5_EXPORT, B_DES_40, N, tls11); add("TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5", 0x0029, --p, K_KRB5_EXPORT, B_DES_40, N, tls11); + add("TLS_KRB5_EXPORT_WITH_RC4_40_SHA", + 0x0028, --p, K_KRB5_EXPORT, B_RC4_40, N, tls11); + add("TLS_KRB5_EXPORT_WITH_RC4_40_MD5", + 0x002b, --p, K_KRB5_EXPORT, B_RC4_40, N, tls11); /* * Other values from the TLS Cipher Suite Registry, as of August 2010. diff --git a/jdk/test/javax/net/ssl/sanity/ciphersuites/CipherSuitesInOrder.java b/jdk/test/javax/net/ssl/sanity/ciphersuites/CipherSuitesInOrder.java index 012fe96720e..5e337f117d6 100644 --- a/jdk/test/javax/net/ssl/sanity/ciphersuites/CipherSuitesInOrder.java +++ b/jdk/test/javax/net/ssl/sanity/ciphersuites/CipherSuitesInOrder.java @@ -85,11 +85,6 @@ public class CipherSuitesInOrder { "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_DSS_WITH_AES_128_CBC_SHA", - "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", - "TLS_ECDHE_RSA_WITH_RC4_128_SHA", - "SSL_RSA_WITH_RC4_128_SHA", - "TLS_ECDH_ECDSA_WITH_RC4_128_SHA", - "TLS_ECDH_RSA_WITH_RC4_128_SHA", "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", @@ -98,6 +93,12 @@ public class CipherSuitesInOrder { "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA", "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA", "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA", + + "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", + "TLS_ECDHE_RSA_WITH_RC4_128_SHA", + "SSL_RSA_WITH_RC4_128_SHA", + "TLS_ECDH_ECDSA_WITH_RC4_128_SHA", + "TLS_ECDH_RSA_WITH_RC4_128_SHA", "SSL_RSA_WITH_RC4_128_MD5", "TLS_EMPTY_RENEGOTIATION_INFO_SCSV", @@ -111,10 +112,23 @@ public class CipherSuitesInOrder { "TLS_DH_anon_WITH_AES_128_CBC_SHA256", "TLS_ECDH_anon_WITH_AES_128_CBC_SHA", "TLS_DH_anon_WITH_AES_128_CBC_SHA", - "TLS_ECDH_anon_WITH_RC4_128_SHA", - "SSL_DH_anon_WITH_RC4_128_MD5", "TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA", "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA", + "TLS_ECDH_anon_WITH_RC4_128_SHA", + "SSL_DH_anon_WITH_RC4_128_MD5", + + "SSL_RSA_WITH_DES_CBC_SHA", + "SSL_DHE_RSA_WITH_DES_CBC_SHA", + "SSL_DHE_DSS_WITH_DES_CBC_SHA", + "SSL_DH_anon_WITH_DES_CBC_SHA", + "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", + "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", + "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", + "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", + + "SSL_RSA_EXPORT_WITH_RC4_40_MD5", + "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", + "TLS_RSA_WITH_NULL_SHA256", "TLS_ECDHE_ECDSA_WITH_NULL_SHA", "TLS_ECDHE_RSA_WITH_NULL_SHA", @@ -123,26 +137,17 @@ public class CipherSuitesInOrder { "TLS_ECDH_RSA_WITH_NULL_SHA", "TLS_ECDH_anon_WITH_NULL_SHA", "SSL_RSA_WITH_NULL_MD5", - "SSL_RSA_WITH_DES_CBC_SHA", - "SSL_DHE_RSA_WITH_DES_CBC_SHA", - "SSL_DHE_DSS_WITH_DES_CBC_SHA", - "SSL_DH_anon_WITH_DES_CBC_SHA", - "SSL_RSA_EXPORT_WITH_RC4_40_MD5", - "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", - "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", - "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", - "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", - "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", - "TLS_KRB5_WITH_RC4_128_SHA", - "TLS_KRB5_WITH_RC4_128_MD5", + "TLS_KRB5_WITH_3DES_EDE_CBC_SHA", "TLS_KRB5_WITH_3DES_EDE_CBC_MD5", + "TLS_KRB5_WITH_RC4_128_SHA", + "TLS_KRB5_WITH_RC4_128_MD5", "TLS_KRB5_WITH_DES_CBC_SHA", "TLS_KRB5_WITH_DES_CBC_MD5", - "TLS_KRB5_EXPORT_WITH_RC4_40_SHA", - "TLS_KRB5_EXPORT_WITH_RC4_40_MD5", "TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA", - "TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5" + "TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5", + "TLS_KRB5_EXPORT_WITH_RC4_40_SHA", + "TLS_KRB5_EXPORT_WITH_RC4_40_MD5" ); private final static String[] protocols = { From 3cc3d82ad9f2cfbc74a5351f777410e121b2dae8 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Wed, 30 Jul 2014 11:08:41 -0700 Subject: [PATCH 09/67] 8052162: REGRESSION: sun/java2d/cmm/ColorConvertOp tests fail since 7u71 b01 Reviewed-by: bae, serb --- jdk/test/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/test/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java b/jdk/test/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java index 12139f6bbda..a867e453389 100644 --- a/jdk/test/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java +++ b/jdk/test/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java @@ -23,7 +23,7 @@ /** * @test - * @bug 6476665 7033534 6830714 + * @bug 6476665 7033534 6830714 8052162 * @summary Verifies color conversion of Component Color Model based images * @run main ColConvCCMTest */ From 01ea2212b1e88a5f0a37a7c4ca4bb0b5c3fa9b93 Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Thu, 21 Aug 2014 17:51:29 +0100 Subject: [PATCH 10/67] 8053963: (dc) Use DatagramChannel.receive() instead of read() in connect Reviewed-by: alanb, chegar --- .../classes/java/net/DatagramSocket.java | 27 +++++---- .../sun/nio/ch/DatagramChannelImpl.java | 2 +- .../libnet/AbstractPlainDatagramSocketImpl.c | 55 +++++++++++++++---- 3 files changed, 61 insertions(+), 23 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/net/DatagramSocket.java b/jdk/src/java.base/share/classes/java/net/DatagramSocket.java index c047b3cf6a4..5d978e596e2 100644 --- a/jdk/src/java.base/share/classes/java/net/DatagramSocket.java +++ b/jdk/src/java.base/share/classes/java/net/DatagramSocket.java @@ -771,6 +771,7 @@ class DatagramSocket implements java.io.Closeable { } // end of while } } + DatagramPacket tmp = null; if ((connectState == ST_CONNECTED_NO_IMPL) || explicitFilter) { // We have to do the filtering the old fashioned way since // the native impl doesn't support connect or the connect @@ -795,11 +796,13 @@ class DatagramSocket implements java.io.Closeable { if ((!connectedAddress.equals(peekAddress)) || (connectedPort != peekPort)) { // throw the packet away and silently continue - DatagramPacket tmp = new DatagramPacket( + tmp = new DatagramPacket( new byte[1024], 1024); getImpl().receive(tmp); if (explicitFilter) { - bytesLeftToFilter -= tmp.getLength(); + if (checkFiltering(tmp)) { + stop = true; + } } } else { stop = true; @@ -809,18 +812,22 @@ class DatagramSocket implements java.io.Closeable { // If the security check succeeds, or the datagram is // connected then receive the packet getImpl().receive(p); - if (explicitFilter) { - bytesLeftToFilter -= p.getLength(); - if (bytesLeftToFilter <= 0) { - explicitFilter = false; - } else { - // break out of filter, if there is no more data queued - explicitFilter = getImpl().dataAvailable() > 0; - } + if (explicitFilter && tmp == null) { + // packet was not filtered, account for it here + checkFiltering(p); } } } + private boolean checkFiltering(DatagramPacket p) throws SocketException { + bytesLeftToFilter -= p.getLength(); + if (bytesLeftToFilter <= 0 || getImpl().dataAvailable() <= 0) { + explicitFilter = false; + return true; + } + return false; + } + /** * Gets the local address to which the socket is bound. * diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java b/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java index b9fd16eae29..e316facf491 100644 --- a/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java +++ b/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java @@ -752,7 +752,7 @@ class DatagramChannelImpl } do { tmpBuf.clear(); - } while (read(tmpBuf) > 0); + } while (receive(tmpBuf) != null); } finally { if (blocking) { configureBlocking(true); diff --git a/jdk/src/java.base/windows/native/libnet/AbstractPlainDatagramSocketImpl.c b/jdk/src/java.base/windows/native/libnet/AbstractPlainDatagramSocketImpl.c index 7244e664c9e..dd2c7e8a92f 100644 --- a/jdk/src/java.base/windows/native/libnet/AbstractPlainDatagramSocketImpl.c +++ b/jdk/src/java.base/windows/native/libnet/AbstractPlainDatagramSocketImpl.c @@ -32,9 +32,11 @@ #include "java_net_AbstractPlainDatagramSocketImpl.h" -static jfieldID IO_fd_fdID; +static jfieldID IO_fd_fdID = NULL; +static jfieldID apdsi_fdID = NULL; -static jfieldID apdsi_fdID; +static jfieldID apdsi_fd1ID = NULL; +static jclass two_stacks_clazz = NULL; /* @@ -48,10 +50,21 @@ Java_java_net_AbstractPlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) { apdsi_fdID = (*env)->GetFieldID(env, cls, "fd", "Ljava/io/FileDescriptor;"); CHECK_NULL(apdsi_fdID); - IO_fd_fdID = NET_GetFileDescriptorID(env); CHECK_NULL(IO_fd_fdID); + two_stacks_clazz = (*env)->FindClass(env, "java/net/TwoStacksPlainDatagramSocketImpl"); + CHECK_NULL(two_stacks_clazz); + + /* Handle both TwoStacks and DualStack here */ + + if (JNU_Equals(env, cls, two_stacks_clazz)) { + /* fd1 present only in TwoStack.. */ + apdsi_fd1ID = (*env)->GetFieldID(env, cls, "fd1", + "Ljava/io/FileDescriptor;"); + CHECK_NULL(apdsi_fd1ID); + } + JNU_CHECK_EXCEPTION(env); } @@ -63,20 +76,38 @@ Java_java_net_AbstractPlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) { JNIEXPORT jint JNICALL Java_java_net_AbstractPlainDatagramSocketImpl_dataAvailable (JNIEnv *env, jobject this) { SOCKET fd; - int retval; - + SOCKET fd1; + int rv = -1, rv1 = -1; jobject fdObj = (*env)->GetObjectField(env, this, apdsi_fdID); - if (IS_NULL(fdObj)) { - JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", - "Socket closed"); - return -1; + if (!IS_NULL(fdObj)) { + int retval = 0; + fd = (SOCKET)(*env)->GetIntField(env, fdObj, IO_fd_fdID); + rv = ioctlsocket(fd, FIONREAD, &retval); + if (retval > 0) { + return retval; + } } - fd = (SOCKET)(*env)->GetIntField(env, fdObj, IO_fd_fdID); - if (ioctlsocket(fd, FIONREAD, &retval) < 0) { + if (!IS_NULL(apdsi_fd1ID)) { + /* TwoStacks */ + jobject fd1Obj = (*env)->GetObjectField(env, this, apdsi_fd1ID); + if (!IS_NULL(fd1Obj)) { + int retval = 0; + fd1 = (SOCKET)(*env)->GetIntField(env, fd1Obj, IO_fd_fdID); + rv1 = ioctlsocket(fd1, FIONREAD, &retval); + if (retval > 0) { + return retval; + } + } + } + + if (rv < 0 && rv1 < 0) { + JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", + "Socket closed"); return -1; } - return retval; + + return 0; } From 33df9eecaaecf8a2f50a186aadbc8799e0de592d Mon Sep 17 00:00:00 2001 From: Bengt Rutisson Date: Fri, 31 Oct 2014 09:29:32 +0100 Subject: [PATCH 11/67] 8061308: Remove iCMS Reviewed-by: mgerdin, jmasa --- jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java index 2795b29f71d..e96898c8fc5 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java @@ -128,8 +128,7 @@ public final class Utils { */ private static final Pattern useGcPattern = Pattern.compile( "(?:\\-XX\\:[\\+\\-]Use.+GC)" - + "|(?:\\-Xconcgc)" - + "|(?:\\-Xincgc)"); + + "|(?:\\-Xconcgc)"); public static List removeGcOpts(List opts) { List optsWithoutGC = new ArrayList(); for (String opt : opts) { From 2476a824bd30be50e9ac15fb28b769475419e137 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Wed, 5 Nov 2014 18:33:28 +0300 Subject: [PATCH 12/67] 7195187: [TEST_BUG] [macosx] javax/swing/SwingUtilities/7088744/bug7088744.java failed Reviewed-by: azvegint, alexsch --- .../SwingUtilities/7088744/bug7088744.java | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/jdk/test/javax/swing/SwingUtilities/7088744/bug7088744.java b/jdk/test/javax/swing/SwingUtilities/7088744/bug7088744.java index 9d2962c8f36..b4ed0351546 100644 --- a/jdk/test/javax/swing/SwingUtilities/7088744/bug7088744.java +++ b/jdk/test/javax/swing/SwingUtilities/7088744/bug7088744.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 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 @@ -27,18 +27,24 @@ @author Pavel Porvatov */ -import sun.awt.SunToolkit; - -import javax.swing.*; -import java.awt.*; +import java.awt.Component; +import java.awt.Event; +import java.awt.Point; +import java.awt.Robot; import java.awt.event.InputEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -public class bug7088744 { - private static volatile JLabel label; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.SwingUtilities; - private static volatile Point point; +public class bug7088744 { + + private static volatile JLabel label; + private static volatile JFrame frame; + + private static volatile Point point = new Point(); private static final int MOUSE_CLICKED = 1; private static final int MOUSE_PRESSED = 2; @@ -117,7 +123,7 @@ public class bug7088744 { SwingUtilities.invokeAndWait(new Runnable() { public void run() { - JFrame frame = new JFrame(); + frame = new JFrame(); label = new JLabel("A label"); @@ -137,26 +143,24 @@ public class bug7088744 { frame.add(label); frame.setSize(200, 100); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLocationRelativeTo(null); frame.setVisible(true); } }); - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); - - toolkit.realSync(); - - // On Linux platforms realSync doesn't guaranties setSize completion - Thread.sleep(1000); + Robot robot = new Robot(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { - point = label.getLocationOnScreen(); + Point pt = label.getLocationOnScreen(); + point.x = pt.x + label.getWidth() / 2; + point.y = pt.y + label.getHeight() / 2; } }); - Robot robot = new Robot(); - robot.setAutoDelay(100); + robot.setAutoWaitForIdle(true); robot.mouseMove(point.x, point.y); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mousePress(InputEvent.BUTTON2_MASK); @@ -165,10 +169,9 @@ public class bug7088744 { robot.mouseRelease(InputEvent.BUTTON2_MASK); robot.mouseRelease(InputEvent.BUTTON3_MASK); - toolkit.realSync(); - SwingUtilities.invokeAndWait(new Runnable() { public void run() { + frame.dispose(); if (eventCount != BUTTON_EVENTS_SEQUENCE.length) { throw new RuntimeException("Not all events received"); } From 7c51cce1adebbcdabe1b77c28539bbea2a8c9c41 Mon Sep 17 00:00:00 2001 From: Martin Buchholz Date: Fri, 14 Nov 2014 11:23:07 -0800 Subject: [PATCH 13/67] 8064846: Lazy-init thread safety problems in core reflection Make several fields in core reflection volatile Reviewed-by: jfranck, shade, plevart --- .../generics/repository/ClassRepository.java | 22 ++++++++++++------- .../repository/GenericDeclRepository.java | 15 +++++++------ .../reflect/generics/scope/AbstractScope.java | 10 +++++++-- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/reflect/generics/repository/ClassRepository.java b/jdk/src/java.base/share/classes/sun/reflect/generics/repository/ClassRepository.java index f60f03346c3..edcdc865889 100644 --- a/jdk/src/java.base/share/classes/sun/reflect/generics/repository/ClassRepository.java +++ b/jdk/src/java.base/share/classes/sun/reflect/generics/repository/ClassRepository.java @@ -42,8 +42,11 @@ public class ClassRepository extends GenericDeclRepository { 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 + /** The generic superclass info. Lazily initialized. */ + private volatile Type superclass; + + /** The generic superinterface info. Lazily initialized. */ + private volatile Type[] superInterfaces; // private, to enforce use of static factory private ClassRepository(String rawSig, GenericsFactory f) { @@ -79,31 +82,34 @@ public class ClassRepository extends GenericDeclRepository { * with which the repository was created. */ - public Type getSuperclass(){ + 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(){ + 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(); // create array to store reified subtree(s) - Type[] sis = new Type[ts.length]; + superInterfaces = new Type[ts.length]; // reify all subtrees for (int i = 0; i < ts.length; i++) { Reifier r = getReifier(); // obtain visitor ts[i].accept(r);// reify subtree // extract result from visitor and store it - sis[i] = r.getResult(); + superInterfaces[i] = r.getResult(); } - superInterfaces = sis; // cache overall result + this.superInterfaces = superInterfaces; } return superInterfaces.clone(); // return cached result } diff --git a/jdk/src/java.base/share/classes/sun/reflect/generics/repository/GenericDeclRepository.java b/jdk/src/java.base/share/classes/sun/reflect/generics/repository/GenericDeclRepository.java index 28cb4b4c70a..e530d573d84 100644 --- a/jdk/src/java.base/share/classes/sun/reflect/generics/repository/GenericDeclRepository.java +++ b/jdk/src/java.base/share/classes/sun/reflect/generics/repository/GenericDeclRepository.java @@ -42,7 +42,8 @@ import sun.reflect.generics.visitor.Reifier; public abstract class GenericDeclRepository extends AbstractRepository { - private TypeVariable[] typeParams; // caches the formal type parameters + /** The formal type parameters. Lazily initialized. */ + private volatile TypeVariable[] typeParams; protected GenericDeclRepository(String rawSig, GenericsFactory f) { super(rawSig, f); @@ -55,8 +56,7 @@ public abstract class GenericDeclRepository * If the corresponding field is non-null, it is returned. * If not, it is created lazily. This is done by selecting the appropriate * part of the tree and transforming it into a reflective object - * using a visitor. - * a visitor, which is created by feeding it the factory + * using a visitor, which is created by feeding it the factory * with which the repository was created. */ @@ -64,20 +64,21 @@ public abstract class GenericDeclRepository * Return the formal type parameters of this generic declaration. * @return the formal type parameters of this generic declaration */ - public TypeVariable[] getTypeParameters(){ + 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(); // create array to store reified subtree(s) - TypeVariable[] tps = new TypeVariable[ftps.length]; + typeParams = new TypeVariable[ftps.length]; // reify all subtrees for (int i = 0; i < ftps.length; i++) { Reifier r = getReifier(); // obtain visitor ftps[i].accept(r); // reify subtree // extract result from visitor and store it - tps[i] = (TypeVariable) r.getResult(); + typeParams[i] = (TypeVariable) r.getResult(); } - typeParams = tps; // cache overall result + this.typeParams = typeParams; // cache overall result } return typeParams.clone(); // return cached result } diff --git a/jdk/src/java.base/share/classes/sun/reflect/generics/scope/AbstractScope.java b/jdk/src/java.base/share/classes/sun/reflect/generics/scope/AbstractScope.java index 8709b3e82a3..6a1827144aa 100644 --- a/jdk/src/java.base/share/classes/sun/reflect/generics/scope/AbstractScope.java +++ b/jdk/src/java.base/share/classes/sun/reflect/generics/scope/AbstractScope.java @@ -42,7 +42,9 @@ public abstract class AbstractScope implements Scope { private final D recvr; // the declaration whose scope this instance represents - private Scope enclosingScope; // the enclosing scope of this scope + + /** The enclosing scope of this scope. Lazily initialized. */ + private volatile Scope enclosingScope; /** * Constructor. Takes a reflective object whose scope the newly @@ -71,7 +73,11 @@ public abstract class AbstractScope * @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; } From 8ecf707b8df884e4c459f902c665ccfbe30a7158 Mon Sep 17 00:00:00 2001 From: Martin Buchholz Date: Thu, 6 Nov 2014 13:29:36 -0800 Subject: [PATCH 14/67] 8062773: Clarifications for Class specification Reviewed-by: darcy, psandoz --- .../share/classes/java/lang/Class.java | 85 +++++++++---------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/Class.java b/jdk/src/java.base/share/classes/java/lang/Class.java index 9063450866f..ee24402ec8d 100644 --- a/jdk/src/java.base/share/classes/java/lang/Class.java +++ b/jdk/src/java.base/share/classes/java/lang/Class.java @@ -719,15 +719,15 @@ public final class Class implements java.io.Serializable, /** - * Returns the {@code Class} representing the superclass of the entity - * (class, interface, primitive type or void) represented by this - * {@code Class}. If this {@code Class} represents either the + * Returns the {@code Class} representing the direct superclass of the + * entity (class, interface, primitive type or void) represented by + * this {@code Class}. If this {@code Class} represents either the * {@code Object} class, an interface, a primitive type, or void, then * null is returned. If this object represents an array class then the * {@code Class} object representing the {@code Object} class is * returned. * - * @return the superclass of the class represented by this object. + * @return the direct superclass of the class represented by this object */ public native Class getSuperclass(); @@ -758,7 +758,7 @@ public final class Class implements java.io.Serializable, * @throws java.lang.reflect.MalformedParameterizedTypeException if the * generic superclass refers to a parameterized type that cannot be * instantiated for any reason - * @return the superclass of the class represented by this object + * @return the direct superclass of the class represented by this object * @since 1.5 */ public Type getGenericSuperclass() { @@ -798,15 +798,15 @@ public final class Class implements java.io.Serializable, /** - * Determines the interfaces implemented by the class or interface + * Returns the interfaces directly implemented by the class or interface * represented by this object. * - *

If this object represents a class, the return value is an array - * containing objects representing all interfaces implemented by the - * class. The order of the interface objects in the array corresponds to - * the order of the interface names in the {@code implements} clause - * of the declaration of the class represented by this object. For - * example, given the declaration: + *

If this object represents a class, the return value is an array + * containing objects representing all interfaces directly implemented by + * the class. The order of the interface objects in the array corresponds + * to the order of the interface names in the {@code implements} clause of + * the declaration of the class represented by this object. For example, + * given the declaration: *

* {@code class Shimmer implements FloorWax, DessertTopping { ... }} *
@@ -823,23 +823,23 @@ public final class Class implements java.io.Serializable, * is the {@code Class} object that represents interface * {@code DessertTopping}. * - *

If this object represents an interface, the array contains objects - * representing all interfaces extended by the interface. The order of the - * interface objects in the array corresponds to the order of the interface - * names in the {@code extends} clause of the declaration of the - * interface represented by this object. + *

If this object represents an interface, the array contains objects + * representing all interfaces directly extended by the interface. The + * order of the interface objects in the array corresponds to the order of + * the interface names in the {@code extends} clause of the declaration of + * the interface represented by this object. * - *

If this object represents a class or interface that implements no + *

If this object represents a class or interface that implements no * interfaces, the method returns an array of length 0. * - *

If this object represents a primitive type or void, the method + *

If this object represents a primitive type or void, the method * returns an array of length 0. * - *

If this {@code Class} object represents an array type, the + *

If this {@code Class} object represents an array type, the * interfaces {@code Cloneable} and {@code java.io.Serializable} are * returned in that order. * - * @return an array of interfaces implemented by this class. + * @return an array of interfaces directly implemented by this class */ public Class[] getInterfaces() { ReflectionData rd = reflectionData(); @@ -873,29 +873,28 @@ public final class Class implements java.io.Serializable, * for the semantics of the creation process for parameterized * types. * - *

If this object represents a class, the return value is an - * array containing objects representing all interfaces - * implemented by the class. The order of the interface objects in - * the array corresponds to the order of the interface names in - * the {@code implements} clause of the declaration of the class - * represented by this object. In the case of an array class, the - * interfaces {@code Cloneable} and {@code Serializable} are + *

If this object represents a class, the return value is an array + * containing objects representing all interfaces directly implemented by + * the class. The order of the interface objects in the array corresponds + * to the order of the interface names in the {@code implements} clause of + * the declaration of the class represented by this object. + * + *

If this object represents an interface, the array contains objects + * representing all interfaces directly extended by the interface. The + * order of the interface objects in the array corresponds to the order of + * the interface names in the {@code extends} clause of the declaration of + * the interface represented by this object. + * + *

If this object represents a class or interface that implements no + * interfaces, the method returns an array of length 0. + * + *

If this object represents a primitive type or void, the method + * returns an array of length 0. + * + *

If this {@code Class} object represents an array type, the + * interfaces {@code Cloneable} and {@code java.io.Serializable} are * returned in that order. * - *

If this object represents an interface, the array contains - * objects representing all interfaces directly extended by the - * interface. The order of the interface objects in the array - * corresponds to the order of the interface names in the - * {@code extends} clause of the declaration of the interface - * represented by this object. - * - *

If this object represents a class or interface that - * implements no interfaces, the method returns an array of length - * 0. - * - *

If this object represents a primitive type or void, the - * method returns an array of length 0. - * * @throws java.lang.reflect.GenericSignatureFormatError * if the generic class signature does not conform to the format * specified in @@ -905,7 +904,7 @@ public final class Class implements java.io.Serializable, * @throws java.lang.reflect.MalformedParameterizedTypeException * if any of the generic superinterfaces refer to a parameterized * type that cannot be instantiated for any reason - * @return an array of interfaces implemented by this class + * @return an array of interfaces directly implemented by this class * @since 1.5 */ public Type[] getGenericInterfaces() { From f465a5f2283c31856a6c8a2ccdc8b17ef8f2a991 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Thu, 6 Nov 2014 15:10:00 -0800 Subject: [PATCH 15/67] 8062163: java/awt/geom/AffineTransform/TestInvertMethods.java test fails Reviewed-by: jgodinez --- .../java/awt/geom/AffineTransform/TestInvertMethods.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jdk/test/java/awt/geom/AffineTransform/TestInvertMethods.java b/jdk/test/java/awt/geom/AffineTransform/TestInvertMethods.java index 6d260a1ad89..d53806d08df 100644 --- a/jdk/test/java/awt/geom/AffineTransform/TestInvertMethods.java +++ b/jdk/test/java/awt/geom/AffineTransform/TestInvertMethods.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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,7 +23,7 @@ /** * @test - * @bug 4987374 + * @bug 4987374 8062163 * @summary Unit test for inversion methods: * * AffineTransform.createInverse(); @@ -188,6 +188,8 @@ public class TestInvertMethods { double m11 = at.getScaleY(); double m02 = at.getTranslateX(); double m12 = at.getTranslateY(); + if (Math.abs(m00-1.0) < 1E-10) m00 = 1.0; + if (Math.abs(m11-1.0) < 1E-10) m11 = 1.0; if (Math.abs(m02) < 1E-10) m02 = 0.0; if (Math.abs(m12) < 1E-10) m12 = 0.0; if (Math.abs(m01) < 1E-15) m01 = 0.0; @@ -273,7 +275,7 @@ public class TestInvertMethods { int inc = full ? 10 : 45; for (int i = -720; i <= 720; i += inc) { AffineTransform at2 = new AffineTransform(init); - at2.rotate(Math.toRadians(i)); + at2.rotate(i / 180.0 * Math.PI); if (verbose) System.out.println("*Rotate("+i+") = "+at2); next.test(at2, full); } From e8c7cc1187a169adf895f7d0c92150fc9933e01f Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Sun, 9 Nov 2014 22:17:45 +0300 Subject: [PATCH 16/67] 7169583: JInternalFrame title not antialiased in Nimbus LaF Reviewed-by: azvegint, alexsch --- .../plaf/basic/BasicInternalFrameTitlePane.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java index 7ae4bc1b408..17284fd4f86 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java @@ -31,16 +31,14 @@ import java.awt.event.*; import javax.accessibility.AccessibleContext; import javax.swing.*; import javax.swing.plaf.*; -import javax.swing.border.*; import javax.swing.event.InternalFrameEvent; -import java.util.EventListener; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeEvent; -import java.beans.VetoableChangeListener; import java.beans.PropertyVetoException; import sun.swing.DefaultLookup; -import sun.swing.UIAction; + +import static sun.swing.SwingUtilities2.AA_TEXT_PROPERTY_KEY; /** * The class that manages a basic title bar @@ -215,6 +213,12 @@ public class BasicInternalFrameTitlePane extends JComponent createButtons(); addSubComponents(); + updateProperties(); + } + + private void updateProperties() { + final Object aaTextInfo = frame.getClientProperty(AA_TEXT_PROPERTY_KEY); + putClientProperty(AA_TEXT_PROPERTY_KEY, aaTextInfo); } /** From 043868fac75236bf49dbb9d6776b57f57a3fef41 Mon Sep 17 00:00:00 2001 From: Yuri Nesterenko Date: Mon, 10 Nov 2014 16:23:30 +0300 Subject: [PATCH 17/67] 8063102: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 1 Reviewed-by: pchelko, serb --- .../sun/awt/Translucency/WindowOpacity.java | 15 ++++---- .../NoUpdateUponShow/NoUpdateUponShow.java | 9 +++-- .../java/awt/Component/PaintAll/PaintAll.java | 17 ++++++---- .../ModalBlockedStealsFocusTest.java | 10 ++++-- .../WindowInitialFocusTest.java | 17 ++++++---- .../ExceptionOnSetExtendedStateTest.java | 11 +++--- .../awt/Frame/FrameSize/TestFrameSize.java | 8 ++++- .../MaximizedByPlatform.java | 18 +++++++--- .../MaximizedToMaximized.java | 5 +-- .../SlideNotResizableTest.java | 7 ++-- .../TranslucentWindow/TranslucentWindow.java | 15 +++++--- .../IncorrectDisplayModeExitFullscreen.java | 20 ++++++----- .../GridBagLayoutIpadXYTest.java | 9 ++++- .../List/ListPeer/R2303044ListSelection.java | 10 +++--- .../SingleModeDeselect.java | 9 +++-- jdk/test/java/awt/Paint/ExposeOnEDT.java | 17 ++++++---- .../ScrollPanePreferredSize.java | 13 ++++--- .../awt/TextArea/DisposeTest/TestDispose.java | 17 ++++++---- .../bug7129742.java | 7 ++-- .../TextAreaTwicePack/TextAreaTwicePack.java | 9 ++--- .../TextField/DisposeTest/TestDispose.java | 16 +++++---- .../PopupMenuLeakTest/PopupMenuLeakTest.java | 10 +++--- .../java/awt/Window/8027025/Test8027025.java | 5 ++- .../AlwaysOnTop/AlwaysOnTopFieldTest.java | 21 +++++++----- .../OwnedWindowsSerialization.java | 5 ++- .../TextEventSequenceTest.java | 34 +++++++++++-------- .../WarningWindowDisposeCrashTest.java | 19 +++++------ .../WarningWindowDisposeTest.java | 23 +++++++------ 28 files changed, 233 insertions(+), 143 deletions(-) diff --git a/jdk/test/com/sun/awt/Translucency/WindowOpacity.java b/jdk/test/com/sun/awt/Translucency/WindowOpacity.java index 26c611c35d5..a8391503238 100644 --- a/jdk/test/com/sun/awt/Translucency/WindowOpacity.java +++ b/jdk/test/com/sun/awt/Translucency/WindowOpacity.java @@ -33,15 +33,12 @@ import java.awt.*; import java.awt.event.*; import com.sun.awt.AWTUtilities; -import sun.awt.SunToolkit; public class WindowOpacity { //*** test-writer defined static variables go here *** - private static void realSync() { - ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); - } + private static Robot robot; private static void init() @@ -60,6 +57,12 @@ public class WindowOpacity System.out.println("Either the Toolkit or the native system does not support controlling the window opacity level."); pass(); } + try { + robot = new Robot(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException ("Unexpected failure"); + } boolean passed; @@ -137,7 +140,7 @@ public class WindowOpacity f.setBounds(100, 100, 300, 200); f.setVisible(true); - realSync(); + robot.waitForIdle(); curOpacity = AWTUtilities.getWindowOpacity(f); if (curOpacity < 0.75f || curOpacity > 0.75f) { @@ -147,7 +150,7 @@ public class WindowOpacity AWTUtilities.setWindowOpacity(f, 0.5f); - realSync(); + robot.waitForIdle(); curOpacity = AWTUtilities.getWindowOpacity(f); if (curOpacity < 0.5f || curOpacity > 0.5f) { diff --git a/jdk/test/java/awt/Component/NoUpdateUponShow/NoUpdateUponShow.java b/jdk/test/java/awt/Component/NoUpdateUponShow/NoUpdateUponShow.java index 80360dfdbe5..d032f0d784b 100644 --- a/jdk/test/java/awt/Component/NoUpdateUponShow/NoUpdateUponShow.java +++ b/jdk/test/java/awt/Component/NoUpdateUponShow/NoUpdateUponShow.java @@ -36,7 +36,6 @@ */ import java.awt.*; -import sun.awt.SunToolkit; public class NoUpdateUponShow { @@ -70,7 +69,13 @@ public class NoUpdateUponShow }); f.setVisible(true); - ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + try { + Robot robot = new Robot(); + robot.waitForIdle(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } if (wasUpdate) { fail(" Unexpected update. "); diff --git a/jdk/test/java/awt/Component/PaintAll/PaintAll.java b/jdk/test/java/awt/Component/PaintAll/PaintAll.java index e734cad1fdf..483f1a5bd5a 100644 --- a/jdk/test/java/awt/Component/PaintAll/PaintAll.java +++ b/jdk/test/java/awt/Component/PaintAll/PaintAll.java @@ -21,8 +21,6 @@ * questions. */ -import sun.awt.SunToolkit; - import java.awt.Button; import java.awt.Canvas; import java.awt.Checkbox; @@ -48,6 +46,8 @@ import java.awt.image.BufferedImage; @bug 6596915 @summary Test Component.paintAll() method @author sergey.bylokhov@oracle.com: area=awt.component + @library ../../../../lib/testlibrary/ + @build ExtendedRobot @run main PaintAll */ public class PaintAll { @@ -66,6 +66,7 @@ public class PaintAll { private static volatile boolean scrollPanePainted; private static volatile boolean textAreaPainted; private static volatile boolean textFieldPainted; + private static ExtendedRobot robot = null; private static final Button buttonStub = new Button() { @Override @@ -283,11 +284,15 @@ public class PaintAll { } private static void sleep() { - ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); - try { - Thread.sleep(500L); - } catch (InterruptedException ignored) { + if(robot == null) { + try { + robot = new ExtendedRobot(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } } + robot.waitForIdle(500); } private static void fail(final String message) { diff --git a/jdk/test/java/awt/Focus/ModalBlockedStealsFocusTest/ModalBlockedStealsFocusTest.java b/jdk/test/java/awt/Focus/ModalBlockedStealsFocusTest/ModalBlockedStealsFocusTest.java index 7c8e6574c92..f718ecbcfc1 100644 --- a/jdk/test/java/awt/Focus/ModalBlockedStealsFocusTest/ModalBlockedStealsFocusTest.java +++ b/jdk/test/java/awt/Focus/ModalBlockedStealsFocusTest/ModalBlockedStealsFocusTest.java @@ -34,11 +34,9 @@ import java.awt.event.*; import java.applet.Applet; import java.util.concurrent.atomic.AtomicBoolean; import java.lang.reflect.InvocationTargetException; -import sun.awt.SunToolkit; import test.java.awt.regtesthelpers.Util; public class ModalBlockedStealsFocusTest extends Applet { - SunToolkit toolkit = (SunToolkit)Toolkit.getDefaultToolkit(); Frame frame = new Frame("Blocked Frame"); Dialog dialog = new Dialog(frame, "Modal Dialog", Dialog.ModalityType.TOOLKIT_MODAL); AtomicBoolean lostFocus = new AtomicBoolean(false); @@ -85,7 +83,13 @@ public class ModalBlockedStealsFocusTest extends Applet { }).start(); Util.waitTillShown(dialog); - toolkit.realSync(); + try { + Robot robot = new Robot(); + robot.waitForIdle(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } // Test 1. Show a modal blocked frame, check that it doesn't steal focus. diff --git a/jdk/test/java/awt/Focus/WindowInitialFocusTest/WindowInitialFocusTest.java b/jdk/test/java/awt/Focus/WindowInitialFocusTest/WindowInitialFocusTest.java index ee047a3b493..38c924b3a6c 100644 --- a/jdk/test/java/awt/Focus/WindowInitialFocusTest/WindowInitialFocusTest.java +++ b/jdk/test/java/awt/Focus/WindowInitialFocusTest/WindowInitialFocusTest.java @@ -33,7 +33,6 @@ import java.awt.*; import java.awt.event.*; import java.applet.Applet; import java.util.concurrent.atomic.AtomicBoolean; -import sun.awt.SunToolkit; import test.java.awt.regtesthelpers.Util; public class WindowInitialFocusTest extends Applet { @@ -41,7 +40,7 @@ public class WindowInitialFocusTest extends Applet { Window window = new Window(frame); Button button = new Button("button"); AtomicBoolean focused = new AtomicBoolean(false); - SunToolkit toolkit = (SunToolkit)Toolkit.getDefaultToolkit(); + Robot robot; public static void main(String[] args) { WindowInitialFocusTest app = new WindowInitialFocusTest(); @@ -75,12 +74,18 @@ public class WindowInitialFocusTest extends Applet { }}); frame.setVisible(true); - toolkit.realSync(); + try { + robot = new Robot(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } + robot.waitForIdle(); // Test 1. Show the window, check that it become focused. window.setVisible(true); - toolkit.realSync(); + robot.waitForIdle(); if (!Util.waitForCondition(focused, 2000L)) { throw new TestFailedException("the window didn't get focused on its showing!"); @@ -89,13 +94,13 @@ public class WindowInitialFocusTest extends Applet { // Test 2. Show unfocusable window, check that it doesn't become focused. window.setVisible(false); - toolkit.realSync(); + robot.waitForIdle(); window.setFocusableWindowState(false); focused.set(false); window.setVisible(true); - toolkit.realSync(); + robot.waitForIdle(); if (Util.waitForCondition(focused, 2000L)) { throw new TestFailedException("the unfocusable window got focused on its showing!"); diff --git a/jdk/test/java/awt/Frame/ExceptionOnSetExtendedStateTest/ExceptionOnSetExtendedStateTest.java b/jdk/test/java/awt/Frame/ExceptionOnSetExtendedStateTest/ExceptionOnSetExtendedStateTest.java index b0f3c63b048..845138ab3bb 100644 --- a/jdk/test/java/awt/Frame/ExceptionOnSetExtendedStateTest/ExceptionOnSetExtendedStateTest.java +++ b/jdk/test/java/awt/Frame/ExceptionOnSetExtendedStateTest/ExceptionOnSetExtendedStateTest.java @@ -30,11 +30,8 @@ import java.awt.*; -import sun.awt.SunToolkit; - public class ExceptionOnSetExtendedStateTest { private static final int[] frameStates = { Frame.NORMAL, Frame.ICONIFIED, Frame.MAXIMIZED_BOTH }; - private static final SunToolkit toolkit = (SunToolkit)Toolkit.getDefaultToolkit(); private static boolean validatePlatform() { String osName = System.getProperty("os.name"); @@ -53,7 +50,13 @@ public class ExceptionOnSetExtendedStateTest { frame.setSize(200, 200); frame.setUndecorated(!decoratedFrame); frame.setVisible(true); - toolkit.realSync(); + try { + Robot robot = new Robot(); + robot.waitForIdle(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } frame.setExtendedState(oldState); sleep(1000); diff --git a/jdk/test/java/awt/Frame/FrameSize/TestFrameSize.java b/jdk/test/java/awt/Frame/FrameSize/TestFrameSize.java index b2a978300a9..b42a70fbd11 100644 --- a/jdk/test/java/awt/Frame/FrameSize/TestFrameSize.java +++ b/jdk/test/java/awt/Frame/FrameSize/TestFrameSize.java @@ -77,7 +77,13 @@ public class TestFrameSize { mainWindow.setVisible(true); - ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + try { + Robot robot = new Robot(); + robot.waitForIdle(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure."); + } Dimension clientSize2 = getClientSize(mainWindow); System.out.println("Client size after showing: " + clientSize2); diff --git a/jdk/test/java/awt/Frame/MaximizedByPlatform/MaximizedByPlatform.java b/jdk/test/java/awt/Frame/MaximizedByPlatform/MaximizedByPlatform.java index 070aa4deba6..224c10e7996 100644 --- a/jdk/test/java/awt/Frame/MaximizedByPlatform/MaximizedByPlatform.java +++ b/jdk/test/java/awt/Frame/MaximizedByPlatform/MaximizedByPlatform.java @@ -25,11 +25,12 @@ * @bug 8026143 * @summary [macosx] Maximized state could be inconsistent between peer and frame * @author Petr Pchelko + * @library ../../../../lib/testlibrary + * @build jdk.testlibrary.OSInfo * @run main MaximizedByPlatform */ -import sun.awt.OSInfo; -import sun.awt.SunToolkit; +import jdk.testlibrary.OSInfo; import java.awt.*; @@ -43,6 +44,13 @@ public class MaximizedByPlatform { return; } + Robot robot; + try { + robot = new Robot(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } availableScreenBounds = getAvailableScreenBounds(); // Test 1. The maximized state is set in setBounds @@ -51,12 +59,12 @@ public class MaximizedByPlatform { frame.setBounds(100, 100, 100, 100); frame.setVisible(true); - ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + robot.waitForIdle(); frame.setBounds(availableScreenBounds.x, availableScreenBounds.y, availableScreenBounds.width, availableScreenBounds.height); - ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + robot.waitForIdle(); if (frame.getExtendedState() != Frame.MAXIMIZED_BOTH) { throw new RuntimeException("Maximized state was not set for frame in setBounds"); @@ -73,7 +81,7 @@ public class MaximizedByPlatform { availableScreenBounds.width + 100, availableScreenBounds.height); frame.setVisible(true); - ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + robot.waitForIdle(); if (frame.getExtendedState() != Frame.MAXIMIZED_BOTH) { throw new RuntimeException("Maximized state was not set for frame in setVisible"); diff --git a/jdk/test/java/awt/Frame/MaximizedToMaximized/MaximizedToMaximized.java b/jdk/test/java/awt/Frame/MaximizedToMaximized/MaximizedToMaximized.java index 83fcfa1701d..e0da056b035 100644 --- a/jdk/test/java/awt/Frame/MaximizedToMaximized/MaximizedToMaximized.java +++ b/jdk/test/java/awt/Frame/MaximizedToMaximized/MaximizedToMaximized.java @@ -28,7 +28,7 @@ import java.awt.GraphicsEnvironment; import java.awt.Insets; import java.awt.Rectangle; import java.awt.Toolkit; -import sun.awt.SunToolkit; +import java.awt.Robot; /** * @test @@ -65,7 +65,8 @@ public class MaximizedToMaximized { Rectangle frameBounds = frame.getBounds(); frame.setExtendedState(Frame.MAXIMIZED_BOTH); - ((SunToolkit) toolkit).realSync(); + Robot robot = new Robot(); + robot.waitForIdle(); Rectangle maximizedFrameBounds = frame.getBounds(); if (maximizedFrameBounds.width < frameBounds.width diff --git a/jdk/test/java/awt/Frame/SlideNotResizableTest/SlideNotResizableTest.java b/jdk/test/java/awt/Frame/SlideNotResizableTest/SlideNotResizableTest.java index 37df055ca22..b5938187185 100644 --- a/jdk/test/java/awt/Frame/SlideNotResizableTest/SlideNotResizableTest.java +++ b/jdk/test/java/awt/Frame/SlideNotResizableTest/SlideNotResizableTest.java @@ -21,8 +21,6 @@ * questions. */ -import sun.awt.SunToolkit; - import java.awt.*; import java.awt.Dimension; import java.awt.Point; @@ -62,8 +60,9 @@ public class SlideNotResizableTest { } } - private static void sync() throws InterruptedException { - ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + private static void sync() throws Exception { + Robot robot = new Robot(); + robot.waitForIdle(); Thread.sleep(1000); } } diff --git a/jdk/test/java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java b/jdk/test/java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java index 1210b0dc551..35ab7dc906f 100644 --- a/jdk/test/java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java +++ b/jdk/test/java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java @@ -34,10 +34,17 @@ import java.awt.geom.*; import static java.awt.GraphicsDevice.WindowTranslucency.*; -import sun.awt.SunToolkit; public class TranslucentWindow { public static void main(String args[]) { + Robot robot; + try { + robot = new Robot(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); @@ -47,10 +54,10 @@ public class TranslucentWindow { // First, check it can be made fullscreen window without any effects applied gd.setFullScreenWindow(f); - ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + robot.waitForIdle(); gd.setFullScreenWindow(null); - ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + robot.waitForIdle(); // Second, check if it applying any effects doesn't prevent the window // from going into the fullscreen mode @@ -64,7 +71,7 @@ public class TranslucentWindow { f.setBackground(new Color(0, 0, 0, 128)); } gd.setFullScreenWindow(f); - ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + robot.waitForIdle(); // Third, make sure all the effects are unset when entering the fullscreen mode if (f.getShape() != null) { diff --git a/jdk/test/java/awt/GraphicsDevice/IncorrectDisplayModeExitFullscreen.java b/jdk/test/java/awt/GraphicsDevice/IncorrectDisplayModeExitFullscreen.java index 1d42db8f47d..ad808c3ab63 100644 --- a/jdk/test/java/awt/GraphicsDevice/IncorrectDisplayModeExitFullscreen.java +++ b/jdk/test/java/awt/GraphicsDevice/IncorrectDisplayModeExitFullscreen.java @@ -27,16 +27,17 @@ import java.awt.DisplayMode; import java.awt.Frame; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; -import java.awt.Toolkit; - -import sun.awt.SunToolkit; /** * @test * @bug 8019587 * @author Sergey Bylokhov + * @library ../../../lib/testlibrary/ + * @build ExtendedRobot + * @run main IncorrectDisplayModeExitFullscreen */ public class IncorrectDisplayModeExitFullscreen { + static ExtendedRobot robot; public static void main(final String[] args) { @@ -64,6 +65,13 @@ public class IncorrectDisplayModeExitFullscreen { return; } + try { + robot = new ExtendedRobot(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } + final Frame frame = new Frame(); frame.setBackground(Color.GREEN); frame.setUndecorated(true); @@ -85,10 +93,6 @@ public class IncorrectDisplayModeExitFullscreen { } } private static void sleep() { - ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); - try { - Thread.sleep(1500); - } catch (InterruptedException ignored) { - } + robot.waitForIdle(1500); } } diff --git a/jdk/test/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java b/jdk/test/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java index f547ead583e..637bed4f3d5 100644 --- a/jdk/test/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java +++ b/jdk/test/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java @@ -71,7 +71,14 @@ public class GridBagLayoutIpadXYTest extends Applet frame.pack(); frame.setVisible(true); - ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + Robot robot; + try { + robot = new Robot(); + robot.waitForIdle(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } Dimension minSize = jtf.getMinimumSize(); if ( minSize.width + customIpadx != jtf.getSize().width || diff --git a/jdk/test/java/awt/List/ListPeer/R2303044ListSelection.java b/jdk/test/java/awt/List/ListPeer/R2303044ListSelection.java index d7ef3902a03..d170fe081b9 100644 --- a/jdk/test/java/awt/List/ListPeer/R2303044ListSelection.java +++ b/jdk/test/java/awt/List/ListPeer/R2303044ListSelection.java @@ -21,12 +21,10 @@ * questions. */ -import sun.awt.SunToolkit; - import java.awt.Frame; import java.awt.HeadlessException; import java.awt.List; -import java.awt.Toolkit; +import java.awt.Robot; /** * @test @@ -57,9 +55,11 @@ public final class R2303044ListSelection { private static void sleep() { try { - ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); + Robot robot = new Robot(); + robot.waitForIdle(); Thread.sleep(1000); - } catch (final InterruptedException ignored) { + } catch (final Exception ignored) { + ignored.printStackTrace(); } } } diff --git a/jdk/test/java/awt/List/SingleModeDeselect/SingleModeDeselect.java b/jdk/test/java/awt/List/SingleModeDeselect/SingleModeDeselect.java index 726835f5f73..c4452cd1015 100644 --- a/jdk/test/java/awt/List/SingleModeDeselect/SingleModeDeselect.java +++ b/jdk/test/java/awt/List/SingleModeDeselect/SingleModeDeselect.java @@ -30,7 +30,6 @@ */ import java.awt.*; -import sun.awt.SunToolkit; public class SingleModeDeselect { @@ -50,7 +49,13 @@ public class SingleModeDeselect list.select(0); list.deselect(1); - ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); + try { + Robot robot = new Robot(); + robot.waitForIdle(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } if (list.getSelectedIndex() != 0){ throw new RuntimeException("Test failed: List.getSelectedIndex() returns "+list.getSelectedIndex()); diff --git a/jdk/test/java/awt/Paint/ExposeOnEDT.java b/jdk/test/java/awt/Paint/ExposeOnEDT.java index cf8a3a547e0..21f7dc00c29 100644 --- a/jdk/test/java/awt/Paint/ExposeOnEDT.java +++ b/jdk/test/java/awt/Paint/ExposeOnEDT.java @@ -22,18 +22,19 @@ */ -import sun.awt.SunToolkit; - import java.awt.*; /** * @test * @bug 7090424 * @author Sergey Bylokhov + * @library ../../../lib/testlibrary/ + * @build ExtendedRobot * @run main ExposeOnEDT */ public final class ExposeOnEDT { + private static ExtendedRobot robot = null; private static final Button buttonStub = new Button() { @Override public void paint(final Graphics g) { @@ -275,11 +276,15 @@ public final class ExposeOnEDT { } private static void sleep() { - ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); - try { - Thread.sleep(1000L); - } catch (InterruptedException ignored) { + if(robot == null) { + try { + robot = new ExtendedRobot(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } } + robot.waitForIdle(1000); } private static void fail(final String message) { diff --git a/jdk/test/java/awt/ScrollPane/ScrollPanePreferredSize/ScrollPanePreferredSize.java b/jdk/test/java/awt/ScrollPane/ScrollPanePreferredSize/ScrollPanePreferredSize.java index 0c799f14a1d..02a84e859fa 100644 --- a/jdk/test/java/awt/ScrollPane/ScrollPanePreferredSize/ScrollPanePreferredSize.java +++ b/jdk/test/java/awt/ScrollPane/ScrollPanePreferredSize/ScrollPanePreferredSize.java @@ -26,12 +26,13 @@ import java.awt.Frame; import java.awt.ScrollPane; import java.awt.Toolkit; -import sun.awt.SunToolkit; - /** * @test * @bug 7124213 * @author Sergey Bylokhov + * @library ../../../../lib/testlibrary/ + * @build ExtendedRobot + * @run main ScrollPanePreferredSize */ public final class ScrollPanePreferredSize { @@ -54,10 +55,12 @@ public final class ScrollPanePreferredSize { } private static void sleep() { - ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); try { - Thread.sleep(500L); - } catch (InterruptedException ignored) { + ExtendedRobot robot = new ExtendedRobot(); + robot.waitForIdle(500); + } catch (Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); } } } diff --git a/jdk/test/java/awt/TextArea/DisposeTest/TestDispose.java b/jdk/test/java/awt/TextArea/DisposeTest/TestDispose.java index 91c795fbfee..47c534be94f 100644 --- a/jdk/test/java/awt/TextArea/DisposeTest/TestDispose.java +++ b/jdk/test/java/awt/TextArea/DisposeTest/TestDispose.java @@ -35,14 +35,12 @@ import java.awt.FlowLayout; import java.awt.Frame; import java.awt.TextArea; -import java.awt.Toolkit; +import java.awt.Robot; import java.lang.reflect.InvocationTargetException; import javax.swing.JFrame; import javax.swing.SwingUtilities; -import sun.awt.SunToolkit; - public class TestDispose { public static Frame frame = null; @@ -51,7 +49,14 @@ public class TestDispose { public void testDispose() throws InvocationTargetException, InterruptedException { - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + Robot robot; + try { + robot = new Robot(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } + SwingUtilities.invokeAndWait(new Runnable() { @Override @@ -69,7 +74,7 @@ public class TestDispose { frame.setVisible(true); } }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { @Override @@ -77,7 +82,7 @@ public class TestDispose { frame.dispose(); } }); - toolkit.realSync(); + robot.waitForIdle(); } public static void main(String[] args) throws Exception{ diff --git a/jdk/test/java/awt/TextArea/TextAreaCaretVisibilityTest/bug7129742.java b/jdk/test/java/awt/TextArea/TextAreaCaretVisibilityTest/bug7129742.java index d3de4954591..94f1d911f89 100644 --- a/jdk/test/java/awt/TextArea/TextAreaCaretVisibilityTest/bug7129742.java +++ b/jdk/test/java/awt/TextArea/TextAreaCaretVisibilityTest/bug7129742.java @@ -34,7 +34,7 @@ import java.awt.FlowLayout; import java.awt.TextArea; -import java.awt.Toolkit; +import java.awt.Robot; import java.lang.reflect.Field; import javax.swing.JFrame; @@ -42,7 +42,6 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.text.DefaultCaret; -import sun.awt.SunToolkit; public class bug7129742 { @@ -51,7 +50,7 @@ public class bug7129742 { public static boolean fastreturn = false; public static void main(String[] args) throws Exception { - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + Robot robot = new Robot(); SwingUtilities.invokeAndWait(new Runnable() { @Override @@ -88,7 +87,7 @@ public class bug7129742 { } } }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { @Override diff --git a/jdk/test/java/awt/TextArea/TextAreaTwicePack/TextAreaTwicePack.java b/jdk/test/java/awt/TextArea/TextAreaTwicePack/TextAreaTwicePack.java index eba92a50063..e134c386c05 100644 --- a/jdk/test/java/awt/TextArea/TextAreaTwicePack/TextAreaTwicePack.java +++ b/jdk/test/java/awt/TextArea/TextAreaTwicePack/TextAreaTwicePack.java @@ -24,9 +24,8 @@ import java.awt.Dimension; import java.awt.Frame; import java.awt.TextArea; -import java.awt.Toolkit; +import java.awt.Robot; -import sun.awt.SunToolkit; /** * @test @@ -55,10 +54,12 @@ public final class TextAreaTwicePack { } private static void sleep() { - ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); try { + Robot robot = new Robot(); + robot.waitForIdle(); Thread.sleep(500L); - } catch (InterruptedException ignored) { + } catch (Exception ignored) { + ignored.printStackTrace(); } } } diff --git a/jdk/test/java/awt/TextField/DisposeTest/TestDispose.java b/jdk/test/java/awt/TextField/DisposeTest/TestDispose.java index 6ef00cd215d..a4adbc2b229 100644 --- a/jdk/test/java/awt/TextField/DisposeTest/TestDispose.java +++ b/jdk/test/java/awt/TextField/DisposeTest/TestDispose.java @@ -35,14 +35,12 @@ import java.awt.FlowLayout; import java.awt.Frame; import java.awt.TextField; -import java.awt.Toolkit; +import java.awt.Robot; import java.lang.reflect.InvocationTargetException; import javax.swing.JFrame; import javax.swing.SwingUtilities; -import sun.awt.SunToolkit; - public class TestDispose { public static Frame frame = null; @@ -51,7 +49,13 @@ public class TestDispose { public void testDispose() throws InvocationTargetException, InterruptedException { - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + Robot robot; + try { + robot = new Robot(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } SwingUtilities.invokeAndWait(new Runnable() { @Override @@ -69,7 +73,7 @@ public class TestDispose { frame.setVisible(true); } }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { @Override @@ -77,7 +81,7 @@ public class TestDispose { frame.dispose(); } }); - toolkit.realSync(); + robot.waitForIdle(); } diff --git a/jdk/test/java/awt/TrayIcon/PopupMenuLeakTest/PopupMenuLeakTest.java b/jdk/test/java/awt/TrayIcon/PopupMenuLeakTest/PopupMenuLeakTest.java index 4d5dd7295f6..5220546fd63 100644 --- a/jdk/test/java/awt/TrayIcon/PopupMenuLeakTest/PopupMenuLeakTest.java +++ b/jdk/test/java/awt/TrayIcon/PopupMenuLeakTest/PopupMenuLeakTest.java @@ -26,12 +26,13 @@ @bug 8007220 @summary Reference to the popup leaks after the TrayIcon is removed @author Petr Pchelko + @library ../../../../lib/testlibrary/ + @build ExtendedRobot @run main/othervm -Xmx50m PopupMenuLeakTest */ import java.awt.*; import javax.swing.SwingUtilities; -import sun.awt.SunToolkit; import java.awt.image.BufferedImage; import java.lang.ref.WeakReference; @@ -42,8 +43,10 @@ public class PopupMenuLeakTest { static final AtomicReference> iconWeakReference = new AtomicReference<>(); static final AtomicReference> popupWeakReference = new AtomicReference<>(); + static ExtendedRobot robot; public static void main(String[] args) throws Exception { + robot = new ExtendedRobot(); SwingUtilities.invokeAndWait(PopupMenuLeakTest::createSystemTrayIcon); sleep(); // To make the test automatic we explicitly call addNotify on a popup to create the peer @@ -141,9 +144,6 @@ public class PopupMenuLeakTest { } private static void sleep() { - ((SunToolkit)Toolkit.getDefaultToolkit()).realSync(); - try { - Thread.sleep(100); - } catch (InterruptedException ignored) { } + robot.waitForIdle(100); } } diff --git a/jdk/test/java/awt/Window/8027025/Test8027025.java b/jdk/test/java/awt/Window/8027025/Test8027025.java index 44988904419..e798354264f 100644 --- a/jdk/test/java/awt/Window/8027025/Test8027025.java +++ b/jdk/test/java/awt/Window/8027025/Test8027025.java @@ -28,8 +28,6 @@ * @run main Test8027025 */ -import sun.awt.SunToolkit; - import javax.swing.*; import java.awt.*; import java.util.concurrent.atomic.AtomicReference; @@ -49,7 +47,8 @@ public class Test8027025 { window.setVisible(true); }); - ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); + Robot robot = new Robot(); + robot.waitForIdle(); AtomicReference point = new AtomicReference<>(); SwingUtilities.invokeAndWait(() -> point.set(window.getLocationOnScreen())); diff --git a/jdk/test/java/awt/Window/AlwaysOnTop/AlwaysOnTopFieldTest.java b/jdk/test/java/awt/Window/AlwaysOnTop/AlwaysOnTopFieldTest.java index 965eb7f5b07..5cfaa00419c 100644 --- a/jdk/test/java/awt/Window/AlwaysOnTop/AlwaysOnTopFieldTest.java +++ b/jdk/test/java/awt/Window/AlwaysOnTop/AlwaysOnTopFieldTest.java @@ -22,9 +22,8 @@ */ import java.awt.Dialog; import java.awt.Frame; -import java.awt.Toolkit; +import java.awt.Robot; import java.awt.Window; -import sun.awt.SunToolkit; /** * @test * @bug 7081594 @@ -35,19 +34,25 @@ import sun.awt.SunToolkit; public class AlwaysOnTopFieldTest { public static void main(String[] args) { - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + Robot robot; + try { + robot = new Robot(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } Window window = new Frame("Window 1"); window.setSize(200, 200); window.setAlwaysOnTop(true); window.setVisible(true); - toolkit.realSync(); + robot.waitForIdle(); Dialog dialog = new Dialog(window, "Owned dialog 1"); dialog.setSize(200, 200); dialog.setLocation(100, 100); dialog.setVisible(true); - toolkit.realSync(); + robot.waitForIdle(); try { if (!window.isAlwaysOnTop()) { @@ -64,17 +69,17 @@ public class AlwaysOnTopFieldTest { window = new Frame("Window 2"); window.setSize(200, 200); window.setVisible(true); - toolkit.realSync(); + robot.waitForIdle(); dialog = new Dialog(window, "Owned dialog 2"); dialog.setSize(200, 200); dialog.setLocation(100, 100); dialog.setVisible(true); - toolkit.realSync(); + robot.waitForIdle(); window.setAlwaysOnTop(true); - toolkit.realSync(); + robot.waitForIdle(); try { if (!window.isAlwaysOnTop()) { diff --git a/jdk/test/java/awt/Window/OwnedWindowsSerialization/OwnedWindowsSerialization.java b/jdk/test/java/awt/Window/OwnedWindowsSerialization/OwnedWindowsSerialization.java index 864c5add1df..9100c500674 100644 --- a/jdk/test/java/awt/Window/OwnedWindowsSerialization/OwnedWindowsSerialization.java +++ b/jdk/test/java/awt/Window/OwnedWindowsSerialization/OwnedWindowsSerialization.java @@ -21,8 +21,6 @@ * questions. */ -import sun.awt.SunToolkit; - import javax.swing.*; import java.awt.*; import java.io.ByteArrayInputStream; @@ -54,7 +52,8 @@ public class OwnedWindowsSerialization { subDialog = new Dialog(dialog, SUBDIALOG_LABEL); }); - ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); + Robot robot = new Robot(); + robot.waitForIdle(); if (!topFrame.isAlwaysOnTop() || !dialog.isAlwaysOnTop() || !subDialog.isAlwaysOnTop()) { throw new RuntimeException("TEST FAILED: AlwaysOnTop was not set properly"); diff --git a/jdk/test/java/awt/event/TextEvent/TextEventSequenceTest/TextEventSequenceTest.java b/jdk/test/java/awt/event/TextEvent/TextEventSequenceTest/TextEventSequenceTest.java index 7836b086f4e..0c06ba162eb 100644 --- a/jdk/test/java/awt/event/TextEvent/TextEventSequenceTest/TextEventSequenceTest.java +++ b/jdk/test/java/awt/event/TextEvent/TextEventSequenceTest/TextEventSequenceTest.java @@ -30,7 +30,6 @@ */ import java.awt.*; import java.awt.event.*; -import sun.awt.SunToolkit; public class TextEventSequenceTest { @@ -48,43 +47,50 @@ public class TextEventSequenceTest { } private static void test(String test) { - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + + Robot robot; + try { + robot = new Robot(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } createAndShowGUI(test); - toolkit.realSync(); + robot.waitForIdle(); initCounts(); t.setText("Hello "); - toolkit.realSync(); + robot.waitForIdle(); t.append("World! !"); - toolkit.realSync(); + robot.waitForIdle(); t.insert("from Roger Pham", 13); - toolkit.realSync(); + robot.waitForIdle(); t.replaceRange("Java Duke", 18, 28); - toolkit.realSync(); + robot.waitForIdle(); checkCounts(0, 4); initCounts(); t.setText(""); - toolkit.realSync(); + robot.waitForIdle(); t.setText(""); - toolkit.realSync(); + robot.waitForIdle(); t.setText(""); - toolkit.realSync(); + robot.waitForIdle(); checkCounts(1, 0); initCounts(); tf.setText("Hello There!"); - toolkit.realSync(); + robot.waitForIdle(); checkCounts(0, 1); initCounts(); tf.setText(""); - toolkit.realSync(); + robot.waitForIdle(); tf.setText(""); - toolkit.realSync(); + robot.waitForIdle(); tf.setText(""); - toolkit.realSync(); + robot.waitForIdle(); checkCounts(1, 0); f.dispose(); diff --git a/jdk/test/java/awt/security/WarningWindowDisposeTest/WarningWindowDisposeCrashTest.java b/jdk/test/java/awt/security/WarningWindowDisposeTest/WarningWindowDisposeCrashTest.java index 298059054d9..25e03d61646 100644 --- a/jdk/test/java/awt/security/WarningWindowDisposeTest/WarningWindowDisposeCrashTest.java +++ b/jdk/test/java/awt/security/WarningWindowDisposeTest/WarningWindowDisposeCrashTest.java @@ -26,26 +26,25 @@ @bug 8041490 @summary tests that the WarningWindow's surface is invalidated on dispose @author Petr Pchelko - @run main/othervm WarningWindowDisposeCrashTest + @run main/othervm/policy=policy -Djava.security.manager WarningWindowDisposeCrashTest */ -import sun.applet.AppletSecurity; -import sun.awt.SunToolkit; import java.awt.*; public class WarningWindowDisposeCrashTest { public static void main(String[] args) throws Exception { - System.setSecurityManager(new AppletSecurity() { - @Override - public void checkPackageAccess (String s){ - } - }); - Frame f = new Frame(); f.setVisible(true); - ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); + Robot robot; + try{ + robot = new Robot(); + robot.waitForIdle(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Cannot create Robot"); + } Thread.sleep(1000); f.dispose(); // If the bug is present VM could crash after this call diff --git a/jdk/test/java/awt/security/WarningWindowDisposeTest/WarningWindowDisposeTest.java b/jdk/test/java/awt/security/WarningWindowDisposeTest/WarningWindowDisposeTest.java index 6f0149dc4d1..3f525e967d9 100644 --- a/jdk/test/java/awt/security/WarningWindowDisposeTest/WarningWindowDisposeTest.java +++ b/jdk/test/java/awt/security/WarningWindowDisposeTest/WarningWindowDisposeTest.java @@ -31,12 +31,11 @@ @run main WarningWindowDisposeTest */ -import sun.applet.AppletSecurity; -import sun.awt.SunToolkit; - import java.awt.*; import java.awt.Toolkit; import java.util.concurrent.atomic.AtomicBoolean; +import java.security.Permission; +import java.io.File; import test.java.awt.regtesthelpers.process.ProcessCommunicator; import test.java.awt.regtesthelpers.process.ProcessResults; @@ -57,7 +56,9 @@ public class WarningWindowDisposeTest { }, "TimeoutThread").start(); String classpath = System.getProperty("java.class.path"); - ProcessResults pres = ProcessCommunicator.executeChildProcess(TestApplication.class, classpath, new String[0]); + String policyPath = System.getProperty("test.src")+File.separatorChar+"policy"; + System.out.println("policyPath in main: "+policyPath); + ProcessResults pres = ProcessCommunicator.executeChildProcess(TestApplication.class, classpath+" -Djava.security.manager -Djava.security.policy="+policyPath, new String[0]); passed.set(true); if (pres.getStdErr() != null && pres.getStdErr().length() > 0) { System.err.println("========= Child VM System.err ========"); @@ -74,14 +75,16 @@ public class WarningWindowDisposeTest { public static class TestApplication { public static void main(String[] args) throws Exception { - System.setSecurityManager(new AppletSecurity() { - @Override - public void checkPackageAccess (String s){ - } - }); + Robot robot; + try{ + robot = new Robot(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Cannot create Robot"); + } Frame f = new Frame("Test frame"); f.setVisible(true); - ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); + robot.waitForIdle(); Thread.sleep(500); f.setVisible(false); f.dispose(); From 41d2bc7e75c358daf3c0def4bbbdcc8371ed46f1 Mon Sep 17 00:00:00 2001 From: Yuri Nesterenko Date: Mon, 10 Nov 2014 16:37:40 +0300 Subject: [PATCH 18/67] 8063106: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 1 Reviewed-by: pchelko, serb --- .../plaf/windows/8016551/bug8016551.java | 7 +- .../CompEventOnHiddenComponent.java | 441 ++++++++++++++++++ .../Window/GetWindowsTest/GetWindowsTest.java | 271 +++++++++++ .../HandleWindowDestroyTest.html | 23 + .../HandleWindowDestroyTest.java | 96 ++++ .../MovedResizedTwiceTest.java | 276 +++++++++++ .../security/WarningWindowDisposeTest/policy | 3 + .../JButtonPaintNPE/JButtonPaintNPE.java | 15 +- .../swing/JComboBox/6406264/bug6406264.java | 118 +++++ .../swing/JComboBox/8015300/Test8015300.java | 17 +- .../ShowPopupAfterHidePopupTest.java | 9 +- .../swing/JComponent/6989617/bug6989617.java | 12 +- .../swing/JEditorPane/4492274/bug4492274.java | 9 +- .../JInternalFrame/4251301/bug4251301.java | 9 +- .../JInternalFrame/6647340/bug6647340.java | 31 +- .../JInternalFrame/6725409/bug6725409.java | 23 +- .../swing/JLayer/6824395/bug6824395.java | 12 +- .../swing/JPopupMenu/6583251/bug6583251.java | 77 +++ .../swing/JPopupMenu/6691503/bug6691503.java | 10 +- .../swing/JPopupMenu/6694823/bug6694823.java | 19 +- .../swing/JScrollBar/4865918/bug4865918.java | 7 +- .../swing/JScrollPane/6274267/bug6274267.java | 100 ++++ .../swing/JSpinner/8008657/bug8008657.java | 17 +- .../swing/JSplitPane/4816114/bug4816114.java | 7 +- .../JTabbedPane/7024235/Test7024235.java | 14 +- .../swing/JTabbedPane/7170310/bug7170310.java | 17 +- .../swing/JTabbedPane/8017284/bug8017284.java | 7 +- .../swing/JTable/8032874/bug8032874.java | 8 +- .../swing/JTextArea/7049024/bug7049024.java | 14 +- .../swing/JToolBar/4529206/bug4529206.java | 91 ++++ .../swing/JViewport/7107099/bug7107099.java | 9 +- .../javax/swing/Popup/6514582/bug6514582.java | 73 +++ .../IconifyTest/IconifyTest.java | 7 +- .../swing/Security/6657138/ComponentTest.java | 8 +- jdk/test/javax/swing/SwingTest.java | 8 +- .../swing/text/Utilities/bug7045593.java | 5 +- .../swing/text/View/8048110/bug8048110.java | 7 +- .../swing/text/html/7189299/bug7189299.java | 7 +- .../html/HTMLDocument/8058120/bug8058120.java | 14 +- .../HTMLEditorKit/4242228/bug4242228.java | 5 +- .../parser/Parser/7165725/bug7165725.java | 6 +- 41 files changed, 1760 insertions(+), 149 deletions(-) create mode 100644 jdk/test/java/awt/Component/CompEventOnHiddenComponent/CompEventOnHiddenComponent.java create mode 100644 jdk/test/java/awt/Window/GetWindowsTest/GetWindowsTest.java create mode 100644 jdk/test/java/awt/Window/HandleWindowDestroyTest/HandleWindowDestroyTest.html create mode 100644 jdk/test/java/awt/Window/HandleWindowDestroyTest/HandleWindowDestroyTest.java create mode 100644 jdk/test/java/awt/event/ComponentEvent/MovedResizedTwiceTest/MovedResizedTwiceTest.java create mode 100644 jdk/test/java/awt/security/WarningWindowDisposeTest/policy create mode 100644 jdk/test/javax/swing/JComboBox/6406264/bug6406264.java create mode 100644 jdk/test/javax/swing/JPopupMenu/6583251/bug6583251.java create mode 100644 jdk/test/javax/swing/JScrollPane/6274267/bug6274267.java create mode 100644 jdk/test/javax/swing/JToolBar/4529206/bug4529206.java create mode 100644 jdk/test/javax/swing/Popup/6514582/bug6514582.java diff --git a/jdk/test/com/sun/java/swing/plaf/windows/8016551/bug8016551.java b/jdk/test/com/sun/java/swing/plaf/windows/8016551/bug8016551.java index 35e55f09174..23c46ff533d 100644 --- a/jdk/test/com/sun/java/swing/plaf/windows/8016551/bug8016551.java +++ b/jdk/test/com/sun/java/swing/plaf/windows/8016551/bug8016551.java @@ -30,8 +30,7 @@ import javax.swing.*; import java.awt.Graphics; -import java.awt.Toolkit; -import sun.awt.SunToolkit; +import java.awt.Robot; public class bug8016551 { private static volatile RuntimeException exception = null; @@ -64,8 +63,8 @@ public class bug8016551 { } }); - SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); - tk.realSync(); + Robot robot = new Robot(); + robot.waitForIdle(); if (exception != null) { throw exception; diff --git a/jdk/test/java/awt/Component/CompEventOnHiddenComponent/CompEventOnHiddenComponent.java b/jdk/test/java/awt/Component/CompEventOnHiddenComponent/CompEventOnHiddenComponent.java new file mode 100644 index 00000000000..43a6d326702 --- /dev/null +++ b/jdk/test/java/awt/Component/CompEventOnHiddenComponent/CompEventOnHiddenComponent.java @@ -0,0 +1,441 @@ +/* + * Copyright (c) 2006, 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. + */ + +/* + @test + @bug 6383903 + @summary REGRESSION: componentMoved is now getting called for some hidden components + @author andrei.dmitriev: area=awt.component + @run main CompEventOnHiddenComponent +*/ + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +public class CompEventOnHiddenComponent +{ + transient static boolean moved = false; + transient static boolean resized = false; + + transient static boolean ancestor_moved = false; + transient static boolean ancestor_resized = false; + static String passed = ""; + + private static void init() + { + String[] instructions = + { + "This is an AUTOMATIC test, simply wait until it is done.", + "The result (passed or failed) will be shown in the", + "message window below." + }; + Sysout.createDialog( ); + Sysout.printInstructions( instructions ); + + Robot robot; + try { + robot = new Robot(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } + + EventQueue.invokeLater(new Runnable(){ + public void run(){ + JFrame f = new JFrame("JFrame"); + JButton b = new JButton("JButton"); + f.add(b); + new JOptionPane(). + createInternalFrame(b, "Test"). + addComponentListener(new ComponentAdapter() { + public void componentMoved(ComponentEvent e) { + moved = true; + System.out.println(e); + } + public void componentResized(ComponentEvent e) { + resized = true; + System.out.println(e); + } + }); + } + }); + + robot.waitForIdle(); + + if (moved || resized){ + passed = "Hidden component got COMPONENT_MOVED or COMPONENT_RESIZED event"; + } else { + System.out.println("Stage 1 passed."); + } + + EventQueue.invokeLater(new Runnable() { + public void run() { + JFrame parentWindow = new JFrame("JFrame 1"); + JButton component = new JButton("JButton 1");; + JButton smallButton = new JButton("Small Button"); + + + smallButton.addHierarchyBoundsListener(new HierarchyBoundsAdapter() { + public void ancestorMoved(HierarchyEvent e) { + ancestor_moved = true; + System.out.println("SMALL COMPONENT >>>>>"+e); + } + public void ancestorResized(HierarchyEvent e) { + ancestor_resized = true; + System.out.println("SMALL COMPONENT >>>>>"+e); + } + }); + + + parentWindow.add(component); + component.add(smallButton); + + component.setSize(100, 100); + component.setLocation(100, 100); + + } + }); + + robot.waitForIdle(); + + if (!ancestor_resized || !ancestor_moved){ + passed = "Hidden component didn't get ANCESTOR event"; + } else { + System.out.println("Stage 2 passed."); + } + + robot.waitForIdle(); + + if (passed.equals("")){ + CompEventOnHiddenComponent.pass(); + } else { + CompEventOnHiddenComponent.fail(passed); + } + + }//End init() + + + + /***************************************************** + * Standard Test Machinery Section + * DO NOT modify anything in this section -- it's a + * standard chunk of code which has all of the + * synchronisation necessary for the test harness. + * By keeping it the same in all tests, it is easier + * to read and understand someone else's test, as + * well as insuring that all tests behave correctly + * with the test harness. + * There is a section following this for test- + * classes + ******************************************************/ + private static boolean theTestPassed = false; + private static boolean testGeneratedInterrupt = false; + private static String failureMessage = ""; + + private static Thread mainThread = null; + + private static int sleepTime = 300000; + + // Not sure about what happens if multiple of this test are + // instantiated in the same VM. Being static (and using + // static vars), it aint gonna work. Not worrying about + // it for now. + public static void main( String args[] ) throws InterruptedException + { + mainThread = Thread.currentThread(); + try + { + init(); + } + catch( TestPassedException e ) + { + //The test passed, so just return from main and harness will + // interepret this return as a pass + return; + } + //At this point, neither test pass nor test fail has been + // called -- either would have thrown an exception and ended the + // test, so we know we have multiple threads. + + //Test involves other threads, so sleep and wait for them to + // called pass() or fail() + try + { + Thread.sleep( sleepTime ); + //Timed out, so fail the test + throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" ); + } + catch (InterruptedException e) + { + //The test harness may have interrupted the test. If so, rethrow the exception + // so that the harness gets it and deals with it. + if( ! testGeneratedInterrupt ) throw e; + + //reset flag in case hit this code more than once for some reason (just safety) + testGeneratedInterrupt = false; + + if ( theTestPassed == false ) + { + throw new RuntimeException( failureMessage ); + } + } + + }//main + + public static synchronized void setTimeoutTo( int seconds ) + { + sleepTime = seconds * 1000; + } + + public static synchronized void pass() + { + Sysout.println( "The test passed." ); + Sysout.println( "The test is over, hit Ctl-C to stop Java VM" ); + //first check if this is executing in main thread + if ( mainThread == Thread.currentThread() ) + { + //Still in the main thread, so set the flag just for kicks, + // and throw a test passed exception which will be caught + // and end the test. + theTestPassed = true; + throw new TestPassedException(); + } + theTestPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + }//pass() + + public static synchronized void fail() + { + //test writer didn't specify why test failed, so give generic + fail( "it just plain failed! :-)" ); + } + + public static synchronized void fail( String whyFailed ) + { + Sysout.println( "The test failed: " + whyFailed ); + Sysout.println( "The test is over, hit Ctl-C to stop Java VM" ); + //check if this called from main thread + if ( mainThread == Thread.currentThread() ) + { + //If main thread, fail now 'cause not sleeping + throw new RuntimeException( whyFailed ); + } + theTestPassed = false; + testGeneratedInterrupt = true; + failureMessage = whyFailed; + mainThread.interrupt(); + }//fail() + +}// class CompEventOnHiddenComponent + +//This exception is used to exit from any level of call nesting +// when it's determined that the test has passed, and immediately +// end the test. +class TestPassedException extends RuntimeException +{ +} + +//*********** End Standard Test Machinery Section ********** + + +//************ Begin classes defined for the test **************** + +// if want to make listeners, here is the recommended place for them, then instantiate +// them in init() + +/* Example of a class which may be written as part of a test +class NewClass implements anInterface + { + static int newVar = 0; + + public void eventDispatched(AWTEvent e) + { + //Counting events to see if we get enough + eventCount++; + + if( eventCount == 20 ) + { + //got enough events, so pass + + CompEventOnHiddenComponent.pass(); + } + else if( tries == 20 ) + { + //tried too many times without getting enough events so fail + + CompEventOnHiddenComponent.fail(); + } + + }// eventDispatched() + + }// NewClass class + +*/ + + +//************** End classes defined for the test ******************* + + + + +/**************************************************** + 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.setVisible(true); + 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.setVisible(true); + 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 ); + System.out.println(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("Center", messageText); + + pack(); + + setVisible(true); + }// 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" ); + System.out.println(messageIn); + } + +}// TestDialog class diff --git a/jdk/test/java/awt/Window/GetWindowsTest/GetWindowsTest.java b/jdk/test/java/awt/Window/GetWindowsTest/GetWindowsTest.java new file mode 100644 index 00000000000..e1a9482cd39 --- /dev/null +++ b/jdk/test/java/awt/Window/GetWindowsTest/GetWindowsTest.java @@ -0,0 +1,271 @@ +/* + * Copyright (c) 2005, 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. + */ + +/* + @test + @bug 6322270 + @summary Test for new API introduced in the fix for 6322270: Window.getWindows(), +Window.getOwnerlessWindows() and Frame.getFrames() + @author artem.ananiev: area=awt.toplevel + @run main GetWindowsTest +*/ + +import java.awt.*; +import java.awt.event.*; + +import java.util.*; + +public class GetWindowsTest +{ + private static Vector frames = new Vector(); + private static Vector windows = new Vector(); + private static Vector ownerless = new Vector(); + + private static void init() + { + Frame f1 = new Frame("F1"); + f1.setBounds(100, 100, 100, 100); + f1.setVisible(true); + addToWindowsList(f1); + + Dialog d1 = new Dialog(f1, "D1", Dialog.ModalityType.MODELESS); + d1.setBounds(120, 120, 100, 100); + d1.setVisible(true); + addToWindowsList(d1); + + Window w1 = new Window(d1); + w1.setBounds(140, 140, 100, 100); + w1.setVisible(true); + addToWindowsList(w1); + + Frame f2 = new Frame("F2"); + f2.setBounds(300, 100, 100, 100); + f2.setVisible(true); + addToWindowsList(f2); + + Window w2 = new Window(f2); + w2.setBounds(320, 120, 100, 100); + w2.setVisible(true); + addToWindowsList(w2); + + Dialog d2 = new Dialog(f2, "D2", Dialog.ModalityType.MODELESS); + d2.setBounds(340, 140, 100, 100); + d2.setVisible(true); + addToWindowsList(d2); + + Dialog d3 = new Dialog((Frame)null, "D3", Dialog.ModalityType.MODELESS); + d3.setBounds(500, 100, 100, 100); + d3.setVisible(true); + addToWindowsList(d3); + + Dialog d4 = new Dialog(d3, "D4", Dialog.ModalityType.MODELESS); + d4.setBounds(520, 120, 100, 100); + d4.setVisible(true); + addToWindowsList(d4); + + Window w3 = new Window((Frame)null); + w3.setBounds(700, 100, 100, 100); + w3.setVisible(true); + addToWindowsList(w3); + + Window w4 = new Window(w3); + w4.setBounds(720, 120, 100, 100); + w4.setVisible(true); + addToWindowsList(w4); + + try { + Robot robot = new Robot(); + robot.waitForIdle(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new Error("Unexpected failure"); + } + + Frame[] fl = Frame.getFrames(); + Vector framesToCheck = new Vector(); + for (Frame f : fl) + { + framesToCheck.add(f); + } + checkWindowsList(frames, framesToCheck, "Frame.getFrames()"); + + Window[] wl = Window.getWindows(); + Vector windowsToCheck = new Vector(); + for (Window w : wl) + { + windowsToCheck.add(w); + } + checkWindowsList(windows, windowsToCheck, "Window.getWindows()"); + + Window[] ol = Window.getOwnerlessWindows(); + Vector ownerlessToCheck = new Vector(); + for (Window o : ol) + { + ownerlessToCheck.add(o); + } + checkWindowsList(ownerless, ownerlessToCheck, "Window.getOwnerlessWindows()"); + + GetWindowsTest.pass(); + } + + private static void addToWindowsList(Window w) + { + if (w instanceof Frame) + { + frames.add(w); + } + windows.add(w); + if (w.getOwner() == null) + { + ownerless.add(w); + } + } + + private static void checkWindowsList(Vector wl1, Vector wl2, String methodName) + { + if ((wl1.size() != wl2.size()) || + !wl1.containsAll(wl2) || + !wl2.containsAll(wl1)) + { + fail("Test FAILED: method " + methodName + " returns incorrect list of windows"); + } + } + +/***************************************************** + * Standard Test Machinery Section + * DO NOT modify anything in this section -- it's a + * standard chunk of code which has all of the + * synchronisation necessary for the test harness. + * By keeping it the same in all tests, it is easier + * to read and understand someone else's test, as + * well as insuring that all tests behave correctly + * with the test harness. + * There is a section following this for test- + * classes + ******************************************************/ + + private static boolean theTestPassed = false; + private static boolean testGeneratedInterrupt = false; + private static String failureMessage = ""; + + private static Thread mainThread = null; + + private static int sleepTime = 300000; + + // Not sure about what happens if multiple of this test are + // instantiated in the same VM. Being static (and using + // static vars), it aint gonna work. Not worrying about + // it for now. + public static void main( String args[] ) throws InterruptedException + { + mainThread = Thread.currentThread(); + try + { + init(); + } + catch( TestPassedException e ) + { + //The test passed, so just return from main and harness will + // interepret this return as a pass + return; + } + //At this point, neither test pass nor test fail has been + // called -- either would have thrown an exception and ended the + // test, so we know we have multiple threads. + + //Test involves other threads, so sleep and wait for them to + // called pass() or fail() + try + { + Thread.sleep( sleepTime ); + //Timed out, so fail the test + throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" ); + } + catch (InterruptedException e) + { + //The test harness may have interrupted the test. If so, rethrow the exception + // so that the harness gets it and deals with it. + if( ! testGeneratedInterrupt ) throw e; + + //reset flag in case hit this code more than once for some reason (just safety) + testGeneratedInterrupt = false; + + if ( theTestPassed == false ) + { + throw new RuntimeException( failureMessage ); + } + } + } + + public static synchronized void setTimeoutTo( int seconds ) + { + sleepTime = seconds * 1000; + } + + public static synchronized void pass() + { + //first check if this is executing in main thread + if ( mainThread == Thread.currentThread() ) + { + //Still in the main thread, so set the flag just for kicks, + // and throw a test passed exception which will be caught + // and end the test. + theTestPassed = true; + throw new TestPassedException(); + } + theTestPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + public static synchronized void fail() + { + //test writer didn't specify why test failed, so give generic + fail( "it just plain failed! :-)" ); + } + + public static synchronized void fail( String whyFailed ) + { + //check if this called from main thread + if ( mainThread == Thread.currentThread() ) + { + //If main thread, fail now 'cause not sleeping + throw new RuntimeException( whyFailed ); + } + theTestPassed = false; + testGeneratedInterrupt = true; + failureMessage = whyFailed; + mainThread.interrupt(); + } +} + +//This exception is used to exit from any level of call nesting +// when it's determined that the test has passed, and immediately +// end the test. +class TestPassedException extends RuntimeException +{ +} + +//*********** End Standard Test Machinery Section ********** diff --git a/jdk/test/java/awt/Window/HandleWindowDestroyTest/HandleWindowDestroyTest.html b/jdk/test/java/awt/Window/HandleWindowDestroyTest/HandleWindowDestroyTest.html new file mode 100644 index 00000000000..aea7f2317e6 --- /dev/null +++ b/jdk/test/java/awt/Window/HandleWindowDestroyTest/HandleWindowDestroyTest.html @@ -0,0 +1,23 @@ + + + + + + + +

HandleWindowDestroyTest
Bug ID: 6260648

+ +

This is an AUTOMATIC test, simply wait for completion

+ + + + + diff --git a/jdk/test/java/awt/Window/HandleWindowDestroyTest/HandleWindowDestroyTest.java b/jdk/test/java/awt/Window/HandleWindowDestroyTest/HandleWindowDestroyTest.java new file mode 100644 index 00000000000..fffcf18dc3b --- /dev/null +++ b/jdk/test/java/awt/Window/HandleWindowDestroyTest/HandleWindowDestroyTest.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2005, 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. + */ + +/* + test + @bug 6260648 + @summary Tests that WINDOW_DESTROY event can be handled by overriding handleEvent(). Also, +tests that handleEvent() is not called by AWT if any listener is added to the component +(i. e. when post-1.1 events schema is used) + @author artem.ananiev: area=awt.event + @run applet HandleWindowDestroyTest.html +*/ + +import java.applet.*; + +import java.awt.*; +import java.awt.event.*; + +public class HandleWindowDestroyTest extends Applet +{ + private volatile boolean handleEventCalled; + + public void start () + { + setSize (200,200); + setVisible(true); + validate(); + + Robot robot; + try { + robot = new Robot(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } + + Frame f = new Frame("Frame") + { + public boolean handleEvent(Event e) + { + if (e.id == Event.WINDOW_DESTROY) + { + handleEventCalled = true; + } + return super.handleEvent(e); + } + }; + f.setBounds(100, 100, 100, 100); + f.setVisible(true); + robot.waitForIdle(); + + handleEventCalled = false; + Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new WindowEvent(f, Event.WINDOW_DESTROY)); + robot.waitForIdle(); + + if (!handleEventCalled) + { + throw new RuntimeException("Test FAILED: handleEvent() is not called"); + } + + f.addWindowListener(new WindowAdapter() + { + }); + + handleEventCalled = false; + Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new WindowEvent(f, Event.WINDOW_DESTROY)); + robot.waitForIdle(); + + if (handleEventCalled) + { + throw new RuntimeException("Test FAILED: handleEvent() is called event with a listener added"); + } + } +} diff --git a/jdk/test/java/awt/event/ComponentEvent/MovedResizedTwiceTest/MovedResizedTwiceTest.java b/jdk/test/java/awt/event/ComponentEvent/MovedResizedTwiceTest/MovedResizedTwiceTest.java new file mode 100644 index 00000000000..d88c54d9fab --- /dev/null +++ b/jdk/test/java/awt/event/ComponentEvent/MovedResizedTwiceTest/MovedResizedTwiceTest.java @@ -0,0 +1,276 @@ +/* + * Copyright (c) 2005, 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. + */ + +/* + @test + @bug 5025858 + @summary Tests that after programmatically moving or resizing a component, +corresponding ComponentEvents are generated only once + @author artem.ananiev: area=awt.event + @run main/manual MovedResizedTwiceTest +*/ + +import java.awt.*; +import java.awt.event.*; + +/* + IMPORTANT: this test is made manual as some window managers may generate + strange events and that would lead to the test to fail. However, on most + popular platforms (windows, linux w/ KDE or GNOME, solaris w/ CDE or + GNOME) it usually passes successfully. +*/ + +public class MovedResizedTwiceTest +{ + private static volatile int componentMovedCount; + private static volatile int componentResizedCount; + + private static volatile int rightX, rightY; + + private static volatile boolean failed = false; + + private static void init() + { + componentMovedCount = componentResizedCount = 0; + + Robot robot; + try { + robot = new Robot(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Cannot create Robot: failure"); + } + + Frame f = new Frame("Frame F"); + f.setLayout(null); + f.setBounds(100, 100, 100, 100); + f.add(new Button("Button")); + + f.setVisible(true); + robot.waitForIdle(); + + ComponentListener cl = new ComponentAdapter() + { + public void componentMoved(ComponentEvent e) + { + componentMovedCount++; + Component c = (Component)e.getSource(); + if (!(c instanceof Window)) + { + return; + } + Point p = c.getLocationOnScreen(); + if ((p.x != rightX) || (p.y != rightY)) + { + System.err.println("Error: wrong location on screen after COMPONENT_MOVED"); + System.err.println("Location on screen is (" + p.x + ", " + p.y + ") against right location (" + rightX + ", " + rightY + ")"); + failed = true; + } + } + public void componentResized(ComponentEvent e) + { + componentResizedCount++; + } + }; + + f.addComponentListener(cl); + + componentResizedCount = componentMovedCount = 0; + rightX = 100; + rightY = 100; + f.setSize(200, 200); + robot.waitForIdle(); + checkResized("setSize", f); + + componentResizedCount = componentMovedCount = 0; + rightX = 200; + rightY = 200; + f.setLocation(200, 200); + robot.waitForIdle(); + checkMoved("setLocation", f); + + componentResizedCount = componentMovedCount = 0; + rightX = 150; + rightY = 150; + f.setBounds(150, 150, 100, 100); + robot.waitForIdle(); + checkResized("setBounds", f); + checkMoved("setBounds", f); + + Button b = new Button("B"); + b.setBounds(10, 10, 40, 40); + f.add(b); + robot.waitForIdle(); + + b.addComponentListener(cl); + + componentResizedCount = componentMovedCount = 0; + b.setBounds(20, 20, 50, 50); + robot.waitForIdle(); + checkMoved("setBounds", b); + checkResized("setBounds", b); + f.remove(b); + + Component c = new Component() {}; + c.setBounds(10, 10, 40, 40); + f.add(c); + robot.waitForIdle(); + + c.addComponentListener(cl); + + componentResizedCount = componentMovedCount = 0; + c.setBounds(20, 20, 50, 50); + robot.waitForIdle(); + checkMoved("setBounds", c); + checkResized("setBounds", c); + f.remove(c); + + if (failed) + { + MovedResizedTwiceTest.fail("Test FAILED"); + } + else + { + MovedResizedTwiceTest.pass(); + } + } + + private static void checkResized(String methodName, Component c) + { + String failMessage = null; + if (componentResizedCount == 1) + { + return; + } + else if (componentResizedCount == 0) + { + failMessage = "Test FAILED: COMPONENT_RESIZED is not sent after call to " + methodName + "()"; + } + else + { + failMessage = "Test FAILED: COMPONENT_RESIZED is sent " + componentResizedCount + " + times after call to " + methodName + "()"; + } + System.err.println("Failed component: " + c); + MovedResizedTwiceTest.fail(failMessage); + } + + private static void checkMoved(String methodName, Component c) + { + String failMessage = null; + if (componentMovedCount == 1) + { + return; + } + if (componentMovedCount == 0) + { + failMessage = "Test FAILED: COMPONENT_MOVED is not sent after call to " + methodName + "()"; + } + else + { + failMessage = "Test FAILED: COMPONENT_MOVED is sent " + componentMovedCount + " times after call to " + methodName + "()"; + } + System.err.println("Failed component: " + c); + MovedResizedTwiceTest.fail(failMessage); + } + + private static boolean theTestPassed = false; + private static boolean testGeneratedInterrupt = false; + private static String failureMessage = ""; + + private static Thread mainThread = null; + + private static int sleepTime = 300000; + + public static void main( String args[] ) throws InterruptedException + { + mainThread = Thread.currentThread(); + try + { + init(); + } + catch (TestPassedException e) + { + return; + } + + try + { + Thread.sleep(sleepTime); + throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" ); + } + catch (InterruptedException e) + { + if (!testGeneratedInterrupt) + { + throw e; + } + + testGeneratedInterrupt = false; + + if (!theTestPassed) + { + throw new RuntimeException( failureMessage ); + } + } + } + + public static synchronized void setTimeoutTo(int seconds) + { + sleepTime = seconds * 1000; + } + + public static synchronized void pass() + { + if (mainThread == Thread.currentThread()) + { + theTestPassed = true; + throw new TestPassedException(); + } + theTestPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + public static synchronized void fail() + { + fail("it just plain failed! :-)"); + } + + public static synchronized void fail(String whyFailed) + { + if (mainThread == Thread.currentThread()) + { + throw new RuntimeException(whyFailed); + } + theTestPassed = false; + testGeneratedInterrupt = true; + failureMessage = whyFailed; + mainThread.interrupt(); + } +} + +class TestPassedException extends RuntimeException +{ +} diff --git a/jdk/test/java/awt/security/WarningWindowDisposeTest/policy b/jdk/test/java/awt/security/WarningWindowDisposeTest/policy new file mode 100644 index 00000000000..22405359e59 --- /dev/null +++ b/jdk/test/java/awt/security/WarningWindowDisposeTest/policy @@ -0,0 +1,3 @@ +grant { + permission java.awt.AWTPermission "createRobot"; +}; diff --git a/jdk/test/javax/swing/JButton/JButtonPaintNPE/JButtonPaintNPE.java b/jdk/test/javax/swing/JButton/JButtonPaintNPE/JButtonPaintNPE.java index 75e49967aa7..e0182a5fc03 100644 --- a/jdk/test/javax/swing/JButton/JButtonPaintNPE/JButtonPaintNPE.java +++ b/jdk/test/javax/swing/JButton/JButtonPaintNPE/JButtonPaintNPE.java @@ -31,12 +31,13 @@ import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.SwingUtilities; -import sun.awt.SunToolkit; - /** * @test * @bug 8009919 * @author Sergey Bylokhov + * @library ../../../../lib/testlibrary/ + * @build ExtendedRobot + * @run main JButtonPaintNPE */ public final class JButtonPaintNPE { @@ -69,9 +70,11 @@ public final class JButtonPaintNPE { private static void sleep() { try { - ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); - Thread.sleep(1000); - } catch (final InterruptedException ignored) { - } + ExtendedRobot robot = new ExtendedRobot(); + robot.waitForIdle(1000); + }catch(Exception ex) { + ex.printStackTrace(); + throw new Error("Unexpected Failure"); + } } } diff --git a/jdk/test/javax/swing/JComboBox/6406264/bug6406264.java b/jdk/test/javax/swing/JComboBox/6406264/bug6406264.java new file mode 100644 index 00000000000..91356c3d476 --- /dev/null +++ b/jdk/test/javax/swing/JComboBox/6406264/bug6406264.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2006, 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. + */ + +/* @test + @bug 6406264 + @summary Tests that JComboBox's focusable popup can be shown. + @author Mikhail Lapshin + @run main bug6406264 + */ + +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import javax.swing.plaf.basic.BasicComboBoxUI; +import javax.swing.plaf.basic.ComboPopup; +import javax.swing.plaf.basic.BasicComboPopup; +import java.awt.*; + +public class bug6406264 extends JComboBox { + + static JFrame frame; + static bug6406264 comboBox; + + public static void main(String[] args) throws Exception { + + Robot robot = new Robot(); + // Setup and show frame + SwingUtilities.invokeAndWait( + new Runnable() { + public void run() { + frame = new JFrame("JComboBox6406264 test"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + comboBox = new bug6406264("One", "Two", "Three"); + frame.getContentPane().add(comboBox); + + frame.setLocationRelativeTo(null); + frame.pack(); + frame.setVisible(true); + } + } + ); + + robot.waitForIdle(); + + // Show popup + SwingUtilities.invokeAndWait( + new Runnable() { + public void run() { + comboBox.showPopup(); + } + }); + robot.waitForIdle(); + + // Check that popup is visible + SwingUtilities.invokeAndWait( + new Runnable() { + public void run() { + if (comboBox.getUI().isPopupVisible(comboBox) == false) + { + throw new RuntimeException("A focusable popup is not visible " + + "in JComboBox!"); + } + } + } + ); + + frame.dispose(); + } + + public bug6406264(Object ... items) { + super(items); + } + + public void updateUI() { + setUI(new CustomComboBoxUI()); + } + + // Use FocusablePopup for our JComboBox + private class CustomComboBoxUI extends BasicComboBoxUI { + protected ComboPopup createPopup() { + return new FocusablePopup(bug6406264.this); + } + } + + // Popup window which can take a focus + private class FocusablePopup extends BasicComboPopup { + public FocusablePopup(JComboBox combo) { + super(combo); + } + + public boolean isFocusable() { + return true; + } + } +} diff --git a/jdk/test/javax/swing/JComboBox/8015300/Test8015300.java b/jdk/test/javax/swing/JComboBox/8015300/Test8015300.java index 1fadfdbb9d1..37a8c0d6404 100644 --- a/jdk/test/javax/swing/JComboBox/8015300/Test8015300.java +++ b/jdk/test/javax/swing/JComboBox/8015300/Test8015300.java @@ -41,10 +41,13 @@ import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE; * @bug 8015300 * @summary Tests that editable combobox select all text * @author Sergey Malenkov + * @library ../../../../lib/testlibrary/ + * @build ExtendedRobot + * @run main Test8015300 */ public class Test8015300 { - private static final SunToolkit STK = (SunToolkit) Toolkit.getDefaultToolkit(); + private static final ExtendedRobot robot = createRobot(); private static final String[] ITEMS = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}; @@ -113,7 +116,15 @@ public class Test8015300 { combo.setSelectedIndex(index); } }); - STK.realSync(); - Thread.sleep(50L); + robot.waitForIdle(50); + } + private static ExtendedRobot createRobot() { + try { + ExtendedRobot robot = new ExtendedRobot(); + return robot; + }catch(Exception ex) { + ex.printStackTrace(); + throw new Error("Unexpected Failure"); + } } } diff --git a/jdk/test/javax/swing/JComboBox/ShowPopupAfterHidePopupTest/ShowPopupAfterHidePopupTest.java b/jdk/test/javax/swing/JComboBox/ShowPopupAfterHidePopupTest/ShowPopupAfterHidePopupTest.java index e015f5ed587..52b9e71ea29 100644 --- a/jdk/test/javax/swing/JComboBox/ShowPopupAfterHidePopupTest/ShowPopupAfterHidePopupTest.java +++ b/jdk/test/javax/swing/JComboBox/ShowPopupAfterHidePopupTest/ShowPopupAfterHidePopupTest.java @@ -25,6 +25,7 @@ @bug 8006417 @summary JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X @author Anton Litvinov + @run main ShowPopupAfterHidePopupTest */ import java.awt.*; @@ -32,8 +33,6 @@ import java.awt.*; import javax.swing.*; import javax.swing.plaf.metal.*; -import sun.awt.SunToolkit; - public class ShowPopupAfterHidePopupTest { private static JFrame frame = null; private static JComboBox comboBox = null; @@ -41,6 +40,7 @@ public class ShowPopupAfterHidePopupTest { public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new MetalLookAndFeel()); + Robot robot = new Robot(); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { @@ -51,8 +51,7 @@ public class ShowPopupAfterHidePopupTest { frame.setVisible(true); } }); - final SunToolkit toolkit = (SunToolkit)Toolkit.getDefaultToolkit(); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { @Override @@ -62,7 +61,7 @@ public class ShowPopupAfterHidePopupTest { comboBox.showPopup(); } }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { @Override diff --git a/jdk/test/javax/swing/JComponent/6989617/bug6989617.java b/jdk/test/javax/swing/JComponent/6989617/bug6989617.java index 23f3754b78a..a13201df761 100644 --- a/jdk/test/javax/swing/JComponent/6989617/bug6989617.java +++ b/jdk/test/javax/swing/JComponent/6989617/bug6989617.java @@ -28,8 +28,6 @@ @run main bug6989617 */ -import sun.awt.SunToolkit; - import javax.swing.*; import java.awt.*; @@ -38,7 +36,7 @@ public class bug6989617 { private static JButton button; public static void main(String... args) throws Exception { - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + Robot robot = new Robot(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { JFrame frame = new JFrame(); @@ -56,14 +54,14 @@ public class bug6989617 { // Testing the panel as a painting origin, // the panel.paintImmediately() must be triggered // when button.repaint() is called - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { panel.resetPaintRectangle(); button.repaint(); } }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { Rectangle pr = panel.getPaintRectangle(); @@ -78,7 +76,7 @@ public class bug6989617 { // Testing the panel as NOT a painting origin // the panel.paintImmediately() must NOT be triggered // when button.repaint() is called - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { panel.resetPaintRectangle(); @@ -89,7 +87,7 @@ public class bug6989617 { button.repaint(); } }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { if(panel.getPaintRectangle() != null) { diff --git a/jdk/test/javax/swing/JEditorPane/4492274/bug4492274.java b/jdk/test/javax/swing/JEditorPane/4492274/bug4492274.java index cf732a9c5f2..369f05f17a7 100644 --- a/jdk/test/javax/swing/JEditorPane/4492274/bug4492274.java +++ b/jdk/test/javax/swing/JEditorPane/4492274/bug4492274.java @@ -25,10 +25,9 @@ * @bug 4492274 * @summary Tests if JEditorPane.getPage() correctly returns anchor reference. * @author Denis Sharypov + * @run main bug4492274 */ -import sun.awt.SunToolkit; - import javax.swing.*; import javax.swing.text.html.HTMLEditorKit; import java.awt.*; @@ -42,8 +41,8 @@ public class bug4492274 { private static JEditorPane jep; public static void main(String args[]) throws Exception { - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + Robot robot = new Robot(); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { @@ -51,7 +50,7 @@ public class bug4492274 { } }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { @Override @@ -65,7 +64,7 @@ public class bug4492274 { } }); - toolkit.realSync(); + robot.waitForIdle(); if (getPageAnchor() == null) { throw new RuntimeException("JEditorPane.getPage() returns null anchor reference"); diff --git a/jdk/test/javax/swing/JInternalFrame/4251301/bug4251301.java b/jdk/test/javax/swing/JInternalFrame/4251301/bug4251301.java index 304d0582407..281b7ec08cd 100644 --- a/jdk/test/javax/swing/JInternalFrame/4251301/bug4251301.java +++ b/jdk/test/javax/swing/JInternalFrame/4251301/bug4251301.java @@ -24,6 +24,8 @@ @bug 4251301 @summary Keybinding for show/hide the system menu. @author Andrey Pikalev + @library ../../../../lib/testlibrary + @build jdk.testlibrary.OSInfo @run main/manual bug4251301 */ @@ -32,12 +34,10 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.*; -import sun.awt.OSInfo; -import sun.awt.SunToolkit; +import jdk.testlibrary.OSInfo; public class bug4251301 { - private static final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); static Test test = new Test(); public static void main(String[] args) throws Exception { if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) { @@ -50,7 +50,8 @@ public class bug4251301 { createAndShowGUI(); } }); - toolkit.realSync(); + Robot robot = new Robot(); + robot.waitForIdle(); test.waitTestResult(); } diff --git a/jdk/test/javax/swing/JInternalFrame/6647340/bug6647340.java b/jdk/test/javax/swing/JInternalFrame/6647340/bug6647340.java index de27c8f2a70..8bb1ffc92e1 100644 --- a/jdk/test/javax/swing/JInternalFrame/6647340/bug6647340.java +++ b/jdk/test/javax/swing/JInternalFrame/6647340/bug6647340.java @@ -26,10 +26,11 @@ * @summary Checks that iconified internal frame follows * the main frame borders properly. * @author Mikhail Lapshin + * @library ../../../../lib/testlibrary/ + * @build ExtendedRobot + * @run main bug6647340 */ -import sun.awt.SunToolkit; - import javax.swing.*; import java.awt.*; import java.beans.PropertyVetoException; @@ -38,6 +39,7 @@ public class bug6647340 { private JFrame frame; private Point location; private JInternalFrame jif; + private static ExtendedRobot robot = createRobot(); public static void main(String[] args) throws Exception { final bug6647340 test = new bug6647340(); @@ -74,13 +76,13 @@ public class bug6647340 { } private void test() throws Exception { - realSync(); + sync(); test1(); - realSync(); + sync(); check1(); - realSync(); + sync(); test2(); - realSync(); + sync(); check2(); } @@ -101,14 +103,14 @@ public class bug6647340 { setIcon(false); } }); - realSync(); + sync(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { Dimension size = frame.getSize(); frame.setSize(size.width - 100, size.height - 100); } }); - realSync(); + sync(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { setIcon(true); @@ -132,8 +134,17 @@ public class bug6647340 { } } - private static void realSync() { - ((SunToolkit) (Toolkit.getDefaultToolkit())).realSync(); + private static void sync() { + robot.waitForIdle(); + } + private static ExtendedRobot createRobot() { + try { + ExtendedRobot robot = new ExtendedRobot(); + return robot; + }catch(Exception ex) { + ex.printStackTrace(); + throw new Error("Unexpected Failure"); + } } private void setIcon(boolean b) { diff --git a/jdk/test/javax/swing/JInternalFrame/6725409/bug6725409.java b/jdk/test/javax/swing/JInternalFrame/6725409/bug6725409.java index 87443b4529f..6fb9b655b77 100644 --- a/jdk/test/javax/swing/JInternalFrame/6725409/bug6725409.java +++ b/jdk/test/javax/swing/JInternalFrame/6725409/bug6725409.java @@ -26,6 +26,9 @@ * @summary Checks that JInternalFrame's system menu * can be localized during run-time * @author Mikhail Lapshin + * @library ../../../../lib/testlibrary/ + * @build ExtendedRobot + * @run main bug6725409 */ import javax.swing.*; @@ -36,6 +39,7 @@ public class bug6725409 { private JInternalFrame iFrame; private TestTitlePane testTitlePane; private boolean passed; + private static ExtendedRobot robot = createRobot(); public static void main(String[] args) throws Exception { try { @@ -53,19 +57,19 @@ public class bug6725409 { bug6725409.setupUIStep1(); } }); - realSync(); + sync(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { bug6725409.setupUIStep2(); } }); - realSync(); + sync(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { bug6725409.test(); } }); - realSync(); + sync(); bug6725409.checkResult(); } finally { if (bug6725409.frame != null) { @@ -137,8 +141,17 @@ public class bug6725409 { } } - private static void realSync() { - ((sun.awt.SunToolkit) (Toolkit.getDefaultToolkit())).realSync(); + private static void sync() { + robot.waitForIdle(); + } + private static ExtendedRobot createRobot() { + try { + ExtendedRobot robot = new ExtendedRobot(); + return robot; + }catch(Exception ex) { + ex.printStackTrace(); + throw new Error("Unexpected Failure"); + } } // Extend WindowsInternalFrameTitlePane to get access to systemPopupMenu diff --git a/jdk/test/javax/swing/JLayer/6824395/bug6824395.java b/jdk/test/javax/swing/JLayer/6824395/bug6824395.java index 1b428697da2..f2040f4b327 100644 --- a/jdk/test/javax/swing/JLayer/6824395/bug6824395.java +++ b/jdk/test/javax/swing/JLayer/6824395/bug6824395.java @@ -25,11 +25,12 @@ * @test * @summary Checks that JLayer inside JViewport works is correctly laid out * @author Alexander Potochkin + * @library ../../../../lib/testlibrary/ + * @build ExtendedRobot * @run main bug6824395 */ -import sun.awt.SunToolkit; import javax.swing.*; import javax.swing.plaf.LayerUI; @@ -40,7 +41,6 @@ public class bug6824395 { static JScrollPane scrollPane; public static void main(String[] args) throws Exception { - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { JFrame frame = new JFrame("testing"); @@ -68,7 +68,13 @@ public class bug6824395 { frame.setVisible(true); } }); - toolkit.realSync(); + try { + ExtendedRobot robot = new ExtendedRobot(); + robot.waitForIdle(300); + }catch(Exception ex) { + ex.printStackTrace(); + throw new Error("Unexpected Failure"); + } SwingUtilities.invokeAndWait(new Runnable() { public void run() { if (scrollPane.getViewportBorderBounds().width != scrollPane.getViewport().getView().getWidth()) { diff --git a/jdk/test/javax/swing/JPopupMenu/6583251/bug6583251.java b/jdk/test/javax/swing/JPopupMenu/6583251/bug6583251.java new file mode 100644 index 00000000000..d44c221093d --- /dev/null +++ b/jdk/test/javax/swing/JPopupMenu/6583251/bug6583251.java @@ -0,0 +1,77 @@ +/* + * 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 + * 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. + */ + +/* +@test +@bug 6583251 +@summary One more ClassCastException in Swing with TrayIcon +@author Alexander Potochkin +@run main bug6583251 +*/ + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.awt.image.BufferedImage; + +public class bug6583251 { + private static JFrame frame; + private static JPopupMenu menu; + + private static void createGui() { + frame = new JFrame(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JPanel panel = new JPanel(); + menu = new JPopupMenu(); + menu.add(new JMenuItem("item")); + panel.setComponentPopupMenu(menu); + frame.add(panel); + + frame.setSize(200, 200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + public static void main(String[] args) throws Exception { + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + createGui(); + } + }); + + Robot robot = new Robot(); + robot.waitForIdle(); + menu.show(frame, 0, 0); + robot.waitForIdle(); + + TrayIcon trayIcon = new TrayIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)); + MouseEvent ev = new MouseEvent( + new JButton(), MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), 0, 0, 0, 1, false); + ev.setSource(trayIcon); + Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ev); + } +} diff --git a/jdk/test/javax/swing/JPopupMenu/6691503/bug6691503.java b/jdk/test/javax/swing/JPopupMenu/6691503/bug6691503.java index c1c16ee5a2c..f07ebd19a35 100644 --- a/jdk/test/javax/swing/JPopupMenu/6691503/bug6691503.java +++ b/jdk/test/javax/swing/JPopupMenu/6691503/bug6691503.java @@ -31,8 +31,6 @@ * @run main bug6691503 */ -import sun.awt.SunToolkit; - import javax.swing.*; import java.awt.*; @@ -93,7 +91,13 @@ public class bug6691503 { } private void checkResult() { - ((SunToolkit)(Toolkit.getDefaultToolkit())).realSync(); + try { + Robot robot = new Robot(); + robot.waitForIdle(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } if (!isAlwaysOnTop1 || isAlwaysOnTop2) { throw new RuntimeException("Malicious applet can show always-on-top " + "popup menu which has whole screen size"); diff --git a/jdk/test/javax/swing/JPopupMenu/6694823/bug6694823.java b/jdk/test/javax/swing/JPopupMenu/6694823/bug6694823.java index 045cc68066f..3e6c4be0c69 100644 --- a/jdk/test/javax/swing/JPopupMenu/6694823/bug6694823.java +++ b/jdk/test/javax/swing/JPopupMenu/6694823/bug6694823.java @@ -32,25 +32,25 @@ import javax.swing.*; import java.awt.*; -import sun.awt.SunToolkit; import java.security.Permission; -import sun.awt.AWTPermissions; public class bug6694823 { private static JFrame frame; private static JPopupMenu popup; - private static SunToolkit toolkit; + private static Toolkit toolkit; private static Insets screenInsets; + private static Robot robot; public static void main(String[] args) throws Exception { - toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + robot = new Robot(); + toolkit = Toolkit.getDefaultToolkit(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { createGui(); } }); - toolkit.realSync(); + robot.waitForIdle(); // Get screen insets screenInsets = toolkit.getScreenInsets(frame.getGraphicsConfiguration()); @@ -61,12 +61,9 @@ public class bug6694823 { System.setSecurityManager(new SecurityManager(){ - private String allowsAlwaysOnTopPermission = - AWTPermissions.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION.getName(); - @Override public void checkPermission(Permission perm) { - if (allowsAlwaysOnTopPermission.equals(perm.getName())) { + if (perm.getName().equals("setWindowAlwaysOnTop") ) { throw new SecurityException(); } } @@ -107,7 +104,7 @@ public class bug6694823 { }); // Ensure frame is visible - toolkit.realSync(); + robot.waitForIdle(); final Point point = new Point(); SwingUtilities.invokeAndWait(new Runnable() { @@ -120,7 +117,7 @@ public class bug6694823 { }); // Ensure popup is visible - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { diff --git a/jdk/test/javax/swing/JScrollBar/4865918/bug4865918.java b/jdk/test/javax/swing/JScrollBar/4865918/bug4865918.java index 8a1a8045fd7..2bf5be45b2d 100644 --- a/jdk/test/javax/swing/JScrollBar/4865918/bug4865918.java +++ b/jdk/test/javax/swing/JScrollBar/4865918/bug4865918.java @@ -33,15 +33,14 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; -import sun.awt.SunToolkit; public class bug4865918 { private static TestScrollBar sbar; public static void main(String[] argv) throws Exception { - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + Robot robot = new Robot(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -49,7 +48,7 @@ public class bug4865918 { } }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { @@ -59,7 +58,7 @@ public class bug4865918 { } }); - toolkit.realSync(); + robot.waitForIdle(); int value = getValue(); diff --git a/jdk/test/javax/swing/JScrollPane/6274267/bug6274267.java b/jdk/test/javax/swing/JScrollPane/6274267/bug6274267.java new file mode 100644 index 00000000000..1783c0f81b1 --- /dev/null +++ b/jdk/test/javax/swing/JScrollPane/6274267/bug6274267.java @@ -0,0 +1,100 @@ +/* + * 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 + * 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. + */ + +/* @test + @bug 6274267 + @summary Checks that ScrollPaneLayout properly calculates preferred + layout size. + @author Mikhail Lapshin + @run main bug6274267 +*/ + +import javax.swing.*; +import java.awt.*; + +public class bug6274267 { + private JFrame frame; + private Component left; + + public static void main(String[] args) throws Exception { + final bug6274267 test = new bug6274267(); + Robot robot = new Robot(); + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + test.setupUI1(); + } + }); + robot.waitForIdle(); + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + test.setupUI2(); + } + }); + test.test(); + } finally { + if (test.frame != null) { + test.frame.dispose(); + } + } + } + + private void setupUI1() { + frame = new JFrame(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + left = new JPanel(); + left.setPreferredSize(new Dimension(100, 100)); + + JPanel rightPanel = new JPanel(); + rightPanel.setPreferredSize(new Dimension(100, 50)); + Component right = new JScrollPane(rightPanel); + + JSplitPane split = + new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right); + + frame = new JFrame(); + frame.add(split); + frame.pack(); + } + + // It is important to separate frame.pack() from frame.setVisible(true). + // Otherwise the repaint manager will combine validate() calls and + // the bug won't appear. + private void setupUI2() { + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + private void test() throws Exception { + if (left.getSize().width == 100) { + System.out.println("Test passed"); + } else { + throw new RuntimeException("ScrollPaneLayout sometimes improperly " + + "calculates the preferred layout size. "); + } + } +} diff --git a/jdk/test/javax/swing/JSpinner/8008657/bug8008657.java b/jdk/test/javax/swing/JSpinner/8008657/bug8008657.java index 63e07730090..3cbe7a61d03 100644 --- a/jdk/test/javax/swing/JSpinner/8008657/bug8008657.java +++ b/jdk/test/javax/swing/JSpinner/8008657/bug8008657.java @@ -22,7 +22,7 @@ */ import java.awt.ComponentOrientation; -import java.awt.Toolkit; +import java.awt.Robot; import java.util.Calendar; import java.util.Date; import javax.swing.JFrame; @@ -32,7 +32,6 @@ import javax.swing.SpinnerDateModel; import javax.swing.SpinnerModel; import javax.swing.SpinnerNumberModel; import javax.swing.SwingUtilities; -import sun.awt.SunToolkit; /** * @test @@ -43,19 +42,19 @@ import sun.awt.SunToolkit; */ public class bug8008657 { - private static SunToolkit toolkit; + private static Robot robot; private static JSpinner spinner; public static void main(String[] args) throws Exception { - toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + robot = new Robot(); SwingUtilities.invokeAndWait(() -> { createDateSpinner(); createAndShowUI(); }); - toolkit.realSync(); + robot.waitForIdle(); testSpinner(false); SwingUtilities.invokeAndWait(() -> { @@ -63,7 +62,7 @@ public class bug8008657 { createAndShowUI(); }); - toolkit.realSync(); + robot.waitForIdle(); testSpinner(true); } @@ -73,7 +72,7 @@ public class bug8008657 { SwingUtilities.invokeAndWait(() -> { spinner.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(() -> { @@ -91,7 +90,7 @@ public class bug8008657 { spinner.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(() -> { JTextField textField = getTextField(); @@ -152,4 +151,4 @@ public class bug8008657 { frame.getContentPane().add(spinner); frame.setVisible(true); } -} \ No newline at end of file +} diff --git a/jdk/test/javax/swing/JSplitPane/4816114/bug4816114.java b/jdk/test/javax/swing/JSplitPane/4816114/bug4816114.java index 0b3247f9746..11296836916 100644 --- a/jdk/test/javax/swing/JSplitPane/4816114/bug4816114.java +++ b/jdk/test/javax/swing/JSplitPane/4816114/bug4816114.java @@ -30,7 +30,6 @@ import javax.swing.*; import java.awt.*; import java.lang.reflect.*; -import sun.awt.SunToolkit; public class bug4816114 { @@ -46,14 +45,14 @@ public class bug4816114 { static bug4816114 test = new bug4816114(); - public static void main(String[] args) throws InterruptedException, InvocationTargetException { + public static void main(String[] args) throws InterruptedException, InvocationTargetException, AWTException { SwingUtilities.invokeAndWait(new Runnable() { public void run() { test.createAndShowGUI(); } }); - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); - toolkit.realSync(); + Robot robot = new Robot(); + robot.waitForIdle(); Thread.sleep(1000); Thread.sleep(2000); diff --git a/jdk/test/javax/swing/JTabbedPane/7024235/Test7024235.java b/jdk/test/javax/swing/JTabbedPane/7024235/Test7024235.java index 228aa008567..e18f4aac8c4 100644 --- a/jdk/test/javax/swing/JTabbedPane/7024235/Test7024235.java +++ b/jdk/test/javax/swing/JTabbedPane/7024235/Test7024235.java @@ -22,7 +22,6 @@ */ import java.awt.BorderLayout; -import sun.awt.SunToolkit; import java.awt.Container; import java.awt.Rectangle; @@ -41,7 +40,10 @@ import javax.swing.UIManager.LookAndFeelInfo; * @test * @bug 7024235 * @summary Tests JFrame.pack() with the JTabbedPane + * @library ../../../../lib/testlibrary/ + * @build ExtendedRobot * @author Sergey Malenkov + * @run main Test7024235 */ public class Test7024235 implements Runnable { @@ -50,13 +52,17 @@ public class Test7024235 implements Runnable { public static void main(String[] args) throws Exception { Test7024235 test = new Test7024235(); - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { UIManager.setLookAndFeel(info.getClassName()); test.test(); - toolkit.realSync(); - Thread.sleep(1000); + try { + ExtendedRobot robot = new ExtendedRobot(); + robot.waitForIdle(1000); + }catch(Exception ex) { + ex.printStackTrace(); + throw new Error("Unexpected Failure"); + } test.test(); } } diff --git a/jdk/test/javax/swing/JTabbedPane/7170310/bug7170310.java b/jdk/test/javax/swing/JTabbedPane/7170310/bug7170310.java index 2ceb8a45ccb..94eaa6e3ce1 100644 --- a/jdk/test/javax/swing/JTabbedPane/7170310/bug7170310.java +++ b/jdk/test/javax/swing/JTabbedPane/7170310/bug7170310.java @@ -34,13 +34,14 @@ import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.plaf.metal.MetalLookAndFeel; -import sun.awt.SunToolkit; /** * @test * @bug 7170310 * @author Alexey Ivanov * @summary Selected tab should be scrolled into view. + * @library ../../../../lib/testlibrary/ + * @build ExtendedRobot * @run main bug7170310 */ public class bug7170310 { @@ -58,12 +59,11 @@ public class bug7170310 { UIManager.setLookAndFeel(new MetalLookAndFeel()); SwingUtilities.invokeAndWait(bug7170310::createAndShowUI); - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); - toolkit.realSync(); + sync(); for (int i = 0; i < TABS_NUMBER; i++) { SwingUtilities.invokeAndWait(bug7170310::addTab); - toolkit.realSync(); + sync(); } SwingUtilities.invokeAndWait(bug7170310::check); @@ -121,4 +121,13 @@ public class bug7170310 { exception = e; } } + private static void sync() { + try { + ExtendedRobot robot = new ExtendedRobot(); + robot.waitForIdle(300); + }catch(Exception ex) { + ex.printStackTrace(); + throw new Error("Unexpected Failure"); + } + } } diff --git a/jdk/test/javax/swing/JTabbedPane/8017284/bug8017284.java b/jdk/test/javax/swing/JTabbedPane/8017284/bug8017284.java index db99233f577..5a71726e631 100644 --- a/jdk/test/javax/swing/JTabbedPane/8017284/bug8017284.java +++ b/jdk/test/javax/swing/JTabbedPane/8017284/bug8017284.java @@ -22,12 +22,12 @@ */ import java.awt.BorderLayout; import java.awt.Toolkit; +import java.awt.Robot; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTabbedPane; import javax.swing.SwingUtilities; import javax.swing.plaf.metal.MetalLookAndFeel; -import sun.awt.SunToolkit; /** * @test @@ -45,6 +45,7 @@ public class bug8017284 { public static void main(String[] args) throws Exception { + Robot robot = new Robot(); SwingUtilities.invokeAndWait(() -> { frame = new JFrame(); frame.setSize(500, 500); @@ -61,7 +62,7 @@ public class bug8017284 { frame.setVisible(true); }); - ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(() -> { for (int j = 0; j < ITERATIONS; j++) { @@ -70,7 +71,7 @@ public class bug8017284 { } } }); - ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(() -> frame.dispose()); } diff --git a/jdk/test/javax/swing/JTable/8032874/bug8032874.java b/jdk/test/javax/swing/JTable/8032874/bug8032874.java index e5d6da00ccf..1116aebe267 100644 --- a/jdk/test/javax/swing/JTable/8032874/bug8032874.java +++ b/jdk/test/javax/swing/JTable/8032874/bug8032874.java @@ -37,15 +37,13 @@ import javax.swing.*; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableRowSorter; -import sun.awt.SunToolkit; - public class bug8032874 { private static final int ROW_COUNT = 5; private static JTable table; private static TestTableModel tableModel; public static void main(String args[]) throws Exception { - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + Robot robot = new Robot(); SwingUtilities.invokeAndWait(new Runnable() { @Override @@ -53,7 +51,7 @@ public class bug8032874 { createAndShowUI(); } }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { @Override @@ -63,7 +61,7 @@ public class bug8032874 { table.setRowSelectionInterval(1, 2); } }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { @Override diff --git a/jdk/test/javax/swing/JTextArea/7049024/bug7049024.java b/jdk/test/javax/swing/JTextArea/7049024/bug7049024.java index d6e232618dd..36d328fe1e8 100644 --- a/jdk/test/javax/swing/JTextArea/7049024/bug7049024.java +++ b/jdk/test/javax/swing/JTextArea/7049024/bug7049024.java @@ -31,8 +31,6 @@ * @author Sean Chou */ -import sun.awt.SunToolkit; - import javax.swing.*; import javax.swing.text.DefaultCaret; import java.awt.*; @@ -53,7 +51,7 @@ public class bug7049024 { public static void main(String[] args) throws Exception { - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + Robot robot = new Robot(); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { @@ -70,7 +68,7 @@ public class bug7049024 { frame.setVisible(true); } }); - toolkit.realSync(); + robot.waitForIdle(); clipboard = textField.getToolkit().getSystemSelection(); if (null == clipboard) { @@ -83,7 +81,7 @@ public class bug7049024 { textField.requestFocusInWindow(); } }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { @Override @@ -93,7 +91,7 @@ public class bug7049024 { caret.moveDot(4); } }); - toolkit.realSync(); + robot.waitForIdle(); String oldSelection = (String) clipboard.getData(DataFlavor.stringFlavor); System.out.println("oldSelection is " + oldSelection); @@ -104,7 +102,7 @@ public class bug7049024 { button.requestFocusInWindow(); } }); - toolkit.realSync(); // So JTextField loses the focus. + robot.waitForIdle(); // So JTextField loses the focus. SwingUtilities.invokeAndWait(new Runnable() { @Override @@ -113,7 +111,7 @@ public class bug7049024 { caret.moveDot(6); } }); - toolkit.realSync(); + robot.waitForIdle(); String newSelection = (String) clipboard.getData(DataFlavor.stringFlavor); System.out.println("newSelection is " + newSelection); diff --git a/jdk/test/javax/swing/JToolBar/4529206/bug4529206.java b/jdk/test/javax/swing/JToolBar/4529206/bug4529206.java new file mode 100644 index 00000000000..61e96b728b0 --- /dev/null +++ b/jdk/test/javax/swing/JToolBar/4529206/bug4529206.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2004, 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. + */ + +/* @test + @bug 4529206 + @summary JToolBar - setFloating does not work correctly + @author Konstantin Eremin + @run main bug4529206 +*/ + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class bug4529206 extends JFrame { + static JFrame frame; + static JToolBar jToolBar1; + public bug4529206() { + setDefaultCloseOperation(EXIT_ON_CLOSE); + JPanel jPanFrame = (JPanel) this.getContentPane(); + jPanFrame.setLayout(new BorderLayout()); + this.setSize(new Dimension(200, 100)); + this.setLocation(125, 75); + this.setTitle("Test Floating Toolbar"); + jToolBar1 = new JToolBar(); + JButton jButton1 = new JButton("Float"); + jPanFrame.add(jToolBar1, BorderLayout.NORTH); + JTextField tf = new JTextField("click here"); + jPanFrame.add(tf); + jToolBar1.add(jButton1, null); + jButton1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + buttonPressed(e); + } + }); + makeToolbarFloat(); + setVisible(true); + } + + private void makeToolbarFloat() { + javax.swing.plaf.basic.BasicToolBarUI ui = (javax.swing.plaf.basic.BasicToolBarUI) jToolBar1.getUI(); + if (!ui.isFloating()) { + ui.setFloatingLocation(100, 100); + ui.setFloating(true, jToolBar1.getLocation()); + } + } + + private void buttonPressed(ActionEvent e) { + makeToolbarFloat(); + } + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame = new bug4529206(); + } + }); + Robot robot = new Robot(); + robot.waitForIdle(); + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + if (frame.isFocused()) { + throw (new RuntimeException("setFloating does not work correctly")); + } + } + }); + } +} diff --git a/jdk/test/javax/swing/JViewport/7107099/bug7107099.java b/jdk/test/javax/swing/JViewport/7107099/bug7107099.java index eff27bccdae..a6bdce4b445 100644 --- a/jdk/test/javax/swing/JViewport/7107099/bug7107099.java +++ b/jdk/test/javax/swing/JViewport/7107099/bug7107099.java @@ -27,8 +27,6 @@ @author Pavel Porvatov */ -import sun.awt.SunToolkit; - import javax.swing.*; import java.awt.*; @@ -43,7 +41,8 @@ public class bug7107099 { private static int extent; public static void main(String[] args) throws Exception { - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + + java.awt.Robot robot = new java.awt.Robot(); SwingUtilities.invokeAndWait(new Runnable() { @Override @@ -61,7 +60,7 @@ public class bug7107099 { } }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { @Override @@ -81,7 +80,7 @@ public class bug7107099 { } }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { @Override diff --git a/jdk/test/javax/swing/Popup/6514582/bug6514582.java b/jdk/test/javax/swing/Popup/6514582/bug6514582.java new file mode 100644 index 00000000000..94fee3f4f82 --- /dev/null +++ b/jdk/test/javax/swing/Popup/6514582/bug6514582.java @@ -0,0 +1,73 @@ +/* + * 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 + * 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. + */ + +/* @test + @bug 6514582 + @summary SubMenu of a JMenu with no items paints a single pixel tiny menu. + @author Alexander Potochkin + @run main bug6514582 +*/ + +import javax.swing.*; +import java.awt.*; + +public class bug6514582 { + private static JPopupMenu popup; + + public static void main(String ...args) throws Exception { + Robot robot = new Robot(); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + popup = new JPopupMenu(); + popup.add(new JMenuItem("item")); + popup.setVisible(true); + + } + }); + + robot.waitForIdle(); + + if (!popup.isShowing()) { + throw new RuntimeException("Where is my popup ?"); + } + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + popup.setVisible(false); + popup.removeAll(); + popup.setVisible(true); + } + }); + + robot.waitForIdle(); + + if (popup.isShowing()) { + throw new RuntimeException("Empty popup is shown"); + } + + popup.setVisible(false); + } +} diff --git a/jdk/test/javax/swing/RepaintManager/IconifyTest/IconifyTest.java b/jdk/test/javax/swing/RepaintManager/IconifyTest/IconifyTest.java index cbe6d2230de..5d4198cc669 100644 --- a/jdk/test/javax/swing/RepaintManager/IconifyTest/IconifyTest.java +++ b/jdk/test/javax/swing/RepaintManager/IconifyTest/IconifyTest.java @@ -31,7 +31,6 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; -import sun.awt.*; public class IconifyTest { private static volatile boolean windowIconifiedIsCalled = false; @@ -40,7 +39,7 @@ public class IconifyTest { static JButton button; public static void main(String[] args) throws Throwable { - SunToolkit toolkit = (SunToolkit) SunToolkit.getDefaultToolkit(); + Robot robot = new Robot(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame = new JFrame(); @@ -61,14 +60,14 @@ public class IconifyTest { frame.setVisible(true); } }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.setExtendedState(Frame.ICONIFIED); } }); - toolkit.realSync(); + robot.waitForIdle(); if (!windowIconifiedIsCalled) { throw new Exception("Test failed: window was not iconified."); diff --git a/jdk/test/javax/swing/Security/6657138/ComponentTest.java b/jdk/test/javax/swing/Security/6657138/ComponentTest.java index bfd818eb6f6..2ee7b84bbfa 100644 --- a/jdk/test/javax/swing/Security/6657138/ComponentTest.java +++ b/jdk/test/javax/swing/Security/6657138/ComponentTest.java @@ -28,8 +28,6 @@ * @author Alexander Potochkin */ -import sun.awt.SunToolkit; - import javax.swing.*; import java.awt.*; @@ -50,14 +48,14 @@ public class ComponentTest extends JFrame { public static void main(String[] args) throws Exception { - SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + Robot robot = new Robot(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame = new ComponentTest(); frame.setVisible(true); } }); - toolkit.realSync(); + robot.waitForIdle(); UIManager.LookAndFeelInfo[] lafs = UIManager.getInstalledLookAndFeels(); for (final UIManager.LookAndFeelInfo laf : lafs) { SwingUtilities.invokeAndWait(new Runnable() { @@ -70,7 +68,7 @@ public class ComponentTest extends JFrame { SwingUtilities.updateComponentTreeUI(frame); } }); - toolkit.realSync(); + robot.waitForIdle(); } } } diff --git a/jdk/test/javax/swing/SwingTest.java b/jdk/test/javax/swing/SwingTest.java index ef8dfea27e0..f7f6889f635 100644 --- a/jdk/test/javax/swing/SwingTest.java +++ b/jdk/test/javax/swing/SwingTest.java @@ -21,7 +21,6 @@ * questions. */ -import sun.awt.SunToolkit; import java.awt.Toolkit; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -134,11 +133,8 @@ final class SwingTest implements Runnable { else { SwingUtilities.invokeLater(this); // invoke on the event dispatch thread } - Toolkit tk = Toolkit.getDefaultToolkit(); - if (tk instanceof SunToolkit) { - SunToolkit stk = (SunToolkit) tk; - stk.realSync(); // wait until done - } + java.awt.Robot robot = new java.awt.Robot(); + robot.waitForIdle(); } while (this.frame != null); if (this.error != null) { diff --git a/jdk/test/javax/swing/text/Utilities/bug7045593.java b/jdk/test/javax/swing/text/Utilities/bug7045593.java index 84beb0d53b9..1de7cc142c2 100644 --- a/jdk/test/javax/swing/text/Utilities/bug7045593.java +++ b/jdk/test/javax/swing/text/Utilities/bug7045593.java @@ -28,8 +28,6 @@ * @author Pavel Porvatov */ -import sun.awt.SunToolkit; - import javax.swing.*; import javax.swing.text.BadLocationException; import java.awt.*; @@ -49,7 +47,8 @@ public class bug7045593 { } }); - ((SunToolkit) SunToolkit.getDefaultToolkit()).realSync(); + Robot robot = new Robot(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { diff --git a/jdk/test/javax/swing/text/View/8048110/bug8048110.java b/jdk/test/javax/swing/text/View/8048110/bug8048110.java index 2151e3fb502..85ae35708e5 100644 --- a/jdk/test/javax/swing/text/View/8048110/bug8048110.java +++ b/jdk/test/javax/swing/text/View/8048110/bug8048110.java @@ -28,8 +28,6 @@ * @run main bug8048110 */ -import sun.awt.SunToolkit; - import javax.swing.*; import javax.swing.text.Element; import javax.swing.text.html.HTMLDocument; @@ -37,7 +35,7 @@ import javax.swing.text.html.HTMLEditorKit; import java.awt.*; public class bug8048110 { - private static SunToolkit toolkit = (SunToolkit)Toolkit.getDefaultToolkit(); + private static Robot robot; private static Object lock = new Object(); private static boolean isRealSyncPerformed = false; private static final String htmlText = "" + @@ -45,6 +43,7 @@ public class bug8048110 { "
PCOk
"; public static void main(String[] args) throws Exception { + robot = new Robot(); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { @@ -55,7 +54,7 @@ public class bug8048110 { Thread thread = new Thread() { @Override public void run() { - toolkit.realSync(); + robot.waitForIdle(); synchronized (lock) { isRealSyncPerformed = true; lock.notifyAll(); diff --git a/jdk/test/javax/swing/text/html/7189299/bug7189299.java b/jdk/test/javax/swing/text/html/7189299/bug7189299.java index 83862122ec2..609635c4fc5 100644 --- a/jdk/test/javax/swing/text/html/7189299/bug7189299.java +++ b/jdk/test/javax/swing/text/html/7189299/bug7189299.java @@ -25,7 +25,7 @@ * Portions Copyright (c) 2013 IBM Corporation */ import java.awt.BorderLayout; -import java.awt.Toolkit; +import java.awt.Robot; import java.awt.event.ActionListener; import javax.swing.DefaultButtonModel; @@ -35,7 +35,6 @@ import javax.swing.SwingUtilities; import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; import javax.swing.text.html.HTMLEditorKit; -import sun.awt.SunToolkit; /* @@ -111,7 +110,7 @@ public class bug7189299 { } public static void main(String[] args) throws Exception { - final SunToolkit toolkit = ((SunToolkit) Toolkit.getDefaultToolkit()); + final Robot robot = new Robot(); SwingUtilities.invokeAndWait(new Runnable() { @@ -120,7 +119,7 @@ public class bug7189299 { setup(); } }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { @Override diff --git a/jdk/test/javax/swing/text/html/HTMLDocument/8058120/bug8058120.java b/jdk/test/javax/swing/text/html/HTMLDocument/8058120/bug8058120.java index 2378fd2e334..86ebdbb963f 100644 --- a/jdk/test/javax/swing/text/html/HTMLDocument/8058120/bug8058120.java +++ b/jdk/test/javax/swing/text/html/HTMLDocument/8058120/bug8058120.java @@ -28,8 +28,6 @@ * @run main bug8058120 */ -import sun.awt.SunToolkit; - import javax.swing.*; import javax.swing.text.Element; import javax.swing.text.html.HTML; @@ -38,12 +36,18 @@ import javax.swing.text.html.HTMLEditorKit; import java.awt.*; public class bug8058120 { - private static SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); private static HTMLDocument document = null; private static final String text = "

ab

"; private static final String textToInsert = "c"; public static void main(String[] args) { + Robot robot; + try { + robot = new Robot(); + }catch(Exception ex) { + ex.printStackTrace(); + throw new RuntimeException("Unexpected failure"); + } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { @@ -51,7 +55,7 @@ public class bug8058120 { } }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeLater(new Runnable() { @Override @@ -64,7 +68,7 @@ public class bug8058120 { } }); - toolkit.realSync(); + robot.waitForIdle(); SwingUtilities.invokeLater(new Runnable() { @Override diff --git a/jdk/test/javax/swing/text/html/HTMLEditorKit/4242228/bug4242228.java b/jdk/test/javax/swing/text/html/HTMLEditorKit/4242228/bug4242228.java index c18dccd02de..835990fa142 100644 --- a/jdk/test/javax/swing/text/html/HTMLEditorKit/4242228/bug4242228.java +++ b/jdk/test/javax/swing/text/html/HTMLEditorKit/4242228/bug4242228.java @@ -27,8 +27,6 @@ @author Peter Zhelezniakov */ -import sun.awt.SunToolkit; - import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -85,7 +83,8 @@ public class bug4242228 { } }); - ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); + Robot robot = new Robot(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { @Override diff --git a/jdk/test/javax/swing/text/html/parser/Parser/7165725/bug7165725.java b/jdk/test/javax/swing/text/html/parser/Parser/7165725/bug7165725.java index 2c89050ef4a..339e52f1e70 100644 --- a/jdk/test/javax/swing/text/html/parser/Parser/7165725/bug7165725.java +++ b/jdk/test/javax/swing/text/html/parser/Parser/7165725/bug7165725.java @@ -28,9 +28,8 @@ @run main bug7165725 */ -import sun.awt.SunToolkit; - import java.awt.BorderLayout; +import java.awt.Robot; import java.io.File; import java.io.FileReader; import java.io.IOException; @@ -127,7 +126,8 @@ public class bug7165725 extends JFrame { } }); - ((SunToolkit) SunToolkit.getDefaultToolkit()).realSync(); + Robot robot = new Robot(); + robot.waitForIdle(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { From 935c33a50c4f510438c5346a5521774a37a7df18 Mon Sep 17 00:00:00 2001 From: Eric McCorkle Date: Mon, 10 Nov 2014 15:06:13 -0500 Subject: [PATCH 19/67] 8062556: Add jdk tests for JDK-8058322 and JDK-8058313 Add tests for two hotspot reflection fixes. Reviewed-by: dholmes --- .../lang/reflect/Parameter/BadClassFiles.java | 239 +++++++++++++++--- .../java/lang/reflect/Parameter/NoName.java | 121 +++++++++ 2 files changed, 323 insertions(+), 37 deletions(-) create mode 100644 jdk/test/java/lang/reflect/Parameter/NoName.java diff --git a/jdk/test/java/lang/reflect/Parameter/BadClassFiles.java b/jdk/test/java/lang/reflect/Parameter/BadClassFiles.java index 581d4ef6f5f..55e67f32710 100644 --- a/jdk/test/java/lang/reflect/Parameter/BadClassFiles.java +++ b/jdk/test/java/lang/reflect/Parameter/BadClassFiles.java @@ -81,10 +81,23 @@ public class BadClassFiles { 0,25,0,0,0,3,0,0, 0,1,-79,0,0,0,1,0, 7,0,0,0,6,0,1,0, - 0,0,2,0,10,0,0,0, - 9,2,0,11,0,0,0,12, - 0,0,0,1,0,13,0,0, - 0,2,0,14 + 0,0,2, + // Method Parameters attribute here + 0,10, + // attribute_length + 0,0,0,9, + // parameter_count + 2, + // first parameter name + 0,11, + // first parameter modifiers + 0,0, + // second parameter name + 0,12, + // second parameter modifiers + 0,0, + // end attribute + 0,1,0,13,0,0,0,2,0,14 }; private static final byte[] BadModifiers_bytes = { @@ -121,10 +134,23 @@ public class BadClassFiles { 25,0,0,0,3,0,0,0, 1,-79,0,0,0,1,0,7, 0,0,0,6,0,1,0,0, - 0,2,0,10,0,0,0,9, - 2,0,11,0,51,51,12,0, - 0,0,1,0,13,0,0,0, - 2,0,14 + 0,2, + // Method Parameters attribute here + 0,10, + // attribute_length + 0,0,0,9, + // parameter_count + 2, + // first parameter name + 0,11, + // first parameter modifiers + 51,51, + // second parameter name + 0,12, + // second parameter modifiers + 0,0, + // end attribute + 0,1,0,13,0,0,0,2,0,14 }; private static final byte[] BadNameIndex_bytes = { @@ -161,10 +187,23 @@ public class BadClassFiles { 25,0,0,0,3,0,0,0, 1,-79,0,0,0,1,0,7, 0,0,0,6,0,1,0,0, - 0,2,0,10,0,0,0,9, - 2,0,1,0,0,0,12,0, - 0,0,1,0,13,0,0,0, - 2,0,14 + 0,2, + // Method Parameters attribute here + 0,10, + // attribute_length + 0,0,0,9, + // parameter_count + 2, + // first parameter name + 0,1, + // first parameter modifiers + 0,0, + // second parameter name + 0,12, + // second parameter modifiers + 0,0, + // end attribute + 0,1,0,13,0,0,0,2,0,14 }; private static final byte[] NameIndexOutOfBounds_bytes = { @@ -203,11 +242,23 @@ public class BadClassFiles { 25,0,0,0,3,0,0,0, 1,-79,0,0,0,1,0,7, 0,0,0,6,0,1,0,0, - 0,2,0,10,0,0,0,9, - 2,0,-1,0,0,0,12,0, - 0,0,1,0,13,0,0,0, - 2,0,14 - + 0,2, + // Method Parameters attribute here + 0,10, + // attribute_length + 0,0,0,9, + // parameter_count + 2, + // first parameter name + 0,-1, + // first parameter modifiers + 0,0, + // second parameter name + 0,12, + // second parameter modifiers + 0,0, + // end attribute + 0,1,0,13,0,0,0,2,0,14 }; private static final byte[] ExtraParams_bytes = { @@ -244,10 +295,26 @@ public class BadClassFiles { 0,0,3,0,0,0,1,-79, 0,0,0,1,0,7,0,0, 0,6,0,1,0,0,0,2, - 0,10,0,0,0,13,3,0, - 11,0,0,0,12,0,0,0, - 11,0,0,0,1,0,13,0, - 0,0,2,0,14 + // Method Parameters attribute here + 0,10, + // attribute_length + 0,0,0,13, + // parameter_count + 3, + // first parameter name + 0,11, + // first parameter modifiers + 0,0, + // second parameter name + 0,12, + // second parameter modifiers + 0,0, + // third parameter name + 0,11, + // third parameter modifiers + 0,0, + // end attribute + 0,1,0,13,0,0,0,2,0,14 }; private static final byte[] BadName1_bytes = { @@ -283,10 +350,23 @@ public class BadClassFiles { 25,0,0,0,3,0,0,0, 1,-79,0,0,0,1,0,7, 0,0,0,6,0,1,0,0, - 0,2,0,10,0,0,0,9, - 2,0,11,0,0,0,12,0, - 0,0,1,0,13,0,0,0, - 2,0,14 + 0,2, + // Method Parameters attribute here + 0,10, + // attribute_length + 0,0,0,9, + // parameter_count + 2, + // first parameter name + 0,11, + // first parameter modifiers + 0,0, + // second parameter name + 0,12, + // second parameter modifiers + 0,0, + // end attribute + 0,1,0,13,0,0,0,2,0,14 }; private static final byte[] BadName2_bytes = { @@ -322,10 +402,23 @@ public class BadClassFiles { 25,0,0,0,3,0,0,0, 1,-79,0,0,0,1,0,7, 0,0,0,6,0,1,0,0, - 0,2,0,10,0,0,0,9, - 2,0,11,0,0,0,12,0, - 0,0,1,0,13,0,0,0, - 2,0,14 + 0,2, + // Method Parameters attribute here + 0,10, + // attribute_length + 0,0,0,9, + // parameter_count + 2, + // first parameter name + 0,11, + // first parameter modifiers + 0,0, + // second parameter name + 0,12, + // second parameter modifiers + 0,0, + // end attribute + 0,1,0,13,0,0,0,2,0,14 }; private static final byte[] BadName3_bytes = { @@ -361,10 +454,23 @@ public class BadClassFiles { 25,0,0,0,3,0,0,0, 1,-79,0,0,0,1,0,7, 0,0,0,6,0,1,0,0, - 0,2,0,10,0,0,0,9, - 2,0,11,0,0,0,12,0, - 0,0,1,0,13,0,0,0, - 2,0,14 + 0,2, + // Method Parameters attribute here + 0,10, + // attribute_length + 0,0,0,9, + // parameter_count + 2, + // first parameter name + 0,11, + // first parameter modifiers + 0,0, + // second parameter name + 0,12, + // second parameter modifiers + 0,0, + // end attribute + 0,1,0,13,0,0,0,2,0,14 }; private static final byte[] BadName4_bytes = { @@ -400,10 +506,68 @@ public class BadClassFiles { 25,0,0,0,3,0,0,0, 1,-79,0,0,0,1,0,7, 0,0,0,6,0,1,0,0, - 0,2,0,10,0,0,0,9, - 2,0,11,0,0,0,12,0, - 0,0,1,0,13,0,0,0, - 2,0,14 + 0,2, + // Method Parameters attribute here + 0,10, + // attribute_length + 0,0,0,9, + // parameter_count + 2, + // first parameter name + 0,11, + // first parameter modifiers + 0,0, + // second parameter name + 0,12, + // second parameter modifiers + 0,0, + // end attribute + 0,1,0,13,0,0,0,2,0,14 + }; + + private static final byte[] BadParams_bytes = { + -54,-2,-70,-66,0,0,0, + 52,0,18,10,0,3,0,15, + 7,0,16,7,0,17,1,0,6, + 60,105,110,105,116,62, + 1,0,3,40,41,86,1,0,4, + 67,111,100,101,1,0,15, + 76,105,110,101,78,117, + 109,98,101,114,84,97, + 98,108,101,1,0,1,109, + 1,0,5,40,73,73,41,86, + 1,0,16,77,101,116,104, + 111,100,80,97,114,97, + 109,101,116,101,114,115, + 1,0,1,97,1,0,1,98,1, + 0,10,83,111,117,114, + 99,101,70,105,108,101, + 1,0,14,66,97,100,80,97, + 114,97,109,115,46,106, + 97,118,97,12,0,4,0,5, + 1,0,9,66,97,100,80,97, + 114,97,109,115,1,0,16, + 106,97,118,97,47,108,97, + 110,103,47,79,98,106, + 101,99,116,0,33,0, + 2,0,3,0,0,0,0,0,2, + 0,1,0,4,0,5,0,1,0, + 6,0,0,0,29,0,1,0,1, + 0,0,0,5,42,-73,0,1, + -79,0,0,0,1,0,7,0,0, + 0,6,0,1,0,0,0,1,0,1, + 0,8,0,9,0,2,0,6,0,0, + 0,25,0,0,0,3,0,0,0,1, + -79,0,0,0,1,0,7,0,0, + 0,6,0,1,0,0,0,2, + // Method Parameters attribute here + 0,10, + // attribute_length + 0,0,0,1, + // parameter_count + 0, + // end attribute + 0,1,0,13,0,0,0,2,0,14 }; private static class InMemoryClassLoader extends ClassLoader { @@ -423,6 +587,7 @@ public class BadClassFiles { loader.defineClass("BadNameIndex", BadNameIndex_bytes), loader.defineClass("NameIndexOutOfBounds", NameIndexOutOfBounds_bytes), loader.defineClass("ExtraParams", ExtraParams_bytes), + loader.defineClass("BadParams", BadParams_bytes), // Name with . loader.defineClass("BadName1", BadName1_bytes), // Name with [ diff --git a/jdk/test/java/lang/reflect/Parameter/NoName.java b/jdk/test/java/lang/reflect/Parameter/NoName.java new file mode 100644 index 00000000000..7f3a1f69580 --- /dev/null +++ b/jdk/test/java/lang/reflect/Parameter/NoName.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2013, 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 + * @run main NoName + * @summary The reflection API should report parameters with no name properly. + */ +import java.lang.Class; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +import java.lang.reflect.MalformedParametersException; +import java.lang.ClassLoader; +import java.lang.ClassNotFoundException; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +public class NoName { + + private static final byte[] NoName_bytes = { + -54,-2,-70,-66,0,0,0,52, + 0,18,10,0,3,0,15,7, + 0,16,7,0,17,1,0,6, + 60,105,110,105,116,62,1,0, + 3,40,41,86,1,0,4,67, + 111,100,101,1,0,15,76,105, + 110,101,78,117,109,98,101,114, + 84,97,98,108,101,1,0,1, + 109,1,0,5,40,73,73,41, + 86,1,0,16,77,101,116,104, + 111,100,80,97,114,97,109,101, + 116,101,114,115,1,0,0,1, + 0,1,98,1,0,10,83,111, + 117,114,99,101,70,105,108,101, + 1,0,14,69,109,112,116,121, + 78,97,109,101,46,106,97,118, + 97,12,0,4,0,5,1,0, + 9,69,109,112,116,121,78,97, + 109,101,1,0,16,106,97,118, + 97,47,108,97,110,103,47,79, + 98,106,101,99,116,0,33,0, + 2,0,3,0,0,0,0,0, + 2,0,1,0,4,0,5,0, + 1,0,6,0,0,0,29,0, + 1,0,1,0,0,0,5,42, + -73,0,1,-79,0,0,0,1, + 0,7,0,0,0,6,0,1, + 0,0,0,1,0,1,0,8, + 0,9,0,2,0,6,0,0, + 0,25,0,0,0,3,0,0, + 0,1,-79,0,0,0,1,0, + 7,0,0,0,6,0,1,0, + 0,0,2, + // Method Parameters attribute here + 0,10, + // attribute_length + 0,0,0,9, + // parameter_count + 2, + // first parameter name + 0,0, + // first parameter modifiers + 0,0, + // second parameter name + 0,12, + // second parameter modifiers + 0,0, + // end attribute + 0,1,0,13,0,0,0,2,0,14 + }; + + private static class InMemoryClassLoader extends ClassLoader { + public Class defineClass(String name, byte[] b) { + return defineClass(name, b, 0, b.length); + } + }; + + private static final InMemoryClassLoader loader = new InMemoryClassLoader(); + + private final Class noName; + + private NoName() throws ClassNotFoundException { + noName = loader.defineClass("EmptyName", NoName_bytes); + } + + public static void main(String... args) + throws NoSuchMethodException, IOException, ClassNotFoundException { + new NoName().run(); + } + + public void run() throws NoSuchMethodException { + final Class cls = noName; + System.err.println("Trying " + cls); + final Method method = cls.getMethod("m", int.class, int.class); + final Parameter[] params = method.getParameters(); + System.err.println("Name " + params[0].getName()); + System.err.println("Name " + params[1].getName()); + } + +} From cc2452b769b8d326c560bdfd08a5fbc072c9ea44 Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Tue, 11 Nov 2014 21:46:02 -0800 Subject: [PATCH 20/67] 6988950: JDWP exit error JVMTI_ERROR_WRONG_PHASE(112) Synchronize the jdwp VirtualMachine command functions with the VM_DEATH event Reviewed-by: dcubed, dsamersoff, dholmes --- .../share/native/libjdwp/debugLoop.c | 35 +++++++------------ 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugLoop.c b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugLoop.c index 388e6ae228b..f49b53c7a69 100644 --- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugLoop.c +++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugLoop.c @@ -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 @@ -45,7 +45,7 @@ struct PacketList { static volatile struct PacketList *cmdQueue; static jrawMonitorID cmdQueueLock; -static jrawMonitorID resumeLock; +static jrawMonitorID vmDeathLock; static jboolean transportError; static jboolean @@ -60,28 +60,17 @@ lastCommand(jdwpCmdPacket *cmd) } } -static jboolean -resumeCommand(jdwpCmdPacket *cmd) -{ - if ( (cmd->cmdSet == JDWP_COMMAND_SET(VirtualMachine)) && - (cmd->cmd == JDWP_COMMAND(VirtualMachine, Resume)) ) { - return JNI_TRUE; - } else { - return JNI_FALSE; - } -} - void debugLoop_initialize(void) { - resumeLock = debugMonitorCreate("JDWP Resume Lock"); + vmDeathLock = debugMonitorCreate("JDWP VM_DEATH Lock"); } void debugLoop_sync(void) { - debugMonitorEnter(resumeLock); - debugMonitorExit(resumeLock); + debugMonitorEnter(vmDeathLock); + debugMonitorExit(vmDeathLock); } /* @@ -136,14 +125,14 @@ debugLoop_run(void) jboolean replyToSender = JNI_TRUE; /* - * For VirtualMachine.Resume commands we hold the resumeLock + * For VirtualMachine commands we hold the vmDeathLock * while executing and replying to the command. This ensures - * that a Resume after VM_DEATH will be allowed to complete + * that a VM command after VM_DEATH will be allowed to complete * before the thread posting the VM_DEATH continues VM * termination. */ - if (resumeCommand(cmd)) { - debugMonitorEnter(resumeLock); + if (cmd->cmdSet == JDWP_COMMAND_SET(VirtualMachine)){ + debugMonitorEnter(vmDeathLock); } /* Initialize the input and output streams */ @@ -181,10 +170,10 @@ debugLoop_run(void) } /* - * Release the resumeLock as the reply has been posted. + * Release the vmDeathLock as the reply has been posted. */ - if (resumeCommand(cmd)) { - debugMonitorExit(resumeLock); + if (cmd->cmdSet == JDWP_COMMAND_SET(VirtualMachine)){ + debugMonitorExit(vmDeathLock); } inStream_destroy(&in); From 4a8e05977e15402904e2b19351ab4c5e8765d5c4 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 13 Nov 2014 01:55:21 +0300 Subject: [PATCH 21/67] 8059677: Thread.getName() instantiates Strings Reviewed-by: chegar, dholmes, sla, rriggs --- .../java.base/share/classes/java/lang/Thread.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/Thread.java b/jdk/src/java.base/share/classes/java/lang/Thread.java index adcc982cf9e..e7477416ecb 100644 --- a/jdk/src/java.base/share/classes/java/lang/Thread.java +++ b/jdk/src/java.base/share/classes/java/lang/Thread.java @@ -145,7 +145,7 @@ class Thread implements Runnable { registerNatives(); } - private volatile char name[]; + private volatile String name; private int priority; private Thread threadQ; private long eetop; @@ -366,7 +366,7 @@ class Thread implements Runnable { throw new NullPointerException("name cannot be null"); } - this.name = name.toCharArray(); + this.name = name; Thread parent = currentThread(); SecurityManager security = System.getSecurityManager(); @@ -1119,7 +1119,11 @@ class Thread implements Runnable { */ public final synchronized void setName(String name) { checkAccess(); - this.name = name.toCharArray(); + if (name == null) { + throw new NullPointerException("name cannot be null"); + } + + this.name = name; if (threadStatus != 0) { setNativeName(name); } @@ -1132,7 +1136,7 @@ class Thread implements Runnable { * @see #setName(String) */ public final String getName() { - return new String(name, true); + return name; } /** From d8d026811c973db15eec4aedbca7492f724f7943 Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Thu, 13 Nov 2014 12:00:39 +0300 Subject: [PATCH 22/67] 8064468: ownedWindowList access requires synchronization in Window.setAlwaysOnTop() method Reviewed-by: serb, pchelko --- .../share/classes/java/awt/Window.java | 13 +++- .../AlwaysOnTop/SyncAlwaysOnTopFieldTest.java | 62 +++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 jdk/test/java/awt/Window/AlwaysOnTop/SyncAlwaysOnTopFieldTest.java diff --git a/jdk/src/java.desktop/share/classes/java/awt/Window.java b/jdk/src/java.desktop/share/classes/java/awt/Window.java index 4417314634c..b5a466cb7f3 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Window.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Window.java @@ -2254,7 +2254,18 @@ public class Window extends Container implements Accessible { } firePropertyChange("alwaysOnTop", oldAlwaysOnTop, alwaysOnTop); } - for (WeakReference ref : ownedWindowList) { + setOwnedWindowsAlwaysOnTop(alwaysOnTop); + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + private void setOwnedWindowsAlwaysOnTop(boolean alwaysOnTop) { + WeakReference[] ownedWindowArray; + synchronized (ownedWindowList) { + ownedWindowArray = new WeakReference[ownedWindowList.size()]; + ownedWindowList.copyInto(ownedWindowArray); + } + + for (WeakReference ref : ownedWindowArray) { Window window = ref.get(); if (window != null) { try { diff --git a/jdk/test/java/awt/Window/AlwaysOnTop/SyncAlwaysOnTopFieldTest.java b/jdk/test/java/awt/Window/AlwaysOnTop/SyncAlwaysOnTopFieldTest.java new file mode 100644 index 00000000000..ed76fa8e0a2 --- /dev/null +++ b/jdk/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 From 9cc6c5c2c5812587eb9be4ee97231704038d52a3 Mon Sep 17 00:00:00 2001 From: Mikael Auno Date: Fri, 14 Nov 2014 10:22:43 +0100 Subject: [PATCH 23/67] 8064799: [TESTBUG] JT-Reg Serviceability tests to be run as part of JPRT submit job Reviewed-by: sla, alanb, dholmes, sspitsyn --- jdk/test/TEST.groups | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups index 6cee6e39d0d..b832f2335a4 100644 --- a/jdk/test/TEST.groups +++ b/jdk/test/TEST.groups @@ -290,6 +290,65 @@ jdk_desktop = \ :jdk_sound \ :jdk_imageio +############################################################################### +# +# Serviceability sanity groups +# +# These groups specify a subset of Serviceability tests that are supposed to +# guard against breakage of Serviceability features by other component teams. +# They are added to the "hotspot" testset in JPRT so that they will run on all +# full-forest pushes through JPRT. +# + +jdk_svc_sanity = \ + :jdk_management_sanity \ + :jdk_instrument_sanity \ + :jdk_jmx_sanity \ + :jdk_jdi_sanity \ + :svc_tools_sanity + +jdk_management_sanity = + +jdk_instrument_sanity = + +jdk_jmx_sanity = + +jdk_jdi_sanity = \ + com/sun/jdi/AcceptTimeout.java \ + com/sun/jdi/AccessSpecifierTest.java \ + com/sun/jdi/AfterThreadDeathTest.java \ + com/sun/jdi/ArrayRangeTest.java \ + com/sun/jdi/ConstantPoolInfo.java \ + com/sun/jdi/CountFilterTest.java \ + com/sun/jdi/EarlyReturnNegativeTest.java \ + com/sun/jdi/EarlyReturnTest.java \ + com/sun/jdi/FieldWatchpoints.java \ + com/sun/jdi/FramesTest.java \ + com/sun/jdi/InstanceFilter.java \ + com/sun/jdi/InterfaceMethodsTest.java \ + com/sun/jdi/InvokeTest.java \ + com/sun/jdi/LocalVariableEqual.java \ + com/sun/jdi/LocationTest.java \ + com/sun/jdi/ModificationWatchpoints.java \ + com/sun/jdi/MonitorEventTest.java \ + com/sun/jdi/MonitorFrameInfo.java \ + com/sun/jdi/NullThreadGroupNameTest.java \ + com/sun/jdi/PopAndStepTest.java \ + com/sun/jdi/PopAsynchronousTest.java \ + com/sun/jdi/ProcessAttachTest.java \ + com/sun/jdi/ReferrersTest.java \ + com/sun/jdi/RequestReflectionTest.java \ + com/sun/jdi/ResumeOneThreadTest.java \ + com/sun/jdi/RunToExit.java \ + com/sun/jdi/SourceNameFilterTest.java \ + com/sun/jdi/VarargsTest.java \ + com/sun/jdi/Vars.java \ + com/sun/jdi/redefineMethod/RedefineTest.java \ + com/sun/jdi/sde/MangleTest.java \ + com/sun/jdi/sde/TemperatureTableTest.java + +svc_tools_sanity = + ############################# # # Stable test groups From 24c525eb116137aaebbd373e6ce22f1f7f799d25 Mon Sep 17 00:00:00 2001 From: Petr Pchelko Date: Fri, 14 Nov 2014 16:19:40 +0400 Subject: [PATCH 24/67] 8023723: Can not paste and copy the text from the text area into the editor Reviewed-by: serb, alexsch --- .../META-INF/services/sun.datatransfer.DesktopDatatransferService | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename jdk/src/java.desktop/share/classes/{sun/awt/datatransfer => }/META-INF/services/sun.datatransfer.DesktopDatatransferService (100%) diff --git a/jdk/src/java.desktop/share/classes/sun/awt/datatransfer/META-INF/services/sun.datatransfer.DesktopDatatransferService b/jdk/src/java.desktop/share/classes/META-INF/services/sun.datatransfer.DesktopDatatransferService similarity index 100% rename from jdk/src/java.desktop/share/classes/sun/awt/datatransfer/META-INF/services/sun.datatransfer.DesktopDatatransferService rename to jdk/src/java.desktop/share/classes/META-INF/services/sun.datatransfer.DesktopDatatransferService From 5b4a9bc9764355ca732617c6a65e94e044fe13df Mon Sep 17 00:00:00 2001 From: Anton Nashatyrev Date: Fri, 14 Nov 2014 17:53:46 +0300 Subject: [PATCH 25/67] 8059739: Dragged and Dropped data is corrupted for two data types Reviewed-by: serb, pchelko --- .../swing/plaf/basic/BasicTransferable.java | 15 +++- .../DataTransfer/8059739/bug8059739.java | 80 +++++++++++++++++++ 2 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 jdk/test/javax/swing/DataTransfer/8059739/bug8059739.java diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTransferable.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTransferable.java index 7ed4e3d53ba..544c2ebe731 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTransferable.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTransferable.java @@ -24,6 +24,8 @@ */ package javax.swing.plaf.basic; +import sun.datatransfer.DataFlavorUtil; + import java.io.*; import java.awt.datatransfer.*; import javax.swing.plaf.UIResource; @@ -145,7 +147,7 @@ class BasicTransferable implements Transferable, UIResource { } else if (Reader.class.equals(flavor.getRepresentationClass())) { return new StringReader(data); } else if (InputStream.class.equals(flavor.getRepresentationClass())) { - return new StringBufferInputStream(data); + return createInputStream(flavor, data); } // fall through to unsupported } else if (isPlainFlavor(flavor)) { @@ -156,7 +158,7 @@ class BasicTransferable implements Transferable, UIResource { } else if (Reader.class.equals(flavor.getRepresentationClass())) { return new StringReader(data); } else if (InputStream.class.equals(flavor.getRepresentationClass())) { - return new StringBufferInputStream(data); + return createInputStream(flavor, data); } // fall through to unsupported @@ -168,6 +170,15 @@ class BasicTransferable implements Transferable, UIResource { throw new UnsupportedFlavorException(flavor); } + private InputStream createInputStream(DataFlavor flavor, String data) + throws IOException, UnsupportedFlavorException { + String cs = DataFlavorUtil.getTextCharset(flavor); + if (cs == null) { + throw new UnsupportedFlavorException(flavor); + } + return new ByteArrayInputStream(data.getBytes(cs)); + } + // --- richer subclass flavors ---------------------------------------------- protected boolean isRicherFlavor(DataFlavor flavor) { diff --git a/jdk/test/javax/swing/DataTransfer/8059739/bug8059739.java b/jdk/test/javax/swing/DataTransfer/8059739/bug8059739.java new file mode 100644 index 00000000000..b2b8bada4da --- /dev/null +++ b/jdk/test/javax/swing/DataTransfer/8059739/bug8059739.java @@ -0,0 +1,80 @@ +/* + * 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 8059739 + @summary Dragged and Dropped data is corrupted for two data types + @author Anton Nashatyrev +*/ + +import javax.swing.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; + +public class bug8059739 { + + private static boolean passed = true; + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + try { + runTest(); + } catch (Exception e) { + e.printStackTrace(); + passed = false; + } + } + }); + + if (!passed) { + throw new RuntimeException("Test FAILED."); + } else { + System.out.println("Passed."); + } + } + + private static void runTest() throws Exception { + String testString = "my string"; + JTextField tf = new JTextField(testString); + tf.selectAll(); + Clipboard clipboard = new Clipboard("clip"); + tf.getTransferHandler().exportToClipboard(tf, clipboard, TransferHandler.COPY); + DataFlavor[] dfs = clipboard.getAvailableDataFlavors(); + for (DataFlavor df: dfs) { + String charset = df.getParameter("charset"); + if (InputStream.class.isAssignableFrom(df.getRepresentationClass()) && + charset != null) { + BufferedReader br = new BufferedReader(new InputStreamReader( + (InputStream) clipboard.getData(df), charset)); + String s = br.readLine(); + System.out.println("Content: '" + s + "'"); + passed &= s.contains(testString); + } + } + } +} From 477b157f387116cf14f674e166eed72adce2363b Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Mon, 17 Nov 2014 23:56:53 +0100 Subject: [PATCH 26/67] 8065070: (fmt) Avoid creating substrings when building FormatSpecifier Reviewed-by: martin, shade --- .../share/classes/java/util/Formatter.java | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/Formatter.java b/jdk/src/java.base/share/classes/java/util/Formatter.java index a12952bde02..70298d5b59f 100644 --- a/jdk/src/java.base/share/classes/java/util/Formatter.java +++ b/jdk/src/java.base/share/classes/java/util/Formatter.java @@ -2624,10 +2624,11 @@ public final class Formatter implements Closeable, Flushable { private boolean dt = false; private char c; - private int index(String s) { - if (s != null) { + private int index(String s, int start, int end) { + if (start >= 0) { try { - index = Integer.parseInt(s.substring(0, s.length() - 1)); + // skip the trailing '$' + index = Integer.parseInt(s, start, end - 1, 10); } catch (NumberFormatException x) { assert(false); } @@ -2648,11 +2649,11 @@ public final class Formatter implements Closeable, Flushable { return f; } - private int width(String s) { + private int width(String s, int start, int end) { width = -1; - if (s != null) { + if (start >= 0) { try { - width = Integer.parseInt(s); + width = Integer.parseInt(s, start, end, 10); if (width < 0) throw new IllegalFormatWidthException(width); } catch (NumberFormatException x) { @@ -2662,12 +2663,12 @@ public final class Formatter implements Closeable, Flushable { return width; } - private int precision(String s) { + private int precision(String s, int start, int end) { precision = -1; - if (s != null) { + if (start >= 0) { try { - // remove the '.' - precision = Integer.parseInt(s.substring(1)); + // skip the leading '.' + precision = Integer.parseInt(s, start + 1, end, 10); if (precision < 0) throw new IllegalFormatPrecisionException(precision); } catch (NumberFormatException x) { @@ -2695,23 +2696,19 @@ public final class Formatter implements Closeable, Flushable { } FormatSpecifier(String s, Matcher m) { - int idx = 1; + index(s, m.start(1), m.end(1)); + flags(s, m.start(2), m.end(2)); + width(s, m.start(3), m.end(3)); + precision(s, m.start(4), m.end(4)); - index(m.group(idx++)); - flags(s, m.start(idx), m.end(idx++)); - width(m.group(idx++)); - precision(m.group(idx++)); - - int tTStart = m.start(idx); - int tTEnd = m.end(idx++); - if (tTStart != -1 && tTEnd != -1) { + int tTStart = m.start(5); + if (tTStart >= 0) { dt = true; - if (tTStart == tTEnd - 1 && s.charAt(tTStart) == 'T') { + if (s.charAt(tTStart) == 'T') { f.add(Flags.UPPERCASE); } } - - conversion(s.charAt(m.start(idx))); + conversion(s.charAt(m.start(6))); if (dt) checkDateTime(); From 53906a2cb4cc06f0817d97be68a405c60edf5efa Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Wed, 19 Nov 2014 21:22:22 -0500 Subject: [PATCH 27/67] 8064932: java/lang/ProcessBuilder/Basic.java: waitFor didn't take long enough Reviewed-by: dholmes, martin --- .../unix/classes/java/lang/UNIXProcess.java | 17 ++++++++++------- .../windows/classes/java/lang/ProcessImpl.java | 18 ++++++++++++++---- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/jdk/src/java.base/unix/classes/java/lang/UNIXProcess.java b/jdk/src/java.base/unix/classes/java/lang/UNIXProcess.java index 85f15407c8f..d3adac90cd2 100644 --- a/jdk/src/java.base/unix/classes/java/lang/UNIXProcess.java +++ b/jdk/src/java.base/unix/classes/java/lang/UNIXProcess.java @@ -406,14 +406,17 @@ final class UNIXProcess extends Process { if (hasExited) return true; if (timeout <= 0) return false; - long timeoutAsNanos = unit.toNanos(timeout); - long startTime = System.nanoTime(); - long rem = timeoutAsNanos; + long remainingNanos = unit.toNanos(timeout); + long deadline = System.nanoTime() + remainingNanos; - while (!hasExited && (rem > 0)) { - wait(Math.max(TimeUnit.NANOSECONDS.toMillis(rem), 1)); - rem = timeoutAsNanos - (System.nanoTime() - startTime); - } + do { + // Round up to next millisecond + wait(TimeUnit.NANOSECONDS.toMillis(remainingNanos + 999_999L)); + if (hasExited) { + return true; + } + remainingNanos = deadline - System.nanoTime(); + } while (remainingNanos > 0); return hasExited; } diff --git a/jdk/src/java.base/windows/classes/java/lang/ProcessImpl.java b/jdk/src/java.base/windows/classes/java/lang/ProcessImpl.java index 02e0c7bf346..ec90ea0da3a 100644 --- a/jdk/src/java.base/windows/classes/java/lang/ProcessImpl.java +++ b/jdk/src/java.base/windows/classes/java/lang/ProcessImpl.java @@ -461,11 +461,21 @@ final class ProcessImpl extends Process { if (getExitCodeProcess(handle) != STILL_ACTIVE) return true; if (timeout <= 0) return false; - long msTimeout = unit.toMillis(timeout); + long remainingNanos = unit.toNanos(timeout); + long deadline = System.nanoTime() + remainingNanos ; + + do { + // Round up to next millisecond + long msTimeout = TimeUnit.NANOSECONDS.toMillis(remainingNanos + 999_999L); + waitForTimeoutInterruptibly(handle, msTimeout); + if (Thread.interrupted()) + throw new InterruptedException(); + if (getExitCodeProcess(handle) != STILL_ACTIVE) { + return true; + } + remainingNanos = deadline - System.nanoTime(); + } while (remainingNanos > 0); - waitForTimeoutInterruptibly(handle, msTimeout); - if (Thread.interrupted()) - throw new InterruptedException(); return (getExitCodeProcess(handle) != STILL_ACTIVE); } From d5aaa2d8ffcc9fe9d6df7927089db4af38ee1f61 Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Wed, 19 Nov 2014 21:28:26 -0500 Subject: [PATCH 28/67] 8065372: Object.wait(ms, ns) timeout returns early Reviewed-by: martin, dholmes --- jdk/src/java.base/share/classes/java/lang/Object.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/classes/java/lang/Object.java b/jdk/src/java.base/share/classes/java/lang/Object.java index bf6133109d5..04ca33153d6 100644 --- a/jdk/src/java.base/share/classes/java/lang/Object.java +++ b/jdk/src/java.base/share/classes/java/lang/Object.java @@ -453,7 +453,7 @@ public class Object { "nanosecond timeout value out of range"); } - if (nanos >= 500000 || (nanos != 0 && timeout == 0)) { + if (nanos > 0) { timeout++; } From f4aff4270865de2eb699c156269bd95685429c54 Mon Sep 17 00:00:00 2001 From: Brent Christian Date: Fri, 14 Nov 2014 13:46:19 -0800 Subject: [PATCH 29/67] 8064288: sun.management.Flag should loadLibrary() Call System.loadLibrary("management") from Flag static initializer Reviewed-by: mchung --- .../share/classes/sun/management/Flag.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jdk/src/java.management/share/classes/sun/management/Flag.java b/jdk/src/java.management/share/classes/sun/management/Flag.java index 4f52cb51495..52da43e8408 100644 --- a/jdk/src/java.management/share/classes/sun/management/Flag.java +++ b/jdk/src/java.management/share/classes/sun/management/Flag.java @@ -28,6 +28,7 @@ package sun.management; import java.util.*; import com.sun.management.VMOption; import com.sun.management.VMOption.Origin; +import java.security.AccessController; /** * Flag class is a helper class for constructing a VMOption. @@ -115,6 +116,13 @@ class Flag { static synchronized native void setStringValue(String name, String value); static { + AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public Void run() { + System.loadLibrary("management"); + return null; + } + }); initialize(); } private static native void initialize(); From f50ee8896ab8c7fff4af38fc9d9ed86649a1c4f5 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Sun, 16 Nov 2014 15:03:46 +0100 Subject: [PATCH 30/67] 8058887: (fmt) Improve java/util/Formatter test coverage of group separators and width Reviewed-by: sherman --- .../java/util/Formatter/Basic-X.java.template | 44 ++++++++- .../java/util/Formatter/BasicBigDecimal.java | 73 ++++++++++++++- .../java/util/Formatter/BasicBigInteger.java | 89 ++++++++++++++++++- .../java/util/Formatter/BasicBoolean.java | 89 ++++++++++++++++++- .../util/Formatter/BasicBooleanObject.java | 89 ++++++++++++++++++- jdk/test/java/util/Formatter/BasicByte.java | 89 ++++++++++++++++++- .../java/util/Formatter/BasicByteObject.java | 89 ++++++++++++++++++- jdk/test/java/util/Formatter/BasicChar.java | 89 ++++++++++++++++++- .../java/util/Formatter/BasicCharObject.java | 89 ++++++++++++++++++- .../java/util/Formatter/BasicDateTime.java | 89 ++++++++++++++++++- jdk/test/java/util/Formatter/BasicDouble.java | 55 ++++++++++-- .../util/Formatter/BasicDoubleObject.java | 73 ++++++++++++++- jdk/test/java/util/Formatter/BasicFloat.java | 73 ++++++++++++++- .../java/util/Formatter/BasicFloatObject.java | 73 ++++++++++++++- jdk/test/java/util/Formatter/BasicInt.java | 89 ++++++++++++++++++- .../java/util/Formatter/BasicIntObject.java | 89 ++++++++++++++++++- jdk/test/java/util/Formatter/BasicLong.java | 89 ++++++++++++++++++- .../java/util/Formatter/BasicLongObject.java | 89 ++++++++++++++++++- jdk/test/java/util/Formatter/BasicShort.java | 89 ++++++++++++++++++- .../java/util/Formatter/BasicShortObject.java | 89 ++++++++++++++++++- jdk/test/java/util/Formatter/genBasic.sh | 2 +- 21 files changed, 1614 insertions(+), 25 deletions(-) diff --git a/jdk/test/java/util/Formatter/Basic-X.java.template b/jdk/test/java/util/Formatter/Basic-X.java.template index 2393cfaa59b..47c5516be49 100644 --- a/jdk/test/java/util/Formatter/Basic-X.java.template +++ b/jdk/test/java/util/Formatter/Basic-X.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class Basic$Type$ extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class Basic$Type$ extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -572,6 +580,14 @@ public class Basic$Type$ extends Basic { test("%(10d", " (12345)", negate(oneToFive)); test("%-10d", "12345 ", oneToFive); test("%-10d", "-12345 ", negate(oneToFive)); + // , variations: + test("% ,d", " 12,345", oneToFive); + test("% ,d", "-12,345", negate(oneToFive)); + test("%0,10d", "000012,345", oneToFive); + test("%0,10d", "-00012,345", negate(oneToFive)); + test("%(,10d", " (12,345)", negate(oneToFive)); + test("%-,10d", "12,345 ", oneToFive); + test("%-,10d", "-12,345 ", negate(oneToFive)); #else[short] #if[prim] @@ -594,6 +610,16 @@ public class Basic$Type$ extends Basic { test("%(10d", " (1234567)", negate(oneToSeven)); test("%-10d", "1234567 ", oneToSeven); test("%-10d", "-1234567 ", negate(oneToSeven)); + // , variations: + test("% ,d", " 1,234,567", oneToSeven); + test("% ,d", "-1,234,567", negate(oneToSeven)); + test("%+,10d", "+1,234,567", oneToSeven); + test("%0,10d", "01,234,567", oneToSeven); + test("%0,10d", "-1,234,567", negate(oneToSeven)); + test("%(,10d", "(1,234,567)", negate(oneToSeven)); + test("%-,10d", "1,234,567 ", oneToSeven); + test("%-,10d", "-1,234,567", negate(oneToSeven)); + #end[prim] #end[short] #end[byte] @@ -781,6 +807,14 @@ public class Basic$Type$ extends Basic { test("%+d", "-1234567", new BigInteger("-1234567", 10)); test("%-10d", "1234567 ", new BigInteger("1234567", 10)); test("%-10d", "-1234567 ", new BigInteger("-1234567", 10)); + // , variations: + test("%0,10d", "01,234,567", new BigInteger("1234567", 10)); + test("%0,10d", "-1,234,567", new BigInteger("-1234567", 10)); + test("%(,10d", "(1,234,567)", new BigInteger("-1234567", 10)); + test("%+,d", "+1,234,567", new BigInteger("1234567", 10)); + test("%+,d", "-1,234,567", new BigInteger("-1234567", 10)); + test("%-,10d", "1,234,567 ", new BigInteger("1234567", 10)); + test("%-,10d", "-1,234,567", new BigInteger("-1234567", 10)); //--------------------------------------------------------------------- // %o - BigInteger @@ -1039,6 +1073,14 @@ public class Basic$Type$ extends Basic { test("%3.0f", "1000000", 1000000.00); test("%3.0f", "10000000", 10000000.00); test("%3.0f", "100000000", 100000000.00); + test("%10.0f", " 1000000", 1000000.00); + test("%,10.0f", " 1,000,000", 1000000.00); + test("%,10.1f", "1,000,000.0", 1000000.00); + test("%,3.0f", "1,000,000", 1000000.00); + test("%,3.0f", "10,000,000", 10000000.00); + test("%,3.0f", "100,000,000", 100000000.00); + test("%,3.0f", "10,000,000", 10000000.00); + test("%,3.0f", "100,000,000", 100000000.00); #if[BigDecimal] //--------------------------------------------------------------------- // %f - BigDecimal diff --git a/jdk/test/java/util/Formatter/BasicBigDecimal.java b/jdk/test/java/util/Formatter/BasicBigDecimal.java index a622e5afd02..00a04f4535f 100644 --- a/jdk/test/java/util/Formatter/BasicBigDecimal.java +++ b/jdk/test/java/util/Formatter/BasicBigDecimal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicBigDecimal extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicBigDecimal extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -810,6 +818,32 @@ public class BasicBigDecimal extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1039,6 +1073,14 @@ public class BasicBigDecimal extends Basic { test("%3.0f", "1000000", 1000000.00); test("%3.0f", "10000000", 10000000.00); test("%3.0f", "100000000", 100000000.00); + test("%10.0f", " 1000000", 1000000.00); + test("%,10.0f", " 1,000,000", 1000000.00); + test("%,10.1f", "1,000,000.0", 1000000.00); + test("%,3.0f", "1,000,000", 1000000.00); + test("%,3.0f", "10,000,000", 10000000.00); + test("%,3.0f", "100,000,000", 100000000.00); + test("%,3.0f", "10,000,000", 10000000.00); + test("%,3.0f", "100,000,000", 100000000.00); //--------------------------------------------------------------------- // %f - BigDecimal @@ -1330,6 +1372,35 @@ public class BasicBigDecimal extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicBigInteger.java b/jdk/test/java/util/Formatter/BasicBigInteger.java index af3cac5e47b..aceecc67c81 100644 --- a/jdk/test/java/util/Formatter/BasicBigInteger.java +++ b/jdk/test/java/util/Formatter/BasicBigInteger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicBigInteger extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicBigInteger extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -735,6 +743,24 @@ public class BasicBigInteger extends Basic { + + + + + + + + + + + + + + + + + + @@ -781,6 +807,14 @@ public class BasicBigInteger extends Basic { test("%+d", "-1234567", new BigInteger("-1234567", 10)); test("%-10d", "1234567 ", new BigInteger("1234567", 10)); test("%-10d", "-1234567 ", new BigInteger("-1234567", 10)); + // , variations: + test("%0,10d", "01,234,567", new BigInteger("1234567", 10)); + test("%0,10d", "-1,234,567", new BigInteger("-1234567", 10)); + test("%(,10d", "(1,234,567)", new BigInteger("-1234567", 10)); + test("%+,d", "+1,234,567", new BigInteger("1234567", 10)); + test("%+,d", "-1,234,567", new BigInteger("-1234567", 10)); + test("%-,10d", "1,234,567 ", new BigInteger("1234567", 10)); + test("%-,10d", "-1,234,567", new BigInteger("-1234567", 10)); //--------------------------------------------------------------------- // %o - BigInteger @@ -1552,6 +1586,59 @@ public class BasicBigInteger extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicBoolean.java b/jdk/test/java/util/Formatter/BasicBoolean.java index 192a2192460..83f8accb1ab 100644 --- a/jdk/test/java/util/Formatter/BasicBoolean.java +++ b/jdk/test/java/util/Formatter/BasicBoolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicBoolean extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicBoolean extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -1552,6 +1560,85 @@ public class BasicBoolean extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicBooleanObject.java b/jdk/test/java/util/Formatter/BasicBooleanObject.java index 830fe729788..86b940591d3 100644 --- a/jdk/test/java/util/Formatter/BasicBooleanObject.java +++ b/jdk/test/java/util/Formatter/BasicBooleanObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicBooleanObject extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicBooleanObject extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -1552,6 +1560,85 @@ public class BasicBooleanObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicByte.java b/jdk/test/java/util/Formatter/BasicByte.java index 4887e948b11..663153f6bd2 100644 --- a/jdk/test/java/util/Formatter/BasicByte.java +++ b/jdk/test/java/util/Formatter/BasicByte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicByte extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicByte extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -578,6 +586,24 @@ public class BasicByte extends Basic { + + + + + + + + + + + + + + + + + + @@ -1552,6 +1578,67 @@ public class BasicByte extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicByteObject.java b/jdk/test/java/util/Formatter/BasicByteObject.java index 9a6dd23adbc..ac4aef83571 100644 --- a/jdk/test/java/util/Formatter/BasicByteObject.java +++ b/jdk/test/java/util/Formatter/BasicByteObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicByteObject extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicByteObject extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -578,6 +586,24 @@ public class BasicByteObject extends Basic { + + + + + + + + + + + + + + + + + + @@ -1552,6 +1578,67 @@ public class BasicByteObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicChar.java b/jdk/test/java/util/Formatter/BasicChar.java index 8fe4bd52323..ce0e5311b09 100644 --- a/jdk/test/java/util/Formatter/BasicChar.java +++ b/jdk/test/java/util/Formatter/BasicChar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicChar extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicChar extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -1552,6 +1560,85 @@ public class BasicChar extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicCharObject.java b/jdk/test/java/util/Formatter/BasicCharObject.java index 744103e8bd2..e1baf82cb80 100644 --- a/jdk/test/java/util/Formatter/BasicCharObject.java +++ b/jdk/test/java/util/Formatter/BasicCharObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicCharObject extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicCharObject extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -1552,6 +1560,85 @@ public class BasicCharObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicDateTime.java b/jdk/test/java/util/Formatter/BasicDateTime.java index 131d7234b65..f31238189d8 100644 --- a/jdk/test/java/util/Formatter/BasicDateTime.java +++ b/jdk/test/java/util/Formatter/BasicDateTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicDateTime extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicDateTime extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -1552,6 +1560,85 @@ public class BasicDateTime extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicDouble.java b/jdk/test/java/util/Formatter/BasicDouble.java index 4d3bcae836e..11760f17f7f 100644 --- a/jdk/test/java/util/Formatter/BasicDouble.java +++ b/jdk/test/java/util/Formatter/BasicDouble.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -36,6 +36,9 @@ import java.math.BigInteger; import java.text.DateFormatSymbols; import java.util.*; +import sun.misc.DoubleConsts; + + import static java.util.Calendar.*; @@ -48,6 +51,10 @@ public class BasicDouble extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -55,6 +62,10 @@ public class BasicDouble extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -838,6 +849,32 @@ public class BasicDouble extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1036,6 +1073,14 @@ public class BasicDouble extends Basic { test("%3.0f", "1000000", 1000000.00); test("%3.0f", "10000000", 10000000.00); test("%3.0f", "100000000", 100000000.00); + test("%10.0f", " 1000000", 1000000.00); + test("%,10.0f", " 1,000,000", 1000000.00); + test("%,10.1f", "1,000,000.0", 1000000.00); + test("%,3.0f", "1,000,000", 1000000.00); + test("%,3.0f", "10,000,000", 10000000.00); + test("%,3.0f", "100,000,000", 100000000.00); + test("%,3.0f", "10,000,000", 10000000.00); + test("%,3.0f", "100,000,000", 100000000.00); @@ -1310,12 +1355,12 @@ public class BasicDouble extends Basic { test("%.1a", "-0x1.0p0", -1.0); test("%.11a", "0x1.80000000000p1", 3.0); test("%.1a", "0x1.8p1", 3.0); - test("%.11a", "0x1.00000000000p-1022", Double.MIN_NORMAL); - test("%.1a", "0x1.0p-1022", Double.MIN_NORMAL); + test("%.11a", "0x1.00000000000p-1022", DoubleConsts.MIN_NORMAL); + test("%.1a", "0x1.0p-1022", DoubleConsts.MIN_NORMAL); test("%.11a", "0x1.00000000000p-1022", - Math.nextDown(Double.MIN_NORMAL)); + Math.nextDown(DoubleConsts.MIN_NORMAL)); test("%.1a", "0x1.0p-1022", - Math.nextDown(Double.MIN_NORMAL)); + Math.nextDown(DoubleConsts.MIN_NORMAL)); test("%.11a", "0x1.ffffffffffep-1023", 0x0.fffffffffffp-1022); test("%.1a", "0x1.0p-1022", 0x0.fffffffffffp-1022); test("%.30a", "0x0.000000000000100000000000000000p-1022", Double.MIN_VALUE); diff --git a/jdk/test/java/util/Formatter/BasicDoubleObject.java b/jdk/test/java/util/Formatter/BasicDoubleObject.java index 8ecfc453d7a..3dea2a346b8 100644 --- a/jdk/test/java/util/Formatter/BasicDoubleObject.java +++ b/jdk/test/java/util/Formatter/BasicDoubleObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicDoubleObject extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicDoubleObject extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -851,6 +859,32 @@ public class BasicDoubleObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1039,6 +1073,14 @@ public class BasicDoubleObject extends Basic { test("%3.0f", "1000000", 1000000.00); test("%3.0f", "10000000", 10000000.00); test("%3.0f", "100000000", 100000000.00); + test("%10.0f", " 1000000", 1000000.00); + test("%,10.0f", " 1,000,000", 1000000.00); + test("%,10.1f", "1,000,000.0", 1000000.00); + test("%,3.0f", "1,000,000", 1000000.00); + test("%,3.0f", "10,000,000", 10000000.00); + test("%,3.0f", "100,000,000", 100000000.00); + test("%,3.0f", "10,000,000", 10000000.00); + test("%,3.0f", "100,000,000", 100000000.00); @@ -1330,6 +1372,35 @@ public class BasicDoubleObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicFloat.java b/jdk/test/java/util/Formatter/BasicFloat.java index 94eb867b4fb..0ac8a6f45f0 100644 --- a/jdk/test/java/util/Formatter/BasicFloat.java +++ b/jdk/test/java/util/Formatter/BasicFloat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicFloat extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicFloat extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -821,6 +829,32 @@ public class BasicFloat extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1039,6 +1073,14 @@ public class BasicFloat extends Basic { test("%3.0f", "1000000", 1000000.00); test("%3.0f", "10000000", 10000000.00); test("%3.0f", "100000000", 100000000.00); + test("%10.0f", " 1000000", 1000000.00); + test("%,10.0f", " 1,000,000", 1000000.00); + test("%,10.1f", "1,000,000.0", 1000000.00); + test("%,3.0f", "1,000,000", 1000000.00); + test("%,3.0f", "10,000,000", 10000000.00); + test("%,3.0f", "100,000,000", 100000000.00); + test("%,3.0f", "10,000,000", 10000000.00); + test("%,3.0f", "100,000,000", 100000000.00); @@ -1330,6 +1372,35 @@ public class BasicFloat extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicFloatObject.java b/jdk/test/java/util/Formatter/BasicFloatObject.java index 5dd9c44efec..d9fb5de7aa4 100644 --- a/jdk/test/java/util/Formatter/BasicFloatObject.java +++ b/jdk/test/java/util/Formatter/BasicFloatObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicFloatObject extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicFloatObject extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -831,6 +839,32 @@ public class BasicFloatObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1039,6 +1073,14 @@ public class BasicFloatObject extends Basic { test("%3.0f", "1000000", 1000000.00); test("%3.0f", "10000000", 10000000.00); test("%3.0f", "100000000", 100000000.00); + test("%10.0f", " 1000000", 1000000.00); + test("%,10.0f", " 1,000,000", 1000000.00); + test("%,10.1f", "1,000,000.0", 1000000.00); + test("%,3.0f", "1,000,000", 1000000.00); + test("%,3.0f", "10,000,000", 10000000.00); + test("%,3.0f", "100,000,000", 100000000.00); + test("%,3.0f", "10,000,000", 10000000.00); + test("%,3.0f", "100,000,000", 100000000.00); @@ -1330,6 +1372,35 @@ public class BasicFloatObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicInt.java b/jdk/test/java/util/Formatter/BasicInt.java index cc71a40172f..7cef571e086 100644 --- a/jdk/test/java/util/Formatter/BasicInt.java +++ b/jdk/test/java/util/Formatter/BasicInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicInt extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicInt extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -566,6 +574,14 @@ public class BasicInt extends Basic { + + + + + + + + @@ -594,6 +610,16 @@ public class BasicInt extends Basic { test("%(10d", " (1234567)", negate(oneToSeven)); test("%-10d", "1234567 ", oneToSeven); test("%-10d", "-1234567 ", negate(oneToSeven)); + // , variations: + test("% ,d", " 1,234,567", oneToSeven); + test("% ,d", "-1,234,567", negate(oneToSeven)); + test("%+,10d", "+1,234,567", oneToSeven); + test("%0,10d", "01,234,567", oneToSeven); + test("%0,10d", "-1,234,567", negate(oneToSeven)); + test("%(,10d", "(1,234,567)", negate(oneToSeven)); + test("%-,10d", "1,234,567 ", oneToSeven); + test("%-,10d", "-1,234,567", negate(oneToSeven)); + @@ -1552,6 +1578,67 @@ public class BasicInt extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicIntObject.java b/jdk/test/java/util/Formatter/BasicIntObject.java index 08b6bd56a5c..df2c2a26a63 100644 --- a/jdk/test/java/util/Formatter/BasicIntObject.java +++ b/jdk/test/java/util/Formatter/BasicIntObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicIntObject extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicIntObject extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -578,6 +586,24 @@ public class BasicIntObject extends Basic { + + + + + + + + + + + + + + + + + + @@ -1552,6 +1578,67 @@ public class BasicIntObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicLong.java b/jdk/test/java/util/Formatter/BasicLong.java index b26d6b0a03d..bcac973aaa0 100644 --- a/jdk/test/java/util/Formatter/BasicLong.java +++ b/jdk/test/java/util/Formatter/BasicLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicLong extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicLong extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -566,6 +574,14 @@ public class BasicLong extends Basic { + + + + + + + + @@ -594,6 +610,16 @@ public class BasicLong extends Basic { test("%(10d", " (1234567)", negate(oneToSeven)); test("%-10d", "1234567 ", oneToSeven); test("%-10d", "-1234567 ", negate(oneToSeven)); + // , variations: + test("% ,d", " 1,234,567", oneToSeven); + test("% ,d", "-1,234,567", negate(oneToSeven)); + test("%+,10d", "+1,234,567", oneToSeven); + test("%0,10d", "01,234,567", oneToSeven); + test("%0,10d", "-1,234,567", negate(oneToSeven)); + test("%(,10d", "(1,234,567)", negate(oneToSeven)); + test("%-,10d", "1,234,567 ", oneToSeven); + test("%-,10d", "-1,234,567", negate(oneToSeven)); + @@ -1552,6 +1578,67 @@ public class BasicLong extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicLongObject.java b/jdk/test/java/util/Formatter/BasicLongObject.java index 847b66c8db4..852bbc4127c 100644 --- a/jdk/test/java/util/Formatter/BasicLongObject.java +++ b/jdk/test/java/util/Formatter/BasicLongObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicLongObject extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicLongObject extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -578,6 +586,24 @@ public class BasicLongObject extends Basic { + + + + + + + + + + + + + + + + + + @@ -1552,6 +1578,67 @@ public class BasicLongObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicShort.java b/jdk/test/java/util/Formatter/BasicShort.java index f2b61b121cc..04923018da5 100644 --- a/jdk/test/java/util/Formatter/BasicShort.java +++ b/jdk/test/java/util/Formatter/BasicShort.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicShort extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicShort extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -572,6 +580,24 @@ public class BasicShort extends Basic { test("%(10d", " (12345)", negate(oneToFive)); test("%-10d", "12345 ", oneToFive); test("%-10d", "-12345 ", negate(oneToFive)); + // , variations: + test("% ,d", " 12,345", oneToFive); + test("% ,d", "-12,345", negate(oneToFive)); + test("%0,10d", "000012,345", oneToFive); + test("%0,10d", "-00012,345", negate(oneToFive)); + test("%(,10d", " (12,345)", negate(oneToFive)); + test("%-,10d", "12,345 ", oneToFive); + test("%-,10d", "-12,345 ", negate(oneToFive)); + + + + + + + + + + @@ -1552,6 +1578,67 @@ public class BasicShort extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicShortObject.java b/jdk/test/java/util/Formatter/BasicShortObject.java index 1ed1263c729..1e8b7809a33 100644 --- a/jdk/test/java/util/Formatter/BasicShortObject.java +++ b/jdk/test/java/util/Formatter/BasicShortObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,6 +51,10 @@ public class BasicShortObject extends Basic { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), Locale.US); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(Locale l, String fs, String exp, Object ... args) @@ -58,6 +62,10 @@ public class BasicShortObject extends Basic { Formatter f = new Formatter(new StringBuilder(), l); f.format(fs, args); ck(fs, exp, f.toString()); + + f = new Formatter(new StringBuilder(), l); + f.format("foo " + fs + " bar", args); + ck(fs, "foo " + exp + " bar", f.toString()); } private static void test(String fs, Object ... args) { @@ -578,6 +586,24 @@ public class BasicShortObject extends Basic { + + + + + + + + + + + + + + + + + + @@ -1552,6 +1578,67 @@ public class BasicShortObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/genBasic.sh b/jdk/test/java/util/Formatter/genBasic.sh index 0931cc15874..24bd5f786e0 100644 --- a/jdk/test/java/util/Formatter/genBasic.sh +++ b/jdk/test/java/util/Formatter/genBasic.sh @@ -23,7 +23,7 @@ # questions. # -javac -d . ../../../../make/tools/src/build/tools/spp/Spp.java +javac -d . ../../../../make/src/classes/build/tools/spp/Spp.java gen() { # if [ $3 = "true" ] From fdb39122a12686ade08ff71ab1309520d6ee19ad Mon Sep 17 00:00:00 2001 From: Aleksei Efimov Date: Mon, 17 Nov 2014 14:11:08 +0300 Subject: [PATCH 31/67] 8064914: tzdb.dat compilation failure when using tzdata2014j Reviewed-by: sherman, coffeys --- .../build/tools/tzdb/TzdbZoneRulesProvider.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java b/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java index 220de9276c7..a59ce61eff9 100644 --- a/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java +++ b/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java @@ -95,7 +95,17 @@ class TzdbZoneRulesProvider { obj = zones.get(zoneId); } if (obj == null) { - throw new ZoneRulesException("Unknown time-zone ID: " + zoneId0); + // Timezone link can be located in 'backward' file and it + // can refer to another link, so we need to check for + // link one more time, before throwing an exception + String zoneIdBack = zoneId; + if (links.containsKey(zoneId)) { + zoneId = links.get(zoneId); + obj = zones.get(zoneId); + } + if (obj == null) { + throw new ZoneRulesException("Unknown time-zone ID: " + zoneIdBack); + } } } if (obj instanceof ZoneRules) { From ee4d018bad9db3e102296ed419179080b72ae76e Mon Sep 17 00:00:00 2001 From: Aleksei Efimov Date: Mon, 17 Nov 2014 14:50:05 +0300 Subject: [PATCH 32/67] 8064560: (tz) Support tzdata2014j Reviewed-by: okutsu --- jdk/make/data/tzdata/VERSION | 2 +- jdk/make/data/tzdata/africa | 79 +++----- jdk/make/data/tzdata/asia | 87 +++++---- jdk/make/data/tzdata/australasia | 12 +- jdk/make/data/tzdata/europe | 18 +- jdk/make/data/tzdata/leapseconds | 4 +- jdk/make/data/tzdata/northamerica | 20 ++- jdk/make/data/tzdata/southamerica | 18 +- jdk/test/sun/util/calendar/zi/tzdata/VERSION | 2 +- jdk/test/sun/util/calendar/zi/tzdata/africa | 136 +++++--------- jdk/test/sun/util/calendar/zi/tzdata/asia | 169 ++++++++++++------ .../sun/util/calendar/zi/tzdata/australasia | 56 ++++-- jdk/test/sun/util/calendar/zi/tzdata/europe | 33 +++- .../sun/util/calendar/zi/tzdata/leapseconds | 4 +- .../sun/util/calendar/zi/tzdata/northamerica | 61 ++++--- .../sun/util/calendar/zi/tzdata/southamerica | 18 +- jdk/test/sun/util/calendar/zi/tzdata/zone.tab | 3 +- 17 files changed, 407 insertions(+), 315 deletions(-) diff --git a/jdk/make/data/tzdata/VERSION b/jdk/make/data/tzdata/VERSION index fa498de5234..9987fde6dcb 100644 --- a/jdk/make/data/tzdata/VERSION +++ b/jdk/make/data/tzdata/VERSION @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2014i +tzdata2014j diff --git a/jdk/make/data/tzdata/africa b/jdk/make/data/tzdata/africa index 92c0d4728f3..43103225577 100644 --- a/jdk/make/data/tzdata/africa +++ b/jdk/make/data/tzdata/africa @@ -29,20 +29,19 @@ # tz@iana.org for general use in the future). For more, please see # the file CONTRIBUTING in the tz distribution. -# From Paul Eggert (2013-02-21): +# From Paul Eggert (2014-10-31): # -# A good source for time zone historical data outside the U.S. is +# Unless otherwise specified, the source for data through 1990 is: # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), # San Diego: ACS Publications, Inc. (2003). +# Unfortunately this book contains many errors and cites no sources. # # Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. -# -# Except where otherwise noted, Shanks & Pottenger is the source for -# entries through 1990, and IATA SSIM is the source for entries afterwards. +# of the IATA's data after 1990. Except where otherwise noted, +# IATA SSIM is the source for entries after 1990. # # Another source occasionally used is Edward W. Whitman, World Time Differences, # Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which @@ -88,7 +87,6 @@ # 3:00 CAST Central Africa Summer Time (no longer used) # 3:00 SAST South Africa Summer Time (no longer used) # 3:00 EAT East Africa Time -# 4:00 EAST East Africa Summer Time (no longer used) # Algeria # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -169,9 +167,7 @@ Zone Africa/Ndjamena 1:00:12 - LMT 1912 # N'Djamena 1:00 - WAT # Comoros -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Comoro 2:53:04 - LMT 1911 Jul # Moroni, Gran Comoro - 3:00 - EAT +# See Africa/Nairobi. # Democratic Republic of the Congo # See Africa/Lagos for the western part and Africa/Maputo for the eastern. @@ -195,9 +191,7 @@ Link Africa/Abidjan Africa/Sao_Tome # São Tomé and Príncipe Link Africa/Abidjan Atlantic/St_Helena # St Helena # Djibouti -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Djibouti 2:52:36 - LMT 1911 Jul - 3:00 - EAT +# See Africa/Nairobi. ############################################################################### @@ -410,27 +404,8 @@ Zone Africa/Cairo 2:05:09 - LMT 1900 Oct # See Africa/Lagos. # Eritrea -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Asmara 2:35:32 - LMT 1870 - 2:35:32 - AMT 1890 # Asmara Mean Time - 2:35:20 - ADMT 1936 May 5 # Adis Dera MT - 3:00 - EAT - # Ethiopia -# From Paul Eggert (2014-07-31): -# Like the Swahili of Kenya and Tanzania, many Ethiopians keep a -# 12-hour clock starting at our 06:00, so their "8 o'clock" is our -# 02:00 or 14:00. Keep this in mind when you ask the time in Amharic. -# -# Shanks & Pottenger write that Ethiopia had six narrowly-spaced time -# zones between 1870 and 1890, that they merged to 38E50 (2:35:20) in -# 1890, and that they switched to 3:00 on 1936-05-05. Perhaps 38E50 -# was for Adis Dera. Quite likely the Shanks data entries are wrong -# anyway. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Addis_Ababa 2:34:48 - LMT 1870 - 2:35:20 - ADMT 1936 May 5 # Adis Dera MT - 3:00 - EAT +# See Africa/Nairobi. # Gabon # See Africa/Lagos. @@ -474,6 +449,15 @@ Zone Africa/Nairobi 2:27:16 - LMT 1928 Jul 2:30 - BEAT 1940 2:45 - BEAUT 1960 3:00 - EAT +Link Africa/Nairobi Africa/Addis_Ababa # Ethiopia +Link Africa/Nairobi Africa/Asmara # Eritrea +Link Africa/Nairobi Africa/Dar_es_Salaam # Tanzania +Link Africa/Nairobi Africa/Djibouti +Link Africa/Nairobi Africa/Kampala # Uganda +Link Africa/Nairobi Africa/Mogadishu # Somalia +Link Africa/Nairobi Indian/Antananarivo # Madagascar +Link Africa/Nairobi Indian/Comoro +Link Africa/Nairobi Indian/Mayotte # Lesotho # See Africa/Johannesburg. @@ -551,11 +535,7 @@ Zone Africa/Tripoli 0:52:44 - LMT 1920 2:00 - EET # Madagascar -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Antananarivo 3:10:04 - LMT 1911 Jul - 3:00 - EAT 1954 Feb 27 23:00s - 3:00 1:00 EAST 1954 May 29 23:00s - 3:00 - EAT +# See Africa/Nairobi. # Malawi # See Africa/Maputo. @@ -658,9 +638,7 @@ Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis # no information; probably like Indian/Mauritius # Mayotte -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Mayotte 3:00:56 - LMT 1911 Jul # Mamoutzou - 3:00 - EAT +# See Africa/Nairobi. # Morocco # See the 'europe' file for Spanish Morocco (Africa/Ceuta). @@ -1072,11 +1050,7 @@ Zone Indian/Mahe 3:41:48 - LMT 1906 Jun # Victoria # See Africa/Abidjan. # Somalia -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Mogadishu 3:01:28 - LMT 1893 Nov - 3:00 - EAT 1931 - 2:30 - BEAT 1957 - 3:00 - EAT +# See Africa/Nairobi. # South Africa # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -1119,11 +1093,7 @@ Link Africa/Khartoum Africa/Juba # See Africa/Johannesburg. # Tanzania -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Dar_es_Salaam 2:37:08 - LMT 1931 - 3:00 - EAT 1948 - 2:45 - BEAUT 1961 - 3:00 - EAT +# See Africa/Nairobi. # Togo # See Africa/Abidjan. @@ -1229,12 +1199,7 @@ Zone Africa/Tunis 0:40:44 - LMT 1881 May 12 1:00 Tunisia CE%sT # Uganda -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Kampala 2:09:40 - LMT 1928 Jul - 3:00 - EAT 1930 - 2:30 - BEAT 1948 - 2:45 - BEAUT 1957 - 3:00 - EAT +# See Africa/Nairobi. # Zambia # Zimbabwe diff --git a/jdk/make/data/tzdata/asia b/jdk/make/data/tzdata/asia index 31754b2d567..960cab5062e 100644 --- a/jdk/make/data/tzdata/asia +++ b/jdk/make/data/tzdata/asia @@ -29,20 +29,19 @@ # tz@iana.org for general use in the future). For more, please see # the file CONTRIBUTING in the tz distribution. -# From Paul Eggert (2013-08-11): +# From Paul Eggert (2014-10-31): # -# A good source for time zone historical data outside the U.S. is +# Unless otherwise specified, the source for data through 1990 is: # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), # San Diego: ACS Publications, Inc. (2003). +# Unfortunately this book contains many errors and cites no sources. # # Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. -# -# Except where otherwise noted, Shanks & Pottenger is the source for -# entries through 1990, and IATA SSIM is the source for entries afterwards. +# of the IATA's data after 1990. Except where otherwise noted, +# IATA SSIM is the source for entries after 1990. # # Another source occasionally used is Edward W. Whitman, World Time Differences, # Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which @@ -1686,44 +1685,70 @@ Zone Asia/Bishkek 4:58:24 - LMT 1924 May 2 # Korea (North and South) # From Annie I. Bang (2006-07-10): -# http://www.koreaherald.co.kr/SITE/data/html_dir/2006/07/10/200607100012.asp -# The Ministry of Commerce, Industry and Energy has already -# commissioned a research project [to reintroduce DST] and has said -# the system may begin as early as 2008.... Korea ran a daylight -# saving program from 1949-61 but stopped it during the 1950-53 Korean War. +# http://www.koreaherald.com/view.php?ud=200607100012 +# Korea ran a daylight saving program from 1949-61 but stopped it +# during the 1950-53 Korean War. The system was temporarily enforced +# between 1987 and 1988 ... + +# From Sanghyuk Jung (2014-10-29): +# http://mm.icann.org/pipermail/tz/2014-October/021830.html +# According to the Korean Wikipedia +# http://ko.wikipedia.org/wiki/한국_표준시 +# [oldid=12896437 2014-09-04 08:03 UTC] +# DST in Republic of Korea was as follows.... And I checked old +# newspapers in Korean, all articles correspond with data in Wikipedia. +# For example, the article in 1948 (Korean Language) proved that DST +# started at June 1 in that year. For another example, the article in +# 1988 said that DST started at 2:00 AM in that year. -# From Shanks & Pottenger: # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule ROK 1960 only - May 15 0:00 1:00 D -Rule ROK 1960 only - Sep 13 0:00 0 S -Rule ROK 1987 1988 - May Sun>=8 0:00 1:00 D -Rule ROK 1987 1988 - Oct Sun>=8 0:00 0 S +Rule ROK 1948 only - Jun 1 0:00 1:00 D +Rule ROK 1948 only - Sep 13 0:00 0 S +Rule ROK 1949 only - Apr 3 0:00 1:00 D +Rule ROK 1949 1951 - Sep Sun>=8 0:00 0 S +Rule ROK 1950 only - Apr 1 0:00 1:00 D +Rule ROK 1951 only - May 6 0:00 1:00 D +Rule ROK 1955 only - May 5 0:00 1:00 D +Rule ROK 1955 only - Sep 9 0:00 0 S +Rule ROK 1956 only - May 20 0:00 1:00 D +Rule ROK 1956 only - Sep 30 0:00 0 S +Rule ROK 1957 1960 - May Sun>=1 0:00 1:00 D +Rule ROK 1957 1960 - Sep Sun>=18 0:00 0 S +Rule ROK 1987 1988 - May Sun>=8 2:00 1:00 D +Rule ROK 1987 1988 - Oct Sun>=8 3:00 0 S -# From Paul Eggert (2014-07-01): -# The following entries are from Shanks & Pottenger, except that I -# guessed that time zone abbreviations through 1945 followed the same +# From Paul Eggert (2014-10-30): +# The Korean Wikipedia entry gives the following sources for UT offsets: +# +# 1908: Official Journal Article No. 3994 (Edict No. 5) +# 1912: Governor-General of Korea Official Gazette Issue No. 367 +# (Announcement No. 338) +# 1954: Presidential Decree No. 876 (1954-03-17) +# 1961: Law No. 676 (1961-08-07) +# 1987: Law No. 3919 (1986-12-31) +# +# The Wikipedia entry also has confusing information about a change +# to UT+9 in April 1910, but then what would be the point of the later change +# to UT+9 on 1912-01-01? Omit the 1910 change for now. +# +# I guessed that time zone abbreviations through 1945 followed the same # rules as discussed under Taiwan, with nominal switches from JST to KST # when the respective cities were taken over by the Allies after WWII. +# +# For Pyongyang we have no information; guess no changes since World War II. # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Seoul 8:27:52 - LMT 1890 - 8:30 - KST 1904 Dec - 9:00 - JCST 1928 - 8:30 - KST 1932 +Zone Asia/Seoul 8:27:52 - LMT 1908 Apr 1 + 8:30 - KST 1912 Jan 1 9:00 - JCST 1937 Oct 1 9:00 - JST 1945 Sep 8 9:00 - KST 1954 Mar 21 - 8:00 ROK K%sT 1961 Aug 10 - 8:30 - KST 1968 Oct + 8:30 ROK K%sT 1961 Aug 10 9:00 ROK K%sT -Zone Asia/Pyongyang 8:23:00 - LMT 1890 - 8:30 - KST 1904 Dec - 9:00 - JCST 1928 - 8:30 - KST 1932 +Zone Asia/Pyongyang 8:23:00 - LMT 1908 Apr 1 + 8:30 - KST 1912 Jan 1 9:00 - JCST 1937 Oct 1 9:00 - JST 1945 Aug 24 - 9:00 - KST 1954 Mar 21 - 8:00 - KST 1961 Aug 10 9:00 - KST ############################################################################### diff --git a/jdk/make/data/tzdata/australasia b/jdk/make/data/tzdata/australasia index c45680ace6a..f2a89e8ee37 100644 --- a/jdk/make/data/tzdata/australasia +++ b/jdk/make/data/tzdata/australasia @@ -820,19 +820,19 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # tz@iana.org for general use in the future). For more, please see # the file CONTRIBUTING in the tz distribution. -# From Paul Eggert (2013-02-21): -# A good source for time zone historical data outside the U.S. is +# From Paul Eggert (2014-10-31): +# +# Unless otherwise specified, the source for data through 1990 is: # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), # San Diego: ACS Publications, Inc. (2003). +# Unfortunately this book contains many errors and cites no sources. # # Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. -# -# Except where otherwise noted, Shanks & Pottenger is the source for -# entries through 1990, and IATA SSIM is the source for entries afterwards. +# of the IATA's data after 1990. Except where otherwise noted, +# IATA SSIM is the source for entries after 1990. # # Another source occasionally used is Edward W. Whitman, World Time Differences, # Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which diff --git a/jdk/make/data/tzdata/europe b/jdk/make/data/tzdata/europe index fb24b87a754..2ed6ad36b5d 100644 --- a/jdk/make/data/tzdata/europe +++ b/jdk/make/data/tzdata/europe @@ -29,16 +29,19 @@ # tz@iana.org for general use in the future). For more, please see # the file CONTRIBUTING in the tz distribution. -# From Paul Eggert (2014-05-31): -# A good source for time zone historical data outside the U.S. is +# From Paul Eggert (2014-10-31): +# +# Unless otherwise specified, the source for data through 1990 is: # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), # San Diego: ACS Publications, Inc. (2003). +# Unfortunately this book contains many errors and cites no sources. # # Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. +# of the IATA's data after 1990. Except where otherwise noted, +# IATA SSIM is the source for entries after 1990. # # A reliable and entertaining source about time zones is # Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997). @@ -310,6 +313,14 @@ # "Timeball on the ballast office is down. Dunsink time." # -- James Joyce, Ulysses +# "Countess Markievicz ... claimed that the [1916] abolition of Dublin Mean Time +# was among various actions undertaken by the 'English' government that +# would 'put the whole country into the SF (Sinn Féin) camp'. She claimed +# Irish 'public feeling (was) outraged by forcing of English time on us'." +# -- Parsons M. Dublin lost its time zone - and 25 minutes - after 1916 Rising. +# Irish Times 2014-10-27. +# http://www.irishtimes.com/news/politics/dublin-lost-its-time-zone-and-25-minutes-after-1916-rising-1.1977411 + # From Joseph S. Myers (2005-01-26): # Irish laws are available online at . # These include various relating to legal time, for example: @@ -617,6 +628,7 @@ Rule Russia 1992 only - Sep lastSat 23:00 0 - Rule Russia 1993 2010 - Mar lastSun 2:00s 1:00 S Rule Russia 1993 1995 - Sep lastSun 2:00s 0 - Rule Russia 1996 2010 - Oct lastSun 2:00s 0 - +# As described below, Russia's 2014 change affects Zone data, not Rule data. # From Alexander Krivenyshev (2011-06-14): # According to Kremlin press service, Russian President Dmitry Medvedev diff --git a/jdk/make/data/tzdata/leapseconds b/jdk/make/data/tzdata/leapseconds index d38abd6a4bd..7612f2bc9b7 100644 --- a/jdk/make/data/tzdata/leapseconds +++ b/jdk/make/data/tzdata/leapseconds @@ -33,8 +33,8 @@ # The NTP Timescale and Leap Seconds # http://www.eecis.udel.edu/~mills/leap.html -# The International Earth Rotation Service periodically uses leap seconds -# to keep UTC to within 0.9 s of UT1 +# The International Earth Rotation and Reference Systems Service +# periodically uses leap seconds to keep UTC to within 0.9 s of UT1 # (which measures the true angular orientation of the earth in space); see # Terry J Quinn, The BIPM and the accurate measure of time, # Proc IEEE 79, 7 (July 1991), 894-905 . diff --git a/jdk/make/data/tzdata/northamerica b/jdk/make/data/tzdata/northamerica index 329b633ba98..86c9503a4eb 100644 --- a/jdk/make/data/tzdata/northamerica +++ b/jdk/make/data/tzdata/northamerica @@ -1014,19 +1014,19 @@ Zone America/Menominee -5:50:27 - LMT 1885 Sep 18 12:00 ################################################################################ -# From Paul Eggert (2006-03-22): -# A good source for time zone historical data outside the U.S. is +# From Paul Eggert (2014-10-31): +# +# Unless otherwise specified, the source for data through 1990 is: # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), # San Diego: ACS Publications, Inc. (2003). +# Unfortunately this book contains many errors and cites no sources. # # Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. -# -# Except where otherwise noted, Shanks & Pottenger is the source for -# entries through 1990, and IATA SSIM is the source for entries afterwards. +# of the IATA's data after 1990. Except where otherwise noted, +# IATA SSIM is the source for entries after 1990. # # Other sources occasionally used include: # @@ -3154,13 +3154,17 @@ Zone America/Miquelon -3:44:40 - LMT 1911 May 15 # St Pierre # From Paul Eggert (2014-08-19): # The 2014-08-13 Cabinet meeting decided to stay on UTC-4 year-round. See: # http://tcweeklynews.com/daylight-savings-time-to-be-maintained-p5353-127.htm -# Model this as a switch from EST/EDT to AST on 2014-11-02 at 02:00. +# Model this as a switch from EST/EDT to AST ... +# From Chris Walton (2014-11-04): +# ... the TCI government appears to have delayed the switch to +# "permanent daylight saving time" by one year.... +# http://tcweeklynews.com/time-change-to-go-ahead-this-november-p5437-127.htm # # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Grand_Turk -4:44:32 - LMT 1890 -5:07:11 - KMT 1912 Feb # Kingston Mean Time -5:00 - EST 1979 - -5:00 US E%sT 2014 Nov 2 2:00 + -5:00 US E%sT 2015 Nov Sun>=1 2:00 -4:00 - AST # British Virgin Is diff --git a/jdk/make/data/tzdata/southamerica b/jdk/make/data/tzdata/southamerica index 398ec0e4f06..0b70dea5616 100644 --- a/jdk/make/data/tzdata/southamerica +++ b/jdk/make/data/tzdata/southamerica @@ -29,23 +29,23 @@ # tz@iana.org for general use in the future). For more, please see # the file CONTRIBUTING in the tz distribution. -# From Paul Eggert (2006-03-22): -# A good source for time zone historical data outside the U.S. is +# From Paul Eggert (2014-10-31): +# +# Unless otherwise specified, the source for data through 1990 is: # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), # San Diego: ACS Publications, Inc. (2003). -# -# For data circa 1899, a common source is: -# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94. -# http://www.jstor.org/stable/1774359 +# Unfortunately this book contains many errors and cites no sources. # # Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. +# of the IATA's data after 1990. Except where otherwise noted, +# IATA SSIM is the source for entries after 1990. # -# Except where otherwise noted, Shanks & Pottenger is the source for -# entries through 1990, and IATA SSIM is the source for entries afterwards. +# For data circa 1899, a common source is: +# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94. +# http://www.jstor.org/stable/1774359 # # Earlier editions of these tables used the North American style (e.g. ARST and # ARDT for Argentine Standard and Daylight Time), but the following quote diff --git a/jdk/test/sun/util/calendar/zi/tzdata/VERSION b/jdk/test/sun/util/calendar/zi/tzdata/VERSION index 5e925ada8df..9987fde6dcb 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/VERSION +++ b/jdk/test/sun/util/calendar/zi/tzdata/VERSION @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2014g +tzdata2014j diff --git a/jdk/test/sun/util/calendar/zi/tzdata/africa b/jdk/test/sun/util/calendar/zi/tzdata/africa index aa91f365ce1..43103225577 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/africa +++ b/jdk/test/sun/util/calendar/zi/tzdata/africa @@ -29,20 +29,19 @@ # tz@iana.org for general use in the future). For more, please see # the file CONTRIBUTING in the tz distribution. -# From Paul Eggert (2013-02-21): +# From Paul Eggert (2014-10-31): # -# A good source for time zone historical data outside the U.S. is +# Unless otherwise specified, the source for data through 1990 is: # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), # San Diego: ACS Publications, Inc. (2003). +# Unfortunately this book contains many errors and cites no sources. # # Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. -# -# Except where otherwise noted, Shanks & Pottenger is the source for -# entries through 1990, and IATA SSIM is the source for entries afterwards. +# of the IATA's data after 1990. Except where otherwise noted, +# IATA SSIM is the source for entries after 1990. # # Another source occasionally used is Edward W. Whitman, World Time Differences, # Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which @@ -88,7 +87,6 @@ # 3:00 CAST Central Africa Summer Time (no longer used) # 3:00 SAST South Africa Summer Time (no longer used) # 3:00 EAT East Africa Time -# 4:00 EAST East Africa Summer Time (no longer used) # Algeria # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -133,23 +131,13 @@ Zone Africa/Algiers 0:12:12 - LMT 1891 Mar 15 0:01 # See Africa/Lagos. # Botswana -# From Paul Eggert (2013-02-21): -# Milne says they were regulated by the Cape Town Signal in 1899; -# assume they switched to 2:00 when Cape Town did. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Gaborone 1:43:40 - LMT 1885 - 1:30 - SAST 1903 Mar - 2:00 - CAT 1943 Sep 19 2:00 - 2:00 1:00 CAST 1944 Mar 19 2:00 - 2:00 - CAT +# See Africa/Maputo. # Burkina Faso # See Africa/Abidjan. # Burundi -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Bujumbura 1:57:28 - LMT 1890 - 2:00 - CAT +# See Africa/Maputo. # Cameroon # See Africa/Lagos. @@ -179,15 +167,10 @@ Zone Africa/Ndjamena 1:00:12 - LMT 1912 # N'Djamena 1:00 - WAT # Comoros -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Comoro 2:53:04 - LMT 1911 Jul # Moroni, Gran Comoro - 3:00 - EAT +# See Africa/Nairobi. # Democratic Republic of the Congo -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Lubumbashi 1:49:52 - LMT 1897 Nov 9 - 2:00 - CAT -# The above is for the eastern part; see Africa/Lagos for the western part. +# See Africa/Lagos for the western part and Africa/Maputo for the eastern. # Republic of the Congo # See Africa/Lagos. @@ -208,9 +191,7 @@ Link Africa/Abidjan Africa/Sao_Tome # São Tomé and Príncipe Link Africa/Abidjan Atlantic/St_Helena # St Helena # Djibouti -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Djibouti 2:52:36 - LMT 1911 Jul - 3:00 - EAT +# See Africa/Nairobi. ############################################################################### @@ -339,7 +320,7 @@ Rule Egypt 2007 only - Sep Thu>=1 24:00 0 - # Egypt is to change back to Daylight system on May 15 # http://english.ahram.org.eg/NewsContent/1/64/100735/Egypt/Politics-/Egypts-government-to-reapply-daylight-saving-time-.aspx -# From Gunther Vermier (2015-05-13): +# From Gunther Vermier (2014-05-13): # our Egypt office confirms that the change will be at 15 May "midnight" (24:00) # From Imed Chihi (2014-06-04): @@ -423,27 +404,8 @@ Zone Africa/Cairo 2:05:09 - LMT 1900 Oct # See Africa/Lagos. # Eritrea -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Asmara 2:35:32 - LMT 1870 - 2:35:32 - AMT 1890 # Asmara Mean Time - 2:35:20 - ADMT 1936 May 5 # Adis Dera MT - 3:00 - EAT - # Ethiopia -# From Paul Eggert (2014-07-31): -# Like the Swahili of Kenya and Tanzania, many Ethiopians keep a -# 12-hour clock starting at our 06:00, so their "8 o'clock" is our -# 02:00 or 14:00. Keep this in mind when you ask the time in Amharic. -# -# Shanks & Pottenger write that Ethiopia had six narrowly-spaced time -# zones between 1870 and 1890, that they merged to 38E50 (2:35:20) in -# 1890, and that they switched to 3:00 on 1936-05-05. Perhaps 38E50 -# was for Adis Dera. Quite likely the Shanks data entries are wrong -# anyway. -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Addis_Ababa 2:34:48 - LMT 1870 - 2:35:20 - ADMT 1936 May 5 # Adis Dera MT - 3:00 - EAT +# See Africa/Nairobi. # Gabon # See Africa/Lagos. @@ -487,13 +449,18 @@ Zone Africa/Nairobi 2:27:16 - LMT 1928 Jul 2:30 - BEAT 1940 2:45 - BEAUT 1960 3:00 - EAT +Link Africa/Nairobi Africa/Addis_Ababa # Ethiopia +Link Africa/Nairobi Africa/Asmara # Eritrea +Link Africa/Nairobi Africa/Dar_es_Salaam # Tanzania +Link Africa/Nairobi Africa/Djibouti +Link Africa/Nairobi Africa/Kampala # Uganda +Link Africa/Nairobi Africa/Mogadishu # Somalia +Link Africa/Nairobi Indian/Antananarivo # Madagascar +Link Africa/Nairobi Indian/Comoro +Link Africa/Nairobi Indian/Mayotte # Lesotho -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Maseru 1:50:00 - LMT 1903 Mar - 2:00 - SAST 1943 Sep 19 2:00 - 2:00 1:00 SAST 1944 Mar 19 2:00 - 2:00 - SAST +# See Africa/Johannesburg. # Liberia # From Paul Eggert (2006-03-22): @@ -568,16 +535,10 @@ Zone Africa/Tripoli 0:52:44 - LMT 1920 2:00 - EET # Madagascar -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Antananarivo 3:10:04 - LMT 1911 Jul - 3:00 - EAT 1954 Feb 27 23:00s - 3:00 1:00 EAST 1954 May 29 23:00s - 3:00 - EAT +# See Africa/Nairobi. # Malawi -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Blantyre 2:20:00 - LMT 1903 Mar - 2:00 - CAT +# See Africa/Maputo. # Mali # Mauritania @@ -677,9 +638,7 @@ Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis # no information; probably like Indian/Mauritius # Mayotte -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Mayotte 3:00:56 - LMT 1911 Jul # Mamoutzou - 3:00 - EAT +# See Africa/Nairobi. # Morocco # See the 'europe' file for Spanish Morocco (Africa/Ceuta). @@ -987,6 +946,13 @@ Zone Africa/El_Aaiun -0:52:48 - LMT 1934 Jan # El Aaiún # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Africa/Maputo 2:10:20 - LMT 1903 Mar 2:00 - CAT +Link Africa/Maputo Africa/Blantyre # Malawi +Link Africa/Maputo Africa/Bujumbura # Burundi +Link Africa/Maputo Africa/Gaborone # Botswana +Link Africa/Maputo Africa/Harare # Zimbabwe +Link Africa/Maputo Africa/Kigali # Rwanda +Link Africa/Maputo Africa/Lubumbashi # E Dem. Rep. of Congo +Link Africa/Maputo Africa/Lusaka # Zambia # Namibia # The 1994-04-03 transition is from Shanks & Pottenger. @@ -1054,9 +1020,7 @@ Zone Indian/Reunion 3:41:52 - LMT 1911 Jun # Saint-Denis # Tromelin - inhabited until at least 1958 # Rwanda -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Kigali 2:00:16 - LMT 1935 Jun - 2:00 - CAT +# See Africa/Maputo. # St Helena # See Africa/Abidjan. @@ -1086,11 +1050,7 @@ Zone Indian/Mahe 3:41:48 - LMT 1906 Jun # Victoria # See Africa/Abidjan. # Somalia -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Mogadishu 3:01:28 - LMT 1893 Nov - 3:00 - EAT 1931 - 2:30 - BEAT 1957 - 3:00 - EAT +# See Africa/Nairobi. # South Africa # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -1100,6 +1060,9 @@ Rule SA 1943 1944 - Mar Sun>=15 2:00 0 - Zone Africa/Johannesburg 1:52:00 - LMT 1892 Feb 8 1:30 - SAST 1903 Mar 2:00 SA SAST +Link Africa/Johannesburg Africa/Maseru # Lesotho +Link Africa/Johannesburg Africa/Mbabane # Swaziland +# # Marion and Prince Edward Is # scientific station since 1947 # no information @@ -1127,16 +1090,10 @@ Zone Africa/Khartoum 2:10:08 - LMT 1931 Link Africa/Khartoum Africa/Juba # Swaziland -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Mbabane 2:04:24 - LMT 1903 Mar - 2:00 - SAST +# See Africa/Johannesburg. # Tanzania -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Dar_es_Salaam 2:37:08 - LMT 1931 - 3:00 - EAT 1948 - 2:45 - BEAUT 1961 - 3:00 - EAT +# See Africa/Nairobi. # Togo # See Africa/Abidjan. @@ -1242,19 +1199,8 @@ Zone Africa/Tunis 0:40:44 - LMT 1881 May 12 1:00 Tunisia CE%sT # Uganda -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Kampala 2:09:40 - LMT 1928 Jul - 3:00 - EAT 1930 - 2:30 - BEAT 1948 - 2:45 - BEAUT 1957 - 3:00 - EAT +# See Africa/Nairobi. # Zambia -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Lusaka 1:53:08 - LMT 1903 Mar - 2:00 - CAT - # Zimbabwe -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Africa/Harare 2:04:12 - LMT 1903 Mar - 2:00 - CAT +# See Africa/Maputo. diff --git a/jdk/test/sun/util/calendar/zi/tzdata/asia b/jdk/test/sun/util/calendar/zi/tzdata/asia index 906c0a97cda..960cab5062e 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/asia +++ b/jdk/test/sun/util/calendar/zi/tzdata/asia @@ -29,20 +29,19 @@ # tz@iana.org for general use in the future). For more, please see # the file CONTRIBUTING in the tz distribution. -# From Paul Eggert (2013-08-11): +# From Paul Eggert (2014-10-31): # -# A good source for time zone historical data outside the U.S. is +# Unless otherwise specified, the source for data through 1990 is: # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), # San Diego: ACS Publications, Inc. (2003). +# Unfortunately this book contains many errors and cites no sources. # # Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. -# -# Except where otherwise noted, Shanks & Pottenger is the source for -# entries through 1990, and IATA SSIM is the source for entries afterwards. +# of the IATA's data after 1990. Except where otherwise noted, +# IATA SSIM is the source for entries after 1990. # # Another source occasionally used is Edward W. Whitman, World Time Differences, # Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which @@ -70,10 +69,11 @@ # 3:30 IRST IRDT Iran # 4:00 GST Gulf* # 5:30 IST India -# 7:00 ICT Indochina* +# 7:00 ICT Indochina, most times and locations* # 7:00 WIB west Indonesia (Waktu Indonesia Barat) # 8:00 WITA central Indonesia (Waktu Indonesia Tengah) # 8:00 CST China +# 8:00 IDT Indochina, 1943-45, 1947-55, 1960-75 (some locations)* # 8:00 JWST Western Standard Time (Japan, 1896/1937)* # 9:00 JCST Central Standard Time (Japan, 1896/1937) # 9:00 WIT east Indonesia (Waktu Indonesia Timur) @@ -294,12 +294,8 @@ Zone Asia/Rangoon 6:24:40 - LMT 1880 # or Yangon 6:30 - MMT # Myanmar Time # Cambodia -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Phnom_Penh 6:59:40 - LMT 1906 Jun 9 - 7:06:20 - SMT 1911 Mar 11 0:01 # Saigon MT? - 7:00 - ICT 1912 May - 8:00 - ICT 1931 May - 7:00 - ICT +# See Asia/Bangkok. + # China @@ -916,6 +912,10 @@ Zone Asia/Kolkata 5:53:28 - LMT 1880 # Kolkata # Indonesia # +# From Paul Eggert (2014-09-06): +# The 1876 Report of the Secretary of the [US] Navy, p 306 says that Batavia +# civil time was 7:07:12.5; round to even for Jakarta. +# # From Gwillim Law (2001-05-28), overriding Shanks & Pottenger: # http://www.sumatera-inc.com/go_to_invest/about_indonesia.asp#standtime # says that Indonesia's time zones changed on 1988-01-01. Looking at some @@ -1685,44 +1685,70 @@ Zone Asia/Bishkek 4:58:24 - LMT 1924 May 2 # Korea (North and South) # From Annie I. Bang (2006-07-10): -# http://www.koreaherald.co.kr/SITE/data/html_dir/2006/07/10/200607100012.asp -# The Ministry of Commerce, Industry and Energy has already -# commissioned a research project [to reintroduce DST] and has said -# the system may begin as early as 2008.... Korea ran a daylight -# saving program from 1949-61 but stopped it during the 1950-53 Korean War. +# http://www.koreaherald.com/view.php?ud=200607100012 +# Korea ran a daylight saving program from 1949-61 but stopped it +# during the 1950-53 Korean War. The system was temporarily enforced +# between 1987 and 1988 ... + +# From Sanghyuk Jung (2014-10-29): +# http://mm.icann.org/pipermail/tz/2014-October/021830.html +# According to the Korean Wikipedia +# http://ko.wikipedia.org/wiki/한국_표준시 +# [oldid=12896437 2014-09-04 08:03 UTC] +# DST in Republic of Korea was as follows.... And I checked old +# newspapers in Korean, all articles correspond with data in Wikipedia. +# For example, the article in 1948 (Korean Language) proved that DST +# started at June 1 in that year. For another example, the article in +# 1988 said that DST started at 2:00 AM in that year. -# From Shanks & Pottenger: # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule ROK 1960 only - May 15 0:00 1:00 D -Rule ROK 1960 only - Sep 13 0:00 0 S -Rule ROK 1987 1988 - May Sun>=8 0:00 1:00 D -Rule ROK 1987 1988 - Oct Sun>=8 0:00 0 S +Rule ROK 1948 only - Jun 1 0:00 1:00 D +Rule ROK 1948 only - Sep 13 0:00 0 S +Rule ROK 1949 only - Apr 3 0:00 1:00 D +Rule ROK 1949 1951 - Sep Sun>=8 0:00 0 S +Rule ROK 1950 only - Apr 1 0:00 1:00 D +Rule ROK 1951 only - May 6 0:00 1:00 D +Rule ROK 1955 only - May 5 0:00 1:00 D +Rule ROK 1955 only - Sep 9 0:00 0 S +Rule ROK 1956 only - May 20 0:00 1:00 D +Rule ROK 1956 only - Sep 30 0:00 0 S +Rule ROK 1957 1960 - May Sun>=1 0:00 1:00 D +Rule ROK 1957 1960 - Sep Sun>=18 0:00 0 S +Rule ROK 1987 1988 - May Sun>=8 2:00 1:00 D +Rule ROK 1987 1988 - Oct Sun>=8 3:00 0 S -# From Paul Eggert (2014-07-01): -# The following entries are from Shanks & Pottenger, except that I -# guessed that time zone abbreviations through 1945 followed the same +# From Paul Eggert (2014-10-30): +# The Korean Wikipedia entry gives the following sources for UT offsets: +# +# 1908: Official Journal Article No. 3994 (Edict No. 5) +# 1912: Governor-General of Korea Official Gazette Issue No. 367 +# (Announcement No. 338) +# 1954: Presidential Decree No. 876 (1954-03-17) +# 1961: Law No. 676 (1961-08-07) +# 1987: Law No. 3919 (1986-12-31) +# +# The Wikipedia entry also has confusing information about a change +# to UT+9 in April 1910, but then what would be the point of the later change +# to UT+9 on 1912-01-01? Omit the 1910 change for now. +# +# I guessed that time zone abbreviations through 1945 followed the same # rules as discussed under Taiwan, with nominal switches from JST to KST # when the respective cities were taken over by the Allies after WWII. +# +# For Pyongyang we have no information; guess no changes since World War II. # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Seoul 8:27:52 - LMT 1890 - 8:30 - KST 1904 Dec - 9:00 - JCST 1928 - 8:30 - KST 1932 +Zone Asia/Seoul 8:27:52 - LMT 1908 Apr 1 + 8:30 - KST 1912 Jan 1 9:00 - JCST 1937 Oct 1 9:00 - JST 1945 Sep 8 9:00 - KST 1954 Mar 21 - 8:00 ROK K%sT 1961 Aug 10 - 8:30 - KST 1968 Oct + 8:30 ROK K%sT 1961 Aug 10 9:00 ROK K%sT -Zone Asia/Pyongyang 8:23:00 - LMT 1890 - 8:30 - KST 1904 Dec - 9:00 - JCST 1928 - 8:30 - KST 1932 +Zone Asia/Pyongyang 8:23:00 - LMT 1908 Apr 1 + 8:30 - KST 1912 Jan 1 9:00 - JCST 1937 Oct 1 9:00 - JST 1945 Aug 24 - 9:00 - KST 1954 Mar 21 - 8:00 - KST 1961 Aug 10 9:00 - KST ############################################################################### @@ -1733,12 +1759,8 @@ Zone Asia/Kuwait 3:11:56 - LMT 1950 3:00 - AST # Laos -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Vientiane 6:50:24 - LMT 1906 Jun 9 # or Viangchan - 7:06:20 - SMT 1911 Mar 11 0:01 # Saigon MT? - 7:00 - ICT 1912 May - 8:00 - ICT 1931 May - 7:00 - ICT +# See Asia/Bangkok. + # Lebanon # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -2751,6 +2773,8 @@ Zone Asia/Dushanbe 4:35:12 - LMT 1924 May 2 Zone Asia/Bangkok 6:42:04 - LMT 1880 6:42:04 - BMT 1920 Apr # Bangkok Mean Time 7:00 - ICT +Link Asia/Bangkok Asia/Phnom_Penh # Cambodia +Link Asia/Bangkok Asia/Vientiane # Laos # Turkmenistan # From Shanks & Pottenger. @@ -2788,22 +2812,65 @@ Zone Asia/Tashkent 4:37:11 - LMT 1924 May 2 # Vietnam -# From Paul Eggert (2013-02-21): +# From Paul Eggert (2014-10-04): # Milne gives 7:16:56 for the meridian of Saigon in 1899, as being # used in Lower Laos, Cambodia, and Annam. But this is quite a ways # from Saigon's location. For now, ignore this and stick with Shanks -# and Pottenger. +# and Pottenger for LMT before 1906. # From Arthur David Olson (2008-03-18): # The English-language name of Vietnam's most populous city is "Ho Chi Minh # City"; use Ho_Chi_Minh below to avoid a name of more than 14 characters. -# From Shanks & Pottenger: +# From Paul Eggert (2014-10-21) after a heads-up from Trần Ngọc Quân: +# Trần Tiến Bình's authoritative book "Lịch Việt Nam: thế kỷ XX-XXI (1901-2100)" +# (Nhà xuất bản Văn Hoá - Thông Tin, Hanoi, 2005), pp 49-50, +# is quoted verbatim in: +# http://www.thoigian.com.vn/?mPage=P80D01 +# is translated by Brian Inglis in: +# http://mm.icann.org/pipermail/tz/2014-October/021654.html +# and is the basis for the information below. +# +# The 1906 transition was effective July 1 and standardized Indochina to +# Phù Liễn Observatory, legally 104 deg. 17'17" east of Paris. +# It's unclear whether this meant legal Paris Mean Time (00:09:21) or +# the Paris Meridian (2 deg. 20'14.03" E); the former yields 07:06:30.1333... +# and the latter 07:06:29.333... so either way it rounds to 07:06:30, +# which is used below even though the modern-day Phù Liễn Observatory +# is closer to 07:06:31. Abbreviate Phù Liễn Mean Time as PLMT. +# +# The following transitions occurred in Indochina in general (before 1954) +# and in South Vietnam in particular (after 1954): +# To 07:00 on 1911-05-01. +# To 08:00 on 1942-12-31 at 23:00. +# To 09:00 in 1945-03-14 at 23:00. +# To 07:00 on 1945-09-02 in Vietnam. +# To 08:00 on 1947-04-01 in French-controlled Indochina. +# To 07:00 on 1955-07-01 in South Vietnam. +# To 08:00 on 1959-12-31 at 23:00 in South Vietnam. +# To 07:00 on 1975-06-13 in South Vietnam. +# +# Trần cites the following sources; it's unclear which supplied the info above. +# +# Hoàng Xuân Hãn: "Lịch và lịch Việt Nam". Tập san Khoa học Xã hội, +# No. 9, Paris, February 1982. +# +# Lê Thành Lân: "Lịch và niên biểu lịch sử hai mươi thế kỷ (0001-2010)", +# NXB Thống kê, Hanoi, 2000. +# +# Lê Thành Lân: "Lịch hai thế kỷ (1802-2010) và các lịch vĩnh cửu", +# NXB Thuận Hoá, Huế, 1995. + # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Ho_Chi_Minh 7:06:40 - LMT 1906 Jun 9 - 7:06:20 - SMT 1911 Mar 11 0:01 # Saigon MT? - 7:00 - ICT 1912 May - 8:00 - ICT 1931 May +Zone Asia/Ho_Chi_Minh 7:06:40 - LMT 1906 Jul 1 + 7:06:30 - PLMT 1911 May 1 + 7:00 - ICT 1942 Dec 31 23:00 + 8:00 - IDT 1945 Mar 14 23:00 + 9:00 - JST 1945 Sep 2 + 7:00 - ICT 1947 Apr 1 + 8:00 - IDT 1955 Jul 1 + 7:00 - ICT 1959 Dec 31 23:00 + 8:00 - IDT 1975 Jun 13 7:00 - ICT # Yemen diff --git a/jdk/test/sun/util/calendar/zi/tzdata/australasia b/jdk/test/sun/util/calendar/zi/tzdata/australasia index 52d32904178..f2a89e8ee37 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/australasia +++ b/jdk/test/sun/util/calendar/zi/tzdata/australasia @@ -354,20 +354,27 @@ Zone Indian/Cocos 6:27:40 - LMT 1900 # Fiji will end DST on 2014-01-19 02:00: # http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVINGS-TO-END-THIS-MONTH-%281%29.aspx -# From Paul Eggert (2014-01-10): -# For now, guess that Fiji springs forward the Sunday before the fourth -# Monday in October, and springs back the penultimate Sunday in January. -# This is ad hoc, but matches recent practice. +# From Ken Rylander (2014-10-20): +# DST will start Nov. 2 this year. +# http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVING-STARTS-ON-SUNDAY,-NOVEMBER-2ND.aspx + +# From Paul Eggert (2014-10-20): +# For now, guess DST from 02:00 the first Sunday in November to +# 03:00 the first Sunday on or after January 18. Although ad hoc, it +# matches this year's plan and seems more likely to match future +# practice than guessing no DST. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Fiji 1998 1999 - Nov Sun>=1 2:00 1:00 S Rule Fiji 1999 2000 - Feb lastSun 3:00 0 - Rule Fiji 2009 only - Nov 29 2:00 1:00 S Rule Fiji 2010 only - Mar lastSun 3:00 0 - -Rule Fiji 2010 max - Oct Sun>=21 2:00 1:00 S +Rule Fiji 2010 2013 - Oct Sun>=21 2:00 1:00 S Rule Fiji 2011 only - Mar Sun>=1 3:00 0 - Rule Fiji 2012 2013 - Jan Sun>=18 3:00 0 - -Rule Fiji 2014 max - Jan Sun>=18 2:00 0 - +Rule Fiji 2014 only - Jan Sun>=18 2:00 0 - +Rule Fiji 2014 max - Nov Sun>=1 2:00 1:00 S +Rule Fiji 2015 max - Jan Sun>=18 3:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Pacific/Fiji 11:55:44 - LMT 1915 Oct 26 # Suva 12:00 Fiji FJ%sT # Fiji Time @@ -542,6 +549,30 @@ Zone Pacific/Palau 8:57:56 - LMT 1901 # Koror Zone Pacific/Port_Moresby 9:48:40 - LMT 1880 9:48:32 - PMMT 1895 # Port Moresby Mean Time 10:00 - PGT # Papua New Guinea Time +# +# From Paul Eggert (2014-10-13): +# Base the Bougainville entry on the Arawa-Kieta region, which appears to have +# the most people even though it was devastated in the Bougainville Civil War. +# +# Although Shanks gives 1942-03-15 / 1943-11-01 for JST, these dates +# are apparently rough guesswork from the starts of military campaigns. +# The World War II entries below are instead based on Arawa-Kieta. +# The Japanese occupied Kieta in July 1942, +# according to the Pacific War Online Encyclopedia +# http://pwencycl.kgbudge.com/B/o/Bougainville.htm +# and seem to have controlled it until their 1945-08-21 surrender. +# +# The Autonomous Region of Bougainville plans to switch from UTC+10 to UTC+11 +# on 2014-12-28 at 02:00. They call UTC+11 "Bougainville Standard Time"; +# abbreviate this as BST. See: +# http://www.bougainville24.com/bougainville-issues/bougainville-gets-own-timezone/ +# +Zone Pacific/Bougainville 10:22:16 - LMT 1880 + 9:48:32 - PMMT 1895 + 10:00 - PGT 1942 Jul + 9:00 - JST 1945 Aug 21 + 10:00 - PGT 2014 Dec 28 2:00 + 11:00 - BST # Pitcairn # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -789,19 +820,19 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # tz@iana.org for general use in the future). For more, please see # the file CONTRIBUTING in the tz distribution. -# From Paul Eggert (2013-02-21): -# A good source for time zone historical data outside the U.S. is +# From Paul Eggert (2014-10-31): +# +# Unless otherwise specified, the source for data through 1990 is: # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), # San Diego: ACS Publications, Inc. (2003). +# Unfortunately this book contains many errors and cites no sources. # # Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. -# -# Except where otherwise noted, Shanks & Pottenger is the source for -# entries through 1990, and IATA SSIM is the source for entries afterwards. +# of the IATA's data after 1990. Except where otherwise noted, +# IATA SSIM is the source for entries after 1990. # # Another source occasionally used is Edward W. Whitman, World Time Differences, # Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which @@ -826,6 +857,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # 10:00 AEST AEDT Eastern Australia # 10:00 ChST Chamorro # 10:30 LHST LHDT Lord Howe* +# 11:00 BST Bougainville* # 11:30 NZMT NZST New Zealand through 1945 # 12:00 NZST NZDT New Zealand 1946-present # 12:15 CHAST Chatham through 1945* diff --git a/jdk/test/sun/util/calendar/zi/tzdata/europe b/jdk/test/sun/util/calendar/zi/tzdata/europe index 0c5f5667da9..2ed6ad36b5d 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/europe +++ b/jdk/test/sun/util/calendar/zi/tzdata/europe @@ -29,16 +29,19 @@ # tz@iana.org for general use in the future). For more, please see # the file CONTRIBUTING in the tz distribution. -# From Paul Eggert (2014-05-31): -# A good source for time zone historical data outside the U.S. is +# From Paul Eggert (2014-10-31): +# +# Unless otherwise specified, the source for data through 1990 is: # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), # San Diego: ACS Publications, Inc. (2003). +# Unfortunately this book contains many errors and cites no sources. # # Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. +# of the IATA's data after 1990. Except where otherwise noted, +# IATA SSIM is the source for entries after 1990. # # A reliable and entertaining source about time zones is # Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997). @@ -91,10 +94,11 @@ # 0:00 WET WEST WEMT Western Europe # 0:19:32.13 AMT NST Amsterdam, Netherlands Summer (1835-1937)* # 0:20 NET NEST Netherlands (1937-1940)* +# 1:00 BST British Standard (1968-1971) # 1:00 CET CEST CEMT Central Europe # 1:00:14 SET Swedish (1879-1899)* # 2:00 EET EEST Eastern Europe -# 3:00 FET Further-eastern Europe* +# 3:00 FET Further-eastern Europe (2011-2014)* # 3:00 MSK MSD MSM* Moscow # From Peter Ilieve (1994-12-04), @@ -309,6 +313,14 @@ # "Timeball on the ballast office is down. Dunsink time." # -- James Joyce, Ulysses +# "Countess Markievicz ... claimed that the [1916] abolition of Dublin Mean Time +# was among various actions undertaken by the 'English' government that +# would 'put the whole country into the SF (Sinn Féin) camp'. She claimed +# Irish 'public feeling (was) outraged by forcing of English time on us'." +# -- Parsons M. Dublin lost its time zone - and 25 minutes - after 1916 Rising. +# Irish Times 2014-10-27. +# http://www.irishtimes.com/news/politics/dublin-lost-its-time-zone-and-25-minutes-after-1916-rising-1.1977411 + # From Joseph S. Myers (2005-01-26): # Irish laws are available online at . # These include various relating to legal time, for example: @@ -616,6 +628,7 @@ Rule Russia 1992 only - Sep lastSat 23:00 0 - Rule Russia 1993 2010 - Mar lastSun 2:00s 1:00 S Rule Russia 1993 1995 - Sep lastSun 2:00s 0 - Rule Russia 1996 2010 - Oct lastSun 2:00s 0 - +# As described below, Russia's 2014 change affects Zone data, not Rule data. # From Alexander Krivenyshev (2011-06-14): # According to Kremlin press service, Russian President Dmitry Medvedev @@ -746,6 +759,13 @@ Zone Europe/Vienna 1:05:21 - LMT 1893 Apr # http://www.belta.by/ru/all_news/society/V-Belarusi-otmenjaetsja-perexod-na-sezonnoe-vremja_i_572952.html # http://naviny.by/rubrics/society/2011/09/16/ic_articles_116_175144/ # http://news.tut.by/society/250578.html +# +# From Alexander Bokovoy (2014-10-09): +# Belarussian government decided against changing to winter time.... +# http://eng.belta.by/all_news/society/Belarus-decides-against-adjusting-time-in-Russias-wake_i_76335.html +# From Paul Eggert (2014-10-08): +# Hence Belarus can share time zone abbreviations with Moscow again. +# # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Europe/Minsk 1:50:16 - LMT 1880 1:50 - MMT 1924 May 2 # Minsk Mean Time @@ -758,7 +778,8 @@ Zone Europe/Minsk 1:50:16 - LMT 1880 2:00 - EET 1992 Mar 29 0:00s 2:00 1:00 EEST 1992 Sep 27 0:00s 2:00 Russia EE%sT 2011 Mar 27 2:00s - 3:00 - FET + 3:00 - FET 2014 Oct 26 1:00s + 3:00 - MSK # Belgium # @@ -2524,7 +2545,7 @@ Zone Asia/Novosibirsk 5:31:40 - LMT 1919 Dec 14 6:00 # The Kemerovo region will remain at UTC+7 through the 2014-10-26 change, thus # realigning itself with KRAT. -Zone Asia/Novokuznetsk 5:48:48 - NMT 1920 Jan 6 +Zone Asia/Novokuznetsk 5:48:48 - LMT 1924 May 1 6:00 - KRAT 1930 Jun 21 # Krasnoyarsk Time 7:00 Russia KRA%sT 1991 Mar 31 2:00s 6:00 Russia KRA%sT 1992 Jan 19 2:00s diff --git a/jdk/test/sun/util/calendar/zi/tzdata/leapseconds b/jdk/test/sun/util/calendar/zi/tzdata/leapseconds index d38abd6a4bd..7612f2bc9b7 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/leapseconds +++ b/jdk/test/sun/util/calendar/zi/tzdata/leapseconds @@ -33,8 +33,8 @@ # The NTP Timescale and Leap Seconds # http://www.eecis.udel.edu/~mills/leap.html -# The International Earth Rotation Service periodically uses leap seconds -# to keep UTC to within 0.9 s of UT1 +# The International Earth Rotation and Reference Systems Service +# periodically uses leap seconds to keep UTC to within 0.9 s of UT1 # (which measures the true angular orientation of the earth in space); see # Terry J Quinn, The BIPM and the accurate measure of time, # Proc IEEE 79, 7 (July 1991), 894-905 . diff --git a/jdk/test/sun/util/calendar/zi/tzdata/northamerica b/jdk/test/sun/util/calendar/zi/tzdata/northamerica index 0dc714aa92d..86c9503a4eb 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/northamerica +++ b/jdk/test/sun/util/calendar/zi/tzdata/northamerica @@ -300,6 +300,12 @@ Zone PST8PDT -8:00 US P%sT # time zone, but we do go by the Eastern time zone because so many people work # in Columbus." +# From Paul Eggert (2014-09-06): +# Monthly Notices of the Royal Astronomical Society 44, 4 (1884-02-08), 208 +# says that New York City Hall time was 3 minutes 58.4 seconds fast of +# Eastern time (i.e., -4:56:01.6) just before the 1883 switch. Round to the +# nearest second. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER Rule NYC 1920 only - Mar lastSun 2:00 1:00 D Rule NYC 1920 only - Oct lastSun 2:00 0 S @@ -1008,19 +1014,19 @@ Zone America/Menominee -5:50:27 - LMT 1885 Sep 18 12:00 ################################################################################ -# From Paul Eggert (2006-03-22): -# A good source for time zone historical data outside the U.S. is +# From Paul Eggert (2014-10-31): +# +# Unless otherwise specified, the source for data through 1990 is: # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), # San Diego: ACS Publications, Inc. (2003). +# Unfortunately this book contains many errors and cites no sources. # # Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. -# -# Except where otherwise noted, Shanks & Pottenger is the source for -# entries through 1990, and IATA SSIM is the source for entries afterwards. +# of the IATA's data after 1990. Except where otherwise noted, +# IATA SSIM is the source for entries after 1990. # # Other sources occasionally used include: # @@ -1118,17 +1124,16 @@ Zone America/Menominee -5:50:27 - LMT 1885 Sep 18 12:00 # An amendment to the Interpretation Act was registered on February 19/2007.... # http://action.attavik.ca/home/justice-gn/attach/2007/gaz02part2.pdf -# From Paul Eggert (2006-04-25): +# From Paul Eggert (2014-10-18): # H. David Matthews and Mary Vincent's map # "It's about TIME", _Canadian Geographic_ (September-October 1998) -# http://www.canadiangeographic.ca/Magazine/SO98/geomap.asp +# http://www.canadiangeographic.ca/Magazine/SO98/alacarte.asp # contains detailed boundaries for regions observing nonstandard # time and daylight saving time arrangements in Canada circa 1998. # -# INMS, the Institute for National Measurement Standards in Ottawa, has -# information about standard and daylight saving time zones in Canada. -# http://inms-ienm.nrc-cnrc.gc.ca/en/time_services/daylight_saving_e.php -# (updated periodically). +# National Research Council Canada maintains info about time zones and DST. +# http://www.nrc-cnrc.gc.ca/eng/services/time/time_zones.html +# http://www.nrc-cnrc.gc.ca/eng/services/time/faq/index.html#Q5 # Its unofficial information is often taken from Matthews and Vincent. # From Paul Eggert (2006-06-27): @@ -1993,10 +1998,7 @@ Zone America/Creston -7:46:04 - LMT 1884 # [Also see (2001-03-09).] # From Gwillim Law (2005-05-21): -# According to maps at -# http://inms-ienm.nrc-cnrc.gc.ca/images/time_services/TZ01SWE.jpg -# http://inms-ienm.nrc-cnrc.gc.ca/images/time_services/TZ01SSE.jpg -# (both dated 2003), and +# According to ... # http://www.canadiangeographic.ca/Magazine/SO98/geomap.asp # (from a 1998 Canadian Geographic article), the de facto and de jure time # for Southampton Island (at the north end of Hudson Bay) is UTC-5 all year @@ -2005,9 +2007,11 @@ Zone America/Creston -7:46:04 - LMT 1884 # predates the creation of Nunavut, it probably goes back many years.... # The Inuktitut name of Coral Harbour is Sallit, but it's rarely used. # -# From Paul Eggert (2005-07-26): +# From Paul Eggert (2014-10-17): # For lack of better information, assume that Southampton Island observed -# daylight saving only during wartime. +# daylight saving only during wartime. Gwillim Law's email also +# mentioned maps now maintained by National Research Council Canada; +# see above for an up-to-date link. # From Chris Walton (2007-03-01): # ... the community of Resolute (located on Cornwallis Island in @@ -3008,10 +3012,21 @@ Zone America/Tegucigalpa -5:48:52 - LMT 1921 Apr # Shanks & Pottenger give -5:07:12, but Milne records -5:07:10.41 from an # unspecified official document, and says "This time is used throughout the # island". Go with Milne. Round to the nearest second as required by zic. +# +# Shanks & Pottenger give April 28 for the 1974 spring-forward transition, but +# Lance Neita writes that Prime Minister Michael Manley decreed it January 5. +# Assume Neita meant Jan 6 02:00, the same as the US. Neita also writes that +# Manley's supporters associated this act with Manley's nickname "Joshua" +# (recall that in the Bible the sun stood still at Joshua's request), +# and with the Rod of Correction which Manley said he had received from +# Haile Selassie, Emperor of Ethiopia. See: +# Neita L. The politician in all of us. Jamaica Observer 2014-09-20 +# http://www.jamaicaobserver.com/columns/The-politician-in-all-of-us_17573647 +# # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Jamaica -5:07:11 - LMT 1890 # Kingston -5:07:11 - KMT 1912 Feb # Kingston Mean Time - -5:00 - EST 1974 Apr 28 2:00 + -5:00 - EST 1974 -5:00 US E%sT 1984 -5:00 - EST @@ -3139,13 +3154,17 @@ Zone America/Miquelon -3:44:40 - LMT 1911 May 15 # St Pierre # From Paul Eggert (2014-08-19): # The 2014-08-13 Cabinet meeting decided to stay on UTC-4 year-round. See: # http://tcweeklynews.com/daylight-savings-time-to-be-maintained-p5353-127.htm -# Model this as a switch from EST/EDT to AST on 2014-11-02 at 02:00. +# Model this as a switch from EST/EDT to AST ... +# From Chris Walton (2014-11-04): +# ... the TCI government appears to have delayed the switch to +# "permanent daylight saving time" by one year.... +# http://tcweeklynews.com/time-change-to-go-ahead-this-november-p5437-127.htm # # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Grand_Turk -4:44:32 - LMT 1890 -5:07:11 - KMT 1912 Feb # Kingston Mean Time -5:00 - EST 1979 - -5:00 US E%sT 2014 Nov 2 2:00 + -5:00 US E%sT 2015 Nov Sun>=1 2:00 -4:00 - AST # British Virgin Is diff --git a/jdk/test/sun/util/calendar/zi/tzdata/southamerica b/jdk/test/sun/util/calendar/zi/tzdata/southamerica index 398ec0e4f06..0b70dea5616 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/southamerica +++ b/jdk/test/sun/util/calendar/zi/tzdata/southamerica @@ -29,23 +29,23 @@ # tz@iana.org for general use in the future). For more, please see # the file CONTRIBUTING in the tz distribution. -# From Paul Eggert (2006-03-22): -# A good source for time zone historical data outside the U.S. is +# From Paul Eggert (2014-10-31): +# +# Unless otherwise specified, the source for data through 1990 is: # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), # San Diego: ACS Publications, Inc. (2003). -# -# For data circa 1899, a common source is: -# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94. -# http://www.jstor.org/stable/1774359 +# Unfortunately this book contains many errors and cites no sources. # # Gwillim Law writes that a good source # for recent time zone data is the International Air Transport # Association's Standard Schedules Information Manual (IATA SSIM), # published semiannually. Law sent in several helpful summaries -# of the IATA's data after 1990. +# of the IATA's data after 1990. Except where otherwise noted, +# IATA SSIM is the source for entries after 1990. # -# Except where otherwise noted, Shanks & Pottenger is the source for -# entries through 1990, and IATA SSIM is the source for entries afterwards. +# For data circa 1899, a common source is: +# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94. +# http://www.jstor.org/stable/1774359 # # Earlier editions of these tables used the North American style (e.g. ARST and # ARDT for Argentine Standard and Daylight Time), but the following quote diff --git a/jdk/test/sun/util/calendar/zi/tzdata/zone.tab b/jdk/test/sun/util/calendar/zi/tzdata/zone.tab index 45351ca8486..0ef9ba869ea 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/zone.tab +++ b/jdk/test/sun/util/calendar/zi/tzdata/zone.tab @@ -330,7 +330,8 @@ PE -1203-07703 America/Lima PF -1732-14934 Pacific/Tahiti Society Islands PF -0900-13930 Pacific/Marquesas Marquesas Islands PF -2308-13457 Pacific/Gambier Gambier Islands -PG -0930+14710 Pacific/Port_Moresby +PG -0930+14710 Pacific/Port_Moresby most locations +PG -0613+15534 Pacific/Bougainville Bougainville PH +1435+12100 Asia/Manila PK +2452+06703 Asia/Karachi PL +5215+02100 Europe/Warsaw From fb6b965e8610ff30a42c1865425969499b9087fb Mon Sep 17 00:00:00 2001 From: Katja Kantserova Date: Tue, 18 Nov 2014 16:20:16 +0100 Subject: [PATCH 33/67] 6542634: TEST BUG: MISC_REGRESSION tests need to have minimum timeouts examined Reviewed-by: sla, jbachorik, egahlin --- jdk/test/ProblemList.txt | 3 + jdk/test/sun/tools/jinfo/Basic.sh | 117 ---------------- jdk/test/sun/tools/jinfo/JInfoHelper.java | 74 ++++++++++ .../jinfo/JInfoRunningProcessFlagTest.java | 128 ++++++++++++++++++ .../tools/jinfo/JInfoRunningProcessTest.java | 64 +++++++++ jdk/test/sun/tools/jinfo/JInfoSanityTest.java | 76 +++++++++++ 6 files changed, 345 insertions(+), 117 deletions(-) delete mode 100644 jdk/test/sun/tools/jinfo/Basic.sh create mode 100644 jdk/test/sun/tools/jinfo/JInfoHelper.java create mode 100644 jdk/test/sun/tools/jinfo/JInfoRunningProcessFlagTest.java create mode 100644 jdk/test/sun/tools/jinfo/JInfoRunningProcessTest.java create mode 100644 jdk/test/sun/tools/jinfo/JInfoSanityTest.java diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 449db57f61f..d3c1c3a0c95 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -315,6 +315,9 @@ sun/tools/jstatd/TestJstatdExternalRegistry.java generic-all # 6456333 sun/tools/jps/TestJpsJarRelative.java generic-all +# 6734748 +sun/tools/jinfo/JInfoRunningProcessFlagTest.java generic-all + # 8057732 sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java generic-all diff --git a/jdk/test/sun/tools/jinfo/Basic.sh b/jdk/test/sun/tools/jinfo/Basic.sh deleted file mode 100644 index 445ccf333f5..00000000000 --- a/jdk/test/sun/tools/jinfo/Basic.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2006, 2012, 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 6402766 -# @summary Unit test for jinfo utility -# -# @library ../common -# @build SimpleApplication ShutdownSimpleApplication -# @run shell Basic.sh - -. ${TESTSRC}/../common/CommonSetup.sh -. ${TESTSRC}/../common/ApplicationSetup.sh - -# Start application and use PORTFILE for coordination -PORTFILE="${TESTCLASSES}"/shutdown.port -startApplication SimpleApplication "${PORTFILE}" - -# all return statuses are checked in this test -set +e -set -x - -failed=0 - -runSA=true - -if [ $isMacos = true -o $isAIX = true -o `uname -m` = ppc64 ]; then - runSA=false -fi - -if [ $isLinux = true ]; then - # Some Linux systems disable non-child ptrace (see 7050524) - ptrace_scope=`/sbin/sysctl -n kernel.yama.ptrace_scope` - if [ $? = 0 ]; then - if [ $ptrace_scope = 1 ]; then - runSA=false - fi - fi -fi - -if [ $runSA = true ]; then - # -sysprops option - ${JINFO} -J-XX:+UsePerfData -F -sysprops $appJavaPid - if [ $? != 0 ]; then failed=1; fi - - # -flags option - ${JINFO} -J-XX:+UsePerfData -F -flags $appJavaPid - if [ $? != 0 ]; then failed=1; fi - - # no option - ${JINFO} -J-XX:+UsePerfData -F $appJavaPid - if [ $? != 0 ]; then failed=1; fi -fi - -# -sysprops option -${JINFO} -J-XX:+UsePerfData -sysprops $appJavaPid -if [ $? != 0 ]; then failed=1; fi - -# -flags option -${JINFO} -J-XX:+UsePerfData -flags $appJavaPid -if [ $? != 0 ]; then failed=1; fi - -# no option -${JINFO} -J-XX:+UsePerfData $appJavaPid -if [ $? != 0 ]; then failed=1; fi - -# -flag option -${JINFO} -J-XX:+UsePerfData -flag +PrintGC $appJavaPid -if [ $? != 0 ]; then failed=1; fi - -${JINFO} -J-XX:+UsePerfData -flag -PrintGC $appJavaPid -if [ $? != 0 ]; then failed=1; fi - -${JINFO} -J-XX:+UsePerfData -flag PrintGC $appJavaPid -if [ $? != 0 ]; then failed=1; fi - -if $isSolaris; then - - ${JINFO} -J-XX:+UsePerfData -flag +ExtendedDTraceProbes $appJavaPid - if [ $? != 0 ]; then failed=1; fi - - ${JINFO} -J-XX:+UsePerfData -flag -ExtendedDTraceProbes $appJavaPid - if [ $? != 0 ]; then failed=1; fi - - ${JINFO} -J-XX:+UsePerfData -flag ExtendedDTraceProbes $appJavaPid - if [ $? != 0 ]; then failed=1; fi - -fi - -set -e - -stopApplication "${PORTFILE}" -waitForApplication - -exit $failed diff --git a/jdk/test/sun/tools/jinfo/JInfoHelper.java b/jdk/test/sun/tools/jinfo/JInfoHelper.java new file mode 100644 index 00000000000..abbc862c2c8 --- /dev/null +++ b/jdk/test/sun/tools/jinfo/JInfoHelper.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. 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. + */ + +import java.util.Arrays; + +import jdk.testlibrary.JDKToolLauncher; +import jdk.testlibrary.OutputAnalyzer; +import jdk.testlibrary.ProcessTools; + +/** + * The helper class for running jinfo utility. + */ +public final class JInfoHelper { + + /** + * Print configuration information for the current process + * + * @param toolArgs List of jinfo options + */ + public static OutputAnalyzer jinfo(String... toolArgs) throws Exception { + return jinfo(true, toolArgs); + } + + /** + * Print usage information + * + * @param toolArgs List of jinfo options + */ + public static OutputAnalyzer jinfoNoPid(String... toolArgs) throws Exception { + return jinfo(false, toolArgs); + } + + private static OutputAnalyzer jinfo(boolean toPid, String... toolArgs) throws Exception { + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jinfo"); + if (toolArgs != null) { + for (String toolArg : toolArgs) { + launcher.addToolArg(toolArg); + } + } + if (toPid) { + launcher.addToolArg(Integer.toString(ProcessTools.getProcessId())); + } + + ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand()); + System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", "")); + OutputAnalyzer output = ProcessTools.executeProcess(processBuilder); + System.out.println(output.getOutput()); + + return output; + } + +} diff --git a/jdk/test/sun/tools/jinfo/JInfoRunningProcessFlagTest.java b/jdk/test/sun/tools/jinfo/JInfoRunningProcessFlagTest.java new file mode 100644 index 00000000000..deb3c860d63 --- /dev/null +++ b/jdk/test/sun/tools/jinfo/JInfoRunningProcessFlagTest.java @@ -0,0 +1,128 @@ +/* + * 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. + */ + +import sun.management.ManagementFactoryHelper; + +import com.sun.management.HotSpotDiagnosticMXBean; + +import jdk.testlibrary.OutputAnalyzer; +import static jdk.testlibrary.Platform.isSolaris; +import static jdk.testlibrary.Asserts.assertEquals; +import static jdk.testlibrary.Asserts.assertNotEquals; +import static jdk.testlibrary.Asserts.assertTrue; + +/** + * @test + * @summary The test sanity checks 'jinfo -flag' option. + * @library /lib/testlibrary + * @build jdk.testlibrary.* JInfoHelper + * @run main/othervm -XX:+HeapDumpOnOutOfMemoryError JInfoRunningProcessFlagTest + */ +public class JInfoRunningProcessFlagTest { + + public static void main(String[] args) throws Exception { + testFlag(); + testFlagPlus(); + testFlagMinus(); + testFlagEqual(); + + testInvalidFlag(); + + testSolarisSpecificFlag(); + } + + private static void testFlag() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfo("-flag", "HeapDumpOnOutOfMemoryError"); + output.shouldHaveExitValue(0); + assertTrue(output.getStderr().isEmpty(), "'jinfo -flag HeapDumpOnOutOfMemoryError' stderr should be empty"); + output.shouldContain("+HeapDumpOnOutOfMemoryError"); + } + + private static void testFlagPlus() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfo("-flag", "+PrintGC"); + output.shouldHaveExitValue(0); + output = JInfoHelper.jinfo("-flag", "PrintGC"); + output.shouldHaveExitValue(0); + output.shouldContain("+PrintGC"); + verifyIsEnabled("PrintGC"); + } + + private static void testFlagMinus() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfo("-flag", "-PrintGC"); + output.shouldHaveExitValue(0); + output = JInfoHelper.jinfo("-flag", "PrintGC"); + output.shouldHaveExitValue(0); + output.shouldContain("-PrintGC"); + verifyIsDisabled("PrintGC"); + } + + private static void testFlagEqual() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfo("-flag", "PrintGC=1"); + output.shouldHaveExitValue(0); + output = JInfoHelper.jinfo("-flag", "PrintGC"); + output.shouldHaveExitValue(0); + output.shouldContain("+PrintGC"); + verifyIsEnabled("PrintGC"); + } + + private static void testInvalidFlag() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfo("-flag", "monkey"); + assertNotEquals(output.getExitValue(), 0, "A non-zero exit code should be returned for invalid flag"); + } + + private static void testSolarisSpecificFlag() throws Exception { + if (!isSolaris()) + return; + + OutputAnalyzer output = JInfoHelper.jinfo("-flag", "+ExtendedDTraceProbes"); + output.shouldHaveExitValue(0); + output = JInfoHelper.jinfo(); + output.shouldContain("+ExtendedDTraceProbes"); + verifyIsEnabled("ExtendedDTraceProbes"); + + output = JInfoHelper.jinfo("-flag", "-ExtendedDTraceProbes"); + output.shouldHaveExitValue(0); + output = JInfoHelper.jinfo(); + output.shouldContain("-ExtendedDTraceProbes"); + verifyIsDisabled("ExtendedDTraceProbes"); + + output = JInfoHelper.jinfo("-flag", "ExtendedDTraceProbes"); + output.shouldContain("-ExtendedDTraceProbes"); + output.shouldHaveExitValue(0); + } + + private static void verifyIsEnabled(String flag) { + HotSpotDiagnosticMXBean hotspotDiagnostic = ManagementFactoryHelper.getDiagnosticMXBean(); + String flagValue = hotspotDiagnostic.getVMOption(flag).getValue(); + assertEquals(flagValue, "true", "Expected '" + flag + "' flag be enabled"); + } + + private static void verifyIsDisabled(String flag) { + HotSpotDiagnosticMXBean hotspotDiagnostic = ManagementFactoryHelper.getDiagnosticMXBean(); + String flagValue = hotspotDiagnostic.getVMOption(flag).getValue(); + assertEquals(flagValue, "false", "Expected '" + flag + "' flag be disabled"); + } + +} diff --git a/jdk/test/sun/tools/jinfo/JInfoRunningProcessTest.java b/jdk/test/sun/tools/jinfo/JInfoRunningProcessTest.java new file mode 100644 index 00000000000..e204254ab34 --- /dev/null +++ b/jdk/test/sun/tools/jinfo/JInfoRunningProcessTest.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. 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. + */ + +import jdk.testlibrary.OutputAnalyzer; +import static jdk.testlibrary.Asserts.assertTrue; + +/** + * @test + * @summary The test sanity checks functionality of 'jinfo', 'jinfo -sysprops' and 'jinfo -flags' + * @library /lib/testlibrary + * @build jdk.testlibrary.* JInfoHelper + * @run main/othervm -XX:+HeapDumpOnOutOfMemoryError JInfoRunningProcessTest + */ +public class JInfoRunningProcessTest { + + public static void main(String[] args) throws Exception { + testNoOptions(); + testSysprops(); + testFlags(); + } + + private static void testNoOptions() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfo(); + output.shouldHaveExitValue(0); + assertTrue(output.getStderr().isEmpty(), "'jinfo' stderr should be empty"); + output.shouldContain("+HeapDumpOnOutOfMemoryError"); + } + + private static void testSysprops() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfo("-sysprops"); + output.shouldHaveExitValue(0); + assertTrue(output.getStderr().isEmpty(), "'jinfo -sysprops' stderr should be empty"); + } + + private static void testFlags() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfo("-flags"); + output.shouldHaveExitValue(0); + assertTrue(output.getStderr().isEmpty(), "'jinfo -flags' stderr should be empty"); + output.shouldContain("+HeapDumpOnOutOfMemoryError"); + } + +} diff --git a/jdk/test/sun/tools/jinfo/JInfoSanityTest.java b/jdk/test/sun/tools/jinfo/JInfoSanityTest.java new file mode 100644 index 00000000000..dfc1b13d1f3 --- /dev/null +++ b/jdk/test/sun/tools/jinfo/JInfoSanityTest.java @@ -0,0 +1,76 @@ +/* + * 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. + */ + +import static jdk.testlibrary.Asserts.assertNotEquals; +import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.testlibrary.Asserts.assertFalse; +import jdk.testlibrary.OutputAnalyzer; + +/** + * @test + * @summary The test sanity checks functionality of 'jinfo -h', 'jinfo -help', + * and verifies jinfo exits abnormally if started with invalid options. + * @library /lib/testlibrary + * @build jdk.testlibrary.* JInfoHelper + * @run main JInfoSanityTest + */ +public class JInfoSanityTest { + + public static void main(String[] args) throws Exception { + test_h(); + test_help(); + testVersion(); + testUnknownHost(); + } + + private static void test_h() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfoNoPid("-h"); + output.shouldHaveExitValue(0); + assertFalse(output.getStderr().isEmpty(), "'jinfo -h' stderr should not be empty"); + assertTrue(output.getStdout().isEmpty(), "'jinfo -h' stdout should be empty"); + } + + private static void test_help() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfoNoPid("-help"); + output.shouldHaveExitValue(0); + assertFalse(output.getStderr().isEmpty(), "'jinfo -help' stderr should not be empty"); + assertTrue(output.getStdout().isEmpty(), "'jinfo -help' stdout should be empty"); + } + + private static void testVersion() throws Exception { + OutputAnalyzer output = JInfoHelper.jinfoNoPid("-version"); + output.shouldHaveExitValue(1); + assertFalse(output.getStderr().isEmpty(), "'jinfo -version' stderr should not be empty"); + assertTrue(output.getStdout().isEmpty(), "'jinfo -version' stdout should be empty"); + } + + private static void testUnknownHost() throws Exception { + String unknownHost = "Oja781nh2ev7vcvbajdg-Sda1-C"; + OutputAnalyzer output = JInfoHelper.jinfoNoPid("med@" + unknownHost); + assertNotEquals(output.getExitValue(), 0, "A non-zero exit code should be returned for invalid operation"); + output.shouldContain("UnknownHostException: " + unknownHost); + } + +} From f30ba73e1622e12ac129138a3db8b3693d034eff Mon Sep 17 00:00:00 2001 From: Sergey Gabdurakhmanov Date: Mon, 17 Nov 2014 13:11:37 +0100 Subject: [PATCH 34/67] 8048050: Agent NullPointerException when rmi.port in use Reviewed-by: jbachorik, dfuchs --- .../classes/sun/management/jmxremote/ConnectorBootstrap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.management/share/classes/sun/management/jmxremote/ConnectorBootstrap.java b/jdk/src/java.management/share/classes/sun/management/jmxremote/ConnectorBootstrap.java index a2f05634c62..e4d1c2f005f 100644 --- a/jdk/src/java.management/share/classes/sun/management/jmxremote/ConnectorBootstrap.java +++ b/jdk/src/java.management/share/classes/sun/management/jmxremote/ConnectorBootstrap.java @@ -767,7 +767,7 @@ public final class ConnectorBootstrap { JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs); connServer.start(); } catch (IOException e) { - if (connServer == null) { + if (connServer == null || connServer.getAddress() == null) { throw new AgentConfigurationError(CONNECTOR_SERVER_IO_ERROR, e, url.toString()); } else { From e1f99ed979672150e8a9532701a7862bb106afd1 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 17 Nov 2014 15:30:22 +0300 Subject: [PATCH 35/67] 8065096: java.net.Authenticator.theAuthenticator should be properly synchronized Reviewed-by: chegar, lancea --- jdk/src/java.base/share/classes/java/net/Authenticator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/classes/java/net/Authenticator.java b/jdk/src/java.base/share/classes/java/net/Authenticator.java index c88a6006b89..a83f40791d2 100644 --- a/jdk/src/java.base/share/classes/java/net/Authenticator.java +++ b/jdk/src/java.base/share/classes/java/net/Authenticator.java @@ -60,7 +60,7 @@ public abstract class Authenticator { // The system-wide authenticator object. See setDefault(). - private static Authenticator theAuthenticator; + private static volatile Authenticator theAuthenticator; private String requestingHost; private InetAddress requestingSite; From 71a33bf0641e4609dd5198e786f4ab95a9852fe2 Mon Sep 17 00:00:00 2001 From: Evgeniya Stepanova Date: Wed, 19 Nov 2014 17:51:06 +0300 Subject: [PATCH 36/67] 8062536: [TESTBUG] Conflicting GC combinations in jdk tests Reviewed-by: brutisso, dholmes --- .../java/lang/management/MemoryMXBean/LowMemoryTest2.sh | 4 ++-- .../MemoryMXBean/MemoryManagementConcMarkSweepGC.sh | 4 ++-- .../management/MemoryMXBean/MemoryManagementParallelGC.sh | 4 ++-- .../management/MemoryMXBean/MemoryManagementSerialGC.sh | 4 ++-- .../java/lang/management/MemoryMXBean/MemoryTestAllGC.sh | 6 ++---- jdk/test/java/lang/management/MemoryMXBean/PendingAllGC.sh | 4 ++-- .../lang/management/RuntimeMXBean/TestInputArgument.sh | 7 +++---- jdk/test/java/lang/ref/EnqueuePollRace.java | 4 ++-- jdk/test/sun/tools/jps/JpsHelper.java | 2 +- 9 files changed, 18 insertions(+), 21 deletions(-) diff --git a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh index d05a75958ee..b584c085b46 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh +++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh @@ -1,5 +1,5 @@ # -# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2004, 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,7 @@ # @test # @bug 4982128 # @summary Test low memory detection of non-heap memory pool -# +# @requires vm.gc=="null" # @run build LowMemoryTest2 MemoryUtil # @run shell/timeout=600 LowMemoryTest2.sh # diff --git a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementConcMarkSweepGC.sh b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementConcMarkSweepGC.sh index 8db78142ef6..a80f2c417f1 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementConcMarkSweepGC.sh +++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementConcMarkSweepGC.sh @@ -1,5 +1,5 @@ # -# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 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 @@ -26,7 +26,7 @@ # @bug 4530538 # @summary Run MemoryManagement test with concurrent mark sweep GC # @author Mandy Chung -# +# @requires vm.gc=="ConcMarkSweep" | vm.gc=="null" # @run build MemoryManagement # @run shell/timeout=600 MemoryManagementConcMarkSweepGC.sh # diff --git a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementParallelGC.sh b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementParallelGC.sh index 0435302e8e9..f315c96eb31 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementParallelGC.sh +++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementParallelGC.sh @@ -1,5 +1,5 @@ # -# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 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 @@ -26,7 +26,7 @@ # @bug 4530538 # @summary Run MemoryManagement test with parallel GC # @author Mandy Chung -# +# @requires vm.gc=="Parallel" | vm.gc=="null" # @run build MemoryManagement # @run shell/timeout=600 MemoryManagementParallelGC.sh # diff --git a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementSerialGC.sh b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementSerialGC.sh index e7ea40a1e8f..043323071d7 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementSerialGC.sh +++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagementSerialGC.sh @@ -1,5 +1,5 @@ # -# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 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 @@ -26,7 +26,7 @@ # @bug 4530538 # @summary Run MemoryManagement test with serial GC # @author Mandy Chung -# +# @requires vm.gc=="Serial" | vm.gc=="null" # @run build MemoryManagement # @run shell/timeout=600 MemoryManagementSerialGC.sh # diff --git a/jdk/test/java/lang/management/MemoryMXBean/MemoryTestAllGC.sh b/jdk/test/java/lang/management/MemoryMXBean/MemoryTestAllGC.sh index be0827ae32a..6dbbc1659d9 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/MemoryTestAllGC.sh +++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryTestAllGC.sh @@ -1,5 +1,5 @@ # -# Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 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 @@ -26,7 +26,7 @@ # @bug 4530538 # @summary # @author Mandy Chung -# +# @requires vm.gc=="Parallel" | vm.gc=="null" # @run compile MemoryTest.java # @run shell MemoryTestAllGC.sh # @@ -52,7 +52,5 @@ runOne MemoryTest 2 # Test MemoryTest with parallel scavenger collector runOne -XX:+UseParallelGC MemoryTest 2 -# Test MemoryTest with concurrent collector -#runOne -XX:+UseConcMarkSweepGC MemoryTest 3 exit 0 diff --git a/jdk/test/java/lang/management/MemoryMXBean/PendingAllGC.sh b/jdk/test/java/lang/management/MemoryMXBean/PendingAllGC.sh index edf18b3ffa0..2a1ccc3be7e 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/PendingAllGC.sh +++ b/jdk/test/java/lang/management/MemoryMXBean/PendingAllGC.sh @@ -1,5 +1,5 @@ # -# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 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 @@ -26,7 +26,7 @@ # @bug 4530538 # @summary # @author Mandy Chung -# +# @requires vm.gc=="null" # @run compile Pending.java # @run shell PendingAllGC.sh # diff --git a/jdk/test/java/lang/management/RuntimeMXBean/TestInputArgument.sh b/jdk/test/java/lang/management/RuntimeMXBean/TestInputArgument.sh index 5c57e4878e5..6c135415875 100644 --- a/jdk/test/java/lang/management/RuntimeMXBean/TestInputArgument.sh +++ b/jdk/test/java/lang/management/RuntimeMXBean/TestInputArgument.sh @@ -1,5 +1,5 @@ # -# Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 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 @@ -26,7 +26,6 @@ # @bug 4530538 # @summary # @author Mandy Chung -# # @run compile InputArgument.java # @run shell TestInputArgument.sh # @@ -48,8 +47,8 @@ runOne() runOne InputArgument -runOne -XX:+UseParallelGC -XX:+PrintGCDetails InputArgument -XX:+PrintGCDetails -runOne -XX:+UseParallelGC -XX:+PrintGCDetails InputArgument -XX:+UseParallelGC +runOne -XX:+UseFastJNIAccessors -XX:+PrintGCDetails InputArgument -XX:+PrintGCDetails +runOne -XX:+UseFastJNIAccessors -XX:+PrintGCDetails InputArgument -XX:+UseFastJNIAccessors runOne "-Dprops=one two three" InputArgument "-Dprops=one two three" exit 0 diff --git a/jdk/test/java/lang/ref/EnqueuePollRace.java b/jdk/test/java/lang/ref/EnqueuePollRace.java index c19a366715d..5171e138e5a 100644 --- a/jdk/test/java/lang/ref/EnqueuePollRace.java +++ b/jdk/test/java/lang/ref/EnqueuePollRace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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,7 @@ * @bug 8014890 * @summary Verify that a race between ReferenceQueue.enqueue() and poll() does not occur. * @author thomas.schatzl@oracle.com - * @run main/othervm -XX:+UseSerialGC -Xmx10M EnqueuePollRace + * @run main/othervm -Xmx10M EnqueuePollRace */ import java.lang.ref.*; diff --git a/jdk/test/sun/tools/jps/JpsHelper.java b/jdk/test/sun/tools/jps/JpsHelper.java index 4e00cc95de4..407f0416c34 100644 --- a/jdk/test/sun/tools/jps/JpsHelper.java +++ b/jdk/test/sun/tools/jps/JpsHelper.java @@ -93,7 +93,7 @@ public final class JpsHelper { /** * VM arguments to start test application with */ - public static final String[] VM_ARGS = {"-Xmx512m", "-XX:+UseParallelGC"}; + public static final String[] VM_ARGS = {"-Xmx512m", "-XX:+PrintGCDetails"}; /** * VM flag to start test application with */ From 2c4ba7c947ada018b9713e3142bdde10c820545c Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Fri, 21 Nov 2014 16:05:11 +0100 Subject: [PATCH 37/67] 8058631: Rename posix to unix in build system to match file name changes Reviewed-by: simonis, erikj, tbell --- jdk/make/CompileDemos.gmk | 8 +-- jdk/make/CreateJars.gmk | 4 +- jdk/make/Import.gmk | 4 +- jdk/make/copy/Copy-java.base.gmk | 4 +- jdk/make/copy/Copy-java.desktop.gmk | 4 +- jdk/make/gensrc/GensrcIcons.gmk | 4 +- jdk/make/gensrc/GensrcX11Wrappers.gmk | 4 +- jdk/make/launcher/Launcher-jdk.runtime.gmk | 4 +- jdk/make/launcher/LauncherCommon.gmk | 11 ++-- jdk/make/lib/Awt2dLibraries.gmk | 62 +++++++++++----------- jdk/make/lib/CoreLibraries.gmk | 12 ++--- jdk/make/lib/Lib-java.instrument.gmk | 2 +- jdk/make/lib/Lib-java.management.gmk | 2 +- jdk/make/lib/Lib-java.prefs.gmk | 2 +- jdk/make/lib/Lib-java.security.jgss.gmk | 4 +- jdk/make/lib/Lib-java.smartcardio.gmk | 8 +-- jdk/make/lib/Lib-jdk.crypto.mscapi.gmk | 2 +- jdk/make/lib/Lib-jdk.crypto.pkcs11.gmk | 4 +- jdk/make/lib/Lib-jdk.jdi.gmk | 2 +- jdk/make/lib/Lib-jdk.jdwp.agent.gmk | 4 +- jdk/make/lib/Lib-jdk.runtime.gmk | 4 +- jdk/make/lib/Lib-jdk.sctp.gmk | 8 +-- jdk/make/lib/Lib-jdk.security.auth.gmk | 2 +- jdk/make/lib/LibCommon.gmk | 6 +-- jdk/make/lib/NetworkingLibraries.gmk | 3 +- jdk/make/lib/NioLibraries.gmk | 6 +-- jdk/make/lib/SoundLibraries.gmk | 4 +- 27 files changed, 91 insertions(+), 93 deletions(-) diff --git a/jdk/make/CompileDemos.gmk b/jdk/make/CompileDemos.gmk index b82548edb7a..6052468b381 100644 --- a/jdk/make/CompileDemos.gmk +++ b/jdk/make/CompileDemos.gmk @@ -44,7 +44,7 @@ BUILD_DEMOS = DEMO_SHARE_SRC := $(JDK_TOPDIR)/src/demo/share DEMO_CLOSED_SHARE_SRC := $(JDK_TOPDIR)/src/closed/demo/share DEMO_SOLARIS_SRC := $(JDK_TOPDIR)/src/demo/solaris -DEMO_OS_API_SRC := $(JDK_TOPDIR)/src/demo/$(OPENJDK_TARGET_OS_API_DIR) +DEMO_OS_TYPE_SRC := $(JDK_TOPDIR)/src/demo/$(OPENJDK_TARGET_OS_TYPE) VERSION_INFO_RESOURCE := $(JDK_TOPDIR)/src/java.base/windows/native/common/version.rc ################################################################################################## @@ -214,13 +214,13 @@ define SetupJVMTIDemo # Param 2 = add these directories to the includes, default is agent_util # Param 3 = extra CFLAGS # Param 4 = C or C++ (defaults to C) - # Param 5 = libs for posix + # Param 5 = libs for unix # Param 6 = libs for windows # Param 7 = libs for solaris # Param 8 = libs for linux # Param 9 = extra directories with required sources BUILD_DEMO_JVMTI_$1_EXTRA_SRC := \ - $$(wildcard $(DEMO_OS_API_SRC)/jvmti/$1) \ + $$(wildcard $(DEMO_OS_TYPE_SRC)/jvmti/$1) \ $$(wildcard $$(addprefix $(DEMO_SHARE_SRC)/jvmti/, $2)) \ $9 BUILD_DEMO_JVMTI_$1_EXTRA_SRC_EXCLUDE := \ @@ -257,7 +257,7 @@ define SetupJVMTIDemo LDFLAGS := $(filter-out -incremental:no -opt:ref, $(LDFLAGS_JDKLIB)), \ LDFLAGS_macosx := $(call SET_EXECUTABLE_ORIGIN), \ LDFLAGS_SUFFIX := $$($1_EXTRA_CXX), \ - LDFLAGS_SUFFIX_posix := $5, \ + LDFLAGS_SUFFIX_unix := $5, \ LDFLAGS_SUFFIX_windows := $6, \ LDFLAGS_SUFFIX_solaris := $7 -lc, \ LDFLAGS_SUFFIX_linux := $8, \ diff --git a/jdk/make/CreateJars.gmk b/jdk/make/CreateJars.gmk index 568eeb2e0f3..3b7438a376a 100644 --- a/jdk/make/CreateJars.gmk +++ b/jdk/make/CreateJars.gmk @@ -656,7 +656,7 @@ endif SRC_ZIP_SRCS := $(wildcard \ $(JDK_TOPDIR)/src/*/share/classes \ $(JDK_TOPDIR)/src/*/$(OPENJDK_TARGET_OS)/classes \ - $(JDK_TOPDIR)/src/*/$(OPENJDK_TARGET_OS_API_DIR)/classes \ + $(JDK_TOPDIR)/src/*/$(OPENJDK_TARGET_OS_TYPE)/classes \ $(LANGTOOLS_TOPDIR)/src/*/share/classes \ $(CORBA_TOPDIR)/src/*/share/classes \ $(JAXP_TOPDIR)/src/*/share/classes \ @@ -679,7 +679,7 @@ $(eval $(call SetupCopyFiles,COPY_LAUNCHER_SRC, \ FILES := $(wildcard \ $(JDK_TOPDIR)/src/java.base/share/native/launcher/* \ $(JDK_TOPDIR)/src/java.base/share/native/libjli/* \ - $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libjli/java_md*))) + $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjli/java_md*))) LAUNCHER_ZIP_SRC := $(COPY_LAUNCHER_SRC) diff --git a/jdk/make/Import.gmk b/jdk/make/Import.gmk index 5bf9437da7f..43c5bc57363 100644 --- a/jdk/make/Import.gmk +++ b/jdk/make/Import.gmk @@ -30,8 +30,8 @@ include MakeBase.gmk ################################################################################ -# Put the libraries here. Different locations for different target apis. -ifeq ($(OPENJDK_TARGET_OS_API), posix) +# Put the libraries here. Different locations for different target OS types. +ifeq ($(OPENJDK_TARGET_OS_TYPE), unix) INSTALL_LIBRARIES_HERE := $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR) HOTSPOT_LIB_DIR := $(HOTSPOT_DIST)/jre/lib$(OPENJDK_TARGET_CPU_LIBDIR) else diff --git a/jdk/make/copy/Copy-java.base.gmk b/jdk/make/copy/Copy-java.base.gmk index fd9a0ef3afa..bcffc7d6459 100644 --- a/jdk/make/copy/Copy-java.base.gmk +++ b/jdk/make/copy/Copy-java.base.gmk @@ -83,7 +83,7 @@ endif ifeq ($(OPENJDK_TARGET_OS), macosx) JVMCFG_SRC := $(JDK_TOPDIR)/src/java.base/macosx/conf/$(JVMCFG_ARCH)/jvm.cfg else - JVMCFG_SRC := $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/conf/$(JVMCFG_ARCH)/jvm.cfg + JVMCFG_SRC := $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/$(JVMCFG_ARCH)/jvm.cfg endif JVMCFG_DIR := $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR) JVMCFG := $(JVMCFG_DIR)/jvm.cfg @@ -190,7 +190,7 @@ $(JDK_OUTPUTDIR)/lib/net.properties: $(JDK_TOPDIR)/src/java.base/share/conf/net. NET_CONF_FILES += $(JDK_OUTPUTDIR)/lib/net.properties ifeq ($(OPENJDK_TARGET_OS), solaris) - $(JDK_OUTPUTDIR)/lib/sdp/sdp.conf.template: $(JDK_TOPDIR)/src/java.base/${OPENJDK_TARGET_OS_API_DIR}/conf/sdp/sdp.conf.template + $(JDK_OUTPUTDIR)/lib/sdp/sdp.conf.template: $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/sdp/sdp.conf.template $(ECHO) $(LOG_INFO) Copying $(@F) $(call install-file) diff --git a/jdk/make/copy/Copy-java.desktop.gmk b/jdk/make/copy/Copy-java.desktop.gmk index b3fd662bf9c..c6f3e24b8f2 100644 --- a/jdk/make/copy/Copy-java.desktop.gmk +++ b/jdk/make/copy/Copy-java.desktop.gmk @@ -102,13 +102,13 @@ DESKTOP_CONF_FILES += $(PSFONTPROPFILE_TARGET_FILES) # Copy cursor.properties and cursors gif files to LIB_DST_DIR # ifneq ($(OPENJDK_TARGET_OS), macosx) - OPENJDK_TARGET_OS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/conf + OPENJDK_TARGET_OS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/conf else OPENJDK_TARGET_OS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/macosx/conf endif CURSORS_DEST_DIR := $(LIB_DST_DIR)/images/cursors -CURSORS_OPENJDK_TARGET_OS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/conf/images/cursors +CURSORS_OPENJDK_TARGET_OS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/conf/images/cursors $(CURSORS_DEST_DIR)/cursors.properties: $(CURSORS_OPENJDK_TARGET_OS_LIB_SRC)/cursors.properties $(call install-file) diff --git a/jdk/make/gensrc/GensrcIcons.gmk b/jdk/make/gensrc/GensrcIcons.gmk index e9b32f8f0b5..6acd8b206b6 100644 --- a/jdk/make/gensrc/GensrcIcons.gmk +++ b/jdk/make/gensrc/GensrcIcons.gmk @@ -29,9 +29,9 @@ GENSRC_AWT_ICONS_TMP := $(JDK_OUTPUTDIR)/gensrc GENSRC_AWT_ICONS_DST := $(GENSRC_AWT_ICONS_TMP)/java.desktop/sun/awt/ ifdef OPENJDK - X11_ICONS_PATH_PREFIX := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR) + X11_ICONS_PATH_PREFIX := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE) else - X11_ICONS_PATH_PREFIX := $(JDK_TOPDIR)/src/closed/java.desktop/$(OPENJDK_TARGET_OS_API_DIR) + X11_ICONS_PATH_PREFIX := $(JDK_TOPDIR)/src/closed/java.desktop/$(OPENJDK_TARGET_OS_TYPE) endif GENSRC_AWT_ICONS_SRC += \ diff --git a/jdk/make/gensrc/GensrcX11Wrappers.gmk b/jdk/make/gensrc/GensrcX11Wrappers.gmk index b21729654f8..f5e85e616a8 100644 --- a/jdk/make/gensrc/GensrcX11Wrappers.gmk +++ b/jdk/make/gensrc/GensrcX11Wrappers.gmk @@ -95,8 +95,8 @@ ifneq ($(COMPILE_TYPE), cross) -I$(JDK_TOPDIR)/src/java.base/share/native/include \ -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_EXPORT_DIR)/native/include \ -I$(JDK_TOPDIR)/src/java.base/share/native/libjava \ - -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libjava \ - -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/common/awt \ + -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava \ + -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/common/awt/debug \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image/cvutils \ # diff --git a/jdk/make/launcher/Launcher-jdk.runtime.gmk b/jdk/make/launcher/Launcher-jdk.runtime.gmk index cf6be2d2467..a8b21fe42e7 100644 --- a/jdk/make/launcher/Launcher-jdk.runtime.gmk +++ b/jdk/make/launcher/Launcher-jdk.runtime.gmk @@ -42,7 +42,7 @@ UNPACKEXE_SRC := $(JDK_TOPDIR)/src/jdk.runtime/share/native/common-unpack \ $(JDK_TOPDIR)/src/jdk.runtime/share/native/unpack200 UNPACKEXE_CFLAGS := -I$(JDK_TOPDIR)/src/jdk.runtime/share/native/common-unpack \ -I$(JDK_TOPDIR)/src/java.base/share/native/libjava \ - -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libjava + -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava ifeq ($(USE_EXTERNAL_LIBZ), true) UNPACKEXE_CFLAGS += -DSYSTEM_ZLIB @@ -102,7 +102,7 @@ $(eval $(call SetupNativeCompilation,BUILD_UNPACKEXE, \ MAPFILE := $(UNPACK_MAPFILE),\ LDFLAGS := $(UNPACKEXE_ZIPOBJS), \ LDFLAGS_windows := $(CXXFLAGS_JDKEXE), \ - LDFLAGS_posix := $(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \ + LDFLAGS_unix := $(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \ $(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)unpack$(SHARED_LIBRARY_SUFFIX)) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_linux := -lc, \ diff --git a/jdk/make/launcher/LauncherCommon.gmk b/jdk/make/launcher/LauncherCommon.gmk index f8ff00c830d..ad344b4faa4 100644 --- a/jdk/make/launcher/LauncherCommon.gmk +++ b/jdk/make/launcher/LauncherCommon.gmk @@ -62,7 +62,7 @@ endif LAUNCHER_SRC := $(JDK_TOPDIR)/src/java.base/share/native/launcher LAUNCHER_CFLAGS := -I$(JDK_TOPDIR)/src/java.base/share/native/launcher \ -I$(JDK_TOPDIR)/src/java.base/share/native/libjli \ - -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libjli \ + -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjli \ -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libjli \ # GLOBAL_VERSION_INFO_RESOURCE := $(JDK_TOPDIR)/src/java.base/windows/native/common/version.rc @@ -71,10 +71,10 @@ MACOSX_PLIST_DIR := $(JDK_TOPDIR)/src/java.base/macosx/native/launcher # Until the shuffle is permanent, we can't add this in configure CFLAGS_JDKEXE := $(filter-out %javavm/export, $(CFLAGS_JDKEXE)) CFLAGS_JDKEXE += -I$(JDK_TOPDIR)/src/java.base/share/native/include \ - -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/include + -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/include CXXFLAGS_JDKEXE := $(filter-out %javavm/export, $(CXXFLAGS_JDKEXE)) CXXFLAGS_JDKEXE += -I$(JDK_TOPDIR)/src/java.base/share/native/include \ - -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/include + -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/include JAVA_MANIFEST := $(JDK_TOPDIR)/src/java.base/windows/native/launcher/java.manifest define SetupLauncher @@ -82,7 +82,7 @@ define SetupLauncher # Parameter 1 is the name of the launcher (java, javac, jar...) # Parameter 2 is extra CFLAGS # Parameter 3 is extra LDFLAGS - # Parameter 4 is extra LDFLAGS_SUFFIX_posix + # Parameter 4 is extra LDFLAGS_SUFFIX_unix # Parameter 5 is extra LDFLAGS_SUFFIX_windows # Parameter 6 is optional Windows JLI library (full path) # Parameter 7 is optional Windows resource (RC) flags @@ -187,7 +187,7 @@ define SetupLauncher $(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)$(SHARED_LIBRARY_SUFFIX)), \ MAPFILE := $$($1_MAPFILE), \ LDFLAGS_SUFFIX := $(LDFLAGS_JDKEXE_SUFFIX) $$($1_LDFLAGS_SUFFIX), \ - LDFLAGS_SUFFIX_posix := $4, \ + LDFLAGS_SUFFIX_unix := $4, \ LDFLAGS_SUFFIX_windows := $$($1_WINDOWS_JLI_LIB) \ $(JDK_OUTPUTDIR)/objs/libjava/java.lib advapi32.lib $5, \ LDFLAGS_SUFFIX_linux := -L$(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/jli -ljli $(LIBDL) -lc, \ @@ -231,4 +231,3 @@ ifdef OPENJDK else JAVA_RC_FLAGS += -i "$(JDK_TOPDIR)/src/closed/java.base/windows/native/launcher/icons" endif - diff --git a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk index 0d38b332892..68b9f69ed20 100644 --- a/jdk/make/lib/Awt2dLibraries.gmk +++ b/jdk/make/lib/Awt2dLibraries.gmk @@ -31,7 +31,7 @@ BUILD_LIBMLIB_SRC := $(JDK_TOPDIR)/src/java.desktop/share/native/libmlib_image \ $(JDK_TOPDIR)/src/java.desktop/share/native/common/awt/medialib BUILD_LIBMLIB_CFLAGS := -D__USE_J2D_NAMES -D__MEDIALIB_OLD_NAMES \ $(addprefix -I, $(BUILD_LIBMLIB_SRC)) \ - -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libmlib_image + -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libmlib_image BUILD_LIBMLIB_LDLIBS := BUILD_LIBMLIB_IMAGE_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libmlib_image/mapfile-vers @@ -144,9 +144,9 @@ endif ################################################################################ LIBAWT_DIRS := $(JDK_TOPDIR)/src/java.desktop/share/native/libawt \ - $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libawt \ + $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libawt \ $(JDK_TOPDIR)/src/java.desktop/share/native/common/awt/debug \ - $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/common/awt \ + $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \ # ifeq ($(OPENJDK_TARGET_OS), aix) @@ -211,7 +211,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) # Why does libawt need java.base headers? LIBAWT_CFLAGS += -I$(JDK_TOPDIR)/src/java.desktop/share/native/common/font \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/common/java2d/opengl \ - -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/common/java2d/opengl \ + -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/java2d/opengl \ -I$(JDK_TOPDIR)/src/java.desktop/windows/native/include \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/include \ -I$(JDK_OUTPUTDIR)/gensrc_headers/java.base \ @@ -298,15 +298,15 @@ ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),) ifndef BUILD_HEADLESS_ONLY LIBAWT_XAWT_DIRS := \ - $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libawt_xawt \ - $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libjawt \ + $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libawt_xawt \ + $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libjawt \ $(JDK_TOPDIR)/src/java.desktop/share/native/common/awt/debug \ $(JDK_TOPDIR)/src/java.desktop/share/native/common/awt/utility \ $(JDK_TOPDIR)/src/java.desktop/share/native/common/font \ $(JDK_TOPDIR)/src/java.desktop/share/native/common/java2d/opengl \ - $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/common/java2d/opengl \ - $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/common/java2d/x11 \ - $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/common/awt \ + $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/java2d/opengl \ + $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/java2d/x11 \ + $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \ # LIBAWT_XAWT_EXCLUDES := medialib @@ -315,15 +315,15 @@ ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),) -I$(JDK_OUTPUTDIR)/gensrc_headers/java.desktop \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/include \ -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS)/native/include \ - -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/include \ + -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/include \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d \ - -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libawt/java2d \ + -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libawt/java2d \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d/loops \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d/pipe \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image/cvutils \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image \ - -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libsunwjdga \ - -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/common/font \ + -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libsunwjdga \ + -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/font \ $(LIBJAVA_HEADER_FLAGS) # @@ -514,14 +514,14 @@ DESKTOP_LIBRARIES += $(BUILD_LIBJAVAJPEG) ################################################################################ LIBFONTMANAGER_SRC := $(JDK_TOPDIR)/src/java.desktop/share/native/libfontmanager \ - $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libfontmanager + $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libfontmanager LIBFONTMANAGER_CFLAGS := \ $(addprefix -I, $(shell $(FIND) \ $(LIBFONTMANAGER_SRC) \ $(JDK_TOPDIR)/src/java.desktop/share/native/libawt \ - $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libawt \ + $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libawt \ $(JDK_TOPDIR)/src/java.desktop/share/native/common \ - $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/common -type d)) \ + $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common -type d)) \ -I$(JDK_OUTPUTDIR)/gensrc_headers/java.desktop \ $(LIBJAVA_HEADER_FLAGS) \ # @@ -542,7 +542,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \ X11TextRenderer.c LIBFONTMANAGER_OPTIMIZATION := HIGHEST - LIBFONTMANAGER_CFLAGS += -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libawt/windows + LIBFONTMANAGER_CFLAGS += -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libawt/windows else ifeq ($(OPENJDK_TARGET_OS), macosx) LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \ X11TextRenderer.c \ @@ -606,12 +606,12 @@ DESKTOP_LIBRARIES += $(BUILD_LIBFONTMANAGER) ################################################################################ ifeq ($(OPENJDK_TARGET_OS), windows) - LIBJAWT_SRC := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libjawt - LIBJAWT_CFLAGS := -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libawt/windows \ + LIBJAWT_SRC := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libjawt + LIBJAWT_CFLAGS := -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libawt/windows \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/common/awt/debug \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image/cvutils \ - -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libawt/java2d/windows \ + -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libawt/java2d/windows \ -I$(JDK_OUTPUTDIR)/gensrc_headers/java.desktop \ -I$(JDK_TOPDIR)/src/java.desktop/windows/native/include \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/include \ @@ -655,12 +655,12 @@ else # OPENJDK_TARGET_OS not windows ifeq ($(OPENJDK_TARGET_OS), macosx) LIBJAWT_SRC := $(JDK_TOPDIR)/src/java.desktop/macosx/native/libjawt else - LIBJAWT_SRC := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libjawt + LIBJAWT_SRC := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libjawt endif LIBJAWT_CFLAGS := \ - -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/common/awt \ + -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \ -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS)/native/include \ - -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/include \ + -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/include \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/include \ $(LIBJAVA_HEADER_FLAGS) \ # @@ -724,9 +724,9 @@ ifeq ($(BUILD_HEADLESS), true) ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx),) LIBAWT_HEADLESS_DIRS := $(JDK_TOPDIR)/src/java.desktop/unix/native/libawt_headless/awt \ - $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/common/awt \ - $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/common/java2d/opengl \ - $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/common/java2d/x11 \ + $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \ + $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/java2d/opengl \ + $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/java2d/x11 \ $(JDK_TOPDIR)/src/java.desktop/share/native/common/java2d/opengl \ $(JDK_TOPDIR)/src/java.desktop/share/native/common/font \ # @@ -739,11 +739,11 @@ ifeq ($(BUILD_HEADLESS), true) -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image/cvutils \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d/pipe \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image \ - -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libawt/java2d \ + -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libawt/java2d \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/common/font \ -I$(JDK_TOPDIR)/src/java.desktop/share/native/common/awt/debug \ - -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/common/font \ - -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libsunwjdga/ \ + -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/font \ + -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libsunwjdga/ \ $(LIBJAVA_HEADER_FLAGS) \ # @@ -817,7 +817,7 @@ ifndef BUILD_HEADLESS_ONLY endif ifneq ($(OPENJDK_TARGET_OS), macosx) - LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libsplashscreen + LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libsplashscreen else LIBSPLASHSCREEN_DIRS += $(JDK_TOPDIR)/src/java.desktop/macosx/native/libsplashscreen endif @@ -988,7 +988,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) -I$(JDK_TOPDIR)/src/java.desktop/macosx/native/libawt_lwawt/awt \ -I$(JDK_TOPDIR)/src/java.desktop/macosx/native/libosxapp \ -I$(JDK_TOPDIR)/src/java.base/share/native/libjava \ - -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libjava \ + -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava \ -I$(JDK_OUTPUTDIR)/gensrc_headers/java.desktop, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN) \ diff --git a/jdk/make/lib/CoreLibraries.gmk b/jdk/make/lib/CoreLibraries.gmk index c6328d4bd38..3642ba35493 100644 --- a/jdk/make/lib/CoreLibraries.gmk +++ b/jdk/make/lib/CoreLibraries.gmk @@ -99,7 +99,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBVERIFY, \ MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libverify/mapfile-vers, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ - LDFLAGS_SUFFIX_posix := -ljvm -lc, \ + LDFLAGS_SUFFIX_unix := -ljvm -lc, \ LDFLAGS_SUFFIX_windows := jvm.lib, \ VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \ RC_FLAGS := $(RC_FLAGS) \ @@ -160,7 +160,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA, \ MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjava/mapfile-vers, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ - LDFLAGS_SUFFIX_posix := -ljvm -lverify, \ + LDFLAGS_SUFFIX_unix := -ljvm -lverify, \ LDFLAGS_SUFFIX_solaris := -lsocket -lnsl -lscf $(LIBDL) $(BUILD_LIBFDLIBM) -lc, \ LDFLAGS_SUFFIX_linux := $(LIBDL) $(BUILD_LIBFDLIBM), \ LDFLAGS_SUFFIX_aix := $(LIBDL) $(BUILD_LIBFDLIBM) -lm,\ @@ -216,9 +216,9 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBZIP, \ CFLAGS := $(CFLAGS_JDKLIB) \ $(ZLIB_CPPFLAGS) \ -I$(JDK_TOPDIR)/src/java.base/share/native/libjava \ - -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libjava \ + -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava \ -I$(JDK_OUTPUTDIR)/gensrc_headers/java.base, \ - CFLAGS_posix := $(BUILD_LIBZIP_MMAP) -UDEBUG, \ + CFLAGS_unix := $(BUILD_LIBZIP_MMAP) -UDEBUG, \ MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libzip/mapfile-vers, \ REORDER := $(BUILD_LIBZIP_REORDER), \ LDFLAGS := $(LDFLAGS_JDKLIB) \ @@ -247,7 +247,7 @@ BASE_LIBRARIES += $(BUILD_LIBZIP) ########################################################################################## BUILD_LIBJLI_SRC_DIRS := $(JDK_TOPDIR)/src/java.base/share/native/libjli \ - $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libjli + $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjli LIBJLI_CFLAGS := $(CFLAGS_JDKLIB) @@ -291,7 +291,7 @@ else ifneq ($(OPENJDK_TARGET_OS), macosx) # if the architecture specific ergo file exists then # use it, else use the generic definitions from ergo.c - ifneq ($(wildcard $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libjli/$(ERGO_ARCH_FILE)), ) + ifneq ($(wildcard $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjli/$(ERGO_ARCH_FILE)), ) BUILD_LIBJLI_FILES += $(ERGO_ARCH_FILE) else # !ERGO_ARCH_FILE LIBJLI_CFLAGS += -DUSE_GENERIC_ERGO diff --git a/jdk/make/lib/Lib-java.instrument.gmk b/jdk/make/lib/Lib-java.instrument.gmk index a54a743af39..a818f05e2c0 100644 --- a/jdk/make/lib/Lib-java.instrument.gmk +++ b/jdk/make/lib/Lib-java.instrument.gmk @@ -28,7 +28,7 @@ include LibCommon.gmk ################################################################################ LIBINSTRUMENT_SRC := $(JDK_TOPDIR)/src/java.instrument/share/native/libinstrument \ - $(JDK_TOPDIR)/src/java.instrument/$(OPENJDK_TARGET_OS_API_DIR)/native/libinstrument \ + $(JDK_TOPDIR)/src/java.instrument/$(OPENJDK_TARGET_OS_TYPE)/native/libinstrument \ # LIBINSTRUMENT_CFLAGS := $(CFLAGS_JDKLIB) \ $(addprefix -I, $(LIBINSTRUMENT_SRC)) \ diff --git a/jdk/make/lib/Lib-java.management.gmk b/jdk/make/lib/Lib-java.management.gmk index 2cc7b850621..21b14c3750a 100644 --- a/jdk/make/lib/Lib-java.management.gmk +++ b/jdk/make/lib/Lib-java.management.gmk @@ -31,7 +31,7 @@ $(eval $(call IncludeCustomExtension, jdk, lib/Lib-java.management.gmk)) ################################################################################ BUILD_LIBMANAGEMENT_SRC += $(JDK_TOPDIR)/src/java.management/share/native/libmanagement \ - $(JDK_TOPDIR)/src/java.management/$(OPENJDK_TARGET_OS_API_DIR)/native/libmanagement + $(JDK_TOPDIR)/src/java.management/$(OPENJDK_TARGET_OS_TYPE)/native/libmanagement BUILD_LIBMANAGEMENT_CFLAGS := -I$(JDK_TOPDIR)/src/java.management/share/native/include \ $(addprefix -I,$(BUILD_LIBMANAGEMENT_SRC)) \ -I$(JDK_OUTPUTDIR)/gensrc_headers/java.management \ diff --git a/jdk/make/lib/Lib-java.prefs.gmk b/jdk/make/lib/Lib-java.prefs.gmk index c034b190f41..e99f655b07c 100644 --- a/jdk/make/lib/Lib-java.prefs.gmk +++ b/jdk/make/lib/Lib-java.prefs.gmk @@ -30,7 +30,7 @@ include LibCommon.gmk ifeq ($(OPENJDK_TARGET_OS), macosx) LIBPREF_SRC_DIRS := $(JDK_TOPDIR)/src/java.prefs/macosx/native/libprefs else - LIBPREF_SRC_DIRS := $(JDK_TOPDIR)/src/java.prefs/$(OPENJDK_TARGET_OS_API_DIR)/native/libprefs + LIBPREF_SRC_DIRS := $(JDK_TOPDIR)/src/java.prefs/$(OPENJDK_TARGET_OS_TYPE)/native/libprefs endif $(eval $(call SetupNativeCompilation,BUILD_LIBPREFS, \ diff --git a/jdk/make/lib/Lib-java.security.jgss.gmk b/jdk/make/lib/Lib-java.security.jgss.gmk index d6f986628ae..50ff52a76fa 100644 --- a/jdk/make/lib/Lib-java.security.jgss.gmk +++ b/jdk/make/lib/Lib-java.security.jgss.gmk @@ -29,7 +29,7 @@ include LibCommon.gmk ifneq ($(OPENJDK_TARGET_OS), windows) LIBJ2GSS_SRC := $(JDK_TOPDIR)/src/java.security.jgss/share/native/libj2gss \ - $(JDK_TOPDIR)/src/java.security.jgss/$(OPENJDK_TARGET_OS_API_DIR)/native/libj2gss \ + $(JDK_TOPDIR)/src/java.security.jgss/$(OPENJDK_TARGET_OS_TYPE)/native/libj2gss \ # $(eval $(call SetupNativeCompilation,BUILD_LIBJ2GSS, \ @@ -58,7 +58,7 @@ ifneq ($(BUILD_CRYPTO), no) BUILD_LIBKRB5_NAME := ifeq ($(OPENJDK_TARGET_OS), windows) BUILD_LIBKRB5_NAME := w2k_lsa_auth - BUILD_LIBKRB5_SRC := $(JDK_TOPDIR)/src/java.security.jgss/$(OPENJDK_TARGET_OS_API_DIR)/native/libw2k_lsa_auth + BUILD_LIBKRB5_SRC := $(JDK_TOPDIR)/src/java.security.jgss/$(OPENJDK_TARGET_OS_TYPE)/native/libw2k_lsa_auth BUILD_LIBKRB5_LIBS := advapi32.lib Secur32.lib netapi32.lib kernel32.lib user32.lib \ gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib \ ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib diff --git a/jdk/make/lib/Lib-java.smartcardio.gmk b/jdk/make/lib/Lib-java.smartcardio.gmk index 7b7be4510b7..c445dcfde38 100644 --- a/jdk/make/lib/Lib-java.smartcardio.gmk +++ b/jdk/make/lib/Lib-java.smartcardio.gmk @@ -28,9 +28,9 @@ include LibCommon.gmk ################################################################################ LIBJ2PCSC_SRC := $(JDK_TOPDIR)/src/java.smartcardio/share/native/libj2pcsc \ - $(JDK_TOPDIR)/src/java.smartcardio/$(OPENJDK_TARGET_OS_API_DIR)/native/libj2pcsc + $(JDK_TOPDIR)/src/java.smartcardio/$(OPENJDK_TARGET_OS_TYPE)/native/libj2pcsc LIBJ2PCSC_CPPFLAGS := $(addprefix -I,$(LIBJ2PCSC_SRC)) \ - -I$(JDK_TOPDIR)/src/java.smartcardio/$(OPENJDK_TARGET_OS_API_DIR)/native/libj2pcsc/MUSCLE \ + -I$(JDK_TOPDIR)/src/java.smartcardio/$(OPENJDK_TARGET_OS_TYPE)/native/libj2pcsc/MUSCLE \ -I$(JDK_OUTPUTDIR)/gensrc_headers/java.smartcardio $(eval $(call SetupNativeCompilation,BUILD_LIBJ2PCSC, \ @@ -38,13 +38,13 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJ2PCSC, \ OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ SRC := $(LIBJ2PCSC_SRC), \ LANG := C, \ - CFLAGS_posix := -D__sun_jdk, \ + CFLAGS_unix := -D__sun_jdk, \ OPTIMIZATION := LOW, \ CFLAGS := $(CFLAGS_JDKLIB) $(LIBJ2PCSC_CPPFLAGS), \ MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libj2pcsc/mapfile-vers, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ - LDFLAGS_SUFFIX_posix := $(LIBDL), \ + LDFLAGS_SUFFIX_unix := $(LIBDL), \ LDFLAGS_SUFFIX_windows := winscard.lib, \ LDFLAGS_SUFFIX_solaris := -lc, \ VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \ diff --git a/jdk/make/lib/Lib-jdk.crypto.mscapi.gmk b/jdk/make/lib/Lib-jdk.crypto.mscapi.gmk index a1e5fc0b15e..899ed6ca9cb 100644 --- a/jdk/make/lib/Lib-jdk.crypto.mscapi.gmk +++ b/jdk/make/lib/Lib-jdk.crypto.mscapi.gmk @@ -29,7 +29,7 @@ include LibCommon.gmk ifeq ($(OPENJDK_TARGET_OS), windows) - LIBSUNMSCAPI_SRC := $(JDK_TOPDIR)/src/jdk.crypto.mscapi/$(OPENJDK_TARGET_OS_API_DIR)/native/libsunmscapi + LIBSUNMSCAPI_SRC := $(JDK_TOPDIR)/src/jdk.crypto.mscapi/$(OPENJDK_TARGET_OS_TYPE)/native/libsunmscapi $(eval $(call SetupNativeCompilation,BUILD_LIBSUNMSCAPI, \ LIBRARY := sunmscapi, \ diff --git a/jdk/make/lib/Lib-jdk.crypto.pkcs11.gmk b/jdk/make/lib/Lib-jdk.crypto.pkcs11.gmk index fd35a9d5f9b..8135d28e18f 100644 --- a/jdk/make/lib/Lib-jdk.crypto.pkcs11.gmk +++ b/jdk/make/lib/Lib-jdk.crypto.pkcs11.gmk @@ -28,7 +28,7 @@ include LibCommon.gmk ################################################################################ LIBJ2PKCS11_SRC := $(JDK_TOPDIR)/src/jdk.crypto.pkcs11/share/native/libj2pkcs11 \ - $(JDK_TOPDIR)/src/jdk.crypto.pkcs11/$(OPENJDK_TARGET_OS_API_DIR)/native/libj2pkcs11 + $(JDK_TOPDIR)/src/jdk.crypto.pkcs11/$(OPENJDK_TARGET_OS_TYPE)/native/libj2pkcs11 $(eval $(call SetupNativeCompilation,BUILD_LIBJ2PKCS11, \ LIBRARY := j2pkcs11, \ @@ -42,7 +42,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJ2PKCS11, \ MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libj2pkcs11/mapfile-vers, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ - LDFLAGS_SUFFIX_posix := $(LIBDL), \ + LDFLAGS_SUFFIX_unix := $(LIBDL), \ LDFLAGS_SUFFIX_solaris := -lc, \ VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \ RC_FLAGS := $(RC_FLAGS) \ diff --git a/jdk/make/lib/Lib-jdk.jdi.gmk b/jdk/make/lib/Lib-jdk.jdi.gmk index 8dc731bbf6c..8bacba8622e 100644 --- a/jdk/make/lib/Lib-jdk.jdi.gmk +++ b/jdk/make/lib/Lib-jdk.jdi.gmk @@ -30,7 +30,7 @@ include LibCommon.gmk ifeq ($(OPENJDK_TARGET_OS), windows) LIBDT_SHMEM_SRC := $(JDK_TOPDIR)/src/jdk.jdi/share/native/libdt_shmem \ - $(JDK_TOPDIR)/src/jdk.jdi/$(OPENJDK_TARGET_OS_API_DIR)/native/libdt_shmem \ + $(JDK_TOPDIR)/src/jdk.jdi/$(OPENJDK_TARGET_OS_TYPE)/native/libdt_shmem \ # LIBDT_SHMEM_CPPFLAGS := -I$(INCLUDEDIR) -I$(JDK_OUTPUTDIR)/include/$(OPENJDK_TARGET_OS) \ $(addprefix -I, $(LIBDT_SHMEM_SRC)) \ diff --git a/jdk/make/lib/Lib-jdk.jdwp.agent.gmk b/jdk/make/lib/Lib-jdk.jdwp.agent.gmk index 7b13248a9be..18552857109 100644 --- a/jdk/make/lib/Lib-jdk.jdwp.agent.gmk +++ b/jdk/make/lib/Lib-jdk.jdwp.agent.gmk @@ -28,7 +28,7 @@ include LibCommon.gmk ################################################################################ LIBDT_SOCKET_SRC := $(JDK_TOPDIR)/src/jdk.jdwp.agent/share/native/libdt_socket \ - $(JDK_TOPDIR)/src/jdk.jdwp.agent/$(OPENJDK_TARGET_OS_API_DIR)/native/libdt_socket + $(JDK_TOPDIR)/src/jdk.jdwp.agent/$(OPENJDK_TARGET_OS_TYPE)/native/libdt_socket LIBDT_SOCKET_CPPFLAGS := \ $(addprefix -I, $(LIBDT_SOCKET_SRC)) \ -I$(JDK_TOPDIR)/src/jdk.jdwp.agent/share/native/libjdwp/export \ @@ -66,7 +66,7 @@ JDWP_LIBRARIES += $(BUILD_LIBDT_SOCKET) ################################################################################ LIBJDWP_SRC := $(JDK_TOPDIR)/src/jdk.jdwp.agent/share/native/libjdwp \ - $(JDK_TOPDIR)/src/jdk.jdwp.agent/$(OPENJDK_TARGET_OS_API_DIR)/native/libjdwp + $(JDK_TOPDIR)/src/jdk.jdwp.agent/$(OPENJDK_TARGET_OS_TYPE)/native/libjdwp LIBJDWP_CPPFLAGS := \ -I$(JDK_TOPDIR)/src/jdk.jdwp.agent/share/native/libjdwp/export \ -I$(JDK_TOPDIR)/src/jdk.jdwp.agent/share/native/include \ diff --git a/jdk/make/lib/Lib-jdk.runtime.gmk b/jdk/make/lib/Lib-jdk.runtime.gmk index 3ffaa72570a..cee0cd7deda 100644 --- a/jdk/make/lib/Lib-jdk.runtime.gmk +++ b/jdk/make/lib/Lib-jdk.runtime.gmk @@ -45,7 +45,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBUNPACK, \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_windows := -map:$(JDK_OUTPUTDIR)/objs/unpack.map -debug \ jvm.lib $(WIN_JAVA_LIB), \ - LDFLAGS_SUFFIX_posix := -ljvm $(LIBCXX) -ljava -lc, \ + LDFLAGS_SUFFIX_unix := -ljvm $(LIBCXX) -ljava -lc, \ OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libunpack, \ VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \ RC_FLAGS := $(RC_FLAGS) \ @@ -61,7 +61,7 @@ UNPACK_LIBRARIES += $(BUILD_LIBUNPACK) ################################################################################ LIBJSDT_SRC := $(JDK_TOPDIR)/src/jdk.runtime/share/native/libjsdt \ - $(JDK_TOPDIR)/src/jdk.runtime/$(OPENJDK_TARGET_OS_API_DIR)/native/libjsdt + $(JDK_TOPDIR)/src/jdk.runtime/$(OPENJDK_TARGET_OS_TYPE)/native/libjsdt $(eval $(call SetupNativeCompilation,BUILD_LIBJSDT, \ LIBRARY := jsdt, \ diff --git a/jdk/make/lib/Lib-jdk.sctp.gmk b/jdk/make/lib/Lib-jdk.sctp.gmk index 7afd0020be7..cfc13838c53 100644 --- a/jdk/make/lib/Lib-jdk.sctp.gmk +++ b/jdk/make/lib/Lib-jdk.sctp.gmk @@ -27,7 +27,7 @@ include LibCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS_API), posix) +ifeq ($(OPENJDK_TARGET_OS_TYPE), unix) ifeq (, $(filter $(OPENJDK_TARGET_OS), macosx aix)) @@ -40,11 +40,11 @@ ifeq ($(OPENJDK_TARGET_OS_API), posix) $(eval $(call SetupNativeCompilation,BUILD_LIBSCTP, \ LIBRARY := sctp, \ OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ - SRC := $(JDK_TOPDIR)/src/jdk.sctp/$(OPENJDK_TARGET_OS_API_DIR)/native/libsctp, \ + SRC := $(JDK_TOPDIR)/src/jdk.sctp/$(OPENJDK_TARGET_OS_TYPE)/native/libsctp, \ LANG := C, \ OPTIMIZATION := LOW, \ CFLAGS := $(CFLAGS_JDKLIB) \ - -I $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libnio/ch \ + -I $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libnio/ch \ -I $(JDK_TOPDIR)/src/java.base/share/native/libnio/ch \ $(addprefix -I, $(call FindSrcDirsForLib, java.base, net)) \ $(LIBJAVA_HEADER_FLAGS) \ @@ -55,7 +55,7 @@ ifeq ($(OPENJDK_TARGET_OS_API), posix) LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_SUFFIX_linux := -lpthread $(LIBDL) -ljava -ljvm, \ - LDFLAGS_SUFFIX_posix := -lnio -lnet, \ + LDFLAGS_SUFFIX_unix := -lnio -lnet, \ LDFLAGS_SUFFIX_solaris := -lsocket -ljava -ljvm -lc, \ LDFLAGS_SUFFIX_macosx := -ljava -ljvm, \ OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libsctp, \ diff --git a/jdk/make/lib/Lib-jdk.security.auth.gmk b/jdk/make/lib/Lib-jdk.security.auth.gmk index 52151773886..17549a71482 100644 --- a/jdk/make/lib/Lib-jdk.security.auth.gmk +++ b/jdk/make/lib/Lib-jdk.security.auth.gmk @@ -43,7 +43,7 @@ endif $(eval $(call SetupNativeCompilation,BUILD_LIBJAAS, \ LIBRARY := $(LIBJAAS_NAME), \ OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ - SRC := $(JDK_TOPDIR)/src/jdk.security.auth/$(OPENJDK_TARGET_OS_API_DIR)/native/libjaas, \ + SRC := $(JDK_TOPDIR)/src/jdk.security.auth/$(OPENJDK_TARGET_OS_TYPE)/native/libjaas, \ LANG := C, \ OPTIMIZATION := LOW, \ CFLAGS := $(CFLAGS_JDKLIB) -I$(JDK_OUTPUTDIR)/gensrc_headers/jdk.security.auth, \ diff --git a/jdk/make/lib/LibCommon.gmk b/jdk/make/lib/LibCommon.gmk index 885ba11c780..eede8fbd8de 100644 --- a/jdk/make/lib/LibCommon.gmk +++ b/jdk/make/lib/LibCommon.gmk @@ -34,8 +34,8 @@ include Tools.gmk GLOBAL_VERSION_INFO_RESOURCE := $(JDK_TOPDIR)/src/java.base/windows/native/common/version.rc -# Put the libraries here. Different locations for different target apis. -ifeq ($(OPENJDK_TARGET_OS_API), posix) +# Put the libraries here. Different locations for different target OS types. +ifeq ($(OPENJDK_TARGET_OS_TYPE), unix) INSTALL_LIBRARIES_HERE := $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR) else INSTALL_LIBRARIES_HERE := $(JDK_OUTPUTDIR)/bin @@ -63,7 +63,7 @@ endif # Param 2 - library name FindSrcDirsForLib = $(call uniq, $(wildcard \ $(JDK_TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS)/native/lib$(strip $2) \ - $(JDK_TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS_API_DIR)/native/lib$(strip $2) \ + $(JDK_TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS_TYPE)/native/lib$(strip $2) \ $(JDK_TOPDIR)/src/$(strip $1)/share/native/lib$(strip $2))) ################################################################################ diff --git a/jdk/make/lib/NetworkingLibraries.gmk b/jdk/make/lib/NetworkingLibraries.gmk index a0825b06ce2..095d2773b46 100644 --- a/jdk/make/lib/NetworkingLibraries.gmk +++ b/jdk/make/lib/NetworkingLibraries.gmk @@ -24,7 +24,7 @@ # LIBNET_SRC_DIRS := $(JDK_TOPDIR)/src/java.base/share/native/libnet \ - $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libnet + $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libnet LIBNET_CFLAGS += -I$(JDK_OUTPUTDIR)/gensrc_headers/java.base \ $(LIBJAVA_HEADER_FLAGS) @@ -77,4 +77,3 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBNET, \ $(BUILD_LIBNET): $(BUILD_LIBJAVA) BASE_LIBRARIES += $(BUILD_LIBNET) - diff --git a/jdk/make/lib/NioLibraries.gmk b/jdk/make/lib/NioLibraries.gmk index 722115fdee5..be851af88eb 100644 --- a/jdk/make/lib/NioLibraries.gmk +++ b/jdk/make/lib/NioLibraries.gmk @@ -25,10 +25,10 @@ BUILD_LIBNIO_SRC := \ $(JDK_TOPDIR)/src/java.base/share/native/libnio/ch \ - $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libnio \ + $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libnio \ $(sort $(wildcard \ - $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libnio/ch \ - $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libnio/fs \ + $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libnio/ch \ + $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libnio/fs \ $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libnio/ch \ $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libnio/fs)) \ # diff --git a/jdk/make/lib/SoundLibraries.gmk b/jdk/make/lib/SoundLibraries.gmk index 6348f7a7d7b..c0a1219b684 100644 --- a/jdk/make/lib/SoundLibraries.gmk +++ b/jdk/make/lib/SoundLibraries.gmk @@ -25,7 +25,7 @@ LIBJSOUND_SRC_DIRS := \ $(JDK_TOPDIR)/src/java.desktop/share/native/libjsound \ - $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libjsound \ + $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libjsound \ # LIBJSOUND_CFLAGS := \ -I$(JDK_OUTPUTDIR)/gensrc_headers/java.desktop \ @@ -165,7 +165,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJSOUND, \ -framework CoreServices -framework AudioUnit $(LIBCXX) \ -framework CoreMIDI -framework AudioToolbox, \ LDFLAGS_windows := $(WIN_JAVA_LIB) advapi32.lib winmm.lib, \ - LDFLAGS_SUFFIX_posix := -ljava -ljvm, \ + LDFLAGS_SUFFIX_unix := -ljava -ljvm, \ LDFLAGS_SUFFIX_solaris := -lc, \ VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \ RC_FLAGS := $(RC_FLAGS) \ From c90bc5b3166aef29211e7c75b9212217b12b3d56 Mon Sep 17 00:00:00 2001 From: Staffan Friberg Date: Fri, 21 Nov 2014 09:28:53 -0800 Subject: [PATCH 38/67] 6321472: Add CRC-32C API To add CRC-32C api and implementation Reviewed-by: sherman --- .../share/classes/java/util/zip/Adler32.java | 49 ++- .../share/classes/java/util/zip/CRC32.java | 50 ++- .../share/classes/java/util/zip/CRC32C.java | 339 ++++++++++++++++++ .../share/classes/java/util/zip/Checksum.java | 86 ++++- .../classes/java/util/zip/package-info.java | 77 ++++ .../share/classes/java/util/zip/package.html | 88 ----- jdk/test/java/util/zip/ChecksumBase.java | 196 ++++++++++ jdk/test/java/util/zip/TestCRC32.java | 40 +++ jdk/test/java/util/zip/TestCRC32C.java | 40 +++ jdk/test/java/util/zip/TestChecksum.java | 66 ++++ 10 files changed, 880 insertions(+), 151 deletions(-) create mode 100644 jdk/src/java.base/share/classes/java/util/zip/CRC32C.java create mode 100644 jdk/src/java.base/share/classes/java/util/zip/package-info.java delete mode 100644 jdk/src/java.base/share/classes/java/util/zip/package.html create mode 100644 jdk/test/java/util/zip/ChecksumBase.java create mode 100644 jdk/test/java/util/zip/TestCRC32.java create mode 100644 jdk/test/java/util/zip/TestCRC32C.java create mode 100644 jdk/test/java/util/zip/TestChecksum.java diff --git a/jdk/src/java.base/share/classes/java/util/zip/Adler32.java b/jdk/src/java.base/share/classes/java/util/zip/Adler32.java index de279f98a83..6a39b7c1c1a 100644 --- a/jdk/src/java.base/share/classes/java/util/zip/Adler32.java +++ b/jdk/src/java.base/share/classes/java/util/zip/Adler32.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 @@ -34,9 +34,8 @@ import sun.nio.ch.DirectBuffer; * can be computed much faster. * *

Passing a {@code null} argument to a method in this class will cause - * a {@link NullPointerException} to be thrown. + * a {@link NullPointerException} to be thrown.

* - * @see Checksum * @author David Connelly */ public @@ -53,9 +52,8 @@ class Adler32 implements Checksum { /** * Updates the checksum with the specified byte (the low eight * bits of the argument b). - * - * @param b the byte to update the checksum with */ + @Override public void update(int b) { adler = update(adler, b); } @@ -63,11 +61,12 @@ class Adler32 implements Checksum { /** * Updates the checksum with the specified array of bytes. * - * @throws ArrayIndexOutOfBoundsException - * if {@code off} is negative, or {@code len} is negative, - * or {@code off+len} is greater than the length of the - * array {@code b} + * @throws ArrayIndexOutOfBoundsException + * if {@code off} is negative, or {@code len} is negative, or + * {@code off+len} is negative or greater than the length of + * the array {@code b}. */ + @Override public void update(byte[] b, int off, int len) { if (b == null) { throw new NullPointerException(); @@ -78,29 +77,16 @@ class Adler32 implements Checksum { adler = updateBytes(adler, b, off, len); } - /** - * Updates the checksum with the specified array of bytes. - * - * @param b the byte array to update the checksum with - */ - public void update(byte[] b) { - adler = updateBytes(adler, b, 0, b.length); - } - - /** * Updates the checksum with the bytes from the specified buffer. * - * The checksum is updated using - * buffer.{@link java.nio.Buffer#remaining() remaining()} - * bytes starting at - * buffer.{@link java.nio.Buffer#position() position()} - * Upon return, the buffer's position will be updated to its - * limit; its limit will not have been changed. + * The checksum is updated with the remaining bytes in the buffer, starting + * at the buffer's position. Upon return, the buffer's position will be + * updated to its limit; its limit will not have been changed. * - * @param buffer the ByteBuffer to update the checksum with * @since 1.8 */ + @Override public void update(ByteBuffer buffer) { int pos = buffer.position(); int limit = buffer.limit(); @@ -113,9 +99,12 @@ class Adler32 implements Checksum { } else if (buffer.hasArray()) { adler = updateBytes(adler, buffer.array(), pos + buffer.arrayOffset(), rem); } else { - byte[] b = new byte[rem]; - buffer.get(b); - adler = updateBytes(adler, b, 0, b.length); + byte[] b = new byte[Math.min(buffer.remaining(), 4096)]; + while (buffer.hasRemaining()) { + int length = Math.min(buffer.remaining(), b.length); + buffer.get(b, 0, length); + update(b, 0, length); + } } buffer.position(limit); } @@ -123,6 +112,7 @@ class Adler32 implements Checksum { /** * Resets the checksum to initial value. */ + @Override public void reset() { adler = 1; } @@ -130,6 +120,7 @@ class Adler32 implements Checksum { /** * Returns the checksum value. */ + @Override public long getValue() { return (long)adler & 0xffffffffL; } diff --git a/jdk/src/java.base/share/classes/java/util/zip/CRC32.java b/jdk/src/java.base/share/classes/java/util/zip/CRC32.java index 0f55579b589..95ead3c3533 100644 --- a/jdk/src/java.base/share/classes/java/util/zip/CRC32.java +++ b/jdk/src/java.base/share/classes/java/util/zip/CRC32.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 @@ -32,9 +32,8 @@ import sun.nio.ch.DirectBuffer; * A class that can be used to compute the CRC-32 of a data stream. * *

Passing a {@code null} argument to a method in this class will cause - * a {@link NullPointerException} to be thrown. + * a {@link NullPointerException} to be thrown.

* - * @see Checksum * @author David Connelly */ public @@ -51,9 +50,8 @@ class CRC32 implements Checksum { /** * Updates the CRC-32 checksum with the specified byte (the low * eight bits of the argument b). - * - * @param b the byte to update the checksum with */ + @Override public void update(int b) { crc = update(crc, b); } @@ -61,11 +59,12 @@ class CRC32 implements Checksum { /** * Updates the CRC-32 checksum with the specified array of bytes. * - * @throws ArrayIndexOutOfBoundsException - * if {@code off} is negative, or {@code len} is negative, - * or {@code off+len} is greater than the length of the - * array {@code b} + * @throws ArrayIndexOutOfBoundsException + * if {@code off} is negative, or {@code len} is negative, or + * {@code off+len} is negative or greater than the length of + * the array {@code b}. */ + @Override public void update(byte[] b, int off, int len) { if (b == null) { throw new NullPointerException(); @@ -77,27 +76,15 @@ class CRC32 implements Checksum { } /** - * Updates the CRC-32 checksum with the specified array of bytes. + * Updates the CRC-32 checksum with the bytes from the specified buffer. * - * @param b the array of bytes to update the checksum with - */ - public void update(byte[] b) { - crc = updateBytes(crc, b, 0, b.length); - } - - /** - * Updates the checksum with the bytes from the specified buffer. + * The checksum is updated with the remaining bytes in the buffer, starting + * at the buffer's position. Upon return, the buffer's position will be + * updated to its limit; its limit will not have been changed. * - * The checksum is updated using - * buffer.{@link java.nio.Buffer#remaining() remaining()} - * bytes starting at - * buffer.{@link java.nio.Buffer#position() position()} - * Upon return, the buffer's position will - * be updated to its limit; its limit will not have been changed. - * - * @param buffer the ByteBuffer to update the checksum with * @since 1.8 */ + @Override public void update(ByteBuffer buffer) { int pos = buffer.position(); int limit = buffer.limit(); @@ -110,9 +97,12 @@ class CRC32 implements Checksum { } else if (buffer.hasArray()) { crc = updateBytes(crc, buffer.array(), pos + buffer.arrayOffset(), rem); } else { - byte[] b = new byte[rem]; - buffer.get(b); - crc = updateBytes(crc, b, 0, b.length); + byte[] b = new byte[Math.min(buffer.remaining(), 4096)]; + while (buffer.hasRemaining()) { + int length = Math.min(buffer.remaining(), b.length); + buffer.get(b, 0, length); + update(b, 0, length); + } } buffer.position(limit); } @@ -120,6 +110,7 @@ class CRC32 implements Checksum { /** * Resets CRC-32 to initial value. */ + @Override public void reset() { crc = 0; } @@ -127,6 +118,7 @@ class CRC32 implements Checksum { /** * Returns CRC-32 value. */ + @Override public long getValue() { return (long)crc & 0xffffffffL; } diff --git a/jdk/src/java.base/share/classes/java/util/zip/CRC32C.java b/jdk/src/java.base/share/classes/java/util/zip/CRC32C.java new file mode 100644 index 00000000000..251e3042800 --- /dev/null +++ b/jdk/src/java.base/share/classes/java/util/zip/CRC32C.java @@ -0,0 +1,339 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package java.util.zip; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import sun.misc.Unsafe; +import sun.nio.ch.DirectBuffer; + +/** + * A class that can be used to compute the CRC-32C of a data stream. + * + *

+ * CRC-32C is defined in RFC + * 3720: Internet Small Computer Systems Interface (iSCSI). + *

+ * + *

+ * Passing a {@code null} argument to a method in this class will cause a + * {@link NullPointerException} to be thrown. + *

+ * + * @since 1.9 + */ +public final class CRC32C implements Checksum { + + /* + * This CRC-32C implementation uses the 'slicing-by-8' algorithm described + * in the paper "A Systematic Approach to Building High Performance + * Software-Based CRC Generators" by Michael E. Kounavis and Frank L. Berry, + * Intel Research and Development + */ + + /** + * CRC-32C Polynomial + */ + private static final int CRC32C_POLY = 0x1EDC6F41; + private static final int REVERSED_CRC32C_POLY = Integer.reverse(CRC32C_POLY); + + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); + + // Lookup tables + // Lookup table for single byte calculations + private static final int[] byteTable; + // Lookup tables for bulk operations in 'slicing-by-8' algorithm + private static final int[][] byteTables = new int[8][256]; + private static final int[] byteTable0 = byteTables[0]; + private static final int[] byteTable1 = byteTables[1]; + private static final int[] byteTable2 = byteTables[2]; + private static final int[] byteTable3 = byteTables[3]; + private static final int[] byteTable4 = byteTables[4]; + private static final int[] byteTable5 = byteTables[5]; + private static final int[] byteTable6 = byteTables[6]; + private static final int[] byteTable7 = byteTables[7]; + + static { + // Generate lookup tables + // High-order polynomial term stored in LSB of r. + for (int index = 0; index < byteTables[0].length; index++) { + int r = index; + for (int i = 0; i < Byte.SIZE; i++) { + if ((r & 1) != 0) { + r = (r >>> 1) ^ REVERSED_CRC32C_POLY; + } else { + r >>>= 1; + } + } + byteTables[0][index] = r; + } + + for (int index = 0; index < byteTables[0].length; index++) { + int r = byteTables[0][index]; + + for (int k = 1; k < byteTables.length; k++) { + r = byteTables[0][r & 0xFF] ^ (r >>> 8); + byteTables[k][index] = r; + } + } + + if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) { + byteTable = byteTables[0]; + } else { // ByteOrder.BIG_ENDIAN + byteTable = new int[byteTable0.length]; + System.arraycopy(byteTable0, 0, byteTable, 0, byteTable0.length); + for (int[] table : byteTables) { + for (int index = 0; index < table.length; index++) { + table[index] = Integer.reverseBytes(table[index]); + } + } + } + } + + /** + * Calculated CRC-32C value + */ + private int crc = 0xFFFFFFFF; + + /** + * Creates a new CRC32C object. + */ + public CRC32C() { + } + + /** + * Updates the CRC-32C checksum with the specified byte (the low eight bits + * of the argument b). + */ + @Override + public void update(int b) { + crc = (crc >>> 8) ^ byteTable[(crc ^ (b & 0xFF)) & 0xFF]; + } + + /** + * Updates the CRC-32C checksum with the specified array of bytes. + * + * @throws ArrayIndexOutOfBoundsException + * if {@code off} is negative, or {@code len} is negative, or + * {@code off+len} is negative or greater than the length of + * the array {@code b}. + */ + @Override + public void update(byte[] b, int off, int len) { + if (b == null) { + throw new NullPointerException(); + } + if (off < 0 || len < 0 || off > b.length - len) { + throw new ArrayIndexOutOfBoundsException(); + } + crc = updateBytes(crc, b, off, (off + len)); + } + + /** + * Updates the CRC-32C checksum with the bytes from the specified buffer. + * + * The checksum is updated with the remaining bytes in the buffer, starting + * at the buffer's position. Upon return, the buffer's position will be + * updated to its limit; its limit will not have been changed. + */ + @Override + public void update(ByteBuffer buffer) { + int pos = buffer.position(); + int limit = buffer.limit(); + assert (pos <= limit); + int rem = limit - pos; + if (rem <= 0) { + return; + } + + if (buffer instanceof DirectBuffer) { + crc = updateDirectByteBuffer(crc, ((DirectBuffer) buffer).address(), + pos, limit); + } else if (buffer.hasArray()) { + crc = updateBytes(crc, buffer.array(), pos + buffer.arrayOffset(), + limit + buffer.arrayOffset()); + } else { + byte[] b = new byte[Math.min(buffer.remaining(), 4096)]; + while (buffer.hasRemaining()) { + int length = Math.min(buffer.remaining(), b.length); + buffer.get(b, 0, length); + update(b, 0, length); + } + } + buffer.position(limit); + } + + /** + * Resets CRC-32C to initial value. + */ + @Override + public void reset() { + crc = 0xFFFFFFFF; + } + + /** + * Returns CRC-32C value. + */ + @Override + public long getValue() { + return (~crc) & 0xFFFFFFFFL; + } + + /** + * Updates the CRC-32C checksum with the specified array of bytes. + */ + private static int updateBytes(int crc, byte[] b, int off, int end) { + + // Do only byte reads for arrays so short they can't be aligned + // or if bytes are stored with a larger witdh than one byte.,% + if (end - off >= 8 && Unsafe.ARRAY_BYTE_INDEX_SCALE == 1) { + + // align on 8 bytes + int alignLength + = (8 - ((Unsafe.ARRAY_BYTE_BASE_OFFSET + off) & 0x7)) & 0x7; + for (int alignEnd = off + alignLength; off < alignEnd; off++) { + crc = (crc >>> 8) ^ byteTable[(crc ^ b[off]) & 0xFF]; + } + + if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) { + crc = Integer.reverseBytes(crc); + } + + // slicing-by-8 + for (; off < (end - Long.BYTES); off += Long.BYTES) { + int firstHalf; + int secondHalf; + if (Unsafe.ADDRESS_SIZE == 4) { + // On 32 bit platforms read two ints instead of a single 64bit long + firstHalf = UNSAFE.getInt(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off); + secondHalf = UNSAFE.getInt(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off + + Integer.BYTES); + } else { + long value = UNSAFE.getLong(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off); + if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) { + firstHalf = (int) value; + secondHalf = (int) (value >>> 32); + } else { // ByteOrder.BIG_ENDIAN + firstHalf = (int) (value >>> 32); + secondHalf = (int) value; + } + } + crc ^= firstHalf; + if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) { + crc = byteTable7[crc & 0xFF] + ^ byteTable6[(crc >>> 8) & 0xFF] + ^ byteTable5[(crc >>> 16) & 0xFF] + ^ byteTable4[crc >>> 24] + ^ byteTable3[secondHalf & 0xFF] + ^ byteTable2[(secondHalf >>> 8) & 0xFF] + ^ byteTable1[(secondHalf >>> 16) & 0xFF] + ^ byteTable0[secondHalf >>> 24]; + } else { // ByteOrder.BIG_ENDIAN + crc = byteTable0[secondHalf & 0xFF] + ^ byteTable1[(secondHalf >>> 8) & 0xFF] + ^ byteTable2[(secondHalf >>> 16) & 0xFF] + ^ byteTable3[secondHalf >>> 24] + ^ byteTable4[crc & 0xFF] + ^ byteTable5[(crc >>> 8) & 0xFF] + ^ byteTable6[(crc >>> 16) & 0xFF] + ^ byteTable7[crc >>> 24]; + } + } + + if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) { + crc = Integer.reverseBytes(crc); + } + } + + // Tail + for (; off < end; off++) { + crc = (crc >>> 8) ^ byteTable[(crc ^ b[off]) & 0xFF]; + } + + return crc; + } + + /** + * Updates the CRC-32C checksum reading from the specified address. + */ + private static int updateDirectByteBuffer(int crc, long address, + int off, int end) { + + // Do only byte reads for arrays so short they can't be aligned + if (end - off >= 8) { + + // align on 8 bytes + int alignLength = (8 - (int) ((address + off) & 0x7)) & 0x7; + for (int alignEnd = off + alignLength; off < alignEnd; off++) { + crc = (crc >>> 8) + ^ byteTable[(crc ^ UNSAFE.getByte(address + off)) & 0xFF]; + } + + if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) { + crc = Integer.reverseBytes(crc); + } + + // slicing-by-8 + for (; off <= (end - Long.BYTES); off += Long.BYTES) { + // Always reading two ints as reading a long followed by + // shifting and casting was slower. + int firstHalf = UNSAFE.getInt(address + off); + int secondHalf = UNSAFE.getInt(address + off + Integer.BYTES); + crc ^= firstHalf; + if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) { + crc = byteTable7[crc & 0xFF] + ^ byteTable6[(crc >>> 8) & 0xFF] + ^ byteTable5[(crc >>> 16) & 0xFF] + ^ byteTable4[crc >>> 24] + ^ byteTable3[secondHalf & 0xFF] + ^ byteTable2[(secondHalf >>> 8) & 0xFF] + ^ byteTable1[(secondHalf >>> 16) & 0xFF] + ^ byteTable0[secondHalf >>> 24]; + } else { // ByteOrder.BIG_ENDIAN + crc = byteTable0[secondHalf & 0xFF] + ^ byteTable1[(secondHalf >>> 8) & 0xFF] + ^ byteTable2[(secondHalf >>> 16) & 0xFF] + ^ byteTable3[secondHalf >>> 24] + ^ byteTable4[crc & 0xFF] + ^ byteTable5[(crc >>> 8) & 0xFF] + ^ byteTable6[(crc >>> 16) & 0xFF] + ^ byteTable7[crc >>> 24]; + } + } + + if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) { + crc = Integer.reverseBytes(crc); + } + } + + // Tail + for (; off < end; off++) { + crc = (crc >>> 8) + ^ byteTable[(crc ^ UNSAFE.getByte(address + off)) & 0xFF]; + } + + return crc; + } +} diff --git a/jdk/src/java.base/share/classes/java/util/zip/Checksum.java b/jdk/src/java.base/share/classes/java/util/zip/Checksum.java index 0369c53b0ed..121b687df0b 100644 --- a/jdk/src/java.base/share/classes/java/util/zip/Checksum.java +++ b/jdk/src/java.base/share/classes/java/util/zip/Checksum.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 1999, 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 @@ -22,16 +22,17 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - package java.util.zip; +import java.nio.ByteBuffer; + /** * An interface representing a data checksum. * - * @author David Connelly + * @author David Connelly */ -public -interface Checksum { +public interface Checksum { + /** * Updates the current checksum with the specified byte. * @@ -41,14 +42,89 @@ interface Checksum { /** * Updates the current checksum with the specified array of bytes. + * + * @implSpec This default implementation is equal to calling + * {@code update(b, 0, b.length)}. + * + * @param b the array of bytes to update the checksum with + * + * @throws NullPointerException + * if {@code b} is {@code null} + * + * @since 1.9 + */ + default public void update(byte[] b) { + update(b, 0, b.length); + } + + /** + * Updates the current checksum with the specified array of bytes. + * * @param b the byte array to update the checksum with * @param off the start offset of the data * @param len the number of bytes to use for the update */ public void update(byte[] b, int off, int len); + /** + * Updates the current checksum with the bytes from the specified buffer. + * + * The checksum is updated with the remaining bytes in the buffer, starting + * at the buffer's position. Upon return, the buffer's position will be + * updated to its limit; its limit will not have been changed. + * + * @apiNote For best performance with DirectByteBuffer and other ByteBuffer + * implementations without a backing array implementers of this interface + * should override this method. + * + * @implSpec The default implementation has the following behavior.
+ * For ByteBuffers backed by an accessible byte array. + *
{@code
+     * update(buffer.array(),
+     *        buffer.position() + buffer.arrayOffset(),
+     *        buffer.remaining());
+     * }
+ * For ByteBuffers not backed by an accessible byte array. + *
{@code
+     * byte[] b = new byte[Math.min(buffer.remaining(), 4096)];
+     * while (buffer.hasRemaining()) {
+     *     int length = Math.min(buffer.remaining(), b.length);
+     *     buffer.get(b, 0, length);
+     *     update(b, 0, length);
+     * }
+     * }
+ * + * @param buffer the ByteBuffer to update the checksum with + * + * @throws NullPointerException + * if {@code buffer} is {@code null} + * + * @since 1.9 + */ + default public void update(ByteBuffer buffer) { + int pos = buffer.position(); + int limit = buffer.limit(); + assert (pos <= limit); + int rem = limit - pos; + if (rem <= 0) { + return; + } + if (buffer.hasArray()) { + update(buffer.array(), pos + buffer.arrayOffset(), rem); + } else { + byte[] b = new byte[Math.min(buffer.remaining(), 4096)]; + while (buffer.hasRemaining()) { + int length = Math.min(buffer.remaining(), b.length); + buffer.get(b, 0, length); + update(b, 0, length); + } + } + buffer.position(limit); + } + /** * Returns the current checksum value. + * * @return the current checksum value */ public long getValue(); diff --git a/jdk/src/java.base/share/classes/java/util/zip/package-info.java b/jdk/src/java.base/share/classes/java/util/zip/package-info.java new file mode 100644 index 00000000000..a6ec2072413 --- /dev/null +++ b/jdk/src/java.base/share/classes/java/util/zip/package-info.java @@ -0,0 +1,77 @@ +/* + * 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 + * 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. + */ + +/** + * Provides classes for reading and writing the standard ZIP and GZIP file + * formats. Also includes classes for compressing and decompressing data using + * the DEFLATE compression algorithm, which is used by the ZIP and GZIP file + * formats. Additionally, there are utility classes for computing the CRC-32, + * CRC-32C and Adler-32 checksums of arbitrary input streams. + * + *

Package Specification

+ * + * + * + * @since 1.1 + */ +package java.util.zip; diff --git a/jdk/src/java.base/share/classes/java/util/zip/package.html b/jdk/src/java.base/share/classes/java/util/zip/package.html deleted file mode 100644 index 9b80819ae3d..00000000000 --- a/jdk/src/java.base/share/classes/java/util/zip/package.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - -Provides classes for reading and writing the standard ZIP and GZIP -file formats. Also includes classes for compressing and decompressing -data using the DEFLATE compression algorithm, which is used by the -ZIP and GZIP file formats. Additionally, there are utility classes -for computing the CRC-32 and Adler-32 checksums of arbitrary -input streams. - - -

Package Specification

- - - - - - -@since 1.1 - - - - diff --git a/jdk/test/java/util/zip/ChecksumBase.java b/jdk/test/java/util/zip/ChecksumBase.java new file mode 100644 index 00000000000..5804be7151b --- /dev/null +++ b/jdk/test/java/util/zip/ChecksumBase.java @@ -0,0 +1,196 @@ +/* + * 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. + */ + +/** + * Base class for Checksum tests + */ +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.charset.StandardCharsets; +import java.util.zip.Checksum; + +public class ChecksumBase { + + private final static byte[] BYTES_123456789 = "123456789".getBytes(StandardCharsets.US_ASCII); + + public static void testAll(Checksum checksum, long expected) { + testBytes(checksum, expected); + testByteArray(checksum, expected); + testWrappedByteBuffer(checksum, expected); + testReadonlyByteBuffer(checksum, expected); + testDirectByteBuffer(checksum, expected); + testByteArrayOffset(checksum, expected); + testDirectByteBufferOffset(checksum, expected); + testLittleEndianDirectByteBufferOffset(checksum, expected); + testWrappedByteBufferOffset(checksum, expected); + testLittleEndianWrappedByteBufferOffset(checksum, expected); + testReadonlyByteBufferOffset(checksum, expected); + testLittleEndianReadonlyByteBufferOffset(checksum, expected); + } + + private static void testBytes(Checksum checksum, long expected) { + checksum.reset(); + for (byte bits : BYTES_123456789) { + checksum.update(bits); + } + checkChecksum(checksum, expected); + } + + private static void testByteArray(Checksum checksum, long expected) { + checksum.reset(); + checksum.update(BYTES_123456789); + checkChecksum(checksum, expected); + } + + private static void testWrappedByteBuffer(Checksum checksum, long expected) { + checksum.reset(); + ByteBuffer bb = ByteBuffer.wrap(BYTES_123456789); + checksum.update(bb); + checkChecksum(checksum, expected); + } + + private static void testReadonlyByteBuffer(Checksum checksum, long expected) { + checksum.reset(); + ByteBuffer bb = ByteBuffer.wrap(BYTES_123456789).asReadOnlyBuffer(); + checksum.update(bb); + checkChecksum(checksum, expected); + } + + private static void testDirectByteBuffer(Checksum checksum, long expected) { + checksum.reset(); + ByteBuffer bb = ByteBuffer.allocateDirect(BYTES_123456789.length); + bb.put(BYTES_123456789); + bb.rewind(); + checksum.update(bb); + checkChecksum(checksum, expected); + } + + private static void checkChecksum(Checksum checksum, long expected) { + if (checksum.getValue() != expected) { + throw new RuntimeException("Calculated checksum result was invalid." + + " Expected " + Long.toHexString(expected) + + ", but got " + Long.toHexString(checksum.getValue()) + "."); + } + } + + private static void testByteArrayOffset(Checksum checksum, long expected) { + byte[] unaligned_bytes_123456789 = new byte[BYTES_123456789.length + 64]; + for (int i = 0; i < unaligned_bytes_123456789.length - BYTES_123456789.length; i++) { + checksum.reset(); + System.arraycopy(BYTES_123456789, 0, unaligned_bytes_123456789, i, BYTES_123456789.length); + checksum.update(unaligned_bytes_123456789, i, BYTES_123456789.length); + checkChecksumOffset(checksum, expected, i); + } + } + + private static void testDirectByteBufferOffset(Checksum checksum, long expected) { + byte[] unaligned_bytes_123456789 = new byte[BYTES_123456789.length + 64]; + for (int i = 0; i < unaligned_bytes_123456789.length - BYTES_123456789.length; i++) { + checksum.reset(); + ByteBuffer bb = ByteBuffer.allocateDirect(unaligned_bytes_123456789.length); + System.arraycopy(BYTES_123456789, 0, unaligned_bytes_123456789, i, BYTES_123456789.length); + bb.put(unaligned_bytes_123456789); + bb.position(i); + bb.limit(i + BYTES_123456789.length); + checksum.update(bb); + checkChecksumOffset(checksum, expected, i); + } + } + + private static void testLittleEndianDirectByteBufferOffset(Checksum checksum, long expected) { + byte[] unaligned_bytes_123456789 = new byte[BYTES_123456789.length + 64]; + for (int i = 0; i < unaligned_bytes_123456789.length - BYTES_123456789.length; i++) { + checksum.reset(); + ByteBuffer bb = ByteBuffer.allocateDirect(unaligned_bytes_123456789.length); + bb.order(ByteOrder.LITTLE_ENDIAN); + System.arraycopy(BYTES_123456789, 0, unaligned_bytes_123456789, i, BYTES_123456789.length); + bb.put(unaligned_bytes_123456789); + bb.position(i); + bb.limit(i + BYTES_123456789.length); + checksum.update(bb); + checkChecksumOffset(checksum, expected, i); + } + } + + private static void testWrappedByteBufferOffset(Checksum checksum, long expected) { + byte[] unaligned_bytes_123456789 = new byte[BYTES_123456789.length + 64]; + for (int i = 0; i < unaligned_bytes_123456789.length - BYTES_123456789.length; i++) { + checksum.reset(); + System.arraycopy(BYTES_123456789, 0, unaligned_bytes_123456789, i, BYTES_123456789.length); + ByteBuffer bb = ByteBuffer.wrap(unaligned_bytes_123456789); + bb.position(i); + bb.limit(i + BYTES_123456789.length); + checksum.update(bb); + checkChecksumOffset(checksum, expected, i); + } + } + + private static void testLittleEndianWrappedByteBufferOffset(Checksum checksum, long expected) { + byte[] unaligned_bytes_123456789 = new byte[BYTES_123456789.length + 64]; + for (int i = 0; i < unaligned_bytes_123456789.length - BYTES_123456789.length; i++) { + checksum.reset(); + System.arraycopy(BYTES_123456789, 0, unaligned_bytes_123456789, i, BYTES_123456789.length); + ByteBuffer bb = ByteBuffer.wrap(unaligned_bytes_123456789); + bb.order(ByteOrder.LITTLE_ENDIAN); + bb.position(i); + bb.limit(i + BYTES_123456789.length); + checksum.update(bb); + checkChecksumOffset(checksum, expected, i); + } + } + + private static void testReadonlyByteBufferOffset(Checksum checksum, long expected) { + byte[] unaligned_bytes_123456789 = new byte[BYTES_123456789.length + 64]; + for (int i = 0; i < unaligned_bytes_123456789.length - BYTES_123456789.length; i++) { + checksum.reset(); + System.arraycopy(BYTES_123456789, 0, unaligned_bytes_123456789, i, BYTES_123456789.length); + ByteBuffer bb = ByteBuffer.wrap(unaligned_bytes_123456789).asReadOnlyBuffer(); + bb.position(i); + bb.limit(i + BYTES_123456789.length); + checksum.update(bb); + checkChecksumOffset(checksum, expected, i); + } + } + + private static void testLittleEndianReadonlyByteBufferOffset(Checksum checksum, long expected) { + byte[] unaligned_bytes_123456789 = new byte[BYTES_123456789.length + 64]; + for (int i = 0; i < unaligned_bytes_123456789.length - BYTES_123456789.length; i++) { + checksum.reset(); + System.arraycopy(BYTES_123456789, 0, unaligned_bytes_123456789, i, BYTES_123456789.length); + ByteBuffer bb = ByteBuffer.wrap(unaligned_bytes_123456789).asReadOnlyBuffer(); + bb.order(ByteOrder.LITTLE_ENDIAN); + bb.position(i); + bb.limit(i + BYTES_123456789.length); + checksum.update(bb); + checkChecksumOffset(checksum, expected, i); + } + } + + private static void checkChecksumOffset(Checksum checksum, long expected, int offset) { + if (checksum.getValue() != expected) { + throw new RuntimeException("Calculated CRC32C result was invalid. Array offset " + + offset + ". Expected: " + Long.toHexString(expected) + ", Got: " + + Long.toHexString(checksum.getValue())); + } + } +} diff --git a/jdk/test/java/util/zip/TestCRC32.java b/jdk/test/java/util/zip/TestCRC32.java new file mode 100644 index 00000000000..68c15aed44b --- /dev/null +++ b/jdk/test/java/util/zip/TestCRC32.java @@ -0,0 +1,40 @@ + +import java.util.zip.CRC32; + +/* + * 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 @summary Check that CRC-32 returns the expected CRC value for the + * string 123456789 + * http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-32 + * @build ChecksumBase + * @run main TestCRC32 + */ + +public class TestCRC32 { + + public static void main(String[] args) { + ChecksumBase.testAll(new CRC32(), 0xCBF43926L); + } +} diff --git a/jdk/test/java/util/zip/TestCRC32C.java b/jdk/test/java/util/zip/TestCRC32C.java new file mode 100644 index 00000000000..bb5ea0447c5 --- /dev/null +++ b/jdk/test/java/util/zip/TestCRC32C.java @@ -0,0 +1,40 @@ + +import java.util.zip.CRC32C; + +/* + * 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 @summary Check that CRC-32C returns the expected CRC value for the + * string 123456789 + * http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-32c + * @build ChecksumBase + * @run main TestCRC32C + */ + +public class TestCRC32C { + + public static void main(String[] args) { + ChecksumBase.testAll(new CRC32C(), 0xE3069283L); + } +} diff --git a/jdk/test/java/util/zip/TestChecksum.java b/jdk/test/java/util/zip/TestChecksum.java new file mode 100644 index 00000000000..07be5910ead --- /dev/null +++ b/jdk/test/java/util/zip/TestChecksum.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 @summary Test that default methods in Checksum works as expected + * @build ChecksumBase + * @run main TestChecksum + */ +import java.util.zip.CRC32C; +import java.util.zip.Checksum; + +public class TestChecksum { + + public static void main(String[] args) { + ChecksumBase.testAll(new MyCRC32C(), 0xE3069283L); + } + + /** + * Only implementing required methods + */ + private static class MyCRC32C implements Checksum { + + private final CRC32C crc32c = new CRC32C(); + + @Override + public void update(int b) { + crc32c.update(b); + } + + @Override + public void update(byte[] b, int off, int len) { + crc32c.update(b, off, len); + } + + @Override + public long getValue() { + return crc32c.getValue(); + } + + @Override + public void reset() { + crc32c.reset(); + } + + } +} From ca85e583e9c19d810645213b5cbb809768253bc7 Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Fri, 21 Nov 2014 15:23:36 -0500 Subject: [PATCH 39/67] 8046949: Generify the javax.xml.crypto API Reviewed-by: xuelei --- .../classes/javax/xml/crypto/NodeSetData.java | 8 ++-- .../xml/crypto/dom/DOMCryptoContext.java | 6 +-- .../javax/xml/crypto/dsig/Manifest.java | 9 ++-- .../javax/xml/crypto/dsig/Reference.java | 5 +-- .../xml/crypto/dsig/SignatureProperties.java | 5 +-- .../xml/crypto/dsig/SignatureProperty.java | 5 +-- .../javax/xml/crypto/dsig/SignedInfo.java | 5 +-- .../javax/xml/crypto/dsig/XMLObject.java | 8 ++-- .../javax/xml/crypto/dsig/XMLSignature.java | 5 +-- .../xml/crypto/dsig/XMLSignatureFactory.java | 41 +++++++---------- .../xml/crypto/dsig/keyinfo/KeyInfo.java | 5 +-- .../crypto/dsig/keyinfo/KeyInfoFactory.java | 22 ++++------ .../xml/crypto/dsig/keyinfo/PGPData.java | 5 +-- .../crypto/dsig/keyinfo/RetrievalMethod.java | 5 +-- .../xml/crypto/dsig/keyinfo/X509Data.java | 5 +-- .../dsig/spec/ExcC14NParameterSpec.java | 27 ++++-------- .../dsig/spec/XPathFilter2ParameterSpec.java | 28 ++++-------- .../dsig/spec/XPathFilterParameterSpec.java | 32 +++++--------- .../javax/xml/crypto/dsig/spec/XPathType.java | 40 ++++++++--------- .../internal/dom/ApacheCanonicalizer.java | 11 ++--- .../dsig/internal/dom/ApacheNodeSetData.java | 2 +- .../dsig/internal/dom/ApacheTransform.java | 3 +- .../dsig/internal/dom/DOMExcC14NMethod.java | 3 +- .../jcp/xml/dsig/internal/dom/DOMKeyInfo.java | 13 +++--- .../dsig/internal/dom/DOMKeyInfoFactory.java | 21 ++++----- .../xml/dsig/internal/dom/DOMKeyValue.java | 1 - .../xml/dsig/internal/dom/DOMManifest.java | 14 +++--- .../jcp/xml/dsig/internal/dom/DOMPGPData.java | 34 +++++--------- .../xml/dsig/internal/dom/DOMReference.java | 36 ++++++--------- .../dsig/internal/dom/DOMRetrievalMethod.java | 19 +++----- .../internal/dom/DOMSignatureProperties.java | 19 ++++---- .../internal/dom/DOMSignatureProperty.java | 25 +++++------ .../xml/dsig/internal/dom/DOMSignedInfo.java | 19 +++----- .../xml/dsig/internal/dom/DOMSubTreeData.java | 2 +- .../jcp/xml/dsig/internal/dom/DOMUtils.java | 2 - .../xml/dsig/internal/dom/DOMX509Data.java | 4 +- .../xml/dsig/internal/dom/DOMXMLObject.java | 18 +++----- .../dsig/internal/dom/DOMXMLSignature.java | 24 +++------- .../internal/dom/DOMXMLSignatureFactory.java | 44 ++++++++----------- .../dom/DOMXPathFilter2Transform.java | 2 - .../dsig/internal/dom/DOMXPathTransform.java | 1 - .../org/jcp/xml/dsig/internal/dom/Utils.java | 4 +- .../xml/crypto/dsig/GenerationTests.java | 36 +++++++-------- .../javax/xml/crypto/dsig/KeySelectors.java | 20 +++------ .../xml/crypto/dsig/SignatureValidator.java | 15 ++++--- .../xml/crypto/dsig/X509KeySelector.java | 10 ++--- 46 files changed, 258 insertions(+), 410 deletions(-) diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/NodeSetData.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/NodeSetData.java index 284753c5f78..9da53d0ea8a 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/NodeSetData.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/NodeSetData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -37,9 +37,10 @@ import java.util.Iterator; * * @author Sean Mullan * @author JSR 105 Expert Group + * @param the type of nodes maintained by this set * @since 1.6 */ -public interface NodeSetData extends Data { +public interface NodeSetData extends Data, Iterable { /** * Returns a read-only iterator over the nodes contained in this @@ -52,6 +53,5 @@ public interface NodeSetData extends Data { * @return an Iterator over the nodes in this * NodeSetData in document order */ - @SuppressWarnings("rawtypes") - Iterator iterator(); + Iterator iterator(); } diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dom/DOMCryptoContext.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dom/DOMCryptoContext.java index 9da528180e4..47f006cc5f8 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dom/DOMCryptoContext.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dom/DOMCryptoContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -33,6 +33,7 @@ import javax.xml.crypto.XMLCryptoContext; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; +import java.util.Map; import org.w3c.dom.Element; /** @@ -219,8 +220,7 @@ public class DOMCryptoContext implements XMLCryptoContext { * * @return a read-only iterator over the set of mappings */ - @SuppressWarnings("rawtypes") - public Iterator iterator() { + public Iterator> iterator() { return Collections.unmodifiableMap(idMap).entrySet().iterator(); } diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/Manifest.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/Manifest.java index 0a34d04d425..351b3a9a674 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/Manifest.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/Manifest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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,8 +51,8 @@ import java.util.List; * *
  *   XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM");
- *   List references = Collections.singletonList(factory.newReference
- *       ("#reference-1", DigestMethod.SHA1));
+ *   Reference ref = factory.newReference("#reference-1", DigestMethod.SHA1);
+ *   List references = Collections.singletonList(ref);
  *   Manifest manifest = factory.newManifest(references, "manifest-1");
  * 
* @@ -86,6 +86,5 @@ public interface Manifest extends XMLStructure { * * @return an unmodifiable list of one or more References */ - @SuppressWarnings("rawtypes") - List getReferences(); + List getReferences(); } diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/Reference.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/Reference.java index f9df64b1b2c..6f3ce617317 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/Reference.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/Reference.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -85,8 +85,7 @@ public interface Reference extends URIReference, XMLStructure { * @return an unmodifiable list of Transforms * (may be empty but never null) */ - @SuppressWarnings("rawtypes") - List getTransforms(); + List getTransforms(); /** * Returns the digest method of this Reference. diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/SignatureProperties.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/SignatureProperties.java index 1093b749373..af12e38f8c0 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/SignatureProperties.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/SignatureProperties.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -87,6 +87,5 @@ public interface SignatureProperties extends XMLStructure { * @return an unmodifiable list of one or more * SignaturePropertys */ - @SuppressWarnings("rawtypes") - List getProperties(); + List getProperties(); } diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/SignatureProperty.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/SignatureProperty.java index f83da44718c..237590125b0 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/SignatureProperty.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/SignatureProperty.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -91,6 +91,5 @@ public interface SignatureProperty extends XMLStructure { * * @return an unmodifiable list of one or more XMLStructures */ - @SuppressWarnings("rawtypes") - List getContent(); + List getContent(); } diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/SignedInfo.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/SignedInfo.java index 3f57b46689e..85cbb347ddb 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/SignedInfo.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/SignedInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -80,8 +80,7 @@ public interface SignedInfo extends XMLStructure { * * @return an unmodifiable list of one or more {@link Reference}s */ - @SuppressWarnings("rawtypes") - List getReferences(); + List getReferences(); /** * Returns the optional Id attribute of this diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLObject.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLObject.java index e535e8fa434..572be86f207 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLObject.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -64,7 +64,8 @@ import javax.xml.crypto.XMLStructure; * *
  *   XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM");
- *   List content = Collections.singletonList(fac.newManifest(references)));
+ *   Manifest manifest = fac.newManifest(references);
+ *   List content = Collections.singletonList(manifest);
  *   XMLObject object = factory.newXMLObject(content, "object-1", null, null);
  * 
* @@ -100,8 +101,7 @@ public interface XMLObject extends XMLStructure { * @return an unmodifiable list of XMLStructures (may be empty * but never null) */ - @SuppressWarnings("rawtypes") - List getContent(); + List getContent(); /** * Returns the Id of this XMLObject. diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignature.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignature.java index 32c05eed10d..4909e700bcf 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignature.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -136,8 +136,7 @@ public interface XMLSignature extends XMLStructure { * @return an unmodifiable list of XMLObjects (may be empty * but never null) */ - @SuppressWarnings("rawtypes") - List getObjects(); + List getObjects(); /** * Returns the optional Id of this XMLSignature. diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java index 52b5198cda2..f776bf322b5 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -365,9 +365,8 @@ public abstract class XMLSignatureFactory { * @throws ClassCastException if any of the objects are not of * type XMLObject */ - @SuppressWarnings("rawtypes") public abstract XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki, - List objects, String id, String signatureValueId); + List objects, String id, String signatureValueId); /** * Creates a Reference with the specified URI and digest @@ -399,9 +398,8 @@ public abstract class XMLSignatureFactory { * compliant * @throws NullPointerException if dm is null */ - @SuppressWarnings("rawtypes") public abstract Reference newReference(String uri, DigestMethod dm, - List transforms, String type, String id); + List transforms, String type, String id); /** * Creates a Reference with the specified parameters and @@ -430,9 +428,9 @@ public abstract class XMLSignatureFactory { * @throws NullPointerException if dm or * digestValue is null */ - @SuppressWarnings("rawtypes") public abstract Reference newReference(String uri, DigestMethod dm, - List transforms, String type, String id, byte[] digestValue); + List transforms, String type, String id, + byte[] digestValue); /** * Creates a Reference with the specified parameters. @@ -473,10 +471,9 @@ public abstract class XMLSignatureFactory { * appliedTransforms or result is * null */ - @SuppressWarnings("rawtypes") public abstract Reference newReference(String uri, DigestMethod dm, - List appliedTransforms, Data result, List transforms, String type, - String id); + List appliedTransforms, Data result, + List transforms, String type, String id); /** * Creates a SignedInfo with the specified canonicalization @@ -493,9 +490,8 @@ public abstract class XMLSignatureFactory { * @throws NullPointerException if any of the parameters * are null */ - @SuppressWarnings("rawtypes") public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm, - SignatureMethod sm, List references); + SignatureMethod sm, List references); /** * Creates a SignedInfo with the specified parameters. @@ -512,9 +508,8 @@ public abstract class XMLSignatureFactory { * @throws NullPointerException if cm, sm, or * references are null */ - @SuppressWarnings("rawtypes") public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm, - SignatureMethod sm, List references, String id); + SignatureMethod sm, List references, String id); // Object factory methods /** @@ -530,9 +525,8 @@ public abstract class XMLSignatureFactory { * @throws ClassCastException if content contains any * entries that are not of type {@link XMLStructure} */ - @SuppressWarnings("rawtypes") - public abstract XMLObject newXMLObject(List content, String id, - String mimeType, String encoding); + public abstract XMLObject newXMLObject(List content, + String id, String mimeType, String encoding); /** * Creates a Manifest containing the specified @@ -547,8 +541,7 @@ public abstract class XMLSignatureFactory { * @throws ClassCastException if references contains any * entries that are not of type {@link Reference} */ - @SuppressWarnings("rawtypes") - public abstract Manifest newManifest(List references); + public abstract Manifest newManifest(List references); /** * Creates a Manifest containing the specified @@ -564,8 +557,8 @@ public abstract class XMLSignatureFactory { * @throws ClassCastException if references contains any * entries that are not of type {@link Reference} */ - @SuppressWarnings("rawtypes") - public abstract Manifest newManifest(List references, String id); + public abstract Manifest newManifest(List references, + String id); /** * Creates a SignatureProperty containing the specified @@ -583,9 +576,8 @@ public abstract class XMLSignatureFactory { * @throws ClassCastException if content contains any * entries that are not of type {@link XMLStructure} */ - @SuppressWarnings("rawtypes") public abstract SignatureProperty newSignatureProperty - (List content, String target, String id); + (List content, String target, String id); /** * Creates a SignatureProperties containing the specified @@ -602,9 +594,8 @@ public abstract class XMLSignatureFactory { * @throws ClassCastException if properties contains any * entries that are not of type {@link SignatureProperty} */ - @SuppressWarnings("rawtypes") public abstract SignatureProperties newSignatureProperties - (List properties, String id); + (List properties, String id); // Algorithm factory methods /** diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfo.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfo.java index def192a1b0e..b3e6d5e8715 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfo.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -94,8 +94,7 @@ public interface KeyInfo extends XMLStructure { * in this KeyInfo. Never returns null or an * empty list. */ - @SuppressWarnings("rawtypes") - List getContent(); + List getContent(); /** * Return the optional Id attribute of this KeyInfo, which diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java index a5e17102214..a9465f79330 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -305,8 +305,7 @@ public abstract class KeyInfoFactory { * @throws ClassCastException if content contains any entries * that are not of type {@link XMLStructure} */ - @SuppressWarnings("rawtypes") - public abstract KeyInfo newKeyInfo(List content); + public abstract KeyInfo newKeyInfo(List content); /** * Creates a KeyInfo containing the specified list of key @@ -325,8 +324,8 @@ public abstract class KeyInfoFactory { * @throws ClassCastException if content contains any entries * that are not of type {@link XMLStructure} */ - @SuppressWarnings("rawtypes") - public abstract KeyInfo newKeyInfo(List content, String id); + public abstract KeyInfo newKeyInfo(List content, + String id); /** * Creates a KeyName from the specified name. @@ -387,9 +386,8 @@ public abstract class KeyInfoFactory { * @throws ClassCastException if other contains any * entries that are not of type {@link XMLStructure} */ - @SuppressWarnings("rawtypes") public abstract PGPData newPGPData(byte[] keyId, byte[] keyPacket, - List other); + List other); /** * Creates a PGPData from the specified PGP key material @@ -411,8 +409,8 @@ public abstract class KeyInfoFactory { * @throws ClassCastException if other contains any * entries that are not of type {@link XMLStructure} */ - @SuppressWarnings("rawtypes") - public abstract PGPData newPGPData(byte[] keyPacket, List other); + public abstract PGPData newPGPData(byte[] keyPacket, + List other); /** * Creates a RetrievalMethod from the specified URI. @@ -443,9 +441,8 @@ public abstract class KeyInfoFactory { * @throws ClassCastException if transforms contains any * entries that are not of type {@link Transform} */ - @SuppressWarnings("rawtypes") public abstract RetrievalMethod newRetrievalMethod(String uri, String type, - List transforms); + List transforms); /** * Creates a X509Data containing the specified list of @@ -469,8 +466,7 @@ public abstract class KeyInfoFactory { * @throws ClassCastException if content contains any entries * that are not of one of the valid types mentioned above */ - @SuppressWarnings("rawtypes") - public abstract X509Data newX509Data(List content); + public abstract X509Data newX509Data(List content); /** * Creates an X509IssuerSerial from the specified X.500 issuer diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/PGPData.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/PGPData.java index 6f9c6a31eda..00daf4d5bdf 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/PGPData.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/PGPData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -112,6 +112,5 @@ public interface PGPData extends XMLStructure { * @return an unmodifiable list of XMLStructures (may be * empty, but never null) */ - @SuppressWarnings("rawtypes") - List getExternalElements(); + List getExternalElements(); } diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/RetrievalMethod.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/RetrievalMethod.java index 3741f348660..7a53f9e41a0 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/RetrievalMethod.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/RetrievalMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -80,8 +80,7 @@ public interface RetrievalMethod extends URIReference, XMLStructure { * @return an unmodifiable list of Transform objects (may be * empty but never null). */ - @SuppressWarnings("rawtypes") - List getTransforms(); + List getTransforms(); /** * Returns the URI of the referenced KeyInfo information. diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/X509Data.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/X509Data.java index 47efc86a116..d732b54e7af 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/X509Data.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/keyinfo/X509Data.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -109,6 +109,5 @@ public interface X509Data extends XMLStructure { * @return an unmodifiable list of the content in this X509Data * (never null or empty) */ - @SuppressWarnings("rawtypes") - List getContent(); + List getContent(); } diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/spec/ExcC14NParameterSpec.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/spec/ExcC14NParameterSpec.java index 990a3eedccd..45ff07f1335 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/spec/ExcC14NParameterSpec.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/spec/ExcC14NParameterSpec.java @@ -59,7 +59,7 @@ import java.util.List; */ public final class ExcC14NParameterSpec implements C14NMethodParameterSpec { - private List preList; + private final List prefixList; /** * Indicates the default namespace ("#default"). @@ -71,7 +71,7 @@ public final class ExcC14NParameterSpec implements C14NMethodParameterSpec { * list. */ public ExcC14NParameterSpec() { - preList = Collections.emptyList(); + prefixList = Collections.emptyList(); } /** @@ -86,22 +86,14 @@ public final class ExcC14NParameterSpec implements C14NMethodParameterSpec { * @throws ClassCastException if any of the entries in the list are not * of type String */ - @SuppressWarnings("rawtypes") - public ExcC14NParameterSpec(List prefixList) { + public ExcC14NParameterSpec(List prefixList) { if (prefixList == null) { throw new NullPointerException("prefixList cannot be null"); } - List copy = new ArrayList<>((List)prefixList); - for (int i = 0, size = copy.size(); i < size; i++) { - if (!(copy.get(i) instanceof String)) { - throw new ClassCastException("not a String"); - } - } - - @SuppressWarnings("unchecked") - List temp = (List)copy; - - preList = Collections.unmodifiableList(temp); + List tempList = Collections.checkedList(new ArrayList<>(), + String.class); + tempList.addAll(prefixList); + this.prefixList = Collections.unmodifiableList(tempList); } /** @@ -114,8 +106,7 @@ public final class ExcC14NParameterSpec implements C14NMethodParameterSpec { * @return the inclusive namespace prefix list (may be empty but never * null) */ - @SuppressWarnings("rawtypes") - public List getPrefixList() { - return preList; + public List getPrefixList() { + return prefixList; } } diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/spec/XPathFilter2ParameterSpec.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/spec/XPathFilter2ParameterSpec.java index 4f879019ed4..acaa651e597 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/spec/XPathFilter2ParameterSpec.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/spec/XPathFilter2ParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -59,27 +59,18 @@ public final class XPathFilter2ParameterSpec implements TransformParameterSpec { * @throws NullPointerException if xPathList is * null */ - @SuppressWarnings("rawtypes") - public XPathFilter2ParameterSpec(List xPathList) { + public XPathFilter2ParameterSpec(List xPathList) { if (xPathList == null) { throw new NullPointerException("xPathList cannot be null"); } - List xPathListCopy = new ArrayList<>((List)xPathList); - if (xPathListCopy.isEmpty()) { + List tempList = + Collections.checkedList(new ArrayList(), + XPathType.class); + tempList.addAll(xPathList); + if (tempList.isEmpty()) { throw new IllegalArgumentException("xPathList cannot be empty"); } - int size = xPathListCopy.size(); - for (int i = 0; i < size; i++) { - if (!(xPathListCopy.get(i) instanceof XPathType)) { - throw new ClassCastException - ("xPathList["+i+"] is not a valid type"); - } - } - - @SuppressWarnings("unchecked") - List temp = (List)xPathListCopy; - - this.xPathList = Collections.unmodifiableList(temp); + this.xPathList = Collections.unmodifiableList(tempList); } /** @@ -91,8 +82,7 @@ public final class XPathFilter2ParameterSpec implements TransformParameterSpec { * @return a List of XPathType objects * (never null or empty) */ - @SuppressWarnings("rawtypes") - public List getXPathList() { + public List getXPathList() { return xPathList; } } diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/spec/XPathFilterParameterSpec.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/spec/XPathFilterParameterSpec.java index c9653fc3e9c..1a0ed7e900b 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/spec/XPathFilterParameterSpec.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/spec/XPathFilterParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -32,7 +32,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import java.util.Map.Entry; /** * Parameters for the @@ -51,8 +50,8 @@ import java.util.Map.Entry; */ public final class XPathFilterParameterSpec implements TransformParameterSpec { - private String xPath; - private Map nsMap; + private final String xPath; + private final Map nsMap; /** * Creates an XPathFilterParameterSpec with the specified @@ -83,26 +82,16 @@ public final class XPathFilterParameterSpec implements TransformParameterSpec { * @throws ClassCastException if any of the map's keys or entries are not * of type String */ - @SuppressWarnings("rawtypes") - public XPathFilterParameterSpec(String xPath, Map namespaceMap) { + public XPathFilterParameterSpec(String xPath, Map namespaceMap) { if (xPath == null || namespaceMap == null) { throw new NullPointerException(); } this.xPath = xPath; - Map copy = new HashMap<>((Map)namespaceMap); - Iterator> entries = copy.entrySet().iterator(); - while (entries.hasNext()) { - Map.Entry me = entries.next(); - if (!(me.getKey() instanceof String) || - !(me.getValue() instanceof String)) { - throw new ClassCastException("not a String"); - } - } - - @SuppressWarnings("unchecked") - Map temp = (Map)copy; - - nsMap = Collections.unmodifiableMap(temp); + Map tempMap = Collections.checkedMap(new HashMap<>(), + String.class, + String.class); + tempMap.putAll(namespaceMap); + this.nsMap = Collections.unmodifiableMap(tempMap); } /** @@ -125,8 +114,7 @@ public final class XPathFilterParameterSpec implements TransformParameterSpec { * @return a Map of namespace prefixes to namespace URIs (may * be empty, but never null) */ - @SuppressWarnings("rawtypes") - public Map getNamespaceMap() { + public Map getNamespaceMap() { return nsMap; } } diff --git a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/spec/XPathType.java b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/spec/XPathType.java index c3203f1c39c..625eaab343e 100644 --- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/spec/XPathType.java +++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/spec/XPathType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -28,7 +28,6 @@ package javax.xml.crypto.dsig.spec; import java.util.Collections; -import java.util.Iterator; import java.util.HashMap; import java.util.Map; @@ -106,7 +105,7 @@ public class XPathType { private final String expression; private final Filter filter; - private Map nsMap; + private final Map nsMap; /** * Creates an XPathType instance with the specified XPath @@ -147,26 +146,24 @@ public class XPathType { * @throws ClassCastException if any of the map's keys or entries are * not of type String */ - @SuppressWarnings("rawtypes") - public XPathType(String expression, Filter filter, Map namespaceMap) { - this(expression, filter); + public XPathType(String expression, Filter filter, + Map namespaceMap) { + if (expression == null) { + throw new NullPointerException("expression cannot be null"); + } + if (filter == null) { + throw new NullPointerException("filter cannot be null"); + } if (namespaceMap == null) { throw new NullPointerException("namespaceMap cannot be null"); } - Map copy = new HashMap<>((Map)namespaceMap); - Iterator> entries = copy.entrySet().iterator(); - while (entries.hasNext()) { - Map.Entry me = entries.next(); - if (!(me.getKey() instanceof String) || - !(me.getValue() instanceof String)) { - throw new ClassCastException("not a String"); - } - } - - @SuppressWarnings("unchecked") - Map temp = (Map)copy; - - nsMap = Collections.unmodifiableMap(temp); + this.expression = expression; + this.filter = filter; + Map tempMap = Collections.checkedMap(new HashMap<>(), + String.class, + String.class); + tempMap.putAll(namespaceMap); + this.nsMap = Collections.unmodifiableMap(tempMap); } /** @@ -198,8 +195,7 @@ public class XPathType { * @return a Map of namespace prefixes to namespace URIs * (may be empty, but never null) */ - @SuppressWarnings("rawtypes") - public Map getNamespaceMap() { + public Map getNamespaceMap() { return nsMap; } } diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java index c1d8257bd22..f708ffc529c 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. */ /* * $Id: ApacheCanonicalizer.java 1333869 2012-05-04 10:42:44Z coheigea $ @@ -166,11 +166,9 @@ public abstract class ApacheCanonicalizer extends TransformService { (subTree.getRoot()))); } } else if (data instanceof NodeSetData) { - NodeSetData nsd = (NodeSetData)data; - // convert Iterator to Set - @SuppressWarnings("unchecked") - Set ns = Utils.toNodeSet(nsd.iterator()); - nodeSet = ns; + NodeSetData nsd = (NodeSetData)data; + // convert Iterator to Set + nodeSet = Utils.toNodeSet(nsd.iterator()); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Canonicalizing " + nodeSet.size() + " nodes"); } @@ -236,7 +234,6 @@ public abstract class ApacheCanonicalizer extends TransformService { in = new XMLSignatureInput(subTree.getRoot()); in.setExcludeComments(subTree.excludeComments()); } else { - @SuppressWarnings("unchecked") Set nodeSet = Utils.toNodeSet(((NodeSetData)data).iterator()); in = new XMLSignatureInput(nodeSet); diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java index 8cbcaba56fe..fdd35049cf8 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java @@ -39,7 +39,7 @@ import com.sun.org.apache.xml.internal.security.signature.NodeFilter; import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput; import com.sun.org.apache.xml.internal.security.utils.XMLUtils; -public class ApacheNodeSetData implements ApacheData, NodeSetData { +public class ApacheNodeSetData implements ApacheData, NodeSetData { private XMLSignatureInput xi; diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java index f5cdec5d250..3cad0fd6f0c 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. */ /* * $Id: ApacheTransform.java 1333869 2012-05-04 10:42:44Z coheigea $ @@ -175,7 +175,6 @@ public abstract class ApacheTransform extends TransformService { in = new XMLSignatureInput(subTree.getRoot()); in.setExcludeComments(subTree.excludeComments()); } else { - @SuppressWarnings("unchecked") Set nodeSet = Utils.toNodeSet(((NodeSetData)data).iterator()); in = new XMLSignatureInput(nodeSet); diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java index 1af95986a61..cda4b4b14b5 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. */ /* * $Id: DOMExcC14NMethod.java 1197150 2011-11-03 14:34:57Z coheigea $ @@ -119,7 +119,6 @@ public final class DOMExcC14NMethod extends ApacheCanonicalizer { ExcC14NParameterSpec params = (ExcC14NParameterSpec)spec; StringBuilder prefixListAttr = new StringBuilder(""); - @SuppressWarnings("unchecked") List prefixList = params.getPrefixList(); for (int i = 0, size = prefixList.size(); i < size; i++) { prefixListAttr.append(prefixList.get(i)); diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java index eafbf623293..71021901802 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java @@ -68,17 +68,14 @@ public final class DOMKeyInfo extends DOMStructure implements KeyInfo { if (content == null) { throw new NullPointerException("content cannot be null"); } - this.keyInfoTypes = - Collections.unmodifiableList(new ArrayList(content)); + List tempList = + Collections.checkedList(new ArrayList(), + XMLStructure.class); + tempList.addAll(content); + this.keyInfoTypes = Collections.unmodifiableList(tempList); if (this.keyInfoTypes.isEmpty()) { throw new IllegalArgumentException("content cannot be empty"); } - for (int i = 0, size = this.keyInfoTypes.size(); i < size; i++) { - if (!(this.keyInfoTypes.get(i) instanceof XMLStructure)) { - throw new ClassCastException - ("content["+i+"] is not a valid KeyInfo type"); - } - } this.id = id; } diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java index 45b5620ed5d..7715b89ff79 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java @@ -34,6 +34,7 @@ import java.security.PublicKey; import java.util.List; import javax.xml.crypto.*; import javax.xml.crypto.dom.DOMCryptoContext; +import javax.xml.crypto.dsig.Transform; import javax.xml.crypto.dsig.keyinfo.*; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -48,13 +49,11 @@ public final class DOMKeyInfoFactory extends KeyInfoFactory { public DOMKeyInfoFactory() { } - @SuppressWarnings("rawtypes") - public KeyInfo newKeyInfo(List content) { + public KeyInfo newKeyInfo(List content) { return newKeyInfo(content, null); } - @SuppressWarnings({ "unchecked", "rawtypes" }) - public KeyInfo newKeyInfo(List content, String id) { + public KeyInfo newKeyInfo(List content, String id) { return new DOMKeyInfo(content, id); } @@ -79,13 +78,13 @@ public final class DOMKeyInfoFactory extends KeyInfoFactory { return newPGPData(keyId, null, null); } - @SuppressWarnings({ "unchecked", "rawtypes" }) - public PGPData newPGPData(byte[] keyId, byte[] keyPacket, List other) { + public PGPData newPGPData(byte[] keyId, byte[] keyPacket, + List other) { return new DOMPGPData(keyId, keyPacket, other); } - @SuppressWarnings({ "unchecked", "rawtypes" }) - public PGPData newPGPData(byte[] keyPacket, List other) { + public PGPData newPGPData(byte[] keyPacket, + List other) { return new DOMPGPData(keyPacket, other); } @@ -93,17 +92,15 @@ public final class DOMKeyInfoFactory extends KeyInfoFactory { return newRetrievalMethod(uri, null, null); } - @SuppressWarnings({ "unchecked", "rawtypes" }) public RetrievalMethod newRetrievalMethod(String uri, String type, - List transforms) { + List transforms) { if (uri == null) { throw new NullPointerException("uri must not be null"); } return new DOMRetrievalMethod(uri, type, transforms); } - @SuppressWarnings("rawtypes") - public X509Data newX509Data(List content) { + public X509Data newX509Data(List content) { return new DOMX509Data(content); } diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java index 12939570d2b..bb7a553beb3 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java @@ -33,7 +33,6 @@ import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dsig.*; import javax.xml.crypto.dsig.keyinfo.KeyValue; -// import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.security.AccessController; diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java index 54e1ac4ae89..2c86d8f65ee 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java @@ -67,18 +67,15 @@ public final class DOMManifest extends DOMStructure implements Manifest { if (references == null) { throw new NullPointerException("references cannot be null"); } - this.references = - Collections.unmodifiableList(new ArrayList(references)); + List tempList = + Collections.checkedList(new ArrayList(), + Reference.class); + tempList.addAll(references); + this.references = Collections.unmodifiableList(tempList); if (this.references.isEmpty()) { throw new IllegalArgumentException("list of references must " + "contain at least one entry"); } - for (int i = 0, size = this.references.size(); i < size; i++) { - if (!(this.references.get(i) instanceof Reference)) { - throw new ClassCastException - ("references["+i+"] is not a valid type"); - } - } this.id = id; } @@ -127,7 +124,6 @@ public final class DOMManifest extends DOMStructure implements Manifest { return id; } - @SuppressWarnings("unchecked") static List getManifestReferences(Manifest mf) { return mf.getReferences(); } diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java index a90725b2094..b845d4cb6b2 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java @@ -73,18 +73,13 @@ public final class DOMPGPData extends DOMStructure implements PGPData { if (keyPacket == null) { throw new NullPointerException("keyPacket cannot be null"); } - if (other == null || other.isEmpty()) { - this.externalElements = Collections.emptyList(); - } else { - this.externalElements = - Collections.unmodifiableList(new ArrayList(other)); - for (int i = 0, size = this.externalElements.size(); i < size; i++) { - if (!(this.externalElements.get(i) instanceof XMLStructure)) { - throw new ClassCastException - ("other["+i+"] is not a valid PGPData type"); - } - } + List tempList = + Collections.checkedList(new ArrayList(), + XMLStructure.class); + if (other != null) { + tempList.addAll(other); } + this.externalElements = Collections.unmodifiableList(tempList); this.keyPacket = keyPacket.clone(); checkKeyPacket(keyPacket); this.keyId = null; @@ -120,18 +115,13 @@ public final class DOMPGPData extends DOMStructure implements PGPData { if (keyId.length != 8) { throw new IllegalArgumentException("keyId must be 8 bytes long"); } - if (other == null || other.isEmpty()) { - this.externalElements = Collections.emptyList(); - } else { - this.externalElements = - Collections.unmodifiableList(new ArrayList(other)); - for (int i = 0, size = this.externalElements.size(); i < size; i++) { - if (!(this.externalElements.get(i) instanceof XMLStructure)) { - throw new ClassCastException - ("other["+i+"] is not a valid PGPData type"); - } - } + List tempList = + Collections.checkedList(new ArrayList(), + XMLStructure.class); + if (other != null) { + tempList.addAll(other); } + this.externalElements = Collections.unmodifiableList(tempList); this.keyId = keyId.clone(); this.keyPacket = keyPacket == null ? null : keyPacket.clone(); diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java index d29782065fe..2cc0f993db5 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java @@ -147,29 +147,21 @@ public final class DOMReference extends DOMStructure if (dm == null) { throw new NullPointerException("DigestMethod must be non-null"); } - if (appliedTransforms == null) { - this.allTransforms = new ArrayList(); - } else { - this.allTransforms = new ArrayList(appliedTransforms); - for (int i = 0, size = this.allTransforms.size(); i < size; i++) { - if (!(this.allTransforms.get(i) instanceof Transform)) { - throw new ClassCastException - ("appliedTransforms["+i+"] is not a valid type"); - } - } + List tempList = + Collections.checkedList(new ArrayList(), + Transform.class); + if (appliedTransforms != null) { + tempList.addAll(appliedTransforms); } - if (transforms == null) { - this.transforms = Collections.emptyList(); - } else { - this.transforms = new ArrayList(transforms); - for (int i = 0, size = this.transforms.size(); i < size; i++) { - if (!(this.transforms.get(i) instanceof Transform)) { - throw new ClassCastException - ("transforms["+i+"] is not a valid type"); - } - } - this.allTransforms.addAll(this.transforms); + List tempList2 = + Collections.checkedList(new ArrayList(), + Transform.class); + if (transforms != null) { + tempList.addAll(transforms); + tempList2.addAll(transforms); } + this.allTransforms = Collections.unmodifiableList(tempList); + this.transforms = tempList2; this.digestMethod = dm; this.uri = uri; if ((uri != null) && (!uri.equals(""))) { @@ -642,7 +634,7 @@ public final class DOMReference extends DOMStructure if (xsi.isNodeSet()) { try { final Set s = xsi.getNodeSet(); - return new NodeSetData() { + return new NodeSetData() { public Iterator iterator() { return s.iterator(); } }; } catch (Exception e) { diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java index ca5e5a5b997..eed6fffe5a5 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java @@ -90,18 +90,13 @@ public final class DOMRetrievalMethod extends DOMStructure if (uri == null) { throw new NullPointerException("uri cannot be null"); } - if (transforms == null || transforms.isEmpty()) { - this.transforms = Collections.emptyList(); - } else { - this.transforms = Collections.unmodifiableList( - new ArrayList(transforms)); - for (int i = 0, size = this.transforms.size(); i < size; i++) { - if (!(this.transforms.get(i) instanceof Transform)) { - throw new ClassCastException - ("transforms["+i+"] is not a valid type"); - } - } + List tempList = + Collections.checkedList(new ArrayList(), + Transform.class); + if (transforms != null) { + tempList.addAll(transforms); } + this.transforms = Collections.unmodifiableList(tempList); this.uri = uri; if (!uri.equals("")) { try { @@ -244,7 +239,7 @@ public final class DOMRetrievalMethod extends DOMStructure // guard against RetrievalMethod loops if ((data instanceof NodeSetData) && Utils.secureValidation(context)) { - NodeSetData nsd = (NodeSetData)data; + NodeSetData nsd = (NodeSetData)data; Iterator i = nsd.iterator(); if (i.hasNext()) { Node root = (Node)i.next(); diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java index 26389e9b7ae..0923eb41c40 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java @@ -69,18 +69,15 @@ public final class DOMSignatureProperties extends DOMStructure { if (properties == null) { throw new NullPointerException("properties cannot be null"); - } else if (properties.isEmpty()) { - throw new IllegalArgumentException("properties cannot be empty"); - } else { - this.properties = Collections.unmodifiableList( - new ArrayList(properties)); - for (int i = 0, size = this.properties.size(); i < size; i++) { - if (!(this.properties.get(i) instanceof SignatureProperty)) { - throw new ClassCastException - ("properties["+i+"] is not a valid type"); - } - } } + List tempList = + Collections.checkedList(new ArrayList(), + SignatureProperty.class); + tempList.addAll(properties); + if (tempList.isEmpty()) { + throw new IllegalArgumentException("properties cannot be empty"); + } + this.properties = Collections.unmodifiableList(tempList); this.id = id; } diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java index 11d2e679ebf..2b43dffda92 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java @@ -71,20 +71,18 @@ public final class DOMSignatureProperty extends DOMStructure { if (target == null) { throw new NullPointerException("target cannot be null"); - } else if (content == null) { - throw new NullPointerException("content cannot be null"); - } else if (content.isEmpty()) { - throw new IllegalArgumentException("content cannot be empty"); - } else { - this.content = Collections.unmodifiableList( - new ArrayList(content)); - for (int i = 0, size = this.content.size(); i < size; i++) { - if (!(this.content.get(i) instanceof XMLStructure)) { - throw new ClassCastException - ("content["+i+"] is not a valid type"); - } - } } + if (content == null) { + throw new NullPointerException("content cannot be null"); + } + List tempList = + Collections.checkedList(new ArrayList(), + XMLStructure.class); + tempList.addAll(content); + if (tempList.isEmpty()) { + throw new IllegalArgumentException("content cannot be empty"); + } + this.content = Collections.unmodifiableList(tempList); this.target = target; this.id = id; } @@ -169,7 +167,6 @@ public final class DOMSignatureProperty extends DOMStructure boolean idsEqual = (id == null ? osp.getId() == null : id.equals(osp.getId())); - @SuppressWarnings("unchecked") List ospContent = osp.getContent(); return (equalsContent(ospContent) && target.equals(osp.getTarget()) && idsEqual); diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java index 71a13c3605c..c18a462fba7 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java @@ -100,19 +100,14 @@ public final class DOMSignedInfo extends DOMStructure implements SignedInfo { } this.canonicalizationMethod = cm; this.signatureMethod = sm; - this.references = Collections.unmodifiableList( - new ArrayList(references)); - if (this.references.isEmpty()) { - throw new IllegalArgumentException("list of references must " + - "contain at least one entry"); - } - for (int i = 0, size = this.references.size(); i < size; i++) { - Object obj = this.references.get(i); - if (!(obj instanceof Reference)) { - throw new ClassCastException("list of references contains " + - "an illegal type"); - } + List tempList = + Collections.checkedList(new ArrayList(), + Reference.class); + tempList.addAll(references); + if (tempList.isEmpty()) { + throw new IllegalArgumentException("references cannot be empty"); } + this.references = Collections.unmodifiableList(tempList); } /** diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java index c0ac945b893..6c43f5f6c7e 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java @@ -44,7 +44,7 @@ import org.w3c.dom.Node; * directly on the subdocument and there is no need to convert it * first to an XPath node-set. */ -public class DOMSubTreeData implements NodeSetData { +public class DOMSubTreeData implements NodeSetData { private boolean excludeComments; private Node root; diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java index 4d4a647642e..964d0d238b4 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java @@ -367,9 +367,7 @@ public class DOMUtils { private static boolean paramsEqual(XPathFilter2ParameterSpec spec1, XPathFilter2ParameterSpec spec2) { - @SuppressWarnings("unchecked") List types = spec1.getXPathList(); - @SuppressWarnings("unchecked") List otypes = spec2.getXPathList(); int size = types.size(); if (size != otypes.size()) { diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java index 72740c709bc..7c27607e236 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java @@ -135,7 +135,7 @@ public final class DOMX509Data extends DOMStructure implements X509Data { this.content = Collections.unmodifiableList(content); } - public List getContent() { + public List getContent() { return content; } @@ -265,7 +265,7 @@ public final class DOMX509Data extends DOMStructure implements X509Data { } X509Data oxd = (X509Data)o; - @SuppressWarnings("unchecked") List ocontent = oxd.getContent(); + List ocontent = oxd.getContent(); int size = content.size(); if (size != ocontent.size()) { return false; diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java index 7abd1e63523..6ce2c4ac736 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java @@ -70,18 +70,13 @@ public final class DOMXMLObject extends DOMStructure implements XMLObject { public DOMXMLObject(List content, String id, String mimeType, String encoding) { - if (content == null || content.isEmpty()) { - this.content = Collections.emptyList(); - } else { - this.content = Collections.unmodifiableList( - new ArrayList(content)); - for (int i = 0, size = this.content.size(); i < size; i++) { - if (!(this.content.get(i) instanceof XMLStructure)) { - throw new ClassCastException - ("content["+i+"] is not a valid type"); - } - } + List tempList = + Collections.checkedList(new ArrayList(), + XMLStructure.class); + if (content != null) { + tempList.addAll(content); } + this.content = Collections.unmodifiableList(tempList); this.id = id; this.mimeType = mimeType; this.encoding = encoding; @@ -204,7 +199,6 @@ public final class DOMXMLObject extends DOMStructure implements XMLObject { (mimeType == null ? oxo.getMimeType() == null : mimeType.equals(oxo.getMimeType())); - @SuppressWarnings("unchecked") List oxoContent = oxo.getContent(); return (idsEqual && encodingsEqual && mimeTypesEqual && equalsContent(oxoContent)); diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java index c4478932ff1..f0a614a9714 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java @@ -109,18 +109,13 @@ public final class DOMXMLSignature extends DOMStructure this.si = si; this.id = id; this.sv = new DOMSignatureValue(signatureValueId); - if (objs == null) { - this.objects = Collections.emptyList(); - } else { - this.objects = - Collections.unmodifiableList(new ArrayList(objs)); - for (int i = 0, size = this.objects.size(); i < size; i++) { - if (!(this.objects.get(i) instanceof XMLObject)) { - throw new ClassCastException - ("objs["+i+"] is not an XMLObject"); - } - } + List tempList = + Collections.checkedList(new ArrayList(), + XMLObject.class); + if (objs != null) { + tempList.addAll(objs); } + this.objects = Collections.unmodifiableList(tempList); this.ki = ki; } @@ -270,7 +265,6 @@ public final class DOMXMLSignature extends DOMStructure } // validate all References - @SuppressWarnings("unchecked") List refs = this.si.getReferences(); boolean validateRefs = true; for (int i = 0, size = refs.size(); validateRefs && i < size; i++) { @@ -297,7 +291,6 @@ public final class DOMXMLSignature extends DOMStructure { for (int i=0, size=objects.size(); validateMans && i < size; i++) { XMLObject xo = objects.get(i); - @SuppressWarnings("unchecked") List content = xo.getContent(); int csize = content.size(); for (int j = 0; validateMans && j < csize; j++) { @@ -307,7 +300,6 @@ public final class DOMXMLSignature extends DOMStructure log.log(java.util.logging.Level.FINE, "validating manifest"); } Manifest man = (Manifest)xs; - @SuppressWarnings("unchecked") List manRefs = man.getReferences(); int rsize = manRefs.size(); for (int k = 0; validateMans && k < rsize; k++) { @@ -348,20 +340,17 @@ public final class DOMXMLSignature extends DOMStructure signatureIdMap = new HashMap(); signatureIdMap.put(id, this); signatureIdMap.put(si.getId(), si); - @SuppressWarnings("unchecked") List refs = si.getReferences(); for (Reference ref : refs) { signatureIdMap.put(ref.getId(), ref); } for (XMLObject obj : objects) { signatureIdMap.put(obj.getId(), obj); - @SuppressWarnings("unchecked") List content = obj.getContent(); for (XMLStructure xs : content) { if (xs instanceof Manifest) { Manifest man = (Manifest)xs; signatureIdMap.put(man.getId(), man); - @SuppressWarnings("unchecked") List manRefs = man.getReferences(); for (Reference ref : manRefs) { allReferences.add(ref); @@ -483,7 +472,6 @@ public final class DOMXMLSignature extends DOMStructure // reference dependencies in the XPath Transform - so be on // the safe side, and skip and do at end in the final sweep if (uri.length() == 0) { - @SuppressWarnings("unchecked") List transforms = ref.getTransforms(); for (Transform transform : transforms) { String transformAlg = transform.getAlgorithm(); diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java index 0e63028c777..13e6221dd0f 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java @@ -58,9 +58,8 @@ public final class DOMXMLSignatureFactory extends XMLSignatureFactory { return new DOMXMLSignature(si, ki, null, null, null); } - @SuppressWarnings({ "unchecked", "rawtypes" }) public XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki, - List objects, String id, String signatureValueId) { + List objects, String id, String signatureValueId) { return new DOMXMLSignature(si, ki, objects, id, signatureValueId); } @@ -68,16 +67,14 @@ public final class DOMXMLSignatureFactory extends XMLSignatureFactory { return newReference(uri, dm, null, null, null); } - @SuppressWarnings({ "unchecked", "rawtypes" }) - public Reference newReference(String uri, DigestMethod dm, List transforms, - String type, String id) { + public Reference newReference(String uri, DigestMethod dm, + List transforms, String type, String id) { return new DOMReference(uri, type, dm, transforms, id, getProvider()); } - @SuppressWarnings({ "unchecked", "rawtypes" }) public Reference newReference(String uri, DigestMethod dm, - List appliedTransforms, Data result, List transforms, String type, - String id) { + List appliedTransforms, Data result, + List transforms, String type, String id) { if (appliedTransforms == null) { throw new NullPointerException("appliedTransforms cannot be null"); } @@ -91,9 +88,9 @@ public final class DOMXMLSignatureFactory extends XMLSignatureFactory { (uri, type, dm, appliedTransforms, result, transforms, id, getProvider()); } - @SuppressWarnings({ "unchecked", "rawtypes" }) - public Reference newReference(String uri, DigestMethod dm, List transforms, - String type, String id, byte[] digestValue) { + public Reference newReference(String uri, DigestMethod dm, + List transforms, String type, String id, + byte[] digestValue) { if (digestValue == null) { throw new NullPointerException("digestValue cannot be null"); } @@ -101,43 +98,38 @@ public final class DOMXMLSignatureFactory extends XMLSignatureFactory { (uri, type, dm, null, null, transforms, id, digestValue, getProvider()); } - @SuppressWarnings("rawtypes") public SignedInfo newSignedInfo(CanonicalizationMethod cm, - SignatureMethod sm, List references) { + SignatureMethod sm, List references) { return newSignedInfo(cm, sm, references, null); } - @SuppressWarnings({ "unchecked", "rawtypes" }) public SignedInfo newSignedInfo(CanonicalizationMethod cm, - SignatureMethod sm, List references, String id) { + SignatureMethod sm, List references, String id) { return new DOMSignedInfo(cm, sm, references, id); } // Object factory methods - @SuppressWarnings({ "unchecked", "rawtypes" }) - public XMLObject newXMLObject(List content, String id, String mimeType, - String encoding) { + public XMLObject newXMLObject(List content, + String id, String mimeType, String encoding) { return new DOMXMLObject(content, id, mimeType, encoding); } - @SuppressWarnings("rawtypes") - public Manifest newManifest(List references) { + public Manifest newManifest(List references) { return newManifest(references, null); } - @SuppressWarnings({ "unchecked", "rawtypes" }) - public Manifest newManifest(List references, String id) { + public Manifest newManifest(List references, + String id) { return new DOMManifest(references, id); } - @SuppressWarnings({ "unchecked", "rawtypes" }) - public SignatureProperties newSignatureProperties(List props, String id) { + public SignatureProperties newSignatureProperties( + List props, String id) { return new DOMSignatureProperties(props, id); } - @SuppressWarnings({ "unchecked", "rawtypes" }) public SignatureProperty newSignatureProperty - (List info, String target, String id) { + (List info, String target, String id) { return new DOMSignatureProperty(info, target, id); } diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java index 0215029b489..0fc63f35526 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java @@ -133,7 +133,6 @@ public final class DOMXPathFilter2Transform extends ApacheTransform { String prefix = DOMUtils.getNSPrefix(context, Transform.XPATH2); String qname = (prefix == null || prefix.length() == 0) ? "xmlns" : "xmlns:" + prefix; - @SuppressWarnings("unchecked") List xpathList = xp.getXPathList(); for (XPathType xpathType : xpathList) { Element elem = DOMUtils.createElement(ownerDoc, "XPath", @@ -146,7 +145,6 @@ public final class DOMXPathFilter2Transform extends ApacheTransform { Transform.XPATH2); // add namespace attributes, if necessary - @SuppressWarnings("unchecked") Set> entries = xpathType.getNamespaceMap().entrySet(); for (Map.Entry entry : entries) { diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java index e88eeb8606a..d22922bcfb3 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java @@ -99,7 +99,6 @@ public final class DOMXPathTransform extends ApacheTransform { xpathElem.appendChild(ownerDoc.createTextNode(xp.getXPath())); // add namespace attributes, if necessary - @SuppressWarnings("unchecked") Set> entries = xp.getNamespaceMap().entrySet(); for (Map.Entry entry : entries) { diff --git a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/Utils.java b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/Utils.java index dd59caef60e..6aca319fb2c 100644 --- a/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/Utils.java +++ b/jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/Utils.java @@ -70,10 +70,10 @@ public final class Utils { * @param i the Iterator * @return the Set of Nodes */ - static Set toNodeSet(Iterator i) { + static Set toNodeSet(Iterator i) { Set nodeSet = new HashSet(); while (i.hasNext()) { - Node n = i.next(); + Node n = (Node)i.next(); nodeSet.add(n); // insert attributes nodes to comply with XPath if (n.getNodeType() == Node.ELEMENT_NODE) { diff --git a/jdk/test/javax/xml/crypto/dsig/GenerationTests.java b/jdk/test/javax/xml/crypto/dsig/GenerationTests.java index 6cc7bbb6865..29261e2f17e 100644 --- a/jdk/test/javax/xml/crypto/dsig/GenerationTests.java +++ b/jdk/test/javax/xml/crypto/dsig/GenerationTests.java @@ -23,7 +23,7 @@ /** * @test - * @bug 4635230 6283345 6303830 6824440 6867348 7094155 8038184 8038349 + * @bug 4635230 6283345 6303830 6824440 6867348 7094155 8038184 8038349 8046949 * @summary Basic unit tests for generating XML Signatures with JSR 105 * @compile -XDignore.symbol.file KeySelectors.java SignatureValidator.java * X509KeySelector.java GenerationTests.java @@ -377,7 +377,7 @@ public class GenerationTests { static void test_create_signature_x509_crt_crl() throws Exception { System.out.println("* Generating signature-x509-crt-crl.xml"); - List xds = new ArrayList(); + List xds = new ArrayList<>(); CertificateFactory cf = CertificateFactory.getInstance("X.509"); xds.add(signingCert); FileInputStream fis = new FileInputStream(CRL); @@ -444,7 +444,7 @@ public class GenerationTests { SignedInfo si = fac.newSignedInfo(withoutComments, rsaSha1, refs); // create objects - List objs = new ArrayList(); + List objs = new ArrayList<>(); // Object 1 List manRefs = Collections.singletonList @@ -559,7 +559,7 @@ public class GenerationTests { System.out.println("* Generating signature.xml"); // create references - List refs = new ArrayList(); + List refs = new ArrayList<>(); // Reference 1 refs.add(fac.newReference(STYLESHEET, sha1)); @@ -610,7 +610,7 @@ public class GenerationTests { SignatureProperties.TYPE, null)); // Reference 8 - List transforms = new ArrayList(); + List transforms = new ArrayList<>(); transforms.add(fac.newTransform (Transform.ENVELOPED, (TransformParameterSpec) null)); refs.add(fac.newReference("", sha1, transforms, null, null)); @@ -685,7 +685,7 @@ public class GenerationTests { Document doc = db.newDocument(); // create objects - List objs = new ArrayList(); + List objs = new ArrayList<>(); // Object 1 objs.add(fac.newXMLObject(Collections.singletonList @@ -705,7 +705,7 @@ public class GenerationTests { (new DOMStructure(nc)), "object-3", null, null)); // Manifest - List manRefs = new ArrayList(); + List manRefs = new ArrayList<>(); // Manifest Reference 1 manRefs.add(fac.newReference(STYLESHEET, @@ -715,7 +715,7 @@ public class GenerationTests { manRefs.add(fac.newReference("#reference-1", sha1)); // Manifest Reference 3 - List manTrans = new ArrayList(); + List manTrans = new ArrayList<>(); String xslt = "" + " xds = new ArrayList(); + List xds = new ArrayList<>(); xds.add("CN=User"); xds.add(kifac.newX509IssuerSerial ("CN=User", new BigInteger("45ef2729", 16))); @@ -930,7 +930,7 @@ public class GenerationTests { static void test_create_exc_signature() throws Exception { System.out.println("* Generating exc_signature.xml"); - List refs = new ArrayList(4); + List refs = new ArrayList<>(4); // create reference 1 refs.add(fac.newReference @@ -942,7 +942,7 @@ public class GenerationTests { null, null)); // create reference 2 - List prefixList = new ArrayList(2); + List prefixList = new ArrayList<>(2); prefixList.add("bar"); prefixList.add("#default"); ExcC14NParameterSpec params = new ExcC14NParameterSpec(prefixList); @@ -963,7 +963,7 @@ public class GenerationTests { null, null)); // create reference 4 - prefixList = new ArrayList(2); + prefixList = new ArrayList<>(2); prefixList.add("bar"); prefixList.add("#default"); params = new ExcC14NParameterSpec(prefixList); @@ -982,7 +982,7 @@ public class GenerationTests { fac.newSignatureMethod(SignatureMethod.DSA_SHA1, null), refs); // create KeyInfo - List kits = new ArrayList(2); + List kits = new ArrayList<>(2); kits.add(kifac.newKeyValue(validatingKey)); KeyInfo ki = kifac.newKeyInfo(kits); @@ -1027,10 +1027,10 @@ public class GenerationTests { static void test_create_sign_spec() throws Exception { System.out.println("* Generating sign-spec.xml"); - List refs = new ArrayList(2); + List refs = new ArrayList<>(2); // create reference 1 - List types = new ArrayList(3); + List types = new ArrayList<>(3); types.add(new XPathType(" //ToBeSigned ", XPathType.Filter.INTERSECT)); types.add(new XPathType(" //NotToBeSigned ", XPathType.Filter.SUBTRACT)); @@ -1043,7 +1043,7 @@ public class GenerationTests { null, null)); // create reference 2 - List trans2 = new ArrayList(2); + List trans2 = new ArrayList<>(2); trans2.add(fac.newTransform(Transform.ENVELOPED, (TransformParameterSpec) null)); XPathFilter2ParameterSpec xp2 = new XPathFilter2ParameterSpec @@ -1061,9 +1061,9 @@ public class GenerationTests { fac.newSignatureMethod(SignatureMethod.DSA_SHA1, null), refs); // create KeyInfo - List kits = new ArrayList(2); + List kits = new ArrayList<>(2); kits.add(kifac.newKeyValue(validatingKey)); - List xds = new ArrayList(2); + List xds = new ArrayList<>(2); xds.add("CN=User"); xds.add(signingCert); kits.add(kifac.newX509Data(xds)); diff --git a/jdk/test/javax/xml/crypto/dsig/KeySelectors.java b/jdk/test/javax/xml/crypto/dsig/KeySelectors.java index 290c55b89da..b8f4d324893 100644 --- a/jdk/test/javax/xml/crypto/dsig/KeySelectors.java +++ b/jdk/test/javax/xml/crypto/dsig/KeySelectors.java @@ -101,9 +101,7 @@ class KeySelectors { throw new KeySelectorException("Null KeyInfo object!"); } // search for X509Data in keyinfo - Iterator iter = keyInfo.getContent().iterator(); - while (iter.hasNext()) { - XMLStructure kiType = (XMLStructure) iter.next(); + for (XMLStructure kiType : keyInfo.getContent()) { if (kiType instanceof X509Data) { X509Data xd = (X509Data) kiType; Object[] entries = xd.getContent().toArray(); @@ -114,10 +112,8 @@ class KeySelectors { crl = (X509CRL) entries[i]; } } - Iterator xi = xd.getContent().iterator(); boolean hasCRL = false; - while (xi.hasNext()) { - Object o = xi.next(); + for (Object o : xd.getContent()) { // skip non-X509Certificate entries if (o instanceof X509Certificate) { if ((purpose != KeySelector.Purpose.VERIFY) && @@ -152,10 +148,8 @@ class KeySelectors { throw new KeySelectorException("Null KeyInfo object!"); } SignatureMethod sm = (SignatureMethod) method; - List list = keyInfo.getContent(); - for (int i = 0; i < list.size(); i++) { - XMLStructure xmlStructure = (XMLStructure) list.get(i); + for (XMLStructure xmlStructure : keyInfo.getContent()) { if (xmlStructure instanceof KeyValue) { PublicKey pk = null; try { @@ -282,9 +276,7 @@ class KeySelectors { if (keyInfo == null) { throw new KeySelectorException("Null KeyInfo object!"); } - Iterator iter = keyInfo.getContent().iterator(); - while (iter.hasNext()) { - XMLStructure xmlStructure = (XMLStructure) iter.next(); + for (XMLStructure xmlStructure : keyInfo.getContent()) { try { if (xmlStructure instanceof KeyName) { String name = ((KeyName)xmlStructure).getName(); @@ -330,14 +322,12 @@ class KeySelectors { } } else if (xmlStructure instanceof X509Data) { List content = ((X509Data)xmlStructure).getContent(); - int size = content.size(); Vector result = null; // Lookup the public key using the information // specified in X509Data element, i.e. searching // over the collection of certificate files under // "certs" subdirectory and return those match. - for (int k = 0; k i = + signature.getSignedInfo().getReferences().iterator(); + for (int j = 0; i.hasNext(); j++) { + Reference ref = i.next(); if (!digestInputEqual(ref)) { throw new Exception ("cached data for Reference[" + j + "] is not correct"); @@ -88,10 +89,10 @@ class SignatureValidator { // check that dereferenced data does not contain comment nodes if (ref.getURI() == "") { System.out.println("checking deref data"); - NodeSetData data = (NodeSetData) ref.getDereferencedData(); - Iterator ni = data.iterator(); - while (ni.hasNext()) { - Node n = (Node) ni.next(); + @SuppressWarnings("unchecked") + NodeSetData data = + (NodeSetData)ref.getDereferencedData(); + for (Node n : data) { if (n.getNodeType() == Node.COMMENT_NODE) { throw new Exception("dereferenced data for " + " Reference[" + j + " contains comment node"); diff --git a/jdk/test/javax/xml/crypto/dsig/X509KeySelector.java b/jdk/test/javax/xml/crypto/dsig/X509KeySelector.java index a21e42910b4..9e3081379c0 100644 --- a/jdk/test/javax/xml/crypto/dsig/X509KeySelector.java +++ b/jdk/test/javax/xml/crypto/dsig/X509KeySelector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -139,9 +139,7 @@ class X509KeySelector extends KeySelector { } // Iterate through KeyInfo types - Iterator i = keyInfo.getContent().iterator(); - while (i.hasNext()) { - XMLStructure kiType = (XMLStructure) i.next(); + for (XMLStructure kiType : keyInfo.getContent()) { // check X509Data if (kiType instanceof X509Data) { X509Data xd = (X509Data) kiType; @@ -303,9 +301,7 @@ class X509KeySelector extends KeySelector { } Collection certs = new ArrayList<>(); - Iterator xi = xd.getContent().iterator(); - while (xi.hasNext()) { - Object o = xi.next(); + for (Object o : xd.getContent()) { // check X509IssuerSerial if (o instanceof X509IssuerSerial) { X509IssuerSerial xis = (X509IssuerSerial) o; From c6db8bd7c761bc0a6d0b3ad25bd8fffa149b0418 Mon Sep 17 00:00:00 2001 From: Olivier Lagneau Date: Fri, 21 Nov 2014 19:31:37 +0100 Subject: [PATCH 40/67] 8062037: java/lang/instrument/RetransformBigClass.sh should be quarantined Add RedefineBigClass.sh and RetransformBigClss.sh in ProblemList.txt Reviewed-by: dcubed, sspitsyn --- jdk/test/ProblemList.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 449db57f61f..03c2bdc7453 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -127,6 +127,10 @@ # 8058536 java/lang/instrument/NativeMethodPrefixAgent.java generic-all +# 8061177 +java/lang/instrument/RedefineBigClass.sh generic-all +java/lang/instrument/RetransformBigClass.sh generic-all + ############################################################################ # jdk_management From da2c303927c30e9fed1c6cd4677bd2250a1c4d38 Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Fri, 21 Nov 2014 13:32:17 -0800 Subject: [PATCH 41/67] 8056313: TEST_BUG: java/util/Timer/NameConstructors.java fails intermittently Reviewed-by: lancea, rriggs --- .../java/util/Timer/NameConstructors.java | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/jdk/test/java/util/Timer/NameConstructors.java b/jdk/test/java/util/Timer/NameConstructors.java index bc74522e473..fbf1649ef06 100644 --- a/jdk/test/java/util/Timer/NameConstructors.java +++ b/jdk/test/java/util/Timer/NameConstructors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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,37 +23,42 @@ /* * @test - * @bug 4279061 + * @bug 4279061 8056313 * @summary Basic test for constructors with thread name */ -import java.util.*; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.LinkedTransferQueue; public class NameConstructors { private static final String NAME1 = "Norm D. Plume"; private static final String NAME2 = "Ann Onymous"; - public static void main (String[] args) throws Exception { - Random rnd = new Random(); + public static void main (String[] args) throws InterruptedException { test(new Timer(NAME1), NAME1); test(new Timer(NAME2, true), NAME2); } - private static boolean done, passed; + public static void test(Timer timer, String expected) throws InterruptedException { + try { + LinkedTransferQueue queue = new LinkedTransferQueue<>(); - public static void test(Timer timer, final String name) throws Exception { - done = passed = false; + TimerTask task = new TimerTask() { + public void run() { + queue.put(Thread.currentThread().getName()); + } + }; - TimerTask task = new TimerTask() { - public void run() { - passed = Thread.currentThread().getName().equals(name); - done = true; + timer.schedule(task, 0L); // immediately + String actual = queue.take(); + + if (!expected.equals(actual)) { + throw new AssertionError( + String.format("expected='%s', actual='%s'", expected, actual)); } - }; - timer.schedule(task, 0); // Immediate - Thread.sleep(500); - if (!(done && passed)) - throw new RuntimeException(done + " : " + passed); - timer.cancel(); + } finally { + timer.cancel(); + } } } From 5ffaffb47eeb6b58d71979b9c620da369e467260 Mon Sep 17 00:00:00 2001 From: Martin Buchholz Date: Fri, 21 Nov 2014 16:30:02 -0800 Subject: [PATCH 42/67] 8065159: AttributedString has quadratic resize algorithm Grow backing arrays geometrically instead of arithmetically Reviewed-by: naoto, okutsu --- .../classes/java/text/AttributedString.java | 53 ++++++++----------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/text/AttributedString.java b/jdk/src/java.base/share/classes/java/text/AttributedString.java index 2e82924510a..daceb62a70f 100644 --- a/jdk/src/java.base/share/classes/java/text/AttributedString.java +++ b/jdk/src/java.base/share/classes/java/text/AttributedString.java @@ -48,21 +48,18 @@ import java.text.AttributedCharacterIterator.Attribute; */ public class AttributedString { - - // since there are no vectors of int, we have to use arrays. - // We allocate them in chunks of 10 elements so we don't have to allocate all the time. - private static final int ARRAY_SIZE_INCREMENT = 10; - // field holding the text String text; - // fields holding run attribute information - // run attributes are organized by run - int runArraySize; // current size of the arrays - int runCount; // actual number of runs, <= runArraySize - int runStarts[]; // start index for each run - Vector runAttributes[]; // vector of attribute keys for each run - Vector runAttributeValues[]; // parallel vector of attribute values for each run + // Fields holding run attribute information. + // Run attributes are organized by run. + // Arrays are always of equal lengths (the current capacity). + // Since there are no vectors of int, we have to use arrays. + private static final int INITIAL_CAPACITY = 10; + int runCount; // actual number of runs, <= current capacity + int[] runStarts; // start index for each run + Vector[] runAttributes; // vector of attribute keys for each run + Vector[] runAttributeValues; // parallel vector of attribute values for each run /** * Constructs an AttributedString instance with the given @@ -416,18 +413,17 @@ public class AttributedString { private final void createRunAttributeDataVectors() { // use temporary variables so things remain consistent in case of an exception - int newRunStarts[] = new int[ARRAY_SIZE_INCREMENT]; + int[] newRunStarts = new int[INITIAL_CAPACITY]; @SuppressWarnings("unchecked") - Vector newRunAttributes[] = (Vector[]) new Vector[ARRAY_SIZE_INCREMENT]; + Vector[] newRunAttributes = (Vector[]) new Vector[INITIAL_CAPACITY]; @SuppressWarnings("unchecked") - Vector newRunAttributeValues[] = (Vector[]) new Vector[ARRAY_SIZE_INCREMENT]; + Vector[] newRunAttributeValues = (Vector[]) new Vector[INITIAL_CAPACITY]; runStarts = newRunStarts; runAttributes = newRunAttributes; runAttributeValues = newRunAttributeValues; - runArraySize = ARRAY_SIZE_INCREMENT; runCount = 1; // assume initial run starting at index 0 } @@ -465,25 +461,22 @@ public class AttributedString { // we'll have to break up a run // first, make sure we have enough space in our arrays - if (runCount == runArraySize) { - int newArraySize = runArraySize + ARRAY_SIZE_INCREMENT; - int newRunStarts[] = new int[newArraySize]; + int currentCapacity = runStarts.length; + if (runCount == currentCapacity) { + // We need to resize - we grow capacity by 25%. + int newCapacity = currentCapacity + (currentCapacity >> 2); - @SuppressWarnings("unchecked") - Vector newRunAttributes[] = (Vector[]) new Vector[newArraySize]; + // use temporary variables so things remain consistent in case of an exception + int[] newRunStarts = + Arrays.copyOf(runStarts, newCapacity); + Vector[] newRunAttributes = + Arrays.copyOf(runAttributes, newCapacity); + Vector[] newRunAttributeValues = + Arrays.copyOf(runAttributeValues, newCapacity); - @SuppressWarnings("unchecked") - Vector newRunAttributeValues[] = (Vector[]) new Vector[newArraySize]; - - for (int i = 0; i < runArraySize; i++) { - newRunStarts[i] = runStarts[i]; - newRunAttributes[i] = runAttributes[i]; - newRunAttributeValues[i] = runAttributeValues[i]; - } runStarts = newRunStarts; runAttributes = newRunAttributes; runAttributeValues = newRunAttributeValues; - runArraySize = newArraySize; } // make copies of the attribute information of the old run that the new one used to be part of From e3e615d6bdced6b25e009d6d3d87b4fd4a60e6d5 Mon Sep 17 00:00:00 2001 From: Mark Sheppard Date: Sat, 22 Nov 2014 14:56:16 +0000 Subject: [PATCH 43/67] 8065222: sun/net/www/protocol/http/B6369510.java doesn't execute as expected Changed address.getHostName() to InetAddress.getLocalHost().getHostName() in URL construction in test's doClient method Reviewed-by: chegar --- jdk/test/sun/net/www/protocol/http/B6369510.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/jdk/test/sun/net/www/protocol/http/B6369510.java b/jdk/test/sun/net/www/protocol/http/B6369510.java index 6d71e819892..c8aa023c636 100644 --- a/jdk/test/sun/net/www/protocol/http/B6369510.java +++ b/jdk/test/sun/net/www/protocol/http/B6369510.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -40,7 +40,7 @@ public class B6369510 com.sun.net.httpserver.HttpServer httpServer; ExecutorService executorService; - public static void main(String[] args) + public static void main(String[] args) throws Exception { new B6369510(); } @@ -58,13 +58,15 @@ public class B6369510 void doClient() { try { InetSocketAddress address = httpServer.getAddress(); + String urlString = "http://" + InetAddress.getLocalHost().getHostName() + ":" + address.getPort() + "/test/"; + System.out.println("URL == " + urlString); // GET Request - URL url = new URL("http://" + address.getHostName() + ":" + address.getPort() + "/test/"); + URL url = new URL("http://" + InetAddress.getLocalHost().getHostName() + ":" + address.getPort() + "/test/"); HttpURLConnection uc = (HttpURLConnection)url.openConnection(); int resp = uc.getResponseCode(); if (resp != 200) - throw new RuntimeException("Failed: Response code from GET is not 200"); + throw new RuntimeException("Failed: Response code from GET is not 200 RSP == " + resp); System.out.println("Response code from GET = 200 OK"); @@ -75,12 +77,13 @@ public class B6369510 OutputStream os = uc.getOutputStream(); resp = uc.getResponseCode(); if (resp != 200) - throw new RuntimeException("Failed: Response code form POST is not 200"); + throw new RuntimeException("Failed: Response code form POST is not 200 RSP == " + resp); System.out.println("Response code from POST = 200 OK"); } catch (IOException e) { e.printStackTrace(); + throw new RuntimeException("Failed with IOException"); } finally { httpServer.stop(1); executorService.shutdown(); From c7b43102bc89a4aedd9bad7b14bb831753febb6e Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Mon, 24 Nov 2014 11:40:49 +0100 Subject: [PATCH 44/67] 8065412: generated source to compile .properties file incorreectly includes the module name in the package name Reviewed-by: tbell, mchung, ihse --- jdk/make/gensrc/GensrcProperties.gmk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jdk/make/gensrc/GensrcProperties.gmk b/jdk/make/gensrc/GensrcProperties.gmk index 0b0520c6fd9..6d7e1cc8489 100644 --- a/jdk/make/gensrc/GensrcProperties.gmk +++ b/jdk/make/gensrc/GensrcProperties.gmk @@ -58,13 +58,15 @@ define SetupCompileProperties $1_CLASS := $3 # Convert .../src//share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties - # to .../langtools/gensrc//com/sun/tools/javac/resources/javac_zh_CN.java + # to .../support/gensrc//com/sun/tools/javac/resources/javac_zh_CN.java # Strip away prefix and suffix, leaving for example only: # "/share/classes/com/sun/tools/javac/resources/javac_zh_CN" $1_JAVAS := $$(patsubst $(JDK_TOPDIR)/src/%, \ $(JDK_OUTPUTDIR)/gensrc/%, \ $$(patsubst %.properties, %.java, \ - $$(subst /share/classes,, $$($1_SRCS)))) + $$(subst /$(OPENJDK_TARGET_OS)/classes,, \ + $$(subst /$(OPENJDK_TARGET_OS_TYPE)/classes,, \ + $$(subst /share/classes,, $$($1_SRCS)))))) # Generate the package dirs for the to be generated java files. Sort to remove # duplicates. From 96da5b9ce34eb1bd72fbc350107719108d9a52ef Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Mon, 24 Nov 2014 17:02:37 +0100 Subject: [PATCH 45/67] 8060132: Handlers configured on abstract nodes in logging.properties are not always properly closed Loggers which have been configured with a handler in the configuration file will be retained by the LogManager until reset() is called. A new configuration property is added to explicitely turn the fix off. Reviewed-by: mchung --- .../classes/java/util/logging/LogManager.java | 69 ++- .../ParentLoggerWithHandlerGC.java | 517 ++++++++++++++++++ 2 files changed, 580 insertions(+), 6 deletions(-) create mode 100644 jdk/test/java/util/logging/LogManager/Configuration/ParentLoggerWithHandlerGC.java diff --git a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java index 45f2c054bd6..3cf6842c871 100644 --- a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java +++ b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java @@ -31,6 +31,7 @@ import java.util.*; import java.security.*; import java.lang.ref.ReferenceQueue; import java.lang.ref.WeakReference; +import java.util.concurrent.CopyOnWriteArrayList; import sun.misc.JavaAWTAccess; import sun.misc.SharedSecrets; @@ -100,6 +101,19 @@ import sun.misc.SharedSecrets; * Note that these Handlers may be created lazily, when they are * first used. * + *
  • A property "<logger>.handlers.ensureCloseOnReset". This defines a + * a boolean value. If "<logger>.handlers" is not defined or is empty, + * this property is ignored. Otherwise it defaults to {@code true}. When the + * value is {@code true}, the handlers associated with the logger are guaranteed + * to be closed on {@linkplain #reset} and shutdown. This can be turned off + * by explicitly setting "<logger>.handlers.ensureCloseOnReset=false" in + * the configuration. Note that turning this property off causes the risk of + * introducing a resource leak, as the logger may get garbage collected before + * {@code reset()} is called, thus preventing its handlers from being closed + * on {@code reset()}. In that case it is the responsibility of the application + * to ensure that the handlers are closed before the logger is garbage + * collected. + * *
  • A property "<logger>.useParentHandlers". This defines a boolean * value. By default every logger calls its parent in addition to * handling the logging message itself, this often result in messages @@ -169,6 +183,33 @@ public class LogManager { // True if JVM death is imminent and the exit hook has been called. private boolean deathImminent; + // This list contains the loggers for which some handlers have been + // explicitly configured in the configuration file. + // It prevents these loggers from being arbitrarily garbage collected. + private static final class CloseOnReset { + private final Logger logger; + private CloseOnReset(Logger ref) { + this.logger = Objects.requireNonNull(ref); + } + @Override + public boolean equals(Object other) { + return (other instanceof CloseOnReset) && ((CloseOnReset)other).logger == logger; + } + @Override + public int hashCode() { + return System.identityHashCode(logger); + } + public Logger get() { + return logger; + } + public static CloseOnReset create(Logger logger) { + return new CloseOnReset(logger); + } + } + private final CopyOnWriteArrayList closeOnResetLoggers = + new CopyOnWriteArrayList<>(); + + private final Map listeners = Collections.synchronizedMap(new IdentityHashMap<>()); @@ -204,7 +245,6 @@ public class LogManager { }); } - // This private class is used as a shutdown hook. // It does a "reset" to close all open handlers. private class Cleaner extends Thread { @@ -875,30 +915,39 @@ public class LogManager { @Override public Object run() { String names[] = parseClassNames(handlersPropertyName); - for (String word : names) { + final boolean ensureCloseOnReset = names.length > 0 + && getBooleanProperty(handlersPropertyName + ".ensureCloseOnReset",true); + + int count = 0; + for (String type : names) { try { - Class clz = ClassLoader.getSystemClassLoader().loadClass(word); + Class clz = ClassLoader.getSystemClassLoader().loadClass(type); Handler hdl = (Handler) clz.newInstance(); // Check if there is a property defining the // this handler's level. - String levs = getProperty(word + ".level"); + String levs = getProperty(type + ".level"); if (levs != null) { Level l = Level.findLevel(levs); if (l != null) { hdl.setLevel(l); } else { // Probably a bad level. Drop through. - System.err.println("Can't set level for " + word); + System.err.println("Can't set level for " + type); } } // Add this Handler to the logger logger.addHandler(hdl); + if (++count == 1 && ensureCloseOnReset) { + // add this logger to the closeOnResetLoggers list. + closeOnResetLoggers.addIfAbsent(CloseOnReset.create(logger)); + } } catch (Exception ex) { - System.err.println("Can't load log handler \"" + word + "\""); + System.err.println("Can't load log handler \"" + type + "\""); System.err.println("" + ex); ex.printStackTrace(); } } + return null; } }); @@ -1233,8 +1282,15 @@ public class LogManager { public void reset() throws SecurityException { checkPermission(); + List persistent; synchronized (this) { props = new Properties(); + // make sure we keep the loggers persistent until reset is done. + // Those are the loggers for which we previously created a + // handler from the configuration, and we need to prevent them + // from being gc'ed until those handlers are closed. + persistent = new ArrayList<>(closeOnResetLoggers); + closeOnResetLoggers.clear(); // Since we are doing a reset we no longer want to initialize // the global handlers, if they haven't been initialized yet. initializedGlobalHandlers = true; @@ -1249,6 +1305,7 @@ public class LogManager { } } } + persistent.clear(); } // Private method to reset an individual target logger. diff --git a/jdk/test/java/util/logging/LogManager/Configuration/ParentLoggerWithHandlerGC.java b/jdk/test/java/util/logging/LogManager/Configuration/ParentLoggerWithHandlerGC.java new file mode 100644 index 00000000000..491d7583243 --- /dev/null +++ b/jdk/test/java/util/logging/LogManager/Configuration/ParentLoggerWithHandlerGC.java @@ -0,0 +1,517 @@ +/* + * 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.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.FilePermission; +import java.io.IOException; +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.CodeSource; +import java.security.Permission; +import java.security.PermissionCollection; +import java.security.Permissions; +import java.security.Policy; +import java.security.ProtectionDomain; +import java.util.Arrays; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.List; +import java.util.Properties; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.Callable; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.logging.FileHandler; +import java.util.logging.Handler; +import java.util.logging.LogManager; +import java.util.logging.Logger; +import java.util.logging.LoggingPermission; + +/** + * @test + * @bug 8060132 + * @summary tests that FileHandlers configured on abstract nodes in logging.properties + * will be closed by reset(). + * @run main/othervm ParentLoggerWithHandlerGC UNSECURE + * @run main/othervm ParentLoggerWithHandlerGC SECURE + * @author danielfuchs + */ +public class ParentLoggerWithHandlerGC { + + /** + * We will test the handling of abstract logger nodes with file handlers in + * two configurations: + * UNSECURE: No security manager. + * SECURE: With the security manager present - and the required + * permissions granted. + */ + public static enum TestCase { + UNSECURE, SECURE; + public void run(Properties propertyFile) throws Exception { + System.out.println("Running test case: " + name()); + Configure.setUp(this, propertyFile); + test(this.name() + " " + propertyFile.getProperty("test.name"), propertyFile); + } + } + + + private static final String PREFIX = + "FileHandler-" + UUID.randomUUID() + ".log"; + private static final String userDir = System.getProperty("user.dir", "."); + private static final boolean userDirWritable = Files.isWritable(Paths.get(userDir)); + + static enum ConfigMode { DEFAULT, ENSURE_CLOSE_ON_RESET_TRUE, ENSURE_CLOSE_ON_RESET_FALSE } + + private static final List properties; + static { + Properties props1 = new Properties(); + props1.setProperty("test.name", "parent logger with handler"); + props1.setProperty("test.config.mode", ConfigMode.DEFAULT.name()); + props1.setProperty(FileHandler.class.getName() + ".pattern", PREFIX); + props1.setProperty(FileHandler.class.getName() + ".limit", String.valueOf(Integer.MAX_VALUE)); + props1.setProperty(FileHandler.class.getName() + ".level", "ALL"); + props1.setProperty(FileHandler.class.getName() + ".formatter", "java.util.logging.SimpleFormatter"); + props1.setProperty("com.foo.handlers", FileHandler.class.getName()); + props1.setProperty("com.bar.level", "FINEST"); + + Properties props2 = new Properties(); + props2.setProperty("test.name", "parent logger with handler"); + props2.setProperty("test.config.mode", ConfigMode.ENSURE_CLOSE_ON_RESET_TRUE.name()); + props2.setProperty(FileHandler.class.getName() + ".pattern", PREFIX); + props2.setProperty(FileHandler.class.getName() + ".limit", String.valueOf(Integer.MAX_VALUE)); + props2.setProperty(FileHandler.class.getName() + ".level", "ALL"); + props2.setProperty(FileHandler.class.getName() + ".formatter", "java.util.logging.SimpleFormatter"); + props2.setProperty("com.foo.handlers", FileHandler.class.getName()); + props2.setProperty("com.foo.handlers.ensureCloseOnReset", "true"); + props2.setProperty("com.bar.level", "FINEST"); + + Properties props3 = new Properties(); + props3.setProperty("test.name", "parent logger with handler"); + props3.setProperty("test.config.mode", ConfigMode.ENSURE_CLOSE_ON_RESET_FALSE.name()); + props3.setProperty(FileHandler.class.getName() + ".pattern", PREFIX); + props3.setProperty(FileHandler.class.getName() + ".limit", String.valueOf(Integer.MAX_VALUE)); + props3.setProperty(FileHandler.class.getName() + ".level", "ALL"); + props3.setProperty(FileHandler.class.getName() + ".formatter", "java.util.logging.SimpleFormatter"); + props3.setProperty("com.foo.handlers", FileHandler.class.getName()); + props3.setProperty("com.foo.handlers.ensureCloseOnReset", "false"); + props3.setProperty("com.bar.level", "FINEST"); + + properties = Collections.unmodifiableList(Arrays.asList( + props1, props2, props3)); + } + + public static void main(String... args) throws Exception { + + + if (args == null || args.length == 0) { + args = new String[] { + TestCase.UNSECURE.name(), + TestCase.SECURE.name(), + }; + } + + try { + for (String testName : args) { + for (Properties propertyFile : properties) { + TestCase test = TestCase.valueOf(testName); + test.run(propertyFile); + } + } + } finally { + if (userDirWritable) { + Configure.doPrivileged(() -> { + // cleanup - delete files that have been created + try { + Files.list(Paths.get(userDir)) + .filter((f) -> f.toString().contains(PREFIX)) + .forEach((f) -> { + try { + System.out.println("deleting " + f); + Files.delete(f); + } catch(Throwable t) { + System.err.println("Failed to delete " + f + ": " + t); + } + }); + } catch(Throwable t) { + System.err.println("Cleanup failed to list files: " + t); + t.printStackTrace(); + } + }); + } + } + } + + static class Configure { + static Policy policy = null; + static final AtomicBoolean allowAll = new AtomicBoolean(false); + static void setUp(TestCase test, Properties propertyFile) { + switch (test) { + case SECURE: + if (policy == null && System.getSecurityManager() != null) { + throw new IllegalStateException("SecurityManager already set"); + } else if (policy == null) { + policy = new SimplePolicy(TestCase.SECURE, allowAll); + Policy.setPolicy(policy); + System.setSecurityManager(new SecurityManager()); + } + if (System.getSecurityManager() == null) { + throw new IllegalStateException("No SecurityManager."); + } + if (policy == null) { + throw new IllegalStateException("policy not configured"); + } + break; + case UNSECURE: + if (System.getSecurityManager() != null) { + throw new IllegalStateException("SecurityManager already set"); + } + break; + default: + new InternalError("No such testcase: " + test); + } + doPrivileged(() -> { + try { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + propertyFile.store(bytes, propertyFile.getProperty("test.name")); + ByteArrayInputStream bais = new ByteArrayInputStream(bytes.toByteArray()); + LogManager.getLogManager().readConfiguration(bais); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + }); + } + static void doPrivileged(Runnable run) { + allowAll.set(true); + try { + run.run(); + } finally { + allowAll.set(false); + } + } + static T callPrivileged(Callable call) throws Exception { + allowAll.set(true); + try { + return call.call(); + } finally { + allowAll.set(false); + } + } + } + + @FunctionalInterface + public static interface FileHandlerSupplier { + public FileHandler test() throws Exception; + } + + static final class TestAssertException extends RuntimeException { + TestAssertException(String msg) { + super(msg); + } + } + + private static void assertEquals(long expected, long received, String msg) { + if (expected != received) { + throw new TestAssertException("Unexpected result for " + msg + + ".\n\texpected: " + expected + + "\n\tactual: " + received); + } else { + System.out.println("Got expected " + msg + ": " + received); + } + } + + + public static void test(String name, Properties props) throws Exception { + ConfigMode configMode = ConfigMode.valueOf(props.getProperty("test.config.mode")); + System.out.println("\nTesting: " + name + " mode=" + configMode); + if (!userDirWritable) { + throw new RuntimeException("Not writable: "+userDir); + } + switch(configMode) { + case DEFAULT: + case ENSURE_CLOSE_ON_RESET_TRUE: + testCloseOnResetTrue(name, props); break; + case ENSURE_CLOSE_ON_RESET_FALSE: + testCloseOnResetFalse(name, props); break; + default: + throw new RuntimeException("Unknwown mode: " + configMode); + } + } + + + // Test a configuration which has either + // com.foo.handlers.ensureCloseOnReset=true, or where + // com.foo.handlers.ensureCloseOnReset is not specified. + public static void testCloseOnResetTrue(String name, Properties props) + throws Exception { + Logger fooChild = Logger.getLogger("com.foo.child"); + fooChild.info("hello world"); + Logger barChild = Logger.getLogger("com.bar.child"); + barChild.info("hello world"); + + ReferenceQueue queue = new ReferenceQueue(); + WeakReference fooRef = new WeakReference<>(Logger.getLogger("com.foo"), queue); + if (fooRef.get() != fooChild.getParent()) { + throw new RuntimeException("Unexpected parent logger: " + + fooChild.getParent() +"\n\texpected: " + fooRef.get()); + } + WeakReference barRef = new WeakReference<>(Logger.getLogger("com.bar"), queue); + if (barRef.get() != barChild.getParent()) { + throw new RuntimeException("Unexpected parent logger: " + + barChild.getParent() +"\n\texpected: " + barRef.get()); + } + fooChild = barChild = null; + Reference ref2 = null; + while ((ref2 = queue.poll()) == null) { + System.gc(); + Thread.sleep(1000); + } + Throwable failed = null; + try { + do { + if (ref2 != barRef) { + throw new RuntimeException("Unexpected reference: " + + ref2 +"\n\texpected: " + barRef); + } + if (ref2.get() != null) { + throw new RuntimeException("Referent not cleared: " + + ref2.get()); + } + System.out.println("Got barRef"); + System.gc(); + Thread.sleep(1000); + } while( (ref2 = queue.poll()) != null); + System.out.println("Parent logger GCed"); + } catch(Throwable t) { + failed = t; + } finally { + final Throwable suppressed = failed; + Configure.doPrivileged(() -> LogManager.getLogManager().reset()); + Configure.doPrivileged(() -> { + try { + StringBuilder builder = new StringBuilder(); + Files.list(Paths.get(userDir)) + .filter((f) -> f.toString().contains(PREFIX)) + .filter((f) -> f.toString().endsWith(".lck")) + .forEach((f) -> { + builder.append(f.toString()).append('\n'); + }); + if (!builder.toString().isEmpty()) { + throw new RuntimeException("Lock files not cleaned:\n" + + builder.toString()); + } + } catch(RuntimeException | Error x) { + if (suppressed != null) x.addSuppressed(suppressed); + throw x; + } catch(Exception x) { + if (suppressed != null) x.addSuppressed(suppressed); + throw new RuntimeException(x); + } + }); + while ((ref2 = queue.poll()) == null) { + System.gc(); + Thread.sleep(1000); + } + if (ref2 != fooRef) { + throw new RuntimeException("Unexpected reference: " + + ref2 +"\n\texpected: " + fooRef); + } + if (ref2.get() != null) { + throw new RuntimeException("Referent not cleared: " + ref2.get()); + } + System.out.println("Got fooRef after reset()"); + + } + if (failed != null) { + // should rarely happen... + throw new RuntimeException(failed); + } + + } + + private static Handler getHandlerToClose() throws Exception { + return Configure.callPrivileged( + () -> Logger.getLogger("com.foo.child").getParent().getHandlers()[0]); + } + + // Test a configuration which has com.foo.handlers.ensureCloseOnReset=false + public static void testCloseOnResetFalse(String name, Properties props) + throws Exception { + Logger fooChild = Logger.getLogger("com.foo.child"); + fooChild.info("hello world"); + Logger barChild = Logger.getLogger("com.bar.child"); + barChild.info("hello world"); + + Handler toClose = getHandlerToClose(); + + ReferenceQueue queue = new ReferenceQueue(); + WeakReference fooRef = new WeakReference<>(Logger.getLogger("com.foo"), queue); + if (fooRef.get() != fooChild.getParent()) { + throw new RuntimeException("Unexpected parent logger: " + + fooChild.getParent() +"\n\texpected: " + fooRef.get()); + } + WeakReference barRef = new WeakReference<>(Logger.getLogger("com.bar"), queue); + if (barRef.get() != barChild.getParent()) { + throw new RuntimeException("Unexpected parent logger: " + + barChild.getParent() +"\n\texpected: " + barRef.get()); + } + fooChild = barChild = null; + Reference ref2 = null; + Set> expectedRefs = new HashSet<>(Arrays.asList(fooRef, barRef)); + Throwable failed = null; + try { + int l=0; + while (failed == null && !expectedRefs.isEmpty()) { + int max = 60; + while ((ref2 = queue.poll()) == null) { + if (l > 0 && max-- <= 0) { + throw new RuntimeException("Logger #2 not GC'ed!" + + " max too short (max=60) or " + + "com.foo.handlers.ensureCloseOnReset=false" + + " does not work"); + } + System.gc(); + Thread.sleep(1000); + } + do { + if (!expectedRefs.contains(ref2)) { + throw new RuntimeException("Unexpected reference: " + + ref2 +"\n\texpected: " + expectedRefs); + } + if (ref2.get() != null) { + throw new RuntimeException("Referent not cleared: " + + ref2.get()); + } + expectedRefs.remove(ref2); + System.out.println("Got "+ + (ref2 == barRef ? "barRef" + : (ref2 == fooRef ? "fooRef" + : ref2.toString()))); + System.gc(); + Thread.sleep(1000); + System.out.println("Logger #" + (++l) + " GCed"); + } while( (ref2 = queue.poll()) != null); + } + } catch(Throwable t) { + failed = t; + } finally { + final Throwable suppressed = failed; + Configure.doPrivileged(() -> LogManager.getLogManager().reset()); + Configure.doPrivileged(() -> { + try { + toClose.close(); + StringBuilder builder = new StringBuilder(); + Files.list(Paths.get(userDir)) + .filter((f) -> f.toString().contains(PREFIX)) + .filter((f) -> f.toString().endsWith(".lck")) + .forEach((f) -> { + builder.append(f.toString()).append('\n'); + }); + if (!builder.toString().isEmpty()) { + throw new RuntimeException("Lock files not cleaned:\n" + builder.toString()); + } + } catch(RuntimeException | Error x) { + if (suppressed != null) x.addSuppressed(suppressed); + throw x; + } catch(Exception x) { + if (suppressed != null) x.addSuppressed(suppressed); + throw new RuntimeException(x); + } + }); + } + if (failed != null) { + // should rarely happen... + throw new RuntimeException(failed); + } + + } + + + final static class PermissionsBuilder { + final Permissions perms; + public PermissionsBuilder() { + this(new Permissions()); + } + public PermissionsBuilder(Permissions perms) { + this.perms = perms; + } + public PermissionsBuilder add(Permission p) { + perms.add(p); + return this; + } + public PermissionsBuilder addAll(PermissionCollection col) { + if (col != null) { + for (Enumeration e = col.elements(); e.hasMoreElements(); ) { + perms.add(e.nextElement()); + } + } + return this; + } + public Permissions toPermissions() { + final PermissionsBuilder builder = new PermissionsBuilder(); + builder.addAll(perms); + return builder.perms; + } + } + + public static class SimplePolicy extends Policy { + + final Permissions permissions; + final Permissions allPermissions; + final AtomicBoolean allowAll; + public SimplePolicy(TestCase test, AtomicBoolean allowAll) { + this.allowAll = allowAll; + permissions = new Permissions(); + permissions.add(new LoggingPermission("control", null)); + permissions.add(new FilePermission(PREFIX+".lck", "read,write,delete")); + permissions.add(new FilePermission(PREFIX, "read,write")); + + // these are used for configuring the test itself... + allPermissions = new Permissions(); + allPermissions.add(new java.security.AllPermission()); + + } + + @Override + public boolean implies(ProtectionDomain domain, Permission permission) { + if (allowAll.get()) return allPermissions.implies(permission); + return permissions.implies(permission); + } + + @Override + public PermissionCollection getPermissions(CodeSource codesource) { + return new PermissionsBuilder().addAll(allowAll.get() + ? allPermissions : permissions).toPermissions(); + } + + @Override + public PermissionCollection getPermissions(ProtectionDomain domain) { + return new PermissionsBuilder().addAll(allowAll.get() + ? allPermissions : permissions).toPermissions(); + } + } + +} From b1ad8012a0fa3247f39dce98df17f0b53e6791ef Mon Sep 17 00:00:00 2001 From: Vladimir Ivanov Date: Mon, 24 Nov 2014 07:16:38 -0800 Subject: [PATCH 46/67] 8063135: Enable full LF sharing by default Reviewed-by: psandoz, shade --- .../java/lang/invoke/MethodHandle.java | 38 +-- .../java/lang/invoke/MethodHandleImpl.java | 6 +- .../java/lang/invoke/MethodHandleStatics.java | 17 +- .../java/lang/invoke/MethodHandles.java | 252 +++++++----------- .../LFCaching/LFGarbageCollectedTest.java | 2 +- .../LFCaching/LFMultiThreadCachingTest.java | 2 +- .../LFCaching/LFSingleThreadCachingTest.java | 2 +- 7 files changed, 115 insertions(+), 204 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java index 17ba24019b8..0a45d2707e9 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java @@ -867,15 +867,11 @@ assertEquals("[A, B, C]", (String) caToString2.invokeExact('A', "BC".toCharArray MethodType postSpreadType = asSpreaderChecks(arrayType, arrayLength); int arity = type().parameterCount(); int spreadArgPos = arity - arrayLength; - if (USE_LAMBDA_FORM_EDITOR) { - MethodHandle afterSpread = this.asType(postSpreadType); - BoundMethodHandle mh = afterSpread.rebind(); - LambdaForm lform = mh.editor().spreadArgumentsForm(1 + spreadArgPos, arrayType, arrayLength); - MethodType preSpreadType = postSpreadType.replaceParameterTypes(spreadArgPos, arity, arrayType); - return mh.copyWith(preSpreadType, lform); - } else { - return MethodHandleImpl.makeSpreadArguments(this, arrayType, spreadArgPos, arrayLength); - } + MethodHandle afterSpread = this.asType(postSpreadType); + BoundMethodHandle mh = afterSpread.rebind(); + LambdaForm lform = mh.editor().spreadArgumentsForm(1 + spreadArgPos, arrayType, arrayLength); + MethodType preSpreadType = postSpreadType.replaceParameterTypes(spreadArgPos, arity, arrayType); + return mh.copyWith(preSpreadType, lform); } /** @@ -996,23 +992,15 @@ assertEquals("[123]", (String) longsToString.invokeExact((long)123)); public MethodHandle asCollector(Class arrayType, int arrayLength) { asCollectorChecks(arrayType, arrayLength); int collectArgPos = type().parameterCount() - 1; - if (USE_LAMBDA_FORM_EDITOR) { - BoundMethodHandle mh = rebind(); - MethodType resultType = type().asCollectorType(arrayType, arrayLength); - MethodHandle newArray = MethodHandleImpl.varargsArray(arrayType, arrayLength); - LambdaForm lform = mh.editor().collectArgumentArrayForm(1 + collectArgPos, newArray); - if (lform != null) { - return mh.copyWith(resultType, lform); - } - lform = mh.editor().collectArgumentsForm(1 + collectArgPos, newArray.type().basicType()); - return mh.copyWithExtendL(resultType, lform, newArray); - } else { - MethodHandle target = this; - if (arrayType != type().parameterType(collectArgPos)) - target = MethodHandleImpl.makePairwiseConvert(this, type().changeParameterType(collectArgPos, arrayType), true); - MethodHandle collector = MethodHandleImpl.varargsArray(arrayType, arrayLength); - return MethodHandles.collectArguments(target, collectArgPos, collector); + BoundMethodHandle mh = rebind(); + MethodType resultType = type().asCollectorType(arrayType, arrayLength); + MethodHandle newArray = MethodHandleImpl.varargsArray(arrayType, arrayLength); + LambdaForm lform = mh.editor().collectArgumentArrayForm(1 + collectArgPos, newArray); + if (lform != null) { + return mh.copyWith(resultType, lform); } + lform = mh.editor().collectArgumentsForm(1 + collectArgPos, newArray.type().basicType()); + return mh.copyWithExtendL(resultType, lform, newArray); } /** diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java index 09864eb19f3..7d8c63490d5 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java @@ -191,11 +191,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; MethodType dstType = target.type(); if (srcType == dstType) return target; - if (USE_LAMBDA_FORM_EDITOR) { - return makePairwiseConvertByEditor(target, srcType, strict, monobox); - } else { - return makePairwiseConvertIndirect(target, srcType, strict, monobox); - } + return makePairwiseConvertByEditor(target, srcType, strict, monobox); } private static int countNonNull(Object[] array) { diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java index 1bd43538a91..43700b4d8db 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java @@ -45,23 +45,21 @@ import sun.misc.Unsafe; static final boolean DUMP_CLASS_FILES; static final boolean TRACE_INTERPRETER; static final boolean TRACE_METHOD_LINKAGE; - static final boolean USE_LAMBDA_FORM_EDITOR; static final int COMPILE_THRESHOLD; static final int DONT_INLINE_THRESHOLD; static final int PROFILE_LEVEL; static { - final Object[] values = new Object[8]; + final Object[] values = new Object[7]; AccessController.doPrivileged(new PrivilegedAction() { public Void run() { values[0] = Boolean.getBoolean("java.lang.invoke.MethodHandle.DEBUG_NAMES"); values[1] = Boolean.getBoolean("java.lang.invoke.MethodHandle.DUMP_CLASS_FILES"); values[2] = Boolean.getBoolean("java.lang.invoke.MethodHandle.TRACE_INTERPRETER"); values[3] = Boolean.getBoolean("java.lang.invoke.MethodHandle.TRACE_METHOD_LINKAGE"); - values[4] = Boolean.getBoolean("java.lang.invoke.MethodHandle.USE_LF_EDITOR"); - values[5] = Integer.getInteger("java.lang.invoke.MethodHandle.COMPILE_THRESHOLD", 30); - values[6] = Integer.getInteger("java.lang.invoke.MethodHandle.DONT_INLINE_THRESHOLD", 30); - values[7] = Integer.getInteger("java.lang.invoke.MethodHandle.PROFILE_LEVEL", 0); + values[4] = Integer.getInteger("java.lang.invoke.MethodHandle.COMPILE_THRESHOLD", 30); + values[5] = Integer.getInteger("java.lang.invoke.MethodHandle.DONT_INLINE_THRESHOLD", 30); + values[6] = Integer.getInteger("java.lang.invoke.MethodHandle.PROFILE_LEVEL", 0); return null; } }); @@ -69,10 +67,9 @@ import sun.misc.Unsafe; DUMP_CLASS_FILES = (Boolean) values[1]; TRACE_INTERPRETER = (Boolean) values[2]; TRACE_METHOD_LINKAGE = (Boolean) values[3]; - USE_LAMBDA_FORM_EDITOR = (Boolean) values[4]; - COMPILE_THRESHOLD = (Integer) values[5]; - DONT_INLINE_THRESHOLD = (Integer) values[6]; - PROFILE_LEVEL = (Integer) values[7]; + COMPILE_THRESHOLD = (Integer) values[4]; + DONT_INLINE_THRESHOLD = (Integer) values[5]; + PROFILE_LEVEL = (Integer) values[6]; } /** Tell if any of the debugging switches are turned on. diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java index 1600658e938..0fe5a897417 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java @@ -2103,115 +2103,65 @@ assert((int)twice.invokeExact(21) == 42); reorder = reorder.clone(); // get a private copy MethodType oldType = target.type(); permuteArgumentChecks(reorder, newType, oldType); - if (USE_LAMBDA_FORM_EDITOR) { - // first detect dropped arguments and handle them separately - int[] originalReorder = reorder; - BoundMethodHandle result = target.rebind(); - LambdaForm form = result.form; - int newArity = newType.parameterCount(); - // Normalize the reordering into a real permutation, - // by removing duplicates and adding dropped elements. - // This somewhat improves lambda form caching, as well - // as simplifying the transform by breaking it up into steps. - for (int ddIdx; (ddIdx = findFirstDupOrDrop(reorder, newArity)) != 0; ) { - if (ddIdx > 0) { - // We found a duplicated entry at reorder[ddIdx]. - // Example: (x,y,z)->asList(x,y,z) - // permuted by [1*,0,1] => (a0,a1)=>asList(a1,a0,a1) - // permuted by [0,1,0*] => (a0,a1)=>asList(a0,a1,a0) - // The starred element corresponds to the argument - // deleted by the dupArgumentForm transform. - int srcPos = ddIdx, dstPos = srcPos, dupVal = reorder[srcPos]; - boolean killFirst = false; - for (int val; (val = reorder[--dstPos]) != dupVal; ) { - // Set killFirst if the dup is larger than an intervening position. - // This will remove at least one inversion from the permutation. - if (dupVal > val) killFirst = true; - } - if (!killFirst) { - srcPos = dstPos; - dstPos = ddIdx; - } - form = form.editor().dupArgumentForm(1 + srcPos, 1 + dstPos); - assert (reorder[srcPos] == reorder[dstPos]); - oldType = oldType.dropParameterTypes(dstPos, dstPos + 1); - // contract the reordering by removing the element at dstPos - int tailPos = dstPos + 1; - System.arraycopy(reorder, tailPos, reorder, dstPos, reorder.length - tailPos); - reorder = Arrays.copyOf(reorder, reorder.length - 1); - } else { - int dropVal = ~ddIdx, insPos = 0; - while (insPos < reorder.length && reorder[insPos] < dropVal) { - // Find first element of reorder larger than dropVal. - // This is where we will insert the dropVal. - insPos += 1; - } - Class ptype = newType.parameterType(dropVal); - form = form.editor().addArgumentForm(1 + insPos, BasicType.basicType(ptype)); - oldType = oldType.insertParameterTypes(insPos, ptype); - // expand the reordering by inserting an element at insPos - int tailPos = insPos + 1; - reorder = Arrays.copyOf(reorder, reorder.length + 1); - System.arraycopy(reorder, insPos, reorder, tailPos, reorder.length - tailPos); - reorder[insPos] = dropVal; + // first detect dropped arguments and handle them separately + int[] originalReorder = reorder; + BoundMethodHandle result = target.rebind(); + LambdaForm form = result.form; + int newArity = newType.parameterCount(); + // Normalize the reordering into a real permutation, + // by removing duplicates and adding dropped elements. + // This somewhat improves lambda form caching, as well + // as simplifying the transform by breaking it up into steps. + for (int ddIdx; (ddIdx = findFirstDupOrDrop(reorder, newArity)) != 0; ) { + if (ddIdx > 0) { + // We found a duplicated entry at reorder[ddIdx]. + // Example: (x,y,z)->asList(x,y,z) + // permuted by [1*,0,1] => (a0,a1)=>asList(a1,a0,a1) + // permuted by [0,1,0*] => (a0,a1)=>asList(a0,a1,a0) + // The starred element corresponds to the argument + // deleted by the dupArgumentForm transform. + int srcPos = ddIdx, dstPos = srcPos, dupVal = reorder[srcPos]; + boolean killFirst = false; + for (int val; (val = reorder[--dstPos]) != dupVal; ) { + // Set killFirst if the dup is larger than an intervening position. + // This will remove at least one inversion from the permutation. + if (dupVal > val) killFirst = true; } - assert (permuteArgumentChecks(reorder, newType, oldType)); + if (!killFirst) { + srcPos = dstPos; + dstPos = ddIdx; + } + form = form.editor().dupArgumentForm(1 + srcPos, 1 + dstPos); + assert (reorder[srcPos] == reorder[dstPos]); + oldType = oldType.dropParameterTypes(dstPos, dstPos + 1); + // contract the reordering by removing the element at dstPos + int tailPos = dstPos + 1; + System.arraycopy(reorder, tailPos, reorder, dstPos, reorder.length - tailPos); + reorder = Arrays.copyOf(reorder, reorder.length - 1); + } else { + int dropVal = ~ddIdx, insPos = 0; + while (insPos < reorder.length && reorder[insPos] < dropVal) { + // Find first element of reorder larger than dropVal. + // This is where we will insert the dropVal. + insPos += 1; + } + Class ptype = newType.parameterType(dropVal); + form = form.editor().addArgumentForm(1 + insPos, BasicType.basicType(ptype)); + oldType = oldType.insertParameterTypes(insPos, ptype); + // expand the reordering by inserting an element at insPos + int tailPos = insPos + 1; + reorder = Arrays.copyOf(reorder, reorder.length + 1); + System.arraycopy(reorder, insPos, reorder, tailPos, reorder.length - tailPos); + reorder[insPos] = dropVal; } - assert (reorder.length == newArity); // a perfect permutation - // Note: This may cache too many distinct LFs. Consider backing off to varargs code. - form = form.editor().permuteArgumentsForm(1, reorder); - if (newType == result.type() && form == result.internalForm()) - return result; - return result.copyWith(newType, form); - } else { - // first detect dropped arguments and handle them separately - MethodHandle originalTarget = target; - int newArity = newType.parameterCount(); - for (int dropIdx; (dropIdx = findFirstDrop(reorder, newArity)) >= 0; ) { - // dropIdx is missing from reorder; add it in at the end - int oldArity = reorder.length; - target = dropArguments(target, oldArity, newType.parameterType(dropIdx)); - reorder = Arrays.copyOf(reorder, oldArity + 1); - reorder[oldArity] = dropIdx; - } - assert(target == originalTarget || permuteArgumentChecks(reorder, newType, target.type())); - // Note: This may cache too many distinct LFs. Consider backing off to varargs code. - BoundMethodHandle result = target.rebind(); - LambdaForm form = result.form.permuteArguments(1, reorder, basicTypes(newType.parameterList())); - return result.copyWith(newType, form); - } - } - - /** Return the first value in [0..newArity-1] that is not present in reorder. */ - private static int findFirstDrop(int[] reorder, int newArity) { - final int BIT_LIMIT = 63; // max number of bits in bit mask - if (newArity < BIT_LIMIT) { - long mask = 0; - for (int arg : reorder) { - assert(arg < newArity); - mask |= (1L << arg); - } - if (mask == (1L << newArity) - 1) { - assert(Long.numberOfTrailingZeros(Long.lowestOneBit(~mask)) == newArity); - return -1; - } - // find first zero - long zeroBit = Long.lowestOneBit(~mask); - int zeroPos = Long.numberOfTrailingZeros(zeroBit); - assert(zeroPos < newArity); - return zeroPos; - } else { - BitSet mask = new BitSet(newArity); - for (int arg : reorder) { - assert (arg < newArity); - mask.set(arg); - } - int zeroPos = mask.nextClearBit(0); - assert(zeroPos <= newArity); - if (zeroPos == newArity) - return -1; - return zeroPos; + assert (permuteArgumentChecks(reorder, newType, oldType)); } + assert (reorder.length == newArity); // a perfect permutation + // Note: This may cache too many distinct LFs. Consider backing off to varargs code. + form = form.editor().permuteArgumentsForm(1, reorder); + if (newType == result.type() && form == result.internalForm()) + return result; + return result.copyWith(newType, form); } /** @@ -2502,13 +2452,9 @@ assertEquals("yz", (String) d0.invokeExact(123, "x", "y", "z")); if (dropped == 0) return target; BoundMethodHandle result = target.rebind(); LambdaForm lform = result.form; - if (USE_LAMBDA_FORM_EDITOR) { - int insertFormArg = 1 + pos; - for (Class ptype : valueTypes) { - lform = lform.editor().addArgumentForm(insertFormArg++, BasicType.basicType(ptype)); - } - } else { - lform = lform.addArguments(pos, valueTypes); + int insertFormArg = 1 + pos; + for (Class ptype : valueTypes) { + lform = lform.editor().addArgumentForm(insertFormArg++, BasicType.basicType(ptype)); } result = result.copyWith(newType, lform); return result; @@ -2659,18 +2605,14 @@ assertEquals("XY", (String) f2.invokeExact("x", "y")); // XY /*non-public*/ static MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) { filterArgumentChecks(target, pos, filter); - if (USE_LAMBDA_FORM_EDITOR) { - MethodType targetType = target.type(); - MethodType filterType = filter.type(); - BoundMethodHandle result = target.rebind(); - Class newParamType = filterType.parameterType(0); - LambdaForm lform = result.editor().filterArgumentForm(1 + pos, BasicType.basicType(newParamType)); - MethodType newType = targetType.changeParameterType(pos, newParamType); - result = result.copyWithExtendL(newType, lform, filter); - return result; - } else { - return MethodHandleImpl.makeCollectArguments(target, filter, pos, false); - } + MethodType targetType = target.type(); + MethodType filterType = filter.type(); + BoundMethodHandle result = target.rebind(); + Class newParamType = filterType.parameterType(0); + LambdaForm lform = result.editor().filterArgumentForm(1 + pos, BasicType.basicType(newParamType)); + MethodType newType = targetType.changeParameterType(pos, newParamType); + result = result.copyWithExtendL(newType, lform, filter); + return result; } private static void filterArgumentsCheckArity(MethodHandle target, int pos, MethodHandle[] filters) { @@ -2797,21 +2739,17 @@ assertEquals("[top, [[up, down, strange], charm], bottom]", public static MethodHandle collectArguments(MethodHandle target, int pos, MethodHandle filter) { MethodType newType = collectArgumentsChecks(target, pos, filter); - if (USE_LAMBDA_FORM_EDITOR) { - MethodType collectorType = filter.type(); - BoundMethodHandle result = target.rebind(); - LambdaForm lform; - if (collectorType.returnType().isArray() && filter.intrinsicName() == Intrinsic.NEW_ARRAY) { - lform = result.editor().collectArgumentArrayForm(1 + pos, filter); - if (lform != null) { - return result.copyWith(newType, lform); - } + MethodType collectorType = filter.type(); + BoundMethodHandle result = target.rebind(); + LambdaForm lform; + if (collectorType.returnType().isArray() && filter.intrinsicName() == Intrinsic.NEW_ARRAY) { + lform = result.editor().collectArgumentArrayForm(1 + pos, filter); + if (lform != null) { + return result.copyWith(newType, lform); } - lform = result.editor().collectArgumentsForm(1 + pos, collectorType.basicType()); - return result.copyWithExtendL(newType, lform, filter); - } else { - return MethodHandleImpl.makeCollectArguments(target, filter, pos, false); } + lform = result.editor().collectArgumentsForm(1 + pos, collectorType.basicType()); + return result.copyWithExtendL(newType, lform, filter); } private static MethodType collectArgumentsChecks(MethodHandle target, int pos, MethodHandle filter) throws RuntimeException { @@ -2890,16 +2828,12 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2 MethodType targetType = target.type(); MethodType filterType = filter.type(); filterReturnValueChecks(targetType, filterType); - if (USE_LAMBDA_FORM_EDITOR) { - BoundMethodHandle result = target.rebind(); - BasicType rtype = BasicType.basicType(filterType.returnType()); - LambdaForm lform = result.editor().filterReturnForm(rtype, false); - MethodType newType = targetType.changeReturnType(filterType.returnType()); - result = result.copyWithExtendL(newType, lform, filter); - return result; - } else { - return MethodHandleImpl.makeCollectArguments(filter, target, 0, false); - } + BoundMethodHandle result = target.rebind(); + BasicType rtype = BasicType.basicType(filterType.returnType()); + LambdaForm lform = result.editor().filterReturnForm(rtype, false); + MethodType newType = targetType.changeReturnType(filterType.returnType()); + result = result.copyWithExtendL(newType, lform, filter); + return result; } private static void filterReturnValueChecks(MethodType targetType, MethodType filterType) throws RuntimeException { @@ -2993,19 +2927,15 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum")); MethodType targetType = target.type(); MethodType combinerType = combiner.type(); Class rtype = foldArgumentChecks(foldPos, targetType, combinerType); - if (USE_LAMBDA_FORM_EDITOR) { - BoundMethodHandle result = target.rebind(); - boolean dropResult = (rtype == void.class); - // Note: This may cache too many distinct LFs. Consider backing off to varargs code. - LambdaForm lform = result.editor().foldArgumentsForm(1 + foldPos, dropResult, combinerType.basicType()); - MethodType newType = targetType; - if (!dropResult) - newType = newType.dropParameterTypes(foldPos, foldPos + 1); - result = result.copyWithExtendL(newType, lform, combiner); - return result; - } else { - return MethodHandleImpl.makeCollectArguments(target, combiner, foldPos, true); - } + BoundMethodHandle result = target.rebind(); + boolean dropResult = (rtype == void.class); + // Note: This may cache too many distinct LFs. Consider backing off to varargs code. + LambdaForm lform = result.editor().foldArgumentsForm(1 + foldPos, dropResult, combinerType.basicType()); + MethodType newType = targetType; + if (!dropResult) + newType = newType.dropParameterTypes(foldPos, foldPos + 1); + result = result.copyWithExtendL(newType, lform, combiner); + return result; } private static Class foldArgumentChecks(int foldPos, MethodType targetType, MethodType combinerType) { diff --git a/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java b/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java index 3b9ed4dea74..451af074bdc 100644 --- a/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java +++ b/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java @@ -31,7 +31,7 @@ * @build TestMethods * @build LambdaFormTestCase * @build LFGarbageCollectedTest - * @run main/othervm/timeout=600 -Djava.lang.invoke.MethodHandle.USE_LF_EDITOR=true -DtestLimit=150 LFGarbageCollectedTest + * @run main/othervm/timeout=600 -DtestLimit=150 LFGarbageCollectedTest */ import java.lang.invoke.MethodHandle; diff --git a/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java b/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java index a41647246bc..21771c1a0a0 100644 --- a/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java +++ b/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java @@ -31,7 +31,7 @@ * @build LambdaFormTestCase * @build LFCachingTestCase * @build LFMultiThreadCachingTest - * @run main/othervm/timeout=300 -Djava.lang.invoke.MethodHandle.USE_LF_EDITOR=true LFMultiThreadCachingTest + * @run main/othervm/timeout=300 LFMultiThreadCachingTest */ import java.lang.invoke.MethodHandle; diff --git a/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java b/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java index 21221aa7caf..bd0ba2bde59 100644 --- a/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java +++ b/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java @@ -31,7 +31,7 @@ * @build LambdaFormTestCase * @build LFCachingTestCase * @build LFSingleThreadCachingTest - * @run main/othervm/timeout=300 -Djava.lang.invoke.MethodHandle.USE_LF_EDITOR=true LFSingleThreadCachingTest + * @run main/othervm/timeout=300 LFSingleThreadCachingTest */ import java.lang.invoke.MethodHandle; From 95ef6e0cb2b59d8f6c8736bac5217a0feb0c4d01 Mon Sep 17 00:00:00 2001 From: Vladimir Ivanov Date: Mon, 24 Nov 2014 07:19:36 -0800 Subject: [PATCH 47/67] 8059880: Get rid of LambdaForm interpretation Reviewed-by: psandoz, kvn, shade --- .../share/classes/java/lang/invoke/MethodHandleStatics.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java index 43700b4d8db..335a32289a7 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java @@ -57,7 +57,7 @@ import sun.misc.Unsafe; values[1] = Boolean.getBoolean("java.lang.invoke.MethodHandle.DUMP_CLASS_FILES"); values[2] = Boolean.getBoolean("java.lang.invoke.MethodHandle.TRACE_INTERPRETER"); values[3] = Boolean.getBoolean("java.lang.invoke.MethodHandle.TRACE_METHOD_LINKAGE"); - values[4] = Integer.getInteger("java.lang.invoke.MethodHandle.COMPILE_THRESHOLD", 30); + values[4] = Integer.getInteger("java.lang.invoke.MethodHandle.COMPILE_THRESHOLD", 0); values[5] = Integer.getInteger("java.lang.invoke.MethodHandle.DONT_INLINE_THRESHOLD", 30); values[6] = Integer.getInteger("java.lang.invoke.MethodHandle.PROFILE_LEVEL", 0); return null; From 3469175a632b593b610f3ee1f93cbc834ce92d9d Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Mon, 24 Nov 2014 18:11:25 +0000 Subject: [PATCH 48/67] 8065720: (ch) AbstractInterruptibleChannel.end sets interrupted to null Reviewed-by: psandoz, chegar --- .../java/nio/channels/spi/AbstractInterruptibleChannel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/classes/java/nio/channels/spi/AbstractInterruptibleChannel.java b/jdk/src/java.base/share/classes/java/nio/channels/spi/AbstractInterruptibleChannel.java index 5000c583cde..fccc2904c7d 100644 --- a/jdk/src/java.base/share/classes/java/nio/channels/spi/AbstractInterruptibleChannel.java +++ b/jdk/src/java.base/share/classes/java/nio/channels/spi/AbstractInterruptibleChannel.java @@ -198,7 +198,7 @@ public abstract class AbstractInterruptibleChannel blockedOn(null); Thread interrupted = this.interrupted; if (interrupted != null && interrupted == Thread.currentThread()) { - interrupted = null; + this.interrupted = null; throw new ClosedByInterruptException(); } if (!completed && !open) From 758644082bddea64c8d88287ab411bdfc1300866 Mon Sep 17 00:00:00 2001 From: Konstantin Shefov Date: Tue, 25 Nov 2014 14:16:55 +0400 Subject: [PATCH 49/67] 8059070: [TESTBUG] java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java failed - timeout Reviewed-by: psandoz, vlivanov --- .../lang/invoke/LFCaching/LFGarbageCollectedTest.java | 2 +- .../invoke/LFCaching/LFMultiThreadCachingTest.java | 2 +- .../invoke/LFCaching/LFSingleThreadCachingTest.java | 2 +- .../lang/invoke/LFCaching/LambdaFormTestCase.java | 11 +++++++++++ jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java | 7 +++++++ 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java b/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java index 451af074bdc..f0f6b034dbb 100644 --- a/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java +++ b/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java @@ -31,7 +31,7 @@ * @build TestMethods * @build LambdaFormTestCase * @build LFGarbageCollectedTest - * @run main/othervm/timeout=600 -DtestLimit=150 LFGarbageCollectedTest + * @run main/othervm LFGarbageCollectedTest */ import java.lang.invoke.MethodHandle; diff --git a/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java b/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java index 21771c1a0a0..35c2f97d191 100644 --- a/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java +++ b/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java @@ -31,7 +31,7 @@ * @build LambdaFormTestCase * @build LFCachingTestCase * @build LFMultiThreadCachingTest - * @run main/othervm/timeout=300 LFMultiThreadCachingTest + * @run main/othervm LFMultiThreadCachingTest */ import java.lang.invoke.MethodHandle; diff --git a/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java b/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java index bd0ba2bde59..6a44e44d8b6 100644 --- a/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java +++ b/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java @@ -31,7 +31,7 @@ * @build LambdaFormTestCase * @build LFCachingTestCase * @build LFSingleThreadCachingTest - * @run main/othervm/timeout=300 LFSingleThreadCachingTest + * @run main/othervm LFSingleThreadCachingTest */ import java.lang.invoke.MethodHandle; diff --git a/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java b/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java index dfdcd15297f..a1821fa696f 100644 --- a/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java +++ b/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java @@ -27,6 +27,7 @@ import java.lang.management.ManagementFactory; import java.lang.reflect.Method; import java.util.Collection; import java.util.function.Function; +import jdk.testlibrary.Utils; /** * Lambda forms caching test case class. Contains all necessary test routines to @@ -41,6 +42,7 @@ public abstract class LambdaFormTestCase { private final static String INTERNAL_FORM_METHOD_NAME = "internalForm"; private static final double ITERATIONS_TO_CODE_CACHE_SIZE_RATIO = 45 / (128.0 * 1024 * 1024); + private static final long TIMEOUT = Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT); /** * Reflection link to {@code j.l.i.MethodHandle.internalForm} method. It is @@ -120,6 +122,7 @@ public abstract class LambdaFormTestCase { System.out.printf("Number of iterations is set to %d (%d cases)%n", iterations, iterations * testCaseNum); System.out.flush(); + long startTime = System.currentTimeMillis(); for (long i = 0; i < iterations; i++) { System.err.println(String.format("Iteration %d:", i)); for (TestMethods testMethod : testMethods) { @@ -137,6 +140,14 @@ public abstract class LambdaFormTestCase { } testCounter++; } + long passedTime = System.currentTimeMillis() - startTime; + long avgIterTime = passedTime / (i + 1); + long remainTime = TIMEOUT - passedTime; + if (avgIterTime > 2 * remainTime) { + System.err.printf("Stopping iterations because of lack of time.%n" + + "Increase timeout factor for more iterations.%n"); + break; + } } if (!passed) { throw new Error(String.format("%d of %d test cases FAILED! %n" diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java index e96898c8fc5..af8cc267493 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java @@ -38,6 +38,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.regex.Pattern; import java.util.regex.Matcher; +import java.util.concurrent.TimeUnit; /** * Common library for various test helper functions. @@ -69,6 +70,12 @@ public final class Utils { TIMEOUT_FACTOR = Double.parseDouble(toFactor); } + /** + * Returns the value of JTREG default test timeout in milliseconds + * converted to {@code long}. + */ + public static final long DEFAULT_TEST_TIMEOUT = TimeUnit.SECONDS.toMillis(120); + private Utils() { // Private constructor to prevent class instantiation } From a6da554cfb11fe793e5b31ea9e25efa2a7738993 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Tue, 25 Nov 2014 18:43:44 +0000 Subject: [PATCH 50/67] 8065072: sun/net/www/http/HttpClient/StreamingRetry.java failed intermittently Reviewed-by: dfuchs --- .../sun/net/www/http/HttpClient/StreamingRetry.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/jdk/test/sun/net/www/http/HttpClient/StreamingRetry.java b/jdk/test/sun/net/www/http/HttpClient/StreamingRetry.java index 35dbc51d2de..d3e2b5215d0 100644 --- a/jdk/test/sun/net/www/http/HttpClient/StreamingRetry.java +++ b/jdk/test/sun/net/www/http/HttpClient/StreamingRetry.java @@ -37,13 +37,13 @@ import static java.lang.System.out; public class StreamingRetry implements Runnable { static final int ACCEPT_TIMEOUT = 20 * 1000; // 20 seconds - ServerSocket ss; + volatile ServerSocket ss; - public static void main(String[] args) throws IOException { + public static void main(String[] args) throws Exception { (new StreamingRetry()).instanceMain(); } - void instanceMain() throws IOException { + void instanceMain() throws Exception { out.println("Test with default method"); test(null); out.println("Test with POST method"); @@ -54,12 +54,13 @@ public class StreamingRetry implements Runnable { if (failed > 0) throw new RuntimeException("Some tests failed"); } - void test(String method) throws IOException { + void test(String method) throws Exception { ss = new ServerSocket(0); ss.setSoTimeout(ACCEPT_TIMEOUT); int port = ss.getLocalPort(); - (new Thread(this)).start(); + Thread otherThread = new Thread(this); + otherThread.start(); try { URL url = new URL("http://localhost:" + port + "/"); @@ -77,6 +78,7 @@ public class StreamingRetry implements Runnable { //expected.printStackTrace(); } finally { ss.close(); + otherThread.join(); } } From eafad5770a80bdfd8451f192fce41ef2d34829fb Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Wed, 26 Nov 2014 15:28:46 +0800 Subject: [PATCH 51/67] 8061253: Spec cleanup for some security-related classes Reviewed-by: mullan --- .../share/classes/java/security/KeyStore.java | 3 +- .../classes/java/security/Principal.java | 3 +- .../javax/security/auth/Destroyable.java | 4 +- .../security/auth/kerberos/EncryptionKey.java | 26 +++++++++---- .../auth/kerberos/KerberosCredMessage.java | 23 ++++++++++++ .../security/auth/kerberos/KerberosKey.java | 37 +++++++++++-------- .../auth/kerberos/KerberosPrincipal.java | 32 +++++++++------- .../auth/kerberos/KerberosTicket.java | 31 +++++++++------- .../javax/security/auth/kerberos/KeyTab.java | 29 +++++++++------ 9 files changed, 122 insertions(+), 66 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/security/KeyStore.java b/jdk/src/java.base/share/classes/java/security/KeyStore.java index 4278369e8be..53e787b7d98 100644 --- a/jdk/src/java.base/share/classes/java/security/KeyStore.java +++ b/jdk/src/java.base/share/classes/java/security/KeyStore.java @@ -416,7 +416,8 @@ public class KeyStore { /** * Retrieves the attributes associated with an entry. - *

    + * + * @implSpec * The default implementation returns an empty {@code Set}. * * @return an unmodifiable {@code Set} of attributes, possibly empty diff --git a/jdk/src/java.base/share/classes/java/security/Principal.java b/jdk/src/java.base/share/classes/java/security/Principal.java index a538e707ee7..db1e7d5fd02 100644 --- a/jdk/src/java.base/share/classes/java/security/Principal.java +++ b/jdk/src/java.base/share/classes/java/security/Principal.java @@ -74,7 +74,8 @@ public interface Principal { /** * Returns true if the specified subject is implied by this principal. * - *

    The default implementation of this method returns true if + * @implSpec + * The default implementation of this method returns true if * {@code subject} is non-null and contains at least one principal that * is equal to this principal. * diff --git a/jdk/src/java.base/share/classes/javax/security/auth/Destroyable.java b/jdk/src/java.base/share/classes/javax/security/auth/Destroyable.java index 15b92006cdf..4d1afe56fd5 100644 --- a/jdk/src/java.base/share/classes/javax/security/auth/Destroyable.java +++ b/jdk/src/java.base/share/classes/javax/security/auth/Destroyable.java @@ -41,7 +41,7 @@ public interface Destroyable { * on this {@code Object} will result in an * {@code IllegalStateException} being thrown. * - *

    + * @implSpec * The default implementation throws {@code DestroyFailedException}. * * @exception DestroyFailedException if the destroy operation fails.

    @@ -56,7 +56,7 @@ public interface Destroyable { /** * Determine if this {@code Object} has been destroyed. * - *

    + * @implSpec * The default implementation returns false. * * @return true if this {@code Object} has been destroyed, diff --git a/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/EncryptionKey.java b/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/EncryptionKey.java index 22730b60844..08b9179a11f 100644 --- a/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/EncryptionKey.java +++ b/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/EncryptionKey.java @@ -158,6 +158,11 @@ public final class EncryptionKey implements SecretKey { return destroyed; } + /** + * Returns an informative textual representation of this {@code EncryptionKey}. + * + * @return an informative textual representation of this {@code EncryptionKey}. + */ @Override public String toString() { if (destroyed) { @@ -166,6 +171,11 @@ public final class EncryptionKey implements SecretKey { return "key " + key.toString(); } + /** + * Returns a hash code for this {@code EncryptionKey}. + * + * @return a hash code for this {@code EncryptionKey}. + */ @Override public int hashCode() { int result = 17; @@ -177,15 +187,17 @@ public final class EncryptionKey implements SecretKey { } /** - * Compares the specified Object with this key for equality. - * Returns true if the given object is also a + * Compares the specified object with this key for equality. + * Returns true if the given object is also an * {@code EncryptionKey} and the two - * {@code EncryptionKey} instances are equivalent. + * {@code EncryptionKey} instances are equivalent. More formally two + * {@code EncryptionKey} instances are equal if they have equal key types + * and key material. + * A destroyed {@code EncryptionKey} object is only equal to itself. * - * @param other the Object to compare to - * @return true if the specified object is equal to this EncryptionKey, - * false otherwise. NOTE: Returns false if either of the EncryptionKey - * objects has been destroyed. + * @param other the object to compare to + * @return true if the specified object is equal to this + * {@code EncryptionKey}, false otherwise. */ @Override public boolean equals(Object other) { diff --git a/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosCredMessage.java b/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosCredMessage.java index ee2010b1531..e45ae2a4cee 100644 --- a/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosCredMessage.java +++ b/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosCredMessage.java @@ -130,6 +130,11 @@ public final class KerberosCredMessage implements Destroyable { return destroyed; } + /** + * Returns an informative textual representation of this {@code KerberosCredMessage}. + * + * @return an informative textual representation of this {@code KerberosCredMessage}. + */ @Override public String toString() { if (destroyed) { @@ -140,6 +145,11 @@ public final class KerberosCredMessage implements Destroyable { } } + /** + * Returns a hash code for this {@code KerberosCredMessage}. + * + * @return a hash code for this {@code KerberosCredMessage}. + */ @Override public int hashCode() { if (isDestroyed()) { @@ -149,6 +159,19 @@ public final class KerberosCredMessage implements Destroyable { } } + /** + * Compares the specified object with this {@code KerberosCredMessage} + * for equality. Returns true if the given object is also a + * {@code KerberosCredMessage} and the two {@code KerberosCredMessage} + * instances are equivalent. More formally two {@code KerberosCredMessage} + * instances are equal if they have equal sender, recipient, and encoded + * KRB_CRED messages. + * A destroyed {@code KerberosCredMessage} object is only equal to itself. + * + * @param other the object to compare to + * @return true if the specified object is equal to this + * {@code KerberosCredMessage}, false otherwise. + */ @Override public boolean equals(Object other) { if (other == this) { diff --git a/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosKey.java b/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosKey.java index b233052f44f..84a39e0e129 100644 --- a/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosKey.java +++ b/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosKey.java @@ -61,10 +61,10 @@ import javax.security.auth.DestroyFailedException; * * It might be necessary for the application to be granted a * {@link javax.security.auth.PrivateCredentialPermission - * PrivateCredentialPermission} if it needs to access the KerberosKey + * PrivateCredentialPermission} if it needs to access the {@code KerberosKey} * instance from a Subject. This permission is not needed when the * application depends on the default JGSS Kerberos mechanism to access the - * KerberosKey. In that case, however, the application will need an + * {@code KerberosKey}. In that case, however, the application will need an * appropriate * {@link javax.security.auth.kerberos.ServicePermission ServicePermission}.

    * @@ -113,9 +113,9 @@ public class KerberosKey implements SecretKey { private transient boolean destroyed = false; /** - * Constructs a KerberosKey from the given bytes when the key type and - * key version number are known. This can be used when reading the secret - * key information from a Kerberos "keytab". + * Constructs a {@code KerberosKey} from the given bytes when the key type + * and key version number are known. This can be used when reading the + * secret key information from a Kerberos "keytab". * * @param principal the principal that this secret key belongs to * @param keyBytes the key material for the secret key @@ -133,9 +133,9 @@ public class KerberosKey implements SecretKey { } /** - * Constructs a KerberosKey from a principal's password using the specified - * algorithm name. The algorithm name (case insensitive) should be provided - * as the encryption type string defined on the IANA + * Constructs a {@code KerberosKey} from a principal's password using the + * specified algorithm name. The algorithm name (case insensitive) should + * be provided as the encryption type string defined on the IANA * Kerberos Encryption Type Numbers * page. The version number of the key generated will be 0. * @@ -261,6 +261,11 @@ public class KerberosKey implements SecretKey { return destroyed; } + /** + * Returns an informative textual representation of this {@code KerberosKey}. + * + * @return an informative textual representation of this {@code KerberosKey}. + */ public String toString() { if (destroyed) { return "Destroyed KerberosKey"; @@ -271,9 +276,9 @@ public class KerberosKey implements SecretKey { } /** - * Returns a hashcode for this KerberosKey. + * Returns a hash code for this {@code KerberosKey}. * - * @return a hashCode() for the {@code KerberosKey} + * @return a hash code for this {@code KerberosKey}. * @since 1.6 */ public int hashCode() { @@ -290,15 +295,15 @@ public class KerberosKey implements SecretKey { } /** - * Compares the specified Object with this KerberosKey for equality. - * Returns true if the given object is also a + * Compares the specified object with this {@code KerberosKey} for + * equality. Returns true if the given object is also a * {@code KerberosKey} and the two * {@code KerberosKey} instances are equivalent. + * A destroyed {@code KerberosKey} object is only equal to itself. * - * @param other the Object to compare to - * @return true if the specified object is equal to this KerberosKey, - * false otherwise. NOTE: Returns false if either of the KerberosKey - * objects has been destroyed. + * @param other the object to compare to + * @return true if the specified object is equal to this {@code KerberosKey}, + * false otherwise. * @since 1.6 */ public boolean equals(Object other) { diff --git a/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosPrincipal.java b/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosPrincipal.java index 1c033803cc7..3a1c2c4c41b 100644 --- a/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosPrincipal.java +++ b/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosPrincipal.java @@ -88,8 +88,8 @@ public final class KerberosPrincipal /** - * Constructs a KerberosPrincipal from the provided string input. The - * name type for this principal defaults to + * Constructs a {@code KerberosPrincipal} from the provided string input. + * The name type for this principal defaults to * {@link #KRB_NT_PRINCIPAL KRB_NT_PRINCIPAL} * This string is assumed to contain a name in the format * that is specified in Section 2.1.1. (Kerberos Principal Name Form) of @@ -127,7 +127,7 @@ public final class KerberosPrincipal } /** - * Constructs a KerberosPrincipal from the provided string and + * Constructs a {@code KerberosPrincipal} from the provided string and * name type input. The string is assumed to contain a name in the * format that is specified in Section 2.1 (Mandatory Name Forms) of * RFC 1964. @@ -137,7 +137,7 @@ public final class KerberosPrincipal * (for example, duke@FOO.COM, is a valid input string for the * name type, KRB_NT_PRINCIPAL where duke * represents a principal, and FOO.COM represents a realm). - + * *

    If the input name does not contain a realm, the default realm * is used. The default realm can be specified either in a Kerberos * configuration file or via the java.security.krb5.realm @@ -179,28 +179,28 @@ public final class KerberosPrincipal } /** - * Returns a hashcode for this principal. The hash code is defined to - * be the result of the following calculation: + * Returns a hash code for this {@code KerberosPrincipal}. The hash code + * is defined to be the result of the following calculation: *

    {@code
          *  hashCode = getName().hashCode();
          * }
    * - * @return a hashCode() for the {@code KerberosPrincipal} + * @return a hash code for this {@code KerberosPrincipal}. */ public int hashCode() { return getName().hashCode(); } /** - * Compares the specified Object with this Principal for equality. + * Compares the specified object with this principal for equality. * Returns true if the given object is also a * {@code KerberosPrincipal} and the two * {@code KerberosPrincipal} instances are equivalent. * More formally two {@code KerberosPrincipal} instances are equal * if the values returned by {@code getName()} are equal. * - * @param other the Object to compare to - * @return true if the Object passed in represents the same principal + * @param other the object to compare to + * @return true if the object passed in represents the same principal * as this one, false otherwise. */ public boolean equals(Object other) { @@ -217,11 +217,11 @@ public final class KerberosPrincipal } /** - * Save the KerberosPrincipal object to a stream + * Save the {@code KerberosPrincipal} object to a stream * * @serialData this {@code KerberosPrincipal} is serialized * by writing out the PrincipalName and the - * realm in their DER-encoded form as specified in Section 5.2.2 of + * Realm in their DER-encoded form as specified in Section 5.2.2 of * RFC4120. */ private void writeObject(ObjectOutputStream oos) @@ -268,7 +268,7 @@ public final class KerberosPrincipal } /** - * Returns the name type of the KerberosPrincipal. Valid name types + * Returns the name type of the {@code KerberosPrincipal}. Valid name types * are specified in Section 6.2 of * RFC4120. * @@ -278,7 +278,11 @@ public final class KerberosPrincipal return nameType; } - // Inherits javadocs from Object + /** + * Returns an informative textual representation of this {@code KerberosPrincipal}. + * + * @return an informative textual representation of this {@code KerberosPrincipal}. + */ public String toString() { return getName(); } diff --git a/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosTicket.java b/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosTicket.java index 513b49c1fc0..2be499ff80b 100644 --- a/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosTicket.java +++ b/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KerberosTicket.java @@ -53,10 +53,10 @@ import sun.misc.HexDumpEncoder; * * It might be necessary for the application to be granted a * {@link javax.security.auth.PrivateCredentialPermission - * PrivateCredentialPermission} if it needs to access a KerberosTicket - * instance from a Subject. This permission is not needed when the + * PrivateCredentialPermission} if it needs to access a {@code KerberosTicket} + * instance from a {@code Subject}. This permission is not needed when the * application depends on the default JGSS Kerberos mechanism to access the - * KerberosTicket. In that case, however, the application will need an + * {@code KerberosTicket}. In that case, however, the application will need an * appropriate * {@link javax.security.auth.kerberos.ServicePermission ServicePermission}. *

    @@ -193,7 +193,7 @@ public class KerberosTicket implements Destroyable, Refreshable, private transient boolean destroyed = false; /** - * Constructs a KerberosTicket using credentials information that a + * Constructs a {@code KerberosTicket} using credentials information that a * client either receives from a KDC or reads from a cache. * * @param asn1Encoding the ASN.1 encoding of the ticket as defined by @@ -565,8 +565,8 @@ public class KerberosTicket implements Destroyable, Refreshable, try { krb5Creds = new sun.security.krb5.Credentials(asn1Encoding, - client.toString(), - server.toString(), + client.getName(), + server.getName(), sessionKey.getEncoded(), sessionKey.getKeyType(), flags, @@ -644,6 +644,11 @@ public class KerberosTicket implements Destroyable, Refreshable, return destroyed; } + /** + * Returns an informative textual representation of this {@code KerberosTicket}. + * + * @return an informative textual representation of this {@code KerberosTicket}. + */ public String toString() { if (destroyed) { return "Destroyed KerberosTicket"; @@ -677,9 +682,9 @@ public class KerberosTicket implements Destroyable, Refreshable, } /** - * Returns a hashcode for this KerberosTicket. + * Returns a hash code for this {@code KerberosTicket}. * - * @return a hashCode() for the {@code KerberosTicket} + * @return a hash code for this {@code KerberosTicket}. * @since 1.6 */ public int hashCode() { @@ -714,15 +719,15 @@ public class KerberosTicket implements Destroyable, Refreshable, } /** - * Compares the specified Object with this KerberosTicket for equality. + * Compares the specified object with this {@code KerberosTicket} for equality. * Returns true if the given object is also a * {@code KerberosTicket} and the two * {@code KerberosTicket} instances are equivalent. + * A destroyed {@code KerberosTicket} object is only equal to itself. * - * @param other the Object to compare to - * @return true if the specified object is equal to this KerberosTicket, - * false otherwise. NOTE: Returns false if either of the KerberosTicket - * objects has been destroyed. + * @param other the object to compare to + * @return true if the specified object is equal to this {@code KerberosTicket}, + * false otherwise. * @since 1.6 */ public boolean equals(Object other) { diff --git a/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KeyTab.java b/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KeyTab.java index db815395e3a..3b636077b08 100644 --- a/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KeyTab.java +++ b/jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos/KeyTab.java @@ -58,10 +58,10 @@ import sun.security.krb5.RealmException; *

    * It might be necessary for the application to be granted a * {@link javax.security.auth.PrivateCredentialPermission - * PrivateCredentialPermission} if it needs to access the KeyTab - * instance from a Subject. This permission is not needed when the + * PrivateCredentialPermission} if it needs to access the {@code KeyTab} + * instance from a {@code Subject}. This permission is not needed when the * application depends on the default JGSS Kerberos mechanism to access the - * KeyTab. In that case, however, the application will need an appropriate + * {@code KeyTab}. In that case, however, the application will need an appropriate * {@link javax.security.auth.kerberos.ServicePermission ServicePermission}. *

    * The keytab file format is described at @@ -249,7 +249,7 @@ public final class KeyTab { * could potentially be expired. *

    * If there is any error (say, I/O error or format error) - * during the reading process of the KeyTab file, a saved result should be + * during the reading process of the keytab file, a saved result should be * returned. If there is no saved result (say, this is the first time this * method is called, or, all previous read attempts failed), an empty array * should be returned. This can make sure the result is not drastically @@ -316,6 +316,11 @@ public final class KeyTab { return !takeSnapshot().isMissing(); } + /** + * Returns an informative textual representation of this {@code KeyTab}. + * + * @return an informative textual representation of this {@code KeyTab}. + */ public String toString() { String s = (file == null) ? "Default keytab" : file.toString(); if (!bound) return s; @@ -324,22 +329,22 @@ public final class KeyTab { } /** - * Returns a hashcode for this KeyTab. + * Returns a hash code for this {@code KeyTab}. * - * @return a hashCode() for the {@code KeyTab} + * @return a hash code for this {@code KeyTab}. */ public int hashCode() { return Objects.hash(file, princ, bound); } /** - * Compares the specified Object with this KeyTab for equality. + * Compares the specified object with this {@code KeyTab} for equality. * Returns true if the given object is also a * {@code KeyTab} and the two * {@code KeyTab} instances are equivalent. * - * @param other the Object to compare to - * @return true if the specified object is equal to this KeyTab + * @param other the object to compare to + * @return true if the specified object is equal to this {@code KeyTab} */ public boolean equals(Object other) { if (other == this) @@ -359,9 +364,9 @@ public final class KeyTab { * Returns the service principal this {@code KeyTab} object * is bound to. Returns {@code null} if it's not bound. *

    - * Please note the deprecated constructors create a KeyTab object bound for - * some unknown principal. In this case, this method also returns null. - * User can call {@link #isBound()} to verify this case. + * Please note the deprecated constructors create a {@code KeyTab} object + * bound for some unknown principal. In this case, this method also returns + * null. User can call {@link #isBound()} to verify this case. * @return the service principal * @since 1.8 */ From 64bb4a891c9480523e1e07879909d19bd0612408 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Wed, 26 Nov 2014 15:15:27 +0100 Subject: [PATCH 52/67] 8065913: Various improvements in SetupNativeCompilation Reviewed-by: erikj --- jdk/make/launcher/Launcher-jdk.runtime.gmk | 2 +- jdk/make/lib/LibCommon.gmk | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/jdk/make/launcher/Launcher-jdk.runtime.gmk b/jdk/make/launcher/Launcher-jdk.runtime.gmk index a8b21fe42e7..af3fc299240 100644 --- a/jdk/make/launcher/Launcher-jdk.runtime.gmk +++ b/jdk/make/launcher/Launcher-jdk.runtime.gmk @@ -77,7 +77,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) EXE_OUT_OPTION := -Fe # With the current way unpack200 is built, debug symbols aren't supported # anyway. - UNPACKEXE_DEBUG_SYMBOLS := + UNPACKEXE_DEBUG_SYMBOLS := false endif # The linker on older SuSE distros (e.g. on SLES 10) complains with: diff --git a/jdk/make/lib/LibCommon.gmk b/jdk/make/lib/LibCommon.gmk index eede8fbd8de..fd6e3428715 100644 --- a/jdk/make/lib/LibCommon.gmk +++ b/jdk/make/lib/LibCommon.gmk @@ -45,15 +45,17 @@ endif # elegant solution to this. WIN_JAVA_LIB := $(JDK_OUTPUTDIR)/objs/libjava/java.lib -# Use this variable to set DEBUG_SYMBOLS true on windows for all libraries, but -# not on other platforms. -ifeq ($(OPENJDK_TARGET_OS), windows) - DEBUG_ALL_BINARIES := true -endif - -# Build everything with debugging on OpenJDK ifdef OPENJDK + # Build everything with debugging on OpenJDK DEBUG_ALL_BINARIES := true +else + # Use this variable to set DEBUG_SYMBOLS true on windows for all libraries, but + # not on other platforms. + ifeq ($(OPENJDK_TARGET_OS), windows) + DEBUG_ALL_BINARIES := true + else + DEBUG_ALL_BINARIES := false + endif endif ################################################################################ From 13f3dfa073c624e5438beefb6041965bbf952314 Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Wed, 26 Nov 2014 11:12:19 -0800 Subject: [PATCH 53/67] 8060026: Update jdk/test/tools/launcher tests to eliminate dependency on sun.tools.jar.Main Reviewed-by: alanb, ksrini, psandoz --- jdk/test/tools/launcher/TestHelper.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/jdk/test/tools/launcher/TestHelper.java b/jdk/test/tools/launcher/TestHelper.java index 40737320d52..840e67ead20 100644 --- a/jdk/test/tools/launcher/TestHelper.java +++ b/jdk/test/tools/launcher/TestHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, 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 @@ -50,6 +50,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Arrays; import javax.tools.JavaCompiler; import javax.tools.ToolProvider; @@ -333,15 +334,10 @@ public class TestHelper { } static void createJar(String... args) { - sun.tools.jar.Main jarTool = - new sun.tools.jar.Main(System.out, System.err, "JarCreator"); - if (!jarTool.run(args)) { - String message = "jar creation failed with command:"; - for (String x : args) { - message = message.concat(" " + x); - } - throw new RuntimeException(message); - } + List cmdList = new ArrayList<>(); + cmdList.add(jarCmd); + cmdList.addAll(Arrays.asList(args)); + doExec(cmdList.toArray(new String[cmdList.size()])); } static void copyStream(InputStream in, OutputStream out) throws IOException { From 6026dc63ea960a00d9c9ad85f513613b9b39ddf4 Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Wed, 26 Nov 2014 20:10:48 +0100 Subject: [PATCH 54/67] 8065748: Add a test to verify that non ascii characters in Encodings.properties do not cause issues Reviewed-by: joehw --- .../jaxp/Encodings/CheckEncodingPropertiesFile.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/jdk/test/javax/xml/jaxp/Encodings/CheckEncodingPropertiesFile.java b/jdk/test/javax/xml/jaxp/Encodings/CheckEncodingPropertiesFile.java index e8f03021e08..88e9648f066 100644 --- a/jdk/test/javax/xml/jaxp/Encodings/CheckEncodingPropertiesFile.java +++ b/jdk/test/javax/xml/jaxp/Encodings/CheckEncodingPropertiesFile.java @@ -23,7 +23,7 @@ /** * @test - * @bug 8008738 + * @bug 8008738 8065138 * @summary checks that the mapping implemented by * com.sun.org.apache.xml.internal.serializer.Encodings * correctly identifies valid Charset names and @@ -64,6 +64,15 @@ public class CheckEncodingPropertiesFile { props.load(is); } + if (!props.containsKey("UTF8")) { + // If the test fails here - it may indicate that you stumbled on an + // issue similar to that fixed by JDK-8065138. + // Check that the content of the Encodings.properties included in + // the tested build image matches the content of the file in the source + // jaxp tree of the jdk forest. + throw new RuntimeException("UTF8 key missing in " + ClassLoader.getSystemResource(ENCODINGS_FILE)); + } + //printAllCharsets(); test(props); From f0b198804a1665117404295f0c5a2839d9766758 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Fri, 28 Nov 2014 14:58:10 +0000 Subject: [PATCH 55/67] 8062955: (fs spec) Files.setLastModifiedTime should specify SecurityException more clearly 8062949: (fs) Files.setLastModifiedTime(path, null) does not throw NPE Reviewed-by: chegar --- .../share/classes/java/nio/file/Files.java | 16 +-- .../java/nio/file/Files/FileAttributes.java | 6 - .../nio/file/Files/SetLastModifiedTime.java | 118 ++++++++++++++++++ 3 files changed, 126 insertions(+), 14 deletions(-) create mode 100644 jdk/test/java/nio/file/Files/SetLastModifiedTime.java diff --git a/jdk/src/java.base/share/classes/java/nio/file/Files.java b/jdk/src/java.base/share/classes/java/nio/file/Files.java index 18ef214e9a0..4d0119393b6 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/Files.java +++ b/jdk/src/java.base/share/classes/java/nio/file/Files.java @@ -1778,7 +1778,7 @@ public final class Files { * @param options * options indicating how symbolic links are handled * - * @return the {@code path} parameter + * @return the given path * * @throws UnsupportedOperationException * if the attribute view is not available @@ -2019,7 +2019,7 @@ public final class Files { * @param perms * The new set of permissions * - * @return The path + * @return The given path * * @throws UnsupportedOperationException * if the associated file system does not support the {@code @@ -2102,7 +2102,7 @@ public final class Files { * @param owner * The new file owner * - * @return The path + * @return The given path * * @throws UnsupportedOperationException * if the associated file system does not support the {@code @@ -2289,14 +2289,14 @@ public final class Files { * @param time * the new last modified time * - * @return the path + * @return the given path * * @throws IOException * if an I/O error occurs * @throws SecurityException - * In the case of the default provider, the security manager's {@link - * SecurityManager#checkWrite(String) checkWrite} method is invoked - * to check write access to file + * In the case of the default provider, and a security manager is + * installed, its {@link SecurityManager#checkWrite(String) + * checkWrite} method denies write access to the file. * * @see BasicFileAttributeView#setTimes */ @@ -2304,7 +2304,7 @@ public final class Files { throws IOException { getFileAttributeView(path, BasicFileAttributeView.class) - .setTimes(time, null, null); + .setTimes(Objects.requireNonNull(time), null, null); return path; } diff --git a/jdk/test/java/nio/file/Files/FileAttributes.java b/jdk/test/java/nio/file/Files/FileAttributes.java index 8b179f8efeb..a993b81e149 100644 --- a/jdk/test/java/nio/file/Files/FileAttributes.java +++ b/jdk/test/java/nio/file/Files/FileAttributes.java @@ -52,12 +52,6 @@ public class FileAttributes { } } - // checks that two time values are within 1s of each other - static void checkNearEqual(FileTime t1, FileTime t2) { - long diff = Math.abs(t1.toMillis() - t2.toMillis()); - assertTrue(diff <= 1000); - } - // Exercise getAttribute/setAttribute/readAttributes on basic attributes static void checkBasicAttributes(Path file, BasicFileAttributes attrs) throws IOException diff --git a/jdk/test/java/nio/file/Files/SetLastModifiedTime.java b/jdk/test/java/nio/file/Files/SetLastModifiedTime.java new file mode 100644 index 00000000000..ef8cfaa0cec --- /dev/null +++ b/jdk/test/java/nio/file/Files/SetLastModifiedTime.java @@ -0,0 +1,118 @@ +/* + * 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.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.attribute.FileTime; + +import org.testng.annotations.Test; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.assertFalse; + +/** + * @test + * @bug 4313887 8062949 + * @library .. + * @run testng SetLastModifiedTime + * @summary Unit test for Files.setLastModifiedTime + */ + +public class SetLastModifiedTime { + + static Path testDir; + + @BeforeClass + void createTestDirectory() throws Exception { + testDir = TestUtil.createTemporaryDirectory(); + } + + @AfterClass + void removeTestDirectory() throws Exception { + TestUtil.removeAll(testDir); + } + + /** + * Exercise Files.setLastModifiedTime on the given file + */ + void test(Path path) throws Exception { + FileTime now = Files.getLastModifiedTime(path); + FileTime zero = FileTime.fromMillis(0L); + + Path result = Files.setLastModifiedTime(path, zero); + assertTrue(result == path); + assertEquals(Files.getLastModifiedTime(path), zero); + + result = Files.setLastModifiedTime(path, now); + assertTrue(result == path); + assertEquals(Files.getLastModifiedTime(path), now); + } + + @Test + public void testRegularFile() throws Exception { + Path file = Files.createFile(testDir.resolve("file")); + test(file); + } + + @Test + public void testDirectory() throws Exception { + Path dir = Files.createDirectory(testDir.resolve("dir")); + test(dir); + } + + @Test + public void testSymbolicLink() throws Exception { + if (TestUtil.supportsLinks(testDir)) { + Path target = Files.createFile(testDir.resolve("target")); + Path link = testDir.resolve("link"); + Files.createSymbolicLink(link, target); + test(link); + } + } + + @Test + public void testNulls() throws Exception { + Path path = Paths.get("foo"); + FileTime zero = FileTime.fromMillis(0L); + + try { + Files.setLastModifiedTime(null, zero); + assertTrue(false); + } catch (NullPointerException expected) { } + + try { + Files.setLastModifiedTime(path, null); + assertTrue(false); + } catch (NullPointerException expected) { } + + try { + Files.setLastModifiedTime(null, null); + assertTrue(false); + } catch (NullPointerException expected) { } + } +} + From db7c757726dddbb4342b2f2969f0b4cca12eabf6 Mon Sep 17 00:00:00 2001 From: Lance Andersen Date: Sat, 29 Nov 2014 11:14:20 -0500 Subject: [PATCH 56/67] 8066188: BaseRowSet default value for escape processing is not correct Reviewed-by: alanb --- .../share/classes/javax/sql/rowset/BaseRowSet.java | 2 +- jdk/test/javax/sql/testng/test/rowset/BaseRowSetTests.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.sql.rowset/share/classes/javax/sql/rowset/BaseRowSet.java b/jdk/src/java.sql.rowset/share/classes/javax/sql/rowset/BaseRowSet.java index 2998715e3c8..7f65c0eed9c 100644 --- a/jdk/src/java.sql.rowset/share/classes/javax/sql/rowset/BaseRowSet.java +++ b/jdk/src/java.sql.rowset/share/classes/javax/sql/rowset/BaseRowSet.java @@ -462,7 +462,7 @@ public abstract class BaseRowSet implements Serializable, Cloneable { * false that it is not. The default is true. * @serial */ - private boolean escapeProcessing; + private boolean escapeProcessing = true; /** * A constant indicating the isolation level of the connection diff --git a/jdk/test/javax/sql/testng/test/rowset/BaseRowSetTests.java b/jdk/test/javax/sql/testng/test/rowset/BaseRowSetTests.java index e1b5457bda8..8e92f20af33 100644 --- a/jdk/test/javax/sql/testng/test/rowset/BaseRowSetTests.java +++ b/jdk/test/javax/sql/testng/test/rowset/BaseRowSetTests.java @@ -186,11 +186,11 @@ public class BaseRowSetTests extends BaseTest { } /* - * Validate that getEscapeProcessing() returns false by default + * Validate that getEscapeProcessing() returns true by default */ @Test public void test08() throws Exception { - assertFalse(brs.getEscapeProcessing()); + assertTrue(brs.getEscapeProcessing()); } /* From 14ee08928760e5d97c574e746775d28c0ae552cb Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Mon, 1 Dec 2014 13:44:57 +0000 Subject: [PATCH 57/67] 8066196: (fs) Typo in Path::normalize, empty path only returned if path does not have a root component Reviewed-by: dfuchs --- jdk/src/java.base/share/classes/java/nio/file/Path.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/classes/java/nio/file/Path.java b/jdk/src/java.base/share/classes/java/nio/file/Path.java index daa09f4cf87..9df57c120e0 100644 --- a/jdk/src/java.base/share/classes/java/nio/file/Path.java +++ b/jdk/src/java.base/share/classes/java/nio/file/Path.java @@ -325,7 +325,7 @@ public interface Path * * @return the resulting path or this path if it does not contain * redundant name elements; an empty path is returned if this path - * does have a root component and all name elements are redundant + * does not have a root component and all name elements are redundant * * @see #getParent * @see #toRealPath From 5f72abe97e68570cff5d58fe52b4efc3d38fa250 Mon Sep 17 00:00:00 2001 From: Lance Andersen Date: Mon, 1 Dec 2014 11:34:44 -0500 Subject: [PATCH 58/67] 8066261: Typo in Connection.isValid Reviewed-by: dfuchs --- jdk/src/java.sql/share/classes/java/sql/Connection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.sql/share/classes/java/sql/Connection.java b/jdk/src/java.sql/share/classes/java/sql/Connection.java index ac73fde29dd..ac5d3158b6e 100644 --- a/jdk/src/java.sql/share/classes/java/sql/Connection.java +++ b/jdk/src/java.sql/share/classes/java/sql/Connection.java @@ -1116,7 +1116,7 @@ public interface Connection extends Wrapper, AutoCloseable { * * @return true if the connection is valid, false otherwise * @exception SQLException if the value supplied for timeout - * is less then 0 + * is less than 0 * @since 1.6 * * @see java.sql.DatabaseMetaData#getClientInfoProperties From 392436eade0b7eef17305e45fd3de51128883bd8 Mon Sep 17 00:00:00 2001 From: Mark Sheppard Date: Mon, 1 Dec 2014 17:20:06 +0000 Subject: [PATCH 59/67] 8066130: com.sun.net.httpserver stop() throws NullPointerException if it is not started Added null check on dispatcherThread variable in stop method Reviewed-by: chegar --- .../sun/net/httpserver/ServerImpl.java | 12 +++--- .../sun/net/httpserver/StopNoStartTest.java | 42 +++++++++++++++++++ 2 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 jdk/test/com/sun/net/httpserver/StopNoStartTest.java diff --git a/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java b/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java index 5952c79ee87..24ab8b014db 100644 --- a/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java +++ b/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java @@ -206,11 +206,13 @@ class ServerImpl implements TimeSource { if (timer1Enabled) { timer1.cancel(); } - try { - dispatcherThread.join(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - logger.log(Level.FINER, "ServerImpl.stop: ", e); + if (dispatcherThread != null) { + try { + dispatcherThread.join(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + logger.log(Level.FINER, "ServerImpl.stop: ", e); + } } } diff --git a/jdk/test/com/sun/net/httpserver/StopNoStartTest.java b/jdk/test/com/sun/net/httpserver/StopNoStartTest.java new file mode 100644 index 00000000000..c10d767e7d7 --- /dev/null +++ b/jdk/test/com/sun/net/httpserver/StopNoStartTest.java @@ -0,0 +1,42 @@ +/* + * 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 8066130 + * @summary Test HttpServer stop method invocation before a start has been called + */ + +import java.net.InetSocketAddress; +import com.sun.net.httpserver.HttpServer; + + +public class StopNoStartTest { + + public static void main(String[] args) throws Exception { + + InetSocketAddress serverAddr = new InetSocketAddress(0); + HttpServer server = HttpServer.create(serverAddr, 0); + server.stop(0); + } +} From 3e1d5786af201705d46af49159e3e74808e7dca9 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Mon, 1 Dec 2014 21:56:54 +0300 Subject: [PATCH 60/67] 8066191: Introduce time limited test executor Reviewed-by: vlivanov, psandoz --- .../jdk/testlibrary/TimeLimitedRunner.java | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 jdk/test/lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java b/jdk/test/lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java new file mode 100644 index 00000000000..5cc98ea8f8a --- /dev/null +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.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 jdk.testlibrary; + +import java.util.Objects; +import java.util.concurrent.Callable; + +/** + * Auxiliary class to run target w/ given timeout. + */ +public class TimeLimitedRunner implements Callable { + private final long stoptime; + private final long timeout; + private final double factor; + private final Callable target; + + /** + * @param timeout a timeout. zero means no time limitation + * @param factor a multiplier used to estimate next iteration time + * @param target a target to run + * @throws NullPointerException if target is null + * @throws IllegalArgumentException if timeout is negative or + factor isn't positive + */ + public TimeLimitedRunner(long timeout, double factor, + Callable target) { + Objects.requireNonNull(target, "target must not be null"); + if (timeout < 0) { + throw new IllegalArgumentException("timeout[" + timeout + "] < 0"); + } + if (factor <= 0d) { + throw new IllegalArgumentException("factor[" + factor + "] <= 0"); + } + this.stoptime = System.currentTimeMillis() + timeout; + this.timeout = timeout; + this.factor = factor; + this.target = target; + } + + /** + * Runs @{linkplan target} while it returns true and timeout isn't exceeded + */ + @Override + public Void call() throws Exception { + long maxDuration = 0L; + long iterStart = System.currentTimeMillis(); + if (timeout != 0 && iterStart > stoptime) { + return null; + } + while (target.call()) { + if (timeout != 0) { + long iterDuration = System.currentTimeMillis() - iterStart; + maxDuration = Math.max(maxDuration, iterDuration); + iterStart = System.currentTimeMillis(); + if (iterStart + (maxDuration * factor) > stoptime) { + System.out.println("Not enough time to continue execution. " + + "Interrupted."); + break; + } + } + } + return null; + } + +} From 7abe24d3ea017b431113c5a709f976519f7492c3 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Mon, 1 Dec 2014 21:58:46 +0300 Subject: [PATCH 61/67] 8039953: [TESTBUG] Timeout java/lang/invoke/MethodHandles/CatchExceptionTest.java Reviewed-by: vlivanov, psandoz --- .../MethodHandles/CatchExceptionTest.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/jdk/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java b/jdk/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java index 52c41dfd991..996ed526413 100644 --- a/jdk/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java +++ b/jdk/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java @@ -24,6 +24,8 @@ package test.java.lang.invoke.MethodHandles; import com.oracle.testlibrary.jsr292.Helper; import jdk.testlibrary.Asserts; +import jdk.testlibrary.TimeLimitedRunner; +import jdk.testlibrary.Utils; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -33,6 +35,7 @@ import java.util.*; import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Supplier; +import java.util.concurrent.TimeUnit; /* @test * @library /lib/testlibrary/jsr292 /lib/testlibrary/ @@ -93,14 +96,23 @@ public class CatchExceptionTest { } public static void main(String[] args) throws Throwable { + TestFactory factory = new TestFactory(); + long timeout = Helper.IS_THOROUGH ? 0L : Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT); + // substract vm init time and reserve time for vm exit + timeout *= 0.9; + TimeLimitedRunner runner = new TimeLimitedRunner(timeout, 2.0d, + () -> { + CatchExceptionTest test = factory.nextTest(); + if (test != null) { + test.runTest(); + return true; + } + return false; + }); for (CatchExceptionTest test : TestFactory.MANDATORY_TEST_CASES) { test.runTest(); } - TestFactory factory = new TestFactory(); - CatchExceptionTest test; - while ((test = factory.nextTest()) != null ) { - test.runTest(); - } + runner.call(); } private List> getThrowerParams(boolean isVararg, int argsCount) { From 3034f050f9c6a5d381c66b728796d42b9b9f127a Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Mon, 1 Dec 2014 21:02:21 +0100 Subject: [PATCH 62/67] 8065552: setAccessible(true) on fields of Class may throw a SecurityException This fix hides the new private Class.classLoader field from reflection, rather than making it not accessible. Reviewed-by: mchung, coffeys --- .../share/classes/java/lang/Class.java | 2 + .../java/lang/reflect/AccessibleObject.java | 7 - .../share/classes/sun/reflect/Reflection.java | 1 + .../ClassDeclaredFieldsTest.java | 205 ++++++++++++++++++ 4 files changed, 208 insertions(+), 7 deletions(-) create mode 100644 jdk/test/java/lang/Class/getDeclaredField/ClassDeclaredFieldsTest.java diff --git a/jdk/src/java.base/share/classes/java/lang/Class.java b/jdk/src/java.base/share/classes/java/lang/Class.java index ee24402ec8d..25ed5c47fec 100644 --- a/jdk/src/java.base/share/classes/java/lang/Class.java +++ b/jdk/src/java.base/share/classes/java/lang/Class.java @@ -691,6 +691,8 @@ public final class Class implements java.io.Serializable, ClassLoader getClassLoader0() { return classLoader; } // Initialized in JVM not by private constructor + // This field is filtered from reflection access, i.e. getDeclaredField + // will throw NoSuchFieldException private final ClassLoader classLoader; /** diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java b/jdk/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java index 01a074f36e0..65755f09826 100644 --- a/jdk/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java +++ b/jdk/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java @@ -140,13 +140,6 @@ public class AccessibleObject implements AnnotatedElement { throw new SecurityException("Cannot make a java.lang.Class" + " constructor accessible"); } - } else if (obj instanceof Field && flag == true) { - Field f = (Field)obj; - if (f.getDeclaringClass() == Class.class && - f.getName().equals("classLoader")) { - throw new SecurityException("Cannot make java.lang.Class.classLoader" + - " accessible"); - } } obj.override = flag; } diff --git a/jdk/src/java.base/share/classes/sun/reflect/Reflection.java b/jdk/src/java.base/share/classes/sun/reflect/Reflection.java index 63baa42abae..bc3e13e23cb 100644 --- a/jdk/src/java.base/share/classes/sun/reflect/Reflection.java +++ b/jdk/src/java.base/share/classes/sun/reflect/Reflection.java @@ -46,6 +46,7 @@ public class Reflection { map.put(Reflection.class, new String[] {"fieldFilterMap", "methodFilterMap"}); map.put(System.class, new String[] {"security"}); + map.put(Class.class, new String[] {"classLoader"}); fieldFilterMap = map; methodFilterMap = new HashMap<>(); diff --git a/jdk/test/java/lang/Class/getDeclaredField/ClassDeclaredFieldsTest.java b/jdk/test/java/lang/Class/getDeclaredField/ClassDeclaredFieldsTest.java new file mode 100644 index 00000000000..c05e1790d59 --- /dev/null +++ b/jdk/test/java/lang/Class/getDeclaredField/ClassDeclaredFieldsTest.java @@ -0,0 +1,205 @@ +/* + * 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.lang.reflect.ReflectPermission; +import java.security.CodeSource; +import java.security.Permission; +import java.security.PermissionCollection; +import java.security.Permissions; +import java.security.Policy; +import java.security.ProtectionDomain; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.concurrent.atomic.AtomicBoolean; + +/** + * @test + * @bug 8065552 + * @summary test that all fields returned by getDeclaredFields() can be + * set accessible if the right permission is granted; this test + * also verifies that Class.classLoader final private field is + * hidden from reflection access. + * @run main/othervm ClassDeclaredFieldsTest UNSECURE + * @run main/othervm ClassDeclaredFieldsTest SECURE + * + * @author danielfuchs + */ +public class ClassDeclaredFieldsTest { + + // Test with or without a security manager + public static enum TestCase { + UNSECURE, SECURE; + public void run() throws Exception { + System.out.println("Running test case: " + name()); + Configure.setUp(this); + test(this); + } + } + /** + * @param args the command line arguments + */ + public static void main(String[] args) throws Exception { + System.out.println(System.getProperty("java.version")); + if (args == null || args.length == 0) { + args = new String[] { "SECURE" }; + } else if (args.length != 1) { + throw new IllegalArgumentException("Only one arg expected: " + + Arrays.asList(args)); + } + TestCase.valueOf(args[0]).run(); + } + + static void test(TestCase test) { + for (Field f : Class.class.getDeclaredFields()) { + f.setAccessible(true); + System.out.println("Field "+f.getName()+" is now accessible."); + if (f.getName().equals("classLoader")) { + throw new RuntimeException("Found "+f.getName()+" field!"); + } + } + try { + Class.class.getDeclaredField("classLoader"); + throw new RuntimeException("Expected NoSuchFieldException for" + + " 'classLoader' field not raised"); + } catch(NoSuchFieldException x) { + System.out.println("Got expected exception: " + x); + } + System.out.println("Passed "+test); + } + + // A helper class to configure the security manager for the test, + // and bypass it when needed. + static class Configure { + static Policy policy = null; + static final ThreadLocal allowAll = new ThreadLocal() { + @Override + protected AtomicBoolean initialValue() { + return new AtomicBoolean(false); + } + }; + static void setUp(TestCase test) { + switch (test) { + case SECURE: + if (policy == null && System.getSecurityManager() != null) { + throw new IllegalStateException("SecurityManager already set"); + } else if (policy == null) { + policy = new SimplePolicy(TestCase.SECURE, allowAll); + Policy.setPolicy(policy); + System.setSecurityManager(new SecurityManager()); + } + if (System.getSecurityManager() == null) { + throw new IllegalStateException("No SecurityManager."); + } + if (policy == null) { + throw new IllegalStateException("policy not configured"); + } + break; + case UNSECURE: + if (System.getSecurityManager() != null) { + throw new IllegalStateException("SecurityManager already set"); + } + break; + default: + throw new InternalError("No such testcase: " + test); + } + } + static void doPrivileged(Runnable run) { + allowAll.get().set(true); + try { + run.run(); + } finally { + allowAll.get().set(false); + } + } + } + + // A Helper class to build a set of permissions. + final static class PermissionsBuilder { + final Permissions perms; + public PermissionsBuilder() { + this(new Permissions()); + } + public PermissionsBuilder(Permissions perms) { + this.perms = perms; + } + public PermissionsBuilder add(Permission p) { + perms.add(p); + return this; + } + public PermissionsBuilder addAll(PermissionCollection col) { + if (col != null) { + for (Enumeration e = col.elements(); e.hasMoreElements(); ) { + perms.add(e.nextElement()); + } + } + return this; + } + public Permissions toPermissions() { + final PermissionsBuilder builder = new PermissionsBuilder(); + builder.addAll(perms); + return builder.perms; + } + } + + // Policy for the test... + public static class SimplePolicy extends Policy { + + final Permissions permissions; + final Permissions allPermissions; + final ThreadLocal allowAll; // actually: this should be in a thread locale + public SimplePolicy(TestCase test, ThreadLocal allowAll) { + this.allowAll = allowAll; + // we don't actually need any permission to create our + // FileHandlers because we're passing invalid parameters + // which will make the creation fail... + permissions = new Permissions(); + permissions.add(new RuntimePermission("accessDeclaredMembers")); + permissions.add(new ReflectPermission("suppressAccessChecks")); + + // these are used for configuring the test itself... + allPermissions = new Permissions(); + allPermissions.add(new java.security.AllPermission()); + + } + + @Override + public boolean implies(ProtectionDomain domain, Permission permission) { + if (allowAll.get().get()) return allPermissions.implies(permission); + return permissions.implies(permission); + } + + @Override + public PermissionCollection getPermissions(CodeSource codesource) { + return new PermissionsBuilder().addAll(allowAll.get().get() + ? allPermissions : permissions).toPermissions(); + } + + @Override + public PermissionCollection getPermissions(ProtectionDomain domain) { + return new PermissionsBuilder().addAll(allowAll.get().get() + ? allPermissions : permissions).toPermissions(); + } + } + +} From 2f9a2c3c320a4413ad843f0c505a75c5792ad249 Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Mon, 1 Dec 2014 17:59:39 -0800 Subject: [PATCH 63/67] 8035000: clean up ActivationLibrary.DestroyThread Reviewed-by: lancea --- .../checkActivateRef/CheckActivateRef.java | 4 +- .../checkAnnotations/CheckAnnotations.java | 4 +- .../CheckImplClassLoader.java | 4 +- .../CheckRegisterInLog.java | 4 +- .../CreatePrivateActivatable.java | 4 +- .../DownloadParameterClass.java | 4 +- .../ElucidateNoSuchMethod.java | 4 +- .../extLoadedImpl/ExtLoadedImplTest.java | 4 +- .../forceLogSnapshot/ForceLogSnapshot.java | 4 +- .../inactiveGroup/InactiveGroup.java | 4 +- .../LookupActivationSystem.java | 4 +- .../nestedActivate/NestedActivate.java | 4 +- .../NonExistentActivatable.java | 4 +- .../RestartCrashedService.java | 4 +- .../restartLatecomer/RestartLatecomer.java | 4 +- .../restartService/RestartService.java | 4 +- .../UnregisterInactive.java | 4 +- .../activateFails/ActivateFails.java | 4 +- .../DownloadActivationGroup.java | 4 +- .../activeGroup/IdempotentActiveGroup.java | 4 +- .../modifyDescriptor/ModifyDescriptor.java | 4 +- .../StubClassesPermitted.java | 4 +- .../unregisterGroup/UnregisterGroup.java | 4 +- .../CommandEnvironment/SetChildEnv.java | 4 +- .../InheritedChannelNotServerSocket.java | 4 +- .../RmidViaInheritedChannel.java | 4 +- .../AltSecurityManager.java | 7 - .../activatable/UseCustomSocketFactory.java | 4 +- .../rmi/testlibrary/ActivationLibrary.java | 64 ------ jdk/test/java/rmi/testlibrary/RMID.java | 216 +++++++++--------- 30 files changed, 160 insertions(+), 235 deletions(-) diff --git a/jdk/test/java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java b/jdk/test/java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java index dcd5990db63..f37fdec54dc 100644 --- a/jdk/test/java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java +++ b/jdk/test/java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, 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 @@ -262,7 +262,7 @@ public class CheckActivateRef e.getClass().getName(), e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); obj = null; } } diff --git a/jdk/test/java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java b/jdk/test/java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java index d2a0bab342c..126fae1e521 100644 --- a/jdk/test/java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java +++ b/jdk/test/java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, 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 @@ -130,7 +130,7 @@ public class CheckAnnotations myRMI = null; System.err.println("rmid shut down"); - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } diff --git a/jdk/test/java/rmi/activation/Activatable/checkImplClassLoader/CheckImplClassLoader.java b/jdk/test/java/rmi/activation/Activatable/checkImplClassLoader/CheckImplClassLoader.java index 556e2895ca9..dc54f82459b 100644 --- a/jdk/test/java/rmi/activation/Activatable/checkImplClassLoader/CheckImplClassLoader.java +++ b/jdk/test/java/rmi/activation/Activatable/checkImplClassLoader/CheckImplClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, 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 @@ -112,7 +112,7 @@ public class CheckImplClassLoader { myRMI = null; System.err.println("rmid shut down"); - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); TestLibrary.unexport(group); } } diff --git a/jdk/test/java/rmi/activation/Activatable/checkRegisterInLog/CheckRegisterInLog.java b/jdk/test/java/rmi/activation/Activatable/checkRegisterInLog/CheckRegisterInLog.java index c294a972d36..0d03562346c 100644 --- a/jdk/test/java/rmi/activation/Activatable/checkRegisterInLog/CheckRegisterInLog.java +++ b/jdk/test/java/rmi/activation/Activatable/checkRegisterInLog/CheckRegisterInLog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, 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 @@ -164,7 +164,7 @@ public class CheckRegisterInLog throw new RuntimeException("CheckRegisterInLog got exception " + e.getMessage()); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/Activatable/createPrivateActivable/CreatePrivateActivatable.java b/jdk/test/java/rmi/activation/Activatable/createPrivateActivable/CreatePrivateActivatable.java index 2900e80964a..414527dfa4b 100644 --- a/jdk/test/java/rmi/activation/Activatable/createPrivateActivable/CreatePrivateActivatable.java +++ b/jdk/test/java/rmi/activation/Activatable/createPrivateActivable/CreatePrivateActivatable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -155,7 +155,7 @@ public class CreatePrivateActivatable e.getClass().getName(), e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); obj = null; } } diff --git a/jdk/test/java/rmi/activation/Activatable/downloadParameterClass/DownloadParameterClass.java b/jdk/test/java/rmi/activation/Activatable/downloadParameterClass/DownloadParameterClass.java index 64f11681341..9f236978a4a 100644 --- a/jdk/test/java/rmi/activation/Activatable/downloadParameterClass/DownloadParameterClass.java +++ b/jdk/test/java/rmi/activation/Activatable/downloadParameterClass/DownloadParameterClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, 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 @@ -138,7 +138,7 @@ public class DownloadParameterClass { } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/Activatable/elucidateNoSuchMethod/ElucidateNoSuchMethod.java b/jdk/test/java/rmi/activation/Activatable/elucidateNoSuchMethod/ElucidateNoSuchMethod.java index 29482121ffb..0e0efb52cd5 100644 --- a/jdk/test/java/rmi/activation/Activatable/elucidateNoSuchMethod/ElucidateNoSuchMethod.java +++ b/jdk/test/java/rmi/activation/Activatable/elucidateNoSuchMethod/ElucidateNoSuchMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, 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 @@ -135,7 +135,7 @@ public class ElucidateNoSuchMethod } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ExtLoadedImplTest.java b/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ExtLoadedImplTest.java index 3fd009b611a..c46baeaf5e7 100644 --- a/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ExtLoadedImplTest.java +++ b/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ExtLoadedImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -69,7 +69,7 @@ public class ExtLoadedImplTest { } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/Activatable/forceLogSnapshot/ForceLogSnapshot.java b/jdk/test/java/rmi/activation/Activatable/forceLogSnapshot/ForceLogSnapshot.java index abbaadfb9f3..55ff0cfd14e 100644 --- a/jdk/test/java/rmi/activation/Activatable/forceLogSnapshot/ForceLogSnapshot.java +++ b/jdk/test/java/rmi/activation/Activatable/forceLogSnapshot/ForceLogSnapshot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, 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 @@ -248,7 +248,7 @@ public class ForceLogSnapshot } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); for (int i = 0 ; i < HOW_MANY ; i ++) { TestLibrary.unexport(unicastObjs[i]); } diff --git a/jdk/test/java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java b/jdk/test/java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java index ad0b14e421a..145e6109df8 100644 --- a/jdk/test/java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java +++ b/jdk/test/java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, 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 @@ -176,7 +176,7 @@ public class InactiveGroup } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/Activatable/lookupActivationSystem/LookupActivationSystem.java b/jdk/test/java/rmi/activation/Activatable/lookupActivationSystem/LookupActivationSystem.java index ce154c4ca99..df778dc8e91 100644 --- a/jdk/test/java/rmi/activation/Activatable/lookupActivationSystem/LookupActivationSystem.java +++ b/jdk/test/java/rmi/activation/Activatable/lookupActivationSystem/LookupActivationSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -118,7 +118,7 @@ public class LookupActivationSystem implements Remote, Serializable { } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/Activatable/nestedActivate/NestedActivate.java b/jdk/test/java/rmi/activation/Activatable/nestedActivate/NestedActivate.java index 48e3e2d701e..507912e90b5 100644 --- a/jdk/test/java/rmi/activation/Activatable/nestedActivate/NestedActivate.java +++ b/jdk/test/java/rmi/activation/Activatable/nestedActivate/NestedActivate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, 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 @@ -165,7 +165,7 @@ public class NestedActivate } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/Activatable/nonExistentActivatable/NonExistentActivatable.java b/jdk/test/java/rmi/activation/Activatable/nonExistentActivatable/NonExistentActivatable.java index 47ddd176ef8..df8ddbef82c 100644 --- a/jdk/test/java/rmi/activation/Activatable/nonExistentActivatable/NonExistentActivatable.java +++ b/jdk/test/java/rmi/activation/Activatable/nonExistentActivatable/NonExistentActivatable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, 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 @@ -139,7 +139,7 @@ public class NonExistentActivatable } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/Activatable/restartCrashedService/RestartCrashedService.java b/jdk/test/java/rmi/activation/Activatable/restartCrashedService/RestartCrashedService.java index 5700f3d72f2..c3026b02c93 100644 --- a/jdk/test/java/rmi/activation/Activatable/restartCrashedService/RestartCrashedService.java +++ b/jdk/test/java/rmi/activation/Activatable/restartCrashedService/RestartCrashedService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, 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 @@ -231,7 +231,7 @@ public class RestartCrashedService } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); TestLibrary.unexport(unicastObj); } } diff --git a/jdk/test/java/rmi/activation/Activatable/restartLatecomer/RestartLatecomer.java b/jdk/test/java/rmi/activation/Activatable/restartLatecomer/RestartLatecomer.java index 747eee68f3a..3bbe8a60c44 100644 --- a/jdk/test/java/rmi/activation/Activatable/restartLatecomer/RestartLatecomer.java +++ b/jdk/test/java/rmi/activation/Activatable/restartLatecomer/RestartLatecomer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -247,7 +247,7 @@ public class RestartLatecomer } catch (Exception e) { TestLibrary.bomb(e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); TestLibrary.unexport(callbackObj); } } diff --git a/jdk/test/java/rmi/activation/Activatable/restartService/RestartService.java b/jdk/test/java/rmi/activation/Activatable/restartService/RestartService.java index e1f2eb554ee..468f5b239f1 100644 --- a/jdk/test/java/rmi/activation/Activatable/restartService/RestartService.java +++ b/jdk/test/java/rmi/activation/Activatable/restartService/RestartService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, 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 @@ -221,7 +221,7 @@ public class RestartService } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); TestLibrary.unexport(unicastObj); } } diff --git a/jdk/test/java/rmi/activation/Activatable/unregisterInactive/UnregisterInactive.java b/jdk/test/java/rmi/activation/Activatable/unregisterInactive/UnregisterInactive.java index 455efd7d7f6..085120b159d 100644 --- a/jdk/test/java/rmi/activation/Activatable/unregisterInactive/UnregisterInactive.java +++ b/jdk/test/java/rmi/activation/Activatable/unregisterInactive/UnregisterInactive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, 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 @@ -125,7 +125,7 @@ public class UnregisterInactive } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ActivateFails.java b/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ActivateFails.java index 6a2eba05864..6d9ccceb141 100644 --- a/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ActivateFails.java +++ b/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ActivateFails.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, 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 @@ -163,7 +163,7 @@ public class ActivateFails } finally { obj1 = obj2 = null; - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java b/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java index f9aed42021d..2f025cf25b8 100644 --- a/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java +++ b/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -156,7 +156,7 @@ public class DownloadActivationGroup } catch (Exception e) { TestLibrary.bomb(e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java b/jdk/test/java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java index f6c08178eec..058d3c7e2d9 100644 --- a/jdk/test/java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java +++ b/jdk/test/java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -108,7 +108,7 @@ public class IdempotentActiveGroup { } catch (NoSuchObjectException unexpected) { throw new AssertionError(unexpected); } - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } diff --git a/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java b/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java index ba376d1a8d9..53ff030e393 100644 --- a/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java +++ b/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, 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 @@ -250,7 +250,7 @@ public class ModifyDescriptor } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java b/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java index b7890e0ebe7..f4970da26ad 100644 --- a/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java +++ b/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -171,7 +171,7 @@ public class StubClassesPermitted } canCreateStubs = null; - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); System.err.println("rmid shut down"); } } diff --git a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java index bc5976b74fe..94976dc0c6f 100644 --- a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java +++ b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, 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 @@ -156,7 +156,7 @@ public class UnregisterGroup extends Activatable implements ActivateMe } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/CommandEnvironment/SetChildEnv.java b/jdk/test/java/rmi/activation/CommandEnvironment/SetChildEnv.java index 7b1a9688ad4..69274a0a797 100644 --- a/jdk/test/java/rmi/activation/CommandEnvironment/SetChildEnv.java +++ b/jdk/test/java/rmi/activation/CommandEnvironment/SetChildEnv.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, 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 @@ -203,7 +203,7 @@ public class SetChildEnv actsys.unregisterGroup(gid); Thread.sleep(5000); - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } public static class DebugExecWatcher diff --git a/jdk/test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java b/jdk/test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java index 4611a83bda5..d375fc84611 100644 --- a/jdk/test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java +++ b/jdk/test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -121,7 +121,7 @@ public class InheritedChannelNotServerSocket { if (obj != null) { UnicastRemoteObject.unexportObject(obj, true); } - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } diff --git a/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java b/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java index 6d81b0f1248..1f3cd6603d5 100644 --- a/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java +++ b/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -119,7 +119,7 @@ public class RmidViaInheritedChannel implements Callback { if (obj != null) { UnicastRemoteObject.unexportObject(obj, true); } - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } diff --git a/jdk/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java b/jdk/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java index 351042965de..ebad01300ae 100644 --- a/jdk/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java +++ b/jdk/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java @@ -104,13 +104,6 @@ public class AltSecurityManager implements Runnable { utilityToStart + " to die"); if (time >= TIME_OUT) { - - // dont pollute other tests; increase the likelihood - // that rmid will go away if it did not exit already. - if (utility.equals(ACTIVATION)) { - RMID.shutdown(port); - } - TestLibrary.bomb(utilityToStart + " took too long to die..."); } else { diff --git a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java index b300e1083bb..5157f789c75 100644 --- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java +++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, 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 @@ -57,7 +57,7 @@ public class UseCustomSocketFactory { RMID rmid = null; try { - rmid = RMID.createRMID(true); + rmid = RMID.createRMID(); rmid.addArguments(new String[] { "-C-Djava.security.policy=" + TestParams.defaultGroupPolicy + diff --git a/jdk/test/java/rmi/testlibrary/ActivationLibrary.java b/jdk/test/java/rmi/testlibrary/ActivationLibrary.java index b33a3035c89..6a7a5b753d8 100644 --- a/jdk/test/java/rmi/testlibrary/ActivationLibrary.java +++ b/jdk/test/java/rmi/testlibrary/ActivationLibrary.java @@ -103,68 +103,4 @@ public class ActivationLibrary { } catch (NoSuchObjectException e) { } } - - /** cleanup after rmid */ - public static void rmidCleanup(RMID rmid) { - if (rmid != null) { - if (!ActivationLibrary.safeDestroy(rmid, SAFE_WAIT_TIME)) { - TestLibrary.bomb("rmid not destroyed in: " + - SAFE_WAIT_TIME + - " milliseconds"); - } - } - RMID.removeLog(); - } - - /** - * Invoke shutdown on rmid in a way that will not cause a test - * to hang. - * - * @return whether or not shutdown completed succesfully in the - * timeAllowed - */ - private static boolean safeDestroy(RMID rmid, long timeAllowed) { - DestroyThread destroyThread = new DestroyThread(rmid); - destroyThread.start(); - - try { - destroyThread.join(timeAllowed); - } catch (InterruptedException ie) { - Thread.currentThread().interrupt(); - } - - return destroyThread.shutdownSucceeded(); - } - - /** - * Thread class to handle the destruction of rmid - */ - private static class DestroyThread extends Thread { - private final RMID rmid; - private final int port; - private boolean succeeded = false; - - DestroyThread(RMID rmid) { - this.rmid = rmid; - this.port = rmid.getPort(); - this.setDaemon(true); - } - - public void run() { - if (RMID.lookupSystem(port) != null) { - rmid.destroy(); - synchronized (this) { - // flag that the test was able to shutdown rmid - succeeded = true; - } - mesg("finished destroying rmid"); - } else { - mesg("tried to shutdown when rmid was not running"); - } - } - - public synchronized boolean shutdownSucceeded() { - return succeeded; - } - } } diff --git a/jdk/test/java/rmi/testlibrary/RMID.java b/jdk/test/java/rmi/testlibrary/RMID.java index bdd8c829d89..29365e8125f 100644 --- a/jdk/test/java/rmi/testlibrary/RMID.java +++ b/jdk/test/java/rmi/testlibrary/RMID.java @@ -21,14 +21,11 @@ * questions. */ -/** - * - */ - import java.io.*; import java.rmi.*; import java.rmi.activation.*; import java.rmi.registry.*; +import java.util.concurrent.TimeoutException; /** * Utility class that creates an instance of rmid with a policy @@ -39,6 +36,14 @@ import java.rmi.registry.*; */ public class RMID extends JavaVM { + // TODO: adjust these based on the timeout factor + // such as jcov.sleep.multiplier; see start(long) method. + // Also consider the test.timeout.factor property (a float). + private static final long TIMEOUT_SHUTDOWN_MS = 60_000L; + private static final long TIMEOUT_DESTROY_MS = 10_000L; + private static final long STARTTIME_MS = 15_000L; + private static final long POLLTIME_MS = 100L; + private static final String SYSTEM_NAME = ActivationSystem.class.getName(); // "java.rmi.activation.ActivationSystem" @@ -140,15 +145,8 @@ public class RMID extends JavaVM { * policy file. */ public static RMID createRMID() { - return createRMID(System.out, System.err, true); - } - - public static RMID createRMID(boolean debugExec) { - return createRMID(System.out, System.err, debugExec); - } - - public static RMID createRMID(OutputStream out, OutputStream err) { - return createRMID(out, err, true); + return createRMID(System.out, System.err, true, true, + TestLibrary.getUnusedRandomPort()); } public static RMID createRMID(OutputStream out, OutputStream err, @@ -173,24 +171,24 @@ public class RMID extends JavaVM { /** - * Test RMID should be created with the createRMID method. + * Private constructor. RMID instances should be created + * using the static factory methods. */ - protected RMID(String classname, String options, String args, + private RMID(String classname, String options, String args, OutputStream out, OutputStream err, int port) { super(classname, options, args, out, err); this.port = port; } + /** + * Removes rmid's log file directory. + */ public static void removeLog() { - /* - * Remove previous log file directory before - * starting up rmid. - */ File f = new File(LOGDIR, log); if (f.exists()) { - mesg("removing rmid's old log file..."); + mesg("Removing rmid's old log file."); String[] files = f.list(); if (files != null) { @@ -199,8 +197,8 @@ public class RMID extends JavaVM { } } - if (f.delete() != true) { - mesg("\t" + " unable to delete old log file."); + if (! f.delete()) { + mesg("Warning: unable to delete old log file."); } } } @@ -215,14 +213,6 @@ public class RMID extends JavaVM { return TestLibrary.getExtraProperty("rmid.jcov.args",""); } - public void start() throws IOException { - start(10000); - } - - public void slowStart() throws IOException { - start(60000); - } - /** * Looks up the activation system in the registry on the given port, * returning its stub, or null if it's not present. This method differs from @@ -239,12 +229,24 @@ public class RMID extends JavaVM { } } + /** + * Starts rmid and waits up to the default timeout period + * to confirm that it's running. + */ + public void start() throws IOException { + start(STARTTIME_MS); + } + + /** + * Starts rmid and waits up to the given timeout period + * to confirm that it's running. + */ public void start(long waitTime) throws IOException { // if rmid is already running, then the test will fail with // a well recognized exception (port already in use...). - mesg("starting rmid on port #" + port + "..."); + mesg("Starting rmid on port " + port + "."); super.start(); int slopFactor = 1; @@ -254,20 +256,17 @@ public class RMID extends JavaVM { } catch (NumberFormatException ignore) {} waitTime = waitTime * slopFactor; - // We check several times (as many as provides passed waitTime) to - // see if Rmid is currently running. Waiting steps last 100 msecs. - final long rmidStartSleepTime = 100; + // We check several times, for a maximum of waitTime, until we have + // verified that rmid is running. do { - // Sleeping for another rmidStartSleepTime time slice. try { - Thread.sleep(Math.min(waitTime, rmidStartSleepTime)); + Thread.sleep(Math.min(waitTime, POLLTIME_MS)); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); - mesg("Thread interrupted while checking for start of Activation System. Giving up check."); - mesg("Activation System state unknown"); + mesg("Interrupted while starting activation system, giving up."); return; } - waitTime -= rmidStartSleepTime; + waitTime -= POLLTIME_MS; // Checking if rmid is present if (lookupSystem(port) != null) { @@ -279,7 +278,7 @@ public class RMID extends JavaVM { * incorrect value. */ System.setProperty("java.rmi.activation.port", Integer.toString(port)); - mesg("finished starting rmid."); + mesg("Started successfully."); return; } else { if (waitTime > 0) { @@ -287,9 +286,15 @@ public class RMID extends JavaVM { } } } while (waitTime > 0); - TestLibrary.bomb("start rmid failed... giving up", null); + TestLibrary.bomb("Failed to start rmid, giving up.", null); } + /** + * Destroys rmid and restarts it. Note that this does NOT clean up + * the log file, because it stores information about restartable + * and activatable objects that must be carried over to the new + * rmid instance. + */ public void restart() throws IOException { destroy(); start(); @@ -298,30 +303,35 @@ public class RMID extends JavaVM { /** * Ask rmid to shutdown gracefully using a remote method call. * catch any errors that might occur from rmid not being present - * at time of shutdown invocation. - * - * Shutdown does not nullify possible references to the rmid - * process object (destroy does though). + * at time of shutdown invocation. If the remote call is + * successful, wait for the process to terminate. Return true + * if the process terminated, otherwise return false. */ - public static void shutdown(int port) { + private boolean shutdown() throws InterruptedException { + mesg("shutdown()"); + ActivationSystem system = lookupSystem(port); + if (system == null) { + mesg("lookupSystem() returned null"); + return false; + } try { - ActivationSystem system = lookupSystem(port); - - if (system == null) { - TestLibrary.bomb("reference to the activation system was null"); - } - + mesg("ActivationSystem.shutdown()"); system.shutdown(); - } catch (RemoteException re) { - mesg("shutting down the activation daemon failed"); } catch (Exception e) { - mesg("caught exception trying to shutdown rmid"); - mesg(e.getMessage()); + mesg("Caught exception from ActivationSystem.shutdown():"); e.printStackTrace(); } - mesg("testlibrary finished shutting down rmid"); + try { + waitFor(TIMEOUT_SHUTDOWN_MS); + mesg("Shutdown successful."); + return true; + } catch (TimeoutException ex) { + mesg("Shutdown timed out:"); + ex.printStackTrace(); + return false; + } } /** @@ -330,60 +340,46 @@ public class RMID extends JavaVM { * if rmid is a child process of the current VM. */ public void destroy() { - // attempt graceful shutdown of the activation system - shutdown(port); - - if (vm != null) { - try { - /* Waiting for distant RMID process to shutdown. - * Waiting is bounded at a hardcoded max of 60 secs (1 min). - * Waiting by steps of 200 msecs, thus at most 300 such attempts - * for termination of distant RMID process. If process is not - * known to be terminated properly after that time, - * we give up for a gracefull termination, and thus go for - * forcibly destroying the process. - */ - boolean vmEnded = false; - int waitingTrials = 0; - final int maxTrials = 300; - final long vmProcessEndWaitInterval = 200; - int vmExitValue; - do { - try { - Thread.sleep(vmProcessEndWaitInterval); - waitingTrials++; - vmExitValue = vm.exitValue(); - mesg("rmid exited on shutdown request"); - vmEnded = true; - } catch (IllegalThreadStateException illegal) { - mesg("RMID's process still not terminated after more than " + - (waitingTrials * vmProcessEndWaitInterval) + " milliseconds"); - } - } - while (!vmEnded && - (waitingTrials < maxTrials)); - - if (waitingTrials >= maxTrials) { - mesg("RMID's process still not terminated after more than " + - (waitingTrials * vmProcessEndWaitInterval) + " milliseconds." + - "Givinp up gracefull termination..."); - mesg("destroying RMID's process using Process.destroy()"); - super.destroy(); - } - - } catch (InterruptedException ie) { - Thread.currentThread().interrupt(); - mesg("Thread interrupted while checking for termination of distant rmid vm. Giving up check."); - } catch (Exception e) { - mesg("caught unexpected exception trying to destroy rmid: " + - e.getMessage()); - e.printStackTrace(); - } - - // rmid will not restart if its process is not null - vm = null; + if (vm == null) { + throw new IllegalStateException("can't wait for RMID that isn't running"); } + + // First, attempt graceful shutdown of the activation system. + try { + if (! shutdown()) { + // Graceful shutdown failed, use Process.destroy(). + mesg("Destroying RMID process."); + vm.destroy(); + try { + waitFor(TIMEOUT_DESTROY_MS); + mesg("Destroy successful."); + } catch (TimeoutException ex) { + mesg("Destroy timed out, giving up."); + ex.printStackTrace(); + } + } + } catch (InterruptedException ie) { + mesg("Shutdown/destroy interrupted, giving up."); + ie.printStackTrace(); + Thread.currentThread().interrupt(); + return; + } + + vm = null; } - public int getPort() {return port;} + /** + * Shuts down rmid and then removes its log file. + */ + public void cleanup() { + destroy(); + RMID.removeLog(); + } + + /** + * Gets the port on which this rmid is listening. + */ + public int getPort() { + return port; + } } From 56d2ce25a92347fae09657b5e413c4c1513ac337 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Tue, 2 Dec 2014 15:12:40 +0100 Subject: [PATCH 64/67] 8065998: Avoid use of _ as a one-character identifier Reviewed-by: alanb, chegar, darcy --- jdk/test/java/io/readBytes/MemoryLeak.java | 2 +- .../lang/Class/TypeCheckMicroBenchmark.java | 4 +- .../java/lang/ProcessBuilder/Zombies.java | 6 +- .../java/lang/invoke/6998541/Test6998541.java | 74 +++++++++---------- jdk/test/java/util/EnumSet/BogusEnumSet.java | 2 +- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/jdk/test/java/io/readBytes/MemoryLeak.java b/jdk/test/java/io/readBytes/MemoryLeak.java index ab099b16956..a9dd8e61209 100644 --- a/jdk/test/java/io/readBytes/MemoryLeak.java +++ b/jdk/test/java/io/readBytes/MemoryLeak.java @@ -40,7 +40,7 @@ public class MemoryLeak { try { s.read(bytes); throw new Error("expected IOException"); - } catch (IOException _) { + } catch (IOException expected) { /* OK */ } catch (OutOfMemoryError oome) { System.out.printf("Got OutOfMemoryError, i=%d%n", i); diff --git a/jdk/test/java/lang/Class/TypeCheckMicroBenchmark.java b/jdk/test/java/lang/Class/TypeCheckMicroBenchmark.java index e406c4f3060..d82de6ed185 100644 --- a/jdk/test/java/lang/Class/TypeCheckMicroBenchmark.java +++ b/jdk/test/java/lang/Class/TypeCheckMicroBenchmark.java @@ -182,7 +182,7 @@ public class TypeCheckMicroBenchmark { for (int i = 0; i < iterations; i++) { for (Object x : list.toArray()) { try { a[0] = x; } - catch (ArrayStoreException _) { + catch (ArrayStoreException unused) { throw new ClassCastException(); }}}}}, new Job("write into dynamic array") { void work() { for (int i = 0; i < iterations; i++) { @@ -190,7 +190,7 @@ public class TypeCheckMicroBenchmark { Object[] a = (Object[]) java.lang.reflect.Array.newInstance(klazz, 1); try { a[0] = x; } - catch (ArrayStoreException _) { + catch (ArrayStoreException unused) { throw new ClassCastException(); }}}}} }; diff --git a/jdk/test/java/lang/ProcessBuilder/Zombies.java b/jdk/test/java/lang/ProcessBuilder/Zombies.java index f8c3b627dd8..c417b696c2b 100644 --- a/jdk/test/java/lang/ProcessBuilder/Zombies.java +++ b/jdk/test/java/lang/ProcessBuilder/Zombies.java @@ -47,17 +47,17 @@ public class Zombies { try { rt.exec("no-such-file"); throw new Error("expected IOException not thrown"); - } catch (IOException _) {/* OK */} + } catch (IOException expected) {/* OK */} try { rt.exec("."); throw new Error("expected IOException not thrown"); - } catch (IOException _) {/* OK */} + } catch (IOException expected) {/* OK */} try { rt.exec(TrueCommand, null, new File("no-such-dir")); throw new Error("expected IOException not thrown"); - } catch (IOException _) {/* OK */} + } catch (IOException expected) {/* OK */} rt.exec(TrueCommand).waitFor(); diff --git a/jdk/test/java/lang/invoke/6998541/Test6998541.java b/jdk/test/java/lang/invoke/6998541/Test6998541.java index e9f467be3f4..59d9d45bffb 100644 --- a/jdk/test/java/lang/invoke/6998541/Test6998541.java +++ b/jdk/test/java/lang/invoke/6998541/Test6998541.java @@ -214,13 +214,13 @@ public class Test6998541 { } private static void boolean2prim_invalid(boolean x) throws Throwable { if (DO_CASTS) return; - try { byte y = (byte) mh_bz.invokeExact(x); fail(); } catch (ClassCastException _) {} // boolean -> byte - try { char y = (char) mh_cz.invokeExact(x); fail(); } catch (ClassCastException _) {} // boolean -> char - try { short y = (short) mh_sz.invokeExact(x); fail(); } catch (ClassCastException _) {} // boolean -> short - try { int y = (int) mh_iz.invokeExact(x); fail(); } catch (ClassCastException _) {} // boolean -> int - try { long y = (long) mh_jz.invokeExact(x); fail(); } catch (ClassCastException _) {} // boolean -> long - try { float y = (float) mh_fz.invokeExact(x); fail(); } catch (ClassCastException _) {} // boolean -> float - try { double y = (double) mh_dz.invokeExact(x); fail(); } catch (ClassCastException _) {} // boolean -> double + try { byte y = (byte) mh_bz.invokeExact(x); fail(); } catch (ClassCastException expected) {} // boolean -> byte + try { char y = (char) mh_cz.invokeExact(x); fail(); } catch (ClassCastException expected) {} // boolean -> char + try { short y = (short) mh_sz.invokeExact(x); fail(); } catch (ClassCastException expected) {} // boolean -> short + try { int y = (int) mh_iz.invokeExact(x); fail(); } catch (ClassCastException expected) {} // boolean -> int + try { long y = (long) mh_jz.invokeExact(x); fail(); } catch (ClassCastException expected) {} // boolean -> long + try { float y = (float) mh_fz.invokeExact(x); fail(); } catch (ClassCastException expected) {} // boolean -> float + try { double y = (double) mh_dz.invokeExact(x); fail(); } catch (ClassCastException expected) {} // boolean -> double } private static MethodHandle mh_b(Class ret) { return mh(ret, byte.class); } @@ -248,8 +248,8 @@ public class Test6998541 { } private static void byte2prim_invalid(byte x) throws Throwable { if (DO_CASTS) return; - try { char y = (char) mh_cb.invokeExact(x); fail(); } catch (ClassCastException _) {} // byte -> char - try { boolean y = (boolean) mh_zb.invokeExact(x); fail(); } catch (ClassCastException _) {} // byte -> boolean + try { char y = (char) mh_cb.invokeExact(x); fail(); } catch (ClassCastException expected) {} // byte -> char + try { boolean y = (boolean) mh_zb.invokeExact(x); fail(); } catch (ClassCastException expected) {} // byte -> boolean } private static MethodHandle mh_c(Class ret) { return mh(ret, char.class); } @@ -277,9 +277,9 @@ public class Test6998541 { } private static void char2prim_invalid(char x) throws Throwable { if (DO_CASTS) return; - try { boolean y = (boolean) mh_zc.invokeExact(x); fail(); } catch (ClassCastException _) {} // char -> boolean - try { byte y = (byte) mh_bc.invokeExact(x); fail(); } catch (ClassCastException _) {} // char -> byte - try { short y = (short) mh_sc.invokeExact(x); fail(); } catch (ClassCastException _) {} // char -> short + try { boolean y = (boolean) mh_zc.invokeExact(x); fail(); } catch (ClassCastException expected) {} // char -> boolean + try { byte y = (byte) mh_bc.invokeExact(x); fail(); } catch (ClassCastException expected) {} // char -> byte + try { short y = (short) mh_sc.invokeExact(x); fail(); } catch (ClassCastException expected) {} // char -> short } private static MethodHandle mh_s(Class ret) { return mh(ret, short.class); } @@ -307,9 +307,9 @@ public class Test6998541 { } private static void short2prim_invalid(short x) throws Throwable { if (DO_CASTS) return; - try { boolean y = (boolean) mh_zs.invokeExact(x); fail(); } catch (ClassCastException _) {} // short -> boolean - try { byte y = (byte) mh_bs.invokeExact(x); fail(); } catch (ClassCastException _) {} // short -> byte - try { char y = (char) mh_cs.invokeExact(x); fail(); } catch (ClassCastException _) {} // short -> char + try { boolean y = (boolean) mh_zs.invokeExact(x); fail(); } catch (ClassCastException expected) {} // short -> boolean + try { byte y = (byte) mh_bs.invokeExact(x); fail(); } catch (ClassCastException expected) {} // short -> byte + try { char y = (char) mh_cs.invokeExact(x); fail(); } catch (ClassCastException expected) {} // short -> char } private static MethodHandle mh_i(Class ret) { return mh(ret, int.class); } @@ -337,10 +337,10 @@ public class Test6998541 { } private static void int2prim_invalid(int x) throws Throwable { if (DO_CASTS) return; - try { boolean y = (boolean) mh_zi.invokeExact(x); fail(); } catch (ClassCastException _) {} // int -> boolean - try { byte y = (byte) mh_bi.invokeExact(x); fail(); } catch (ClassCastException _) {} // int -> byte - try { char y = (char) mh_ci.invokeExact(x); fail(); } catch (ClassCastException _) {} // int -> char - try { short y = (short) mh_si.invokeExact(x); fail(); } catch (ClassCastException _) {} // int -> short + try { boolean y = (boolean) mh_zi.invokeExact(x); fail(); } catch (ClassCastException expected) {} // int -> boolean + try { byte y = (byte) mh_bi.invokeExact(x); fail(); } catch (ClassCastException expected) {} // int -> byte + try { char y = (char) mh_ci.invokeExact(x); fail(); } catch (ClassCastException expected) {} // int -> char + try { short y = (short) mh_si.invokeExact(x); fail(); } catch (ClassCastException expected) {} // int -> short } private static MethodHandle mh_j(Class ret) { return mh(ret, long.class); } @@ -368,11 +368,11 @@ public class Test6998541 { } private static void long2prim_invalid(long x) throws Throwable { if (DO_CASTS) return; - try { boolean y = (boolean) mh_zj.invokeExact(x); fail(); } catch (ClassCastException _) {} // long -> boolean - try { byte y = (byte) mh_bj.invokeExact(x); fail(); } catch (ClassCastException _) {} // long -> byte - try { char y = (char) mh_cj.invokeExact(x); fail(); } catch (ClassCastException _) {} // long -> char - try { short y = (short) mh_sj.invokeExact(x); fail(); } catch (ClassCastException _) {} // long -> short - try { int y = (int) mh_ij.invokeExact(x); fail(); } catch (ClassCastException _) {} // long -> int + try { boolean y = (boolean) mh_zj.invokeExact(x); fail(); } catch (ClassCastException expected) {} // long -> boolean + try { byte y = (byte) mh_bj.invokeExact(x); fail(); } catch (ClassCastException expected) {} // long -> byte + try { char y = (char) mh_cj.invokeExact(x); fail(); } catch (ClassCastException expected) {} // long -> char + try { short y = (short) mh_sj.invokeExact(x); fail(); } catch (ClassCastException expected) {} // long -> short + try { int y = (int) mh_ij.invokeExact(x); fail(); } catch (ClassCastException expected) {} // long -> int } private static MethodHandle mh_f(Class ret) { return mh(ret, float.class); } @@ -400,12 +400,12 @@ public class Test6998541 { } private static void float2prim_invalid(float x) throws Throwable { if (DO_CASTS) return; - try { boolean y = (boolean) mh_zf.invokeExact(x); fail(); } catch (ClassCastException _) {} // float -> boolean - try { byte y = (byte) mh_bf.invokeExact(x); fail(); } catch (ClassCastException _) {} // float -> byte - try { char y = (char) mh_cf.invokeExact(x); fail(); } catch (ClassCastException _) {} // float -> char - try { short y = (short) mh_sf.invokeExact(x); fail(); } catch (ClassCastException _) {} // float -> short - try { int y = (int) mh_if.invokeExact(x); fail(); } catch (ClassCastException _) {} // float -> int - try { long y = (long) mh_jf.invokeExact(x); fail(); } catch (ClassCastException _) {} // float -> long + try { boolean y = (boolean) mh_zf.invokeExact(x); fail(); } catch (ClassCastException expected) {} // float -> boolean + try { byte y = (byte) mh_bf.invokeExact(x); fail(); } catch (ClassCastException expected) {} // float -> byte + try { char y = (char) mh_cf.invokeExact(x); fail(); } catch (ClassCastException expected) {} // float -> char + try { short y = (short) mh_sf.invokeExact(x); fail(); } catch (ClassCastException expected) {} // float -> short + try { int y = (int) mh_if.invokeExact(x); fail(); } catch (ClassCastException expected) {} // float -> int + try { long y = (long) mh_jf.invokeExact(x); fail(); } catch (ClassCastException expected) {} // float -> long } private static MethodHandle mh_d(Class ret) { return mh(ret, double.class); } @@ -433,13 +433,13 @@ public class Test6998541 { } private static void double2prim_invalid(double x) throws Throwable { if (DO_CASTS) return; - try { boolean y = (boolean) mh_zd.invokeExact(x); fail(); } catch (ClassCastException _) {} // double -> boolean - try { byte y = (byte) mh_bd.invokeExact(x); fail(); } catch (ClassCastException _) {} // double -> byte - try { char y = (char) mh_cd.invokeExact(x); fail(); } catch (ClassCastException _) {} // double -> char - try { short y = (short) mh_sd.invokeExact(x); fail(); } catch (ClassCastException _) {} // double -> short - try { int y = (int) mh_id.invokeExact(x); fail(); } catch (ClassCastException _) {} // double -> int - try { long y = (long) mh_jd.invokeExact(x); fail(); } catch (ClassCastException _) {} // double -> long - try { float y = (float) mh_fd.invokeExact(x); fail(); } catch (ClassCastException _) {} // double -> float + try { boolean y = (boolean) mh_zd.invokeExact(x); fail(); } catch (ClassCastException expected) {} // double -> boolean + try { byte y = (byte) mh_bd.invokeExact(x); fail(); } catch (ClassCastException expected) {} // double -> byte + try { char y = (char) mh_cd.invokeExact(x); fail(); } catch (ClassCastException expected) {} // double -> char + try { short y = (short) mh_sd.invokeExact(x); fail(); } catch (ClassCastException expected) {} // double -> short + try { int y = (int) mh_id.invokeExact(x); fail(); } catch (ClassCastException expected) {} // double -> int + try { long y = (long) mh_jd.invokeExact(x); fail(); } catch (ClassCastException expected) {} // double -> long + try { float y = (float) mh_fd.invokeExact(x); fail(); } catch (ClassCastException expected) {} // double -> float } private final static MethodHandle mh_zv = mh(boolean.class); diff --git a/jdk/test/java/util/EnumSet/BogusEnumSet.java b/jdk/test/java/util/EnumSet/BogusEnumSet.java index 1f52b90440a..9769cfebe2d 100644 --- a/jdk/test/java/util/EnumSet/BogusEnumSet.java +++ b/jdk/test/java/util/EnumSet/BogusEnumSet.java @@ -82,7 +82,7 @@ public class BogusEnumSet { System.out.println("Set size: " + es.size()); // 64 System.out.println("Set: " + es); // Throws IndexOutOfBoundsException throw new AssertionError("Expected exception InvalidObjectException not thrown"); - } catch (java.io.InvalidObjectException _) { /* OK */ } + } catch (java.io.InvalidObjectException expected) { /* OK */ } } private static Object deserialize(byte[] sf) throws Throwable { From 31af33c0e2b113578b3447ecd1f508f9185d71a4 Mon Sep 17 00:00:00 2001 From: Shanliang Jiang Date: Wed, 3 Dec 2014 11:38:56 +0100 Subject: [PATCH 65/67] 8065764: javax/management/monitor/CounterMonitorTest.java hangs Reviewed-by: jbachorik, dfuchs --- .../monitor/CounterMonitorTest.java | 46 ++++++++++++++----- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/jdk/test/javax/management/monitor/CounterMonitorTest.java b/jdk/test/javax/management/monitor/CounterMonitorTest.java index 6c4ea1022e3..939f1ece0df 100644 --- a/jdk/test/javax/management/monitor/CounterMonitorTest.java +++ b/jdk/test/javax/management/monitor/CounterMonitorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -26,7 +26,7 @@ * @bug 4981829 * @summary Test that the counter monitor, when running in difference mode, * emits a notification every time the threshold is exceeded. - * @author Luis-Miguel Alventosa + * @author Luis-Miguel Alventosa, Shanliang JIANG * @run clean CounterMonitorTest * @run build CounterMonitorTest * @run main CounterMonitorTest @@ -50,23 +50,31 @@ public class CounterMonitorTest implements NotificationListener { private boolean notifyFlag = true; // granularity period - private int granularityperiod = 500; + private int granularityperiod = 10; - // counter values - private int[] values = new int[] {4, 6, 9, 11}; + // derived gauge + private volatile int derivedGauge = 2; // flag to notify that a message has been received private volatile boolean messageReceived = false; + private volatile Object observedValue = null; + // MBean class public class StdObservedObject implements StdObservedObjectMBean { public Object getNbObjects() { + echo(">>> StdObservedObject.getNbObjects: " + count); + synchronized(CounterMonitorTest.class) { + observedValue = count; + CounterMonitorTest.class.notifyAll(); + } return count; } public void setNbObjects(Object n) { + echo(">>> StdObservedObject.setNbObjects: " + n); count = n; } - private Object count= null; + private volatile Object count= null; } // MBean interface @@ -166,18 +174,18 @@ public class CounterMonitorTest implements NotificationListener { Attribute attrib = new Attribute("NbObjects", data); server.setAttribute(stdObsObjName, attrib); - // Wait for granularity period (multiplied by 2 for sure) - // - Thread.sleep(granularityperiod * 2); + waitObservation(data); // Loop through the values // - for (int i = 0; i < values.length; i++) { - data = new Integer(values[i]); - echo(">>> Set data = " + data.intValue()); + while (derivedGauge++ < 10) { + System.out.print(">>> Set data from " + data.intValue()); + data = new Integer(data.intValue() + derivedGauge); + echo(" to " + data.intValue()); attrib = new Attribute("NbObjects", data); server.setAttribute(stdObsObjName, attrib); + waitObservation(data); echo("\tdoWait in Counter Monitor"); doWait(); @@ -214,6 +222,20 @@ public class CounterMonitorTest implements NotificationListener { } } + private void waitObservation(Object value) { + synchronized (CounterMonitorTest.class) { + while (value != observedValue) { + try { + CounterMonitorTest.class.wait(); + } catch (InterruptedException e) { + System.err.println("Got unexpected exception: " + e); + e.printStackTrace(); + break; + } + } + } + } + /* * Print message */ From cec929efaf2cd44dcbd4f77842e87106293ebf6a Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Wed, 3 Dec 2014 12:00:26 +0100 Subject: [PATCH 66/67] 8066397: Remove network-related seed initialization code in ThreadLocal/SplittableRandom Reviewed-by: alanb, dl, chegar, rriggs, shade --- .../classes/java/util/SplittableRandom.java | 39 +++---------------- .../util/concurrent/ThreadLocalRandom.java | 31 +-------------- 2 files changed, 6 insertions(+), 64 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/SplittableRandom.java b/jdk/src/java.base/share/classes/java/util/SplittableRandom.java index 00de113a6f8..285655d40c9 100644 --- a/jdk/src/java.base/share/classes/java/util/SplittableRandom.java +++ b/jdk/src/java.base/share/classes/java/util/SplittableRandom.java @@ -25,7 +25,6 @@ package java.util; -import java.net.NetworkInterface; import java.util.concurrent.atomic.AtomicLong; import java.util.function.IntConsumer; import java.util.function.LongConsumer; @@ -140,11 +139,10 @@ public final class SplittableRandom { * other cases, this split must be performed in a thread-safe * manner, so we use an AtomicLong to represent the seed rather * than use an explicit SplittableRandom. To bootstrap the - * defaultGen, we start off using a seed based on current time and - * network interface address unless the java.util.secureRandomSeed - * property is set. This serves as a slimmed-down (and insecure) - * variant of SecureRandom that also avoids stalls that may occur - * when using /dev/random. + * defaultGen, we start off using a seed based on current time + * unless the java.util.secureRandomSeed property is set. This + * serves as a slimmed-down (and insecure) variant of SecureRandom + * that also avoids stalls that may occur when using /dev/random. * * It is a relatively simple matter to apply the basic design here * to use 128 bit seeds. However, emulating 128bit arithmetic and @@ -237,34 +235,7 @@ public final class SplittableRandom { s = (s << 8) | ((long)(seedBytes[i]) & 0xffL); return s; } - long h = 0L; - try { - Enumeration ifcs = - NetworkInterface.getNetworkInterfaces(); - boolean retry = false; // retry once if getHardwareAddress is null - while (ifcs.hasMoreElements()) { - NetworkInterface ifc = ifcs.nextElement(); - if (!ifc.isVirtual()) { // skip fake addresses - byte[] bs = ifc.getHardwareAddress(); - if (bs != null) { - int n = bs.length; - int m = Math.min(n >>> 1, 4); - for (int i = 0; i < m; ++i) - h = (h << 16) ^ (bs[i] << 8) ^ bs[n-1-i]; - if (m < 4) - h = (h << 8) ^ bs[n-1-m]; - h = mix64(h); - break; - } - else if (!retry) - retry = true; - else - break; - } - } - } catch (Exception ignore) { - } - return (h ^ mix64(System.currentTimeMillis()) ^ + return (mix64(System.currentTimeMillis()) ^ mix64(System.nanoTime())); } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java index 2606bed44be..95cc6549b9f 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java @@ -36,8 +36,6 @@ package java.util.concurrent; import java.io.ObjectStreamField; -import java.net.NetworkInterface; -import java.util.Enumeration; import java.util.Random; import java.util.Spliterator; import java.util.concurrent.atomic.AtomicInteger; @@ -147,34 +145,7 @@ public class ThreadLocalRandom extends Random { s = (s << 8) | ((long)(seedBytes[i]) & 0xffL); return s; } - long h = 0L; - try { - Enumeration ifcs = - NetworkInterface.getNetworkInterfaces(); - boolean retry = false; // retry once if getHardwareAddress is null - while (ifcs.hasMoreElements()) { - NetworkInterface ifc = ifcs.nextElement(); - if (!ifc.isVirtual()) { // skip fake addresses - byte[] bs = ifc.getHardwareAddress(); - if (bs != null) { - int n = bs.length; - int m = Math.min(n >>> 1, 4); - for (int i = 0; i < m; ++i) - h = (h << 16) ^ (bs[i] << 8) ^ bs[n-1-i]; - if (m < 4) - h = (h << 8) ^ bs[n-1-m]; - h = mix64(h); - break; - } - else if (!retry) - retry = true; - else - break; - } - } - } catch (Exception ignore) { - } - return (h ^ mix64(System.currentTimeMillis()) ^ + return (mix64(System.currentTimeMillis()) ^ mix64(System.nanoTime())); } From 65904e6ad16ec9506782b6f0e6cad08b7f21c629 Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Wed, 3 Dec 2014 14:34:42 +0000 Subject: [PATCH 67/67] 8066131: Update java/nio/charset/Charset/NIOCharsetAvailabilityTest.java to eliminate dependency on sun.misc.Launcher Reviewed-by: alanb --- .../Charset/NIOCharsetAvailabilityTest.java | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/jdk/test/java/nio/charset/Charset/NIOCharsetAvailabilityTest.java b/jdk/test/java/nio/charset/Charset/NIOCharsetAvailabilityTest.java index 1e505712cda..a00cd804818 100644 --- a/jdk/test/java/nio/charset/Charset/NIOCharsetAvailabilityTest.java +++ b/jdk/test/java/nio/charset/Charset/NIOCharsetAvailabilityTest.java @@ -31,10 +31,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLClassLoader; import java.nio.charset.Charset; import java.security.AccessController; import java.security.PrivilegedAction; @@ -45,7 +41,6 @@ import java.util.Set; import java.util.Vector; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import sun.misc.Launcher; public class NIOCharsetAvailabilityTest { @@ -111,18 +106,6 @@ public class NIOCharsetAvailabilityTest { classPathSegments.insertElementAt(dir, 0); } - // add extensions from the extension class loader - ClassLoader appLoader = Launcher.getLauncher().getClassLoader(); - URLClassLoader extLoader = (URLClassLoader) appLoader.getParent(); - URL[] urls = extLoader.getURLs(); - for (int i = 0; i < urls.length; i++) { - try { - URI uri = new URI(urls[i].toString()); - classPathSegments.insertElementAt(uri.getPath(), 0); - } catch (URISyntaxException e) { - } - } - String[] classList = (String[]) java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() {