From 3162db1047e97db7ffb101ed4310961364332ef9 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Fri, 9 May 2014 09:47:07 +0100 Subject: [PATCH 01/15] 8042816: (fs) Path.register doesn't throw IllegalArgumentException if multiple OVERFLOW events are specified, part 2 Reviewed-by: chegar --- jdk/src/share/classes/sun/nio/fs/PollingWatchService.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/sun/nio/fs/PollingWatchService.java b/jdk/src/share/classes/sun/nio/fs/PollingWatchService.java index 30de2473bee..d3d9891223d 100644 --- a/jdk/src/share/classes/sun/nio/fs/PollingWatchService.java +++ b/jdk/src/share/classes/sun/nio/fs/PollingWatchService.java @@ -74,8 +74,6 @@ class PollingWatchService throws IOException { // check events - CCE will be thrown if there are invalid elements - if (events.length == 0) - throw new IllegalArgumentException("No events to register"); final Set> eventSet = new HashSet>(events.length); for (WatchEvent.Kind event: events) { @@ -90,8 +88,6 @@ class PollingWatchService // OVERFLOW is ignored if (event == StandardWatchEventKinds.OVERFLOW) { - if (events.length == 1) - throw new IllegalArgumentException("No events to register"); continue; } @@ -100,6 +96,8 @@ class PollingWatchService throw new NullPointerException("An element in event set is 'null'"); throw new UnsupportedOperationException(event.name()); } + if (eventSet.isEmpty()) + throw new IllegalArgumentException("No events to register"); // A modifier may be used to specify the sensitivity level SensitivityWatchEventModifier sensivity = SensitivityWatchEventModifier.MEDIUM; From 70bf57509cbff0010b96b0cfe1c88aa13b78d62b Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Fri, 9 May 2014 12:06:13 +0200 Subject: [PATCH 02/15] 8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework Reviewed-by: igerasim, alanb, dsamersoff --- .../AttachOperationFailedException.java | 54 +++++++++++++++++++ .../com/sun/tools/attach/VirtualMachine.java | 20 +++++-- .../tools/attach/HotSpotVirtualMachine.java | 16 +++++- .../share/classes/sun/tools/jcmd/JCmd.java | 15 +++++- .../sun/tools/attach/BsdVirtualMachine.java | 17 ++++-- .../sun/tools/attach/LinuxVirtualMachine.java | 14 +++-- .../tools/attach/SolarisVirtualMachine.java | 14 +++-- .../sun/tools/attach/BsdVirtualMachine.c | 6 +-- .../sun/tools/attach/LinuxVirtualMachine.c | 4 +- .../sun/tools/attach/SolarisVirtualMachine.c | 8 +-- .../tools/attach/WindowsVirtualMachine.java | 16 ++++-- .../sun/tools/attach/WindowsVirtualMachine.c | 2 +- .../jmxremote/startstop/JMXStartStopTest.java | 6 +-- 13 files changed, 156 insertions(+), 36 deletions(-) create mode 100644 jdk/src/share/classes/com/sun/tools/attach/AttachOperationFailedException.java diff --git a/jdk/src/share/classes/com/sun/tools/attach/AttachOperationFailedException.java b/jdk/src/share/classes/com/sun/tools/attach/AttachOperationFailedException.java new file mode 100644 index 00000000000..7f676ee4993 --- /dev/null +++ b/jdk/src/share/classes/com/sun/tools/attach/AttachOperationFailedException.java @@ -0,0 +1,54 @@ +/* + * 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 com.sun.tools.attach; + +import java.io.IOException; + +/** + * Exception type to signal that an attach operation failed in the target VM. + * + *

This exception can be thrown by the various operations of + * {@link com.sun.tools.attach.VirtualMachine} when the operation + * fails in the target VM. If there is a communication error, + * a regular IOException will be thrown. + * + * @since 1.9 + */ +@jdk.Exported +public class AttachOperationFailedException extends IOException { + + private static final long serialVersionUID = 2140308168167478043L; + + /** + * Constructs an AttachOperationFailedException with + * the specified detail message. + * + * @param s the detail message. + */ + public AttachOperationFailedException(String message) { + super(message); + } +} diff --git a/jdk/src/share/classes/com/sun/tools/attach/VirtualMachine.java b/jdk/src/share/classes/com/sun/tools/attach/VirtualMachine.java index 1bea7512147..642f5516396 100644 --- a/jdk/src/share/classes/com/sun/tools/attach/VirtualMachine.java +++ b/jdk/src/share/classes/com/sun/tools/attach/VirtualMachine.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 @@ -564,8 +564,15 @@ public abstract class VirtualMachine { * * @return The system properties * + * @throws AttachOperationFailedException + * If the target virtual machine is unable to complete the + * attach operation. A more specific error message will be + * given by {@link AttachOperationFailedException#getMessage()}. + * * @throws IOException - * If an I/O error occurs + * If an I/O error occurs, a communication error for example, + * that cannot be identified as an error to indicate that the + * operation failed in the target VM. * * @see java.lang.System#getProperties * @see #loadAgentLibrary @@ -591,8 +598,15 @@ public abstract class VirtualMachine { * * @return The agent properties * + * @throws AttachOperationFailedException + * If the target virtual machine is unable to complete the + * attach operation. A more specific error message will be + * given by {@link AttachOperationFailedException#getMessage()}. + * * @throws IOException - * If an I/O error occurs + * If an I/O error occurs, a communication error for example, + * that cannot be identified as an error to indicate that the + * operation failed in the target VM. */ public abstract Properties getAgentProperties() throws IOException; diff --git a/jdk/src/share/classes/sun/tools/attach/HotSpotVirtualMachine.java b/jdk/src/share/classes/sun/tools/attach/HotSpotVirtualMachine.java index 4b858bbb82c..862b07cf494 100644 --- a/jdk/src/share/classes/sun/tools/attach/HotSpotVirtualMachine.java +++ b/jdk/src/share/classes/sun/tools/attach/HotSpotVirtualMachine.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 @@ -257,6 +257,20 @@ public abstract class HotSpotVirtualMachine extends VirtualMachine { return value; } + /* + * Utility method to read data into a String. + */ + String readErrorMessage(InputStream sis) throws IOException { + byte b[] = new byte[1024]; + int n; + StringBuffer message = new StringBuffer(); + while ((n = sis.read(b)) != -1) { + message.append(new String(b, 0, n, "UTF-8")); + } + return message.toString(); + } + + // -- attach timeout support private static long defaultAttachTimeout = 5000; diff --git a/jdk/src/share/classes/sun/tools/jcmd/JCmd.java b/jdk/src/share/classes/sun/tools/jcmd/JCmd.java index 8c5a2c50274..0ff46323ec6 100644 --- a/jdk/src/share/classes/sun/tools/jcmd/JCmd.java +++ b/jdk/src/share/classes/sun/tools/jcmd/JCmd.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,10 +33,12 @@ import java.util.ArrayList; import java.util.Comparator; import java.net.URISyntaxException; +import com.sun.tools.attach.AttachOperationFailedException; import com.sun.tools.attach.VirtualMachine; import com.sun.tools.attach.VirtualMachineDescriptor; import com.sun.tools.attach.AgentLoadException; import com.sun.tools.attach.AttachNotSupportedException; + import sun.tools.attach.HotSpotVirtualMachine; import sun.tools.jstat.JStatLogger; import sun.jvmstat.monitor.Monitor; @@ -119,6 +121,7 @@ public class JCmd { pids.add(arg.getPid() + ""); } + boolean success = true; for (String pid : pids) { System.out.println(pid + ":"); if (arg.isListCounters()) { @@ -126,11 +129,16 @@ public class JCmd { } else { try { executeCommandForPid(pid, arg.getCommand()); + } catch(AttachOperationFailedException ex) { + System.err.println(ex.getMessage()); + success = false; } catch(Exception ex) { ex.printStackTrace(); + success = false; } } } + System.exit(success ? 0 : 1); } private static void executeCommandForPid(String pid, String command) @@ -150,13 +158,18 @@ public class JCmd { // read to EOF and just print output byte b[] = new byte[256]; int n; + boolean messagePrinted = false; do { n = in.read(b); if (n > 0) { String s = new String(b, 0, n, "UTF-8"); System.out.print(s); + messagePrinted = true; } } while (n > 0); + if (!messagePrinted) { + System.out.println("Command executed successfully"); + } } } vm.detach(); diff --git a/jdk/src/solaris/classes/sun/tools/attach/BsdVirtualMachine.java b/jdk/src/solaris/classes/sun/tools/attach/BsdVirtualMachine.java index d58a4c100f6..ad344f1411e 100644 --- a/jdk/src/solaris/classes/sun/tools/attach/BsdVirtualMachine.java +++ b/jdk/src/solaris/classes/sun/tools/attach/BsdVirtualMachine.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 @@ -24,14 +24,14 @@ */ package sun.tools.attach; -import com.sun.tools.attach.VirtualMachine; +import com.sun.tools.attach.AttachOperationFailedException; import com.sun.tools.attach.AgentLoadException; import com.sun.tools.attach.AttachNotSupportedException; import com.sun.tools.attach.spi.AttachProvider; + import java.io.InputStream; import java.io.IOException; import java.io.File; -import java.util.Properties; /* * Bsd implementation of HotSpotVirtualMachine @@ -191,6 +191,8 @@ public class BsdVirtualMachine extends HotSpotVirtualMachine { } if (completionStatus != 0) { + // read from the stream and use that as the error message + String message = readErrorMessage(sis); sis.close(); // In the event of a protocol mismatch then the target VM @@ -205,7 +207,11 @@ public class BsdVirtualMachine extends HotSpotVirtualMachine { if (cmd.equals("load")) { throw new AgentLoadException("Failed to load agent library"); } else { - throw new IOException("Command failed in target VM"); + if (message == null) { + throw new AttachOperationFailedException("Command failed in target VM"); + } else { + throw new AttachOperationFailedException(message); + } } } @@ -237,8 +243,9 @@ public class BsdVirtualMachine extends HotSpotVirtualMachine { if ((off < 0) || (off > bs.length) || (len < 0) || ((off + len) > bs.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); - } else if (len == 0) + } else if (len == 0) { return 0; + } return BsdVirtualMachine.read(s, bs, off, len); } diff --git a/jdk/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java b/jdk/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java index 1e08d70446e..9dec425da0d 100644 --- a/jdk/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java +++ b/jdk/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.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 @@ -24,14 +24,14 @@ */ package sun.tools.attach; -import com.sun.tools.attach.VirtualMachine; +import com.sun.tools.attach.AttachOperationFailedException; import com.sun.tools.attach.AgentLoadException; import com.sun.tools.attach.AttachNotSupportedException; import com.sun.tools.attach.spi.AttachProvider; + import java.io.InputStream; import java.io.IOException; import java.io.File; -import java.util.Properties; /* * Linux implementation of HotSpotVirtualMachine @@ -207,6 +207,8 @@ public class LinuxVirtualMachine extends HotSpotVirtualMachine { } if (completionStatus != 0) { + // read from the stream and use that as the error message + String message = readErrorMessage(sis); sis.close(); // In the event of a protocol mismatch then the target VM @@ -221,7 +223,11 @@ public class LinuxVirtualMachine extends HotSpotVirtualMachine { if (cmd.equals("load")) { throw new AgentLoadException("Failed to load agent library"); } else { - throw new IOException("Command failed in target VM"); + if (message == null) { + throw new AttachOperationFailedException("Command failed in target VM"); + } else { + throw new AttachOperationFailedException(message); + } } } diff --git a/jdk/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java b/jdk/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java index c7dcf21cf03..3c57e4bda6a 100644 --- a/jdk/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java +++ b/jdk/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.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 @@ -24,15 +24,15 @@ */ package sun.tools.attach; -import com.sun.tools.attach.VirtualMachine; +import com.sun.tools.attach.AttachOperationFailedException; import com.sun.tools.attach.AgentLoadException; import com.sun.tools.attach.AttachNotSupportedException; import com.sun.tools.attach.spi.AttachProvider; + import java.io.InputStream; import java.io.IOException; import java.io.File; import java.io.FileNotFoundException; -import java.util.Properties; /* * Solaris implementation of HotSpotVirtualMachine. @@ -147,11 +147,17 @@ public class SolarisVirtualMachine extends HotSpotVirtualMachine { // If non-0 it means an error but we need to special-case the // "load" command to ensure that the right exception is thrown. if (completionStatus != 0) { + // read from the stream and use that as the error message + String message = readErrorMessage(sis); sis.close(); if (cmd.equals("load")) { throw new AgentLoadException("Failed to load agent library"); } else { - throw new IOException("Command failed in target VM"); + if (message == null) { + throw new AttachOperationFailedException("Command failed in target VM"); + } else { + throw new AttachOperationFailedException(message); + } } } diff --git a/jdk/src/solaris/native/sun/tools/attach/BsdVirtualMachine.c b/jdk/src/solaris/native/sun/tools/attach/BsdVirtualMachine.c index dbc751fa366..7735a90b4ba 100644 --- a/jdk/src/solaris/native/sun/tools/attach/BsdVirtualMachine.c +++ b/jdk/src/solaris/native/sun/tools/attach/BsdVirtualMachine.c @@ -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 @@ -200,14 +200,14 @@ JNIEXPORT jint JNICALL Java_sun_tools_attach_BsdVirtualMachine_read len = remaining; } - RESTARTABLE(read(fd, buf+off, len), n); + RESTARTABLE(read(fd, buf, len), n); if (n == -1) { JNU_ThrowIOExceptionWithLastError(env, "read"); } else { if (n == 0) { n = -1; // EOF } else { - (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf+off)); + (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf)); } } return n; diff --git a/jdk/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c b/jdk/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c index 5646a326542..855ad9299f7 100644 --- a/jdk/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c +++ b/jdk/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c @@ -418,14 +418,14 @@ JNIEXPORT jint JNICALL Java_sun_tools_attach_LinuxVirtualMachine_read len = remaining; } - RESTARTABLE(read(fd, buf+off, len), n); + RESTARTABLE(read(fd, buf, len), n); if (n == -1) { JNU_ThrowIOExceptionWithLastError(env, "read"); } else { if (n == 0) { n = -1; // EOF } else { - (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf+off)); + (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf)); } } return n; diff --git a/jdk/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c b/jdk/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c index 45b38eafe5e..a79fca6aa36 100644 --- a/jdk/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c +++ b/jdk/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c @@ -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 @@ -161,14 +161,14 @@ JNIEXPORT jint JNICALL Java_sun_tools_attach_SolarisVirtualMachine_read len = remaining; } - RESTARTABLE(read(fd, buf+off, len), n); + RESTARTABLE(read(fd, buf, len), n); if (n == -1) { JNU_ThrowIOExceptionWithLastError(env, "read"); } else { if (n == 0) { n = -1; // EOF } else { - (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf+off)); + (*env)->SetByteArrayRegion(env, ba, off, (jint)n, (jbyte *)(buf)); } } return n; diff --git a/jdk/src/windows/classes/sun/tools/attach/WindowsVirtualMachine.java b/jdk/src/windows/classes/sun/tools/attach/WindowsVirtualMachine.java index 6ea66773f1d..3b34c0d181a 100644 --- a/jdk/src/windows/classes/sun/tools/attach/WindowsVirtualMachine.java +++ b/jdk/src/windows/classes/sun/tools/attach/WindowsVirtualMachine.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 @@ -24,15 +24,15 @@ */ package sun.tools.attach; -import com.sun.tools.attach.VirtualMachine; +import com.sun.tools.attach.AttachOperationFailedException; import com.sun.tools.attach.AgentLoadException; import com.sun.tools.attach.AttachNotSupportedException; import com.sun.tools.attach.spi.AttachProvider; + import sun.tools.attach.HotSpotVirtualMachine; + import java.io.IOException; -import java.io.File; import java.io.InputStream; -import java.util.Properties; import java.util.Random; public class WindowsVirtualMachine extends HotSpotVirtualMachine { @@ -105,11 +105,17 @@ public class WindowsVirtualMachine extends HotSpotVirtualMachine { // read completion status int status = readInt(is); if (status != 0) { + // read from the stream and use that as the error message + String message = readErrorMessage(is); // special case the load command so that the right exception is thrown if (cmd.equals("load")) { throw new AgentLoadException("Failed to load agent library"); } else { - throw new IOException("Command failed in target VM"); + if (message == null) { + throw new AttachOperationFailedException("Command failed in target VM"); + } else { + throw new AttachOperationFailedException(message); + } } } diff --git a/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c b/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c index ad6df257d50..94fb2f72ceb 100644 --- a/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c +++ b/jdk/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c @@ -343,7 +343,7 @@ JNIEXPORT jint JNICALL Java_sun_tools_attach_WindowsVirtualMachine_readPipe if (nread == 0) { return (jint)-1; // EOF } else { - (*env)->SetByteArrayRegion(env, ba, off, (jint)nread, (jbyte *)(buf+off)); + (*env)->SetByteArrayRegion(env, ba, off, (jint)nread, (jbyte *)(buf)); } } diff --git a/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java index 8835cc3c3ff..c6d539e5465 100644 --- a/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java +++ b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -616,7 +616,7 @@ public class JMXStartStopTest { final boolean[] checks = new boolean[3]; jcmd( line -> { - if (line.equals("java.lang.RuntimeException: Invalid agent state")) { + if (line.contains("java.lang.RuntimeException: Invalid agent state")) { checks[0] = true; } }, @@ -627,7 +627,7 @@ public class JMXStartStopTest { jcmd( line -> { - if (line.equals("java.lang.RuntimeException: Invalid agent state")) { + if (line.contains("java.lang.RuntimeException: Invalid agent state")) { checks[1] = true; } }, From fc6f28f9ad036a8e5e954a76ec7620737b1812f3 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Fri, 9 May 2014 09:04:41 -0700 Subject: [PATCH 03/15] 8040059: Change default policy for extensions to no permission Reviewed-by: alanb, mullan, erikj --- jdk/make/CopyFiles.gmk | 20 +++++++++-- .../classes/jdk/nio/zipfs/ZipFileSystem.java | 22 ++++++++---- jdk/src/share/lib/security/java.policy | 36 +++++++++++++++++-- jdk/src/windows/lib/security/java.policy | 3 ++ jdk/test/TEST.groups | 4 +-- jdk/test/jdk/nio/zipfs/Basic.java | 5 ++- jdk/test/jdk/nio/zipfs/PathOps.java | 5 ++- jdk/test/jdk/nio/zipfs/ZFSTests.java | 7 ++-- jdk/test/jdk/nio/zipfs/ZipFSTester.java | 4 ++- jdk/test/jdk/nio/zipfs/test.policy | 16 +++++++++ jdk/test/jdk/nio/zipfs/test.policy.readonly | 12 +++++++ .../security/java.policy/Ext_AllPolicy.java | 22 +++++++++--- .../lib/security/java.policy/Ext_AllPolicy.sh | 7 ++-- jdk/test/lib/security/java.policy/test.policy | 3 ++ 14 files changed, 142 insertions(+), 24 deletions(-) create mode 100644 jdk/src/windows/lib/security/java.policy create mode 100644 jdk/test/jdk/nio/zipfs/test.policy create mode 100644 jdk/test/jdk/nio/zipfs/test.policy.readonly create mode 100644 jdk/test/lib/security/java.policy/test.policy diff --git a/jdk/make/CopyFiles.gmk b/jdk/make/CopyFiles.gmk index 5566d4628d4..c1fa0d4062b 100644 --- a/jdk/make/CopyFiles.gmk +++ b/jdk/make/CopyFiles.gmk @@ -367,8 +367,24 @@ COPY_FILES += $(PROPS_DST) POLICY_SRC := $(JDK_TOPDIR)/src/share/lib/security/java.policy POLICY_DST := $(JDK_OUTPUTDIR)/lib/security/java.policy -$(POLICY_DST): $(POLICY_SRC) - $(call install-file) +POLICY_SRC_LIST := + +ifeq ($(OPENJDK_TARGET_OS), windows) + POLICY_SRC_LIST += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS)/lib/security/java.policy +endif +ifndef OPENJDK + ifneq (, $(filter $(OPENJDK_TARGET_OS), windows solaris)) + POLICY_SRC_LIST += $(JDK_TOPDIR)/src/closed/$(OPENJDK_TARGET_OS)/lib/security/java.policy + endif +endif + +POLICY_SRC_LIST += $(POLICY_SRC) + +$(POLICY_DST): $(POLICY_SRC_LIST) + $(MKDIR) -p $(@D) + $(RM) $@ $@.tmp + $(foreach f,$(POLICY_SRC_LIST),$(CAT) $(f) >> $@.tmp;) + $(MV) $@.tmp $@ COPY_FILES += $(POLICY_DST) diff --git a/jdk/src/share/classes/jdk/nio/zipfs/ZipFileSystem.java b/jdk/src/share/classes/jdk/nio/zipfs/ZipFileSystem.java index 34e0bc0435c..b5fec0ebe1f 100644 --- a/jdk/src/share/classes/jdk/nio/zipfs/ZipFileSystem.java +++ b/jdk/src/share/classes/jdk/nio/zipfs/ZipFileSystem.java @@ -41,6 +41,8 @@ import java.nio.file.attribute.*; import java.nio.file.spi.*; import java.security.AccessController; import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; import java.util.*; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; @@ -110,7 +112,9 @@ class ZipFileSystem extends FileSystem { } // sm and existence check zfpath.getFileSystem().provider().checkAccess(zfpath, AccessMode.READ); - if (!Files.isWritable(zfpath)) + boolean writeable = AccessController.doPrivileged( + (PrivilegedAction) () -> Files.isWritable(zfpath)); + if (!writeable) this.readOnly = true; this.zc = ZipCoder.get(nameEncoding); this.defaultdir = new ZipPath(this, getBytes(defaultDir)); @@ -262,9 +266,13 @@ class ZipFileSystem extends FileSystem { } beginWrite(); // lock and sync try { - sync(); - ch.close(); // close the ch just in case no update - } finally { // and sync dose not close the ch + AccessController.doPrivileged((PrivilegedExceptionAction) () -> { + sync(); return null; + }); + ch.close(); // close the ch just in case no update + } catch (PrivilegedActionException e) { // and sync dose not close the ch + throw (IOException)e.getException(); + } finally { endWrite(); } @@ -281,8 +289,10 @@ class ZipFileSystem extends FileSystem { synchronized (tmppaths) { for (Path p: tmppaths) { try { - Files.deleteIfExists(p); - } catch (IOException x) { + AccessController.doPrivileged( + (PrivilegedExceptionAction)() -> Files.deleteIfExists(p)); + } catch (PrivilegedActionException e) { + IOException x = (IOException)e.getException(); if (ioe == null) ioe = x; else diff --git a/jdk/src/share/lib/security/java.policy b/jdk/src/share/lib/security/java.policy index 120694d6993..b3165881ac4 100644 --- a/jdk/src/share/lib/security/java.policy +++ b/jdk/src/share/lib/security/java.policy @@ -1,7 +1,39 @@ +// permissions required by each component +grant codeBase "file:${java.home}/lib/ext/zipfs.jar" { + permission java.io.FilePermission "<>", "read,write,delete"; + permission java.lang.RuntimePermission "fileSystemProvider"; + permission java.util.PropertyPermission "*", "read"; +}; -// Standard extensions get all permissions by default +grant codeBase "file:${java.home}/lib/ext/cldrdata.jar" { + permission java.lang.RuntimePermission "accessClassInPackage.sun.text.*"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.util.*"; + permission java.util.PropertyPermission "*", "read"; +}; -grant codeBase "file:${{java.ext.dirs}}/*" { +grant codeBase "file:${java.home}/lib/ext/localedata.jar" { + permission java.lang.RuntimePermission "accessClassInPackage.sun.text.*"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.util.*"; + permission java.util.PropertyPermission "*", "read"; +}; + +grant codeBase "file:${java.home}/lib/ext/dnsns.jar" { + permission java.security.AllPermission; +}; + +grant codeBase "file:${java.home}/lib/ext/nashorn.jar" { + permission java.security.AllPermission; +}; + +grant codeBase "file:${java.home}/lib/ext/sunec.jar" { + permission java.security.AllPermission; +}; + +grant codeBase "file:${java.home}/lib/ext/sunjce_provider.jar" { + permission java.security.AllPermission; +}; + +grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" { permission java.security.AllPermission; }; diff --git a/jdk/src/windows/lib/security/java.policy b/jdk/src/windows/lib/security/java.policy new file mode 100644 index 00000000000..05368dee3cf --- /dev/null +++ b/jdk/src/windows/lib/security/java.policy @@ -0,0 +1,3 @@ +grant codeBase "file:${java.home}/lib/ext/sunmscapi.jar" { + permission java.security.AllPermission; +}; diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups index 812a30e7108..9efa1bd05c3 100644 --- a/jdk/test/TEST.groups +++ b/jdk/test/TEST.groups @@ -97,7 +97,8 @@ jdk_io = \ jdk_nio = \ java/nio \ - sun/nio + sun/nio \ + jdk/nio jdk_net = \ java/net \ @@ -203,7 +204,6 @@ jdk_other = \ com/sun/jndi \ com/sun/corba \ lib/testlibrary \ - jdk/nio/zipfs \ sample # diff --git a/jdk/test/jdk/nio/zipfs/Basic.java b/jdk/test/jdk/nio/zipfs/Basic.java index b4b526ad489..e533b2f82d9 100644 --- a/jdk/test/jdk/nio/zipfs/Basic.java +++ b/jdk/test/jdk/nio/zipfs/Basic.java @@ -31,8 +31,11 @@ import java.io.IOException; /** * * @test - * @bug 8038500 + * @bug 8038500 8040059 * @summary Basic test for zip provider + * + * @run main Basic + * @run main/othervm/policy=test.policy Basic */ public class Basic { diff --git a/jdk/test/jdk/nio/zipfs/PathOps.java b/jdk/test/jdk/nio/zipfs/PathOps.java index 321de439c58..20e8c5d8fa5 100644 --- a/jdk/test/jdk/nio/zipfs/PathOps.java +++ b/jdk/test/jdk/nio/zipfs/PathOps.java @@ -29,8 +29,11 @@ import java.io.IOException; /** * * @test - * @bug 8038500 + * @bug 8038500 8040059 * @summary Tests path operations for zip provider. + * + * @run main PathOps + * @run main/othervm/policy=test.policy.readonly PathOps */ public class PathOps { diff --git a/jdk/test/jdk/nio/zipfs/ZFSTests.java b/jdk/test/jdk/nio/zipfs/ZFSTests.java index c5d6e8c9e9f..a774a271363 100644 --- a/jdk/test/jdk/nio/zipfs/ZFSTests.java +++ b/jdk/test/jdk/nio/zipfs/ZFSTests.java @@ -22,8 +22,11 @@ */ /* @test - @bug 7156873 - @summary ZipFileSystem regression tests + * @bug 7156873 8040059 + * @summary ZipFileSystem regression tests + * + * @run main ZFSTests + * @run main/othervm/policy=test.policy ZFSTests */ diff --git a/jdk/test/jdk/nio/zipfs/ZipFSTester.java b/jdk/test/jdk/nio/zipfs/ZipFSTester.java index 47e75e11ec6..95e68fa0e63 100644 --- a/jdk/test/jdk/nio/zipfs/ZipFSTester.java +++ b/jdk/test/jdk/nio/zipfs/ZipFSTester.java @@ -40,8 +40,10 @@ import static java.nio.file.StandardCopyOption.*; * * @test * @bug 6990846 7009092 7009085 7015391 7014948 7005986 7017840 7007596 - * 7157656 8002390 7012868 7012856 8015728 8038500 + * 7157656 8002390 7012868 7012856 8015728 8038500 8040059 * @summary Test Zip filesystem provider + * @run main ZipFSTester + * @run main/othervm/policy=test.policy ZipFSTester */ public class ZipFSTester { diff --git a/jdk/test/jdk/nio/zipfs/test.policy b/jdk/test/jdk/nio/zipfs/test.policy new file mode 100644 index 00000000000..81261720ad7 --- /dev/null +++ b/jdk/test/jdk/nio/zipfs/test.policy @@ -0,0 +1,16 @@ +grant codeBase "file:${java.home}/lib/ext/zipfs.jar" { + permission java.io.FilePermission "<>", "read,write"; + permission java.lang.RuntimePermission "fileSystemProvider"; + permission java.util.PropertyPermission "*", "read"; +}; + +grant codeBase "file:${java.home}/lib/ext/sunpkcs11.jar" { + permission java.lang.RuntimePermission "accessClassInPackage.sun.security.*"; +}; + +grant { + permission java.io.FilePermission "<>","read,write,delete"; + permission java.util.PropertyPermission "test.jdk","read"; + permission java.util.PropertyPermission "test.src","read"; + permission java.util.PropertyPermission "user.dir","read"; +}; diff --git a/jdk/test/jdk/nio/zipfs/test.policy.readonly b/jdk/test/jdk/nio/zipfs/test.policy.readonly new file mode 100644 index 00000000000..fbd2f14231b --- /dev/null +++ b/jdk/test/jdk/nio/zipfs/test.policy.readonly @@ -0,0 +1,12 @@ +grant codeBase "file:${java.home}/lib/ext/zipfs.jar" { + permission java.io.FilePermission "<>", "read,write"; + permission java.lang.RuntimePermission "fileSystemProvider"; + permission java.util.PropertyPermission "*", "read"; +}; + +grant { + permission java.io.FilePermission "<>","read"; + permission java.util.PropertyPermission "test.jdk","read"; + permission java.util.PropertyPermission "test.src","read"; + permission java.util.PropertyPermission "user.dir","read"; +}; diff --git a/jdk/test/lib/security/java.policy/Ext_AllPolicy.java b/jdk/test/lib/security/java.policy/Ext_AllPolicy.java index 3e6e969d33d..8a5755390c6 100644 --- a/jdk/test/lib/security/java.policy/Ext_AllPolicy.java +++ b/jdk/test/lib/security/java.policy/Ext_AllPolicy.java @@ -30,12 +30,24 @@ import java.io.*; import java.security.*; public class Ext_AllPolicy { - public static void main (String[] args) { - FilePermission mine = new FilePermission("/tmp/bar", "read"); - SecurityManager sm = System.getSecurityManager(); + public static void main (String[] args) { + boolean allPerms = args.length == 1 && args[0].equals("AllPermission"); + FilePermission mine = new FilePermission("/tmp/bar", "read"); + SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(mine); + if (sm != null) { + try { + sm.checkPermission(mine); + if (!allPerms) { + // Default has no privilege. + throw new RuntimeException(mine + " expected to deny access"); } + } catch (AccessControlException e) { + if (allPerms) { + // expected all permissions granted + throw e; + } + } } + } } diff --git a/jdk/test/lib/security/java.policy/Ext_AllPolicy.sh b/jdk/test/lib/security/java.policy/Ext_AllPolicy.sh index b3bd5d6cb0f..8b8701a987a 100644 --- a/jdk/test/lib/security/java.policy/Ext_AllPolicy.sh +++ b/jdk/test/lib/security/java.policy/Ext_AllPolicy.sh @@ -22,7 +22,7 @@ # # @test -# @bug 4215035 +# @bug 4215035 8040059 # @summary standard extensions path is hard-coded in default system policy file # # @build Ext_AllPolicy @@ -81,6 +81,9 @@ ${COMPILEJAVA}${FS}bin${FS}jar ${TESTTOOLVMOPTS} -cvf Ext_AllPolicy.jar Ext_AllP rm Ext_AllPolicy.class ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} \ - -Djava.security.manager -Djava.ext.dirs="${TESTCLASSES}" Ext_AllPolicy + -Djava.security.manager -Djava.ext.dirs="${TESTCLASSES}" Ext_AllPolicy || exit 10 +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} \ + -Djava.security.policy=${TESTSRC}${FS}test.policy \ + -Djava.security.manager -Djava.ext.dirs="${TESTCLASSES}" Ext_AllPolicy AllPermission exit $? diff --git a/jdk/test/lib/security/java.policy/test.policy b/jdk/test/lib/security/java.policy/test.policy new file mode 100644 index 00000000000..ee814957fd0 --- /dev/null +++ b/jdk/test/lib/security/java.policy/test.policy @@ -0,0 +1,3 @@ +grant codeBase "file:${{java.ext.dirs}}/*" { + permission java.security.AllPermission; +}; From 2fea2c21d65504f99abdcfd16dd3e839aae81da1 Mon Sep 17 00:00:00 2001 From: Eric McCorkle Date: Fri, 9 May 2014 15:27:02 -0400 Subject: [PATCH 04/15] 8042859: Build broken for Solaris Remove stray quotes causing build failures Reviewed-by: sla, chegar --- jdk/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c b/jdk/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c index a79fca6aa36..32dd249f321 100644 --- a/jdk/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c +++ b/jdk/src/solaris/native/sun/tools/attach/SolarisVirtualMachine.c @@ -1,4 +1,4 @@ -''/* +/* * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * From 0c78d5f9e338f294c2c3c237c7f38ec7e14a9bba Mon Sep 17 00:00:00 2001 From: Katja Kantserova Date: Fri, 9 May 2014 15:24:57 +0200 Subject: [PATCH 05/15] 8034960: Serviceability tests using @library failing with java.lang.NoClassDefFoundError Reviewed-by: sla, alanb --- .../com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java | 1 + jdk/test/com/sun/tools/attach/BasicTests.java | 2 +- jdk/test/com/sun/tools/attach/PermissionTest.java | 2 +- jdk/test/com/sun/tools/attach/ProviderTest.java | 2 +- jdk/test/java/io/BufferedInputStream/LargeCopyWithMark.java | 1 + .../java/lang/instrument/PremainClass/NoPremainAgentTest.java | 2 +- .../java/lang/instrument/PremainClass/PremainClassTest.java | 2 +- .../lang/instrument/PremainClass/ZeroArgPremainAgentTest.java | 2 +- .../lang/management/MemoryMXBean/CollectionUsageThreshold.java | 2 +- jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java | 2 +- jdk/test/java/net/URLPermission/nstest/lookup.sh | 2 +- jdk/test/javax/management/monitor/StartStopTest.java | 2 +- .../sun/management/jmxremote/bootstrap/CustomLauncherTest.java | 2 +- .../reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java | 1 + jdk/test/sun/tools/jcmd/TestJcmdDefaults.java | 1 + jdk/test/sun/tools/jcmd/TestJcmdSanity.java | 1 + jdk/test/sun/tools/jmap/BasicJMapTest.java | 1 + jdk/test/sun/tools/jstack/BasicJStackTest.java | 1 + 18 files changed, 18 insertions(+), 11 deletions(-) diff --git a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java index 9bc7c86b452..378310cf56a 100644 --- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java +++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java @@ -26,6 +26,7 @@ * @bug 8028994 * @author Staffan Larsen * @library /lib/testlibrary + * @build jdk.testlibrary.* * @run main CheckOrigin */ diff --git a/jdk/test/com/sun/tools/attach/BasicTests.java b/jdk/test/com/sun/tools/attach/BasicTests.java index 95cf4dcd2fe..f380c28b3a7 100644 --- a/jdk/test/com/sun/tools/attach/BasicTests.java +++ b/jdk/test/com/sun/tools/attach/BasicTests.java @@ -38,7 +38,7 @@ import jdk.testlibrary.ProcessThread; * @bug 6173612 6273707 6277253 6335921 6348630 6342019 6381757 * @summary Basic unit tests for the VM attach mechanism. * @library /lib/testlibrary - * @run build Agent BadAgent RedefineAgent Application Shutdown RedefineDummy RunnerUtil + * @run build jdk.testlibrary.* Agent BadAgent RedefineAgent Application Shutdown RedefineDummy RunnerUtil * @run main BasicTests * * This test will perform a number of basic attach tests. diff --git a/jdk/test/com/sun/tools/attach/PermissionTest.java b/jdk/test/com/sun/tools/attach/PermissionTest.java index 933ec2c23e8..5ac458a3754 100644 --- a/jdk/test/com/sun/tools/attach/PermissionTest.java +++ b/jdk/test/com/sun/tools/attach/PermissionTest.java @@ -34,7 +34,7 @@ import jdk.testlibrary.ProcessThread; * @bug 6173612 6273707 6277253 6335921 6348630 6342019 6381757 * @summary Basic unit tests for the VM attach mechanism. * @library /lib/testlibrary - * @run build Application Shutdown + * @run build jdk.testlibrary.* Application Shutdown * @run main PermissionTest * * Unit test for Attach API - diff --git a/jdk/test/com/sun/tools/attach/ProviderTest.java b/jdk/test/com/sun/tools/attach/ProviderTest.java index 58ea6d5e75a..883951f444d 100644 --- a/jdk/test/com/sun/tools/attach/ProviderTest.java +++ b/jdk/test/com/sun/tools/attach/ProviderTest.java @@ -33,7 +33,7 @@ import com.sun.tools.attach.spi.AttachProvider; * @bug 6173612 6273707 6277253 6335921 6348630 6342019 6381757 * @summary Basic unit tests for the VM attach mechanism. * @library /lib/testlibrary - * @run build SimpleProvider + * @run build jdk.testlibrary.* SimpleProvider * @run main ProviderTest * * The test will attach and detach to/from the running Application. diff --git a/jdk/test/java/io/BufferedInputStream/LargeCopyWithMark.java b/jdk/test/java/io/BufferedInputStream/LargeCopyWithMark.java index 2555a1faa5f..74aeda92932 100644 --- a/jdk/test/java/io/BufferedInputStream/LargeCopyWithMark.java +++ b/jdk/test/java/io/BufferedInputStream/LargeCopyWithMark.java @@ -26,6 +26,7 @@ * @summary BufferedInputStream calculates negative array size with large * streams and mark * @library /lib/testlibrary + * @build jdk.testlibrary.* * @run main/othervm LargeCopyWithMark */ diff --git a/jdk/test/java/lang/instrument/PremainClass/NoPremainAgentTest.java b/jdk/test/java/lang/instrument/PremainClass/NoPremainAgentTest.java index 9d08a7bd9ec..d9710d3bece 100644 --- a/jdk/test/java/lang/instrument/PremainClass/NoPremainAgentTest.java +++ b/jdk/test/java/lang/instrument/PremainClass/NoPremainAgentTest.java @@ -30,7 +30,7 @@ import jdk.testlibrary.Utils; * @bug 6289149 * @summary test when the agent's class is missing the premain() function. * @library /lib/testlibrary - * @run build DummyMain + * @run build jdk.testlibrary.* DummyMain * @run shell ../MakeJAR3.sh NoPremainAgent * @run main NoPremainAgentTest */ diff --git a/jdk/test/java/lang/instrument/PremainClass/PremainClassTest.java b/jdk/test/java/lang/instrument/PremainClass/PremainClassTest.java index 9ebe4a68d2c..2d20ae98dc0 100644 --- a/jdk/test/java/lang/instrument/PremainClass/PremainClassTest.java +++ b/jdk/test/java/lang/instrument/PremainClass/PremainClassTest.java @@ -30,7 +30,7 @@ import jdk.testlibrary.Utils; * @bug 5055293 * @summary Test non ascii characters in the Premain-Class attribute. * @library /lib/testlibrary - * @run build DummyMain + * @run build jdk.testlibrary.* DummyMain * @run main PremainClassTest */ public class PremainClassTest { diff --git a/jdk/test/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java b/jdk/test/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java index 7b67e4c31b7..fb6fab1a677 100644 --- a/jdk/test/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java +++ b/jdk/test/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java @@ -30,7 +30,7 @@ import jdk.testlibrary.Utils; * @bug 6289149 * @summary test when the agent's class has a zero arg premain() function. * @library /lib/testlibrary - * @run build DummyMain + * @run build jdk.testlibrary.* DummyMain * @run shell ../MakeJAR3.sh ZeroArgPremainAgent * @run main ZeroArgPremainAgentTest */ diff --git a/jdk/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java b/jdk/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java index 1309e9c3949..64224d23306 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java +++ b/jdk/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java @@ -31,7 +31,7 @@ * @author Mandy Chung * * @library /lib/testlibrary/ - * @build CollectionUsageThreshold MemoryUtil RunUtil + * @build jdk.testlibrary.* CollectionUsageThreshold MemoryUtil RunUtil * @run main/timeout=300 CollectionUsageThreshold */ diff --git a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java index 379b1293060..891e2fbd4cb 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java +++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java @@ -31,7 +31,7 @@ * @author Mandy Chung * * @library /lib/testlibrary/ - * @build LowMemoryTest MemoryUtil RunUtil + * @build jdk.testlibrary.* LowMemoryTest MemoryUtil RunUtil * @run main/timeout=600 LowMemoryTest */ diff --git a/jdk/test/java/net/URLPermission/nstest/lookup.sh b/jdk/test/java/net/URLPermission/nstest/lookup.sh index 1c7e3cfcb2f..33afed78ba6 100644 --- a/jdk/test/java/net/URLPermission/nstest/lookup.sh +++ b/jdk/test/java/net/URLPermission/nstest/lookup.sh @@ -26,7 +26,7 @@ # @library /lib/testlibrary # @compile -XDignore.symbol.file=true SimpleNameService.java # LookupTest.java SimpleNameServiceDescriptor.java -# @build jdk.testlibrary.Utils +# @build jdk.testlibrary.* # @run shell/timeout=50 lookup.sh # diff --git a/jdk/test/javax/management/monitor/StartStopTest.java b/jdk/test/javax/management/monitor/StartStopTest.java index 80694c63e05..c1feb295956 100644 --- a/jdk/test/javax/management/monitor/StartStopTest.java +++ b/jdk/test/javax/management/monitor/StartStopTest.java @@ -28,7 +28,7 @@ * monitors are started and stopped in a loop. * @author Luis-Miguel Alventosa * @library /lib/testlibrary - * @run build jdk.testlibrary.Utils + * @build jdk.testlibrary.* * @run clean StartStopTest * @run build StartStopTest * @run main/othervm/timeout=300 StartStopTest 1 diff --git a/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java b/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java index ca448159cd1..9745169b639 100644 --- a/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java +++ b/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java @@ -41,7 +41,7 @@ import jdk.testlibrary.ProcessTools; * @test * @bug 6434402 8004926 * @library /lib/testlibrary - * @build jdk.testlibrary.ProcessTools + * @build jdk.testlibrary.* * @build TestManager TestApplication CustomLauncherTest * @run main/othervm CustomLauncherTest * @author Jaroslav Bachorik diff --git a/jdk/test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java b/jdk/test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java index ae5c6596c1f..063746b175a 100644 --- a/jdk/test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java +++ b/jdk/test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java @@ -28,6 +28,7 @@ * @author Robert Field * @library /lib/testlibrary * @compile -XDignore.symbol.file ManyNewInstanceAnonTest.java + * @build jdk.testlibrary.* * @run main ClassFileInstaller ManyNewInstanceAnonTest * @run main/othervm -Xbootclasspath/a:. -Xverify:all ManyNewInstanceAnonTest * @run main/othervm -Xbootclasspath/a:. -Xverify:all -Dsun.reflection.noInflation=true ManyNewInstanceAnonTest diff --git a/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java b/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java index a5310862859..2292be403da 100644 --- a/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java +++ b/jdk/test/sun/tools/jcmd/TestJcmdDefaults.java @@ -39,6 +39,7 @@ import jdk.testlibrary.Utils; * @test * @bug 7104647 * @library /lib/testlibrary + * @build jdk.testlibrary.* * @run main TestJcmdDefaults */ public class TestJcmdDefaults { diff --git a/jdk/test/sun/tools/jcmd/TestJcmdSanity.java b/jdk/test/sun/tools/jcmd/TestJcmdSanity.java index 52fa840fe43..d32fb18d2c1 100644 --- a/jdk/test/sun/tools/jcmd/TestJcmdSanity.java +++ b/jdk/test/sun/tools/jcmd/TestJcmdSanity.java @@ -40,6 +40,7 @@ import jdk.testlibrary.Utils; * @test * @bug 7104647 7154822 * @library /lib/testlibrary + * @build jdk.testlibrary.* * @run main TestJcmdSanity */ public class TestJcmdSanity { diff --git a/jdk/test/sun/tools/jmap/BasicJMapTest.java b/jdk/test/sun/tools/jmap/BasicJMapTest.java index 12be7d3e1bb..3630e9da288 100644 --- a/jdk/test/sun/tools/jmap/BasicJMapTest.java +++ b/jdk/test/sun/tools/jmap/BasicJMapTest.java @@ -34,6 +34,7 @@ import jdk.testlibrary.ProcessTools; * @bug 6321286 * @summary Unit test for jmap utility * @library /lib/testlibrary + * @build jdk.testlibrary.* * @run main BasicJMapTest */ public class BasicJMapTest { diff --git a/jdk/test/sun/tools/jstack/BasicJStackTest.java b/jdk/test/sun/tools/jstack/BasicJStackTest.java index 0794447f5d2..4b3c3656bcd 100644 --- a/jdk/test/sun/tools/jstack/BasicJStackTest.java +++ b/jdk/test/sun/tools/jstack/BasicJStackTest.java @@ -32,6 +32,7 @@ import jdk.testlibrary.ProcessTools; * @bug 6260070 * @summary Unit test for jstack utility * @library /lib/testlibrary + * @build jdk.testlibrary.* * @run main BasicJStackTest */ public class BasicJStackTest { From 0547ad28981c56e79c2996a07409c12e0d1b3040 Mon Sep 17 00:00:00 2001 From: Alexander Stepanov Date: Mon, 12 May 2014 14:12:33 +0400 Subject: [PATCH 06/15] 8030709: Tidy warnings cleanup for java.lang package; minor cleanup in java.math, javax.script Reviewed-by: lancea --- jdk/src/share/classes/java/lang/Character.java | 7 ++----- jdk/src/share/classes/java/lang/Math.java | 1 - jdk/src/share/classes/java/lang/Runtime.java | 8 ++++---- jdk/src/share/classes/java/lang/SecurityManager.java | 3 --- jdk/src/share/classes/java/lang/String.java | 6 +++--- jdk/src/share/classes/java/lang/System.java | 5 +---- .../share/classes/java/lang/instrument/package.html | 4 ++-- .../share/classes/java/lang/invoke/MethodHandles.java | 4 ++-- .../java/lang/management/MemoryNotificationInfo.java | 4 ++-- .../share/classes/java/lang/management/ThreadInfo.java | 6 +++--- .../share/classes/java/lang/management/package.html | 10 +++------- jdk/src/share/classes/java/math/BigInteger.java | 6 +++--- .../classes/javax/script/ScriptEngineFactory.java | 1 - 13 files changed, 25 insertions(+), 40 deletions(-) diff --git a/jdk/src/share/classes/java/lang/Character.java b/jdk/src/share/classes/java/lang/Character.java index 3fda1bbb4a5..3251a49d033 100644 --- a/jdk/src/share/classes/java/lang/Character.java +++ b/jdk/src/share/classes/java/lang/Character.java @@ -4498,7 +4498,6 @@ class Character implements java.io.Serializable, Comparable { * Character case is ignored for all of the valid script names. * The en_US locale's case mapping rules are used to provide * case-insensitive string comparisons for script name validation. - *

* * @param scriptName A {@code UnicodeScript} name. * @return The {@code UnicodeScript} constant identified @@ -5503,7 +5502,7 @@ class Character implements java.io.Serializable, Comparable { * '\u00D0' '\u00D1' '\u00D2' '\u00D3' '\u00D4' '\u00D5' '\u00D6' '\u00D8' * '\u00D9' '\u00DA' '\u00DB' '\u00DC' '\u00DD' '\u00DE' * - *

Many other Unicode characters are uppercase too.

+ *

Many other Unicode characters are uppercase too. * * @param codePoint the character (Unicode code point) to be tested. * @return {@code true} if the character is uppercase; @@ -5581,7 +5580,7 @@ class Character implements java.io.Serializable, Comparable { *

  • {@code LATIN CAPITAL LETTER N WITH SMALL LETTER J} *
  • {@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z} * - *

    Many other Unicode characters are titlecase too.

    + *

    Many other Unicode characters are titlecase too. * * @param codePoint the character (Unicode code point) to be tested. * @return {@code true} if the character is titlecase; @@ -6777,7 +6776,6 @@ class Character implements java.io.Serializable, Comparable { *

  • It is {@code '\u005Cu001E'}, U+001E RECORD SEPARATOR. *
  • It is {@code '\u005Cu001F'}, U+001F UNIT SEPARATOR. * - *

    * * @param codePoint the character (Unicode code point) to be tested. * @return {@code true} if the character is a Java whitespace @@ -7121,7 +7119,6 @@ class Character implements java.io.Serializable, Comparable { /** * Converts the character (Unicode code point) argument to uppercase using * information from the UnicodeData file. - *

    * * @param codePoint the character (Unicode code point) to be converted. * @return either the uppercase equivalent of the character, if diff --git a/jdk/src/share/classes/java/lang/Math.java b/jdk/src/share/classes/java/lang/Math.java index ae2cd096afe..8740bb1c65a 100644 --- a/jdk/src/share/classes/java/lang/Math.java +++ b/jdk/src/share/classes/java/lang/Math.java @@ -1048,7 +1048,6 @@ public final class Math { * whereas {@code (-4 / 3) == -1}. *

  • * - *

    * * @param x the dividend * @param y the divisor diff --git a/jdk/src/share/classes/java/lang/Runtime.java b/jdk/src/share/classes/java/lang/Runtime.java index 9e53dc939ec..d91b8ad26d3 100644 --- a/jdk/src/share/classes/java/lang/Runtime.java +++ b/jdk/src/share/classes/java/lang/Runtime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -83,7 +83,7 @@ public class Runtime { * blocks indefinitely. * *

    The {@link System#exit(int) System.exit} method is the - * conventional and convenient means of invoking this method.

    + * conventional and convenient means of invoking this method. * * @param status * Termination status. By convention, a nonzero status code @@ -180,7 +180,7 @@ public class Runtime { * method goes awry by, for example, corrupting internal data structures or * attempting to access nonexistent memory. If the virtual machine aborts * then no guarantee can be made about whether or not any shutdown hooks - * will be run.

    + * will be run. * * @param hook * An initialized but unstarted {@link Thread} object @@ -248,7 +248,7 @@ public class Runtime { * hooks to be started and does not run uninvoked finalizers if * finalization-on-exit has been enabled. If the shutdown sequence has * already been initiated then this method does not wait for any running - * shutdown hooks or finalizers to finish their work.

    + * shutdown hooks or finalizers to finish their work. * * @param status * Termination status. By convention, a nonzero status code diff --git a/jdk/src/share/classes/java/lang/SecurityManager.java b/jdk/src/share/classes/java/lang/SecurityManager.java index e0aeb32de17..f7f3a58e4f2 100644 --- a/jdk/src/share/classes/java/lang/SecurityManager.java +++ b/jdk/src/share/classes/java/lang/SecurityManager.java @@ -1242,7 +1242,6 @@ class SecurityManager { * super.checkPropertiesAccess * at the point the overridden method would normally throw an * exception. - *

    * * @exception SecurityException if the calling thread does not have * permission to access or modify the system properties. @@ -1320,7 +1319,6 @@ class SecurityManager { * super.checkPrintJobAccess * at the point the overridden method would normally throw an * exception. - *

    * * @exception SecurityException if the calling thread does not have * permission to initiate a print job request. @@ -1566,7 +1564,6 @@ class SecurityManager { * super.checkSetFactory * at the point the overridden method would normally throw an * exception. - *

    * * @exception SecurityException if the calling thread does not have * permission to specify a socket factory or a stream diff --git a/jdk/src/share/classes/java/lang/String.java b/jdk/src/share/classes/java/lang/String.java index 4e68fe30dc0..120fe0c8a08 100644 --- a/jdk/src/share/classes/java/lang/String.java +++ b/jdk/src/share/classes/java/lang/String.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 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 @@ -2650,7 +2650,7 @@ public final class String * LATIN SMALL LETTER DOTLESS I character. * To obtain correct results for locale insensitive strings, use * {@code toLowerCase(Locale.ROOT)}. - *

    + * * @return the {@code String}, converted to lowercase. * @see java.lang.String#toLowerCase(Locale) */ @@ -2812,7 +2812,7 @@ public final class String * LATIN CAPITAL LETTER I WITH DOT ABOVE character. * To obtain correct results for locale insensitive strings, use * {@code toUpperCase(Locale.ROOT)}. - *

    + * * @return the {@code String}, converted to uppercase. * @see java.lang.String#toUpperCase(Locale) */ diff --git a/jdk/src/share/classes/java/lang/System.java b/jdk/src/share/classes/java/lang/System.java index 69d1d0fe1ef..0a8cc3a4802 100644 --- a/jdk/src/share/classes/java/lang/System.java +++ b/jdk/src/share/classes/java/lang/System.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 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 @@ -133,7 +133,6 @@ public final class System { *

    First, if there is a security manager, its checkPermission * method is called with a RuntimePermission("setIO") permission * to see if it's ok to reassign the "standard" input stream. - *

    * * @param in the new standard input stream. * @@ -762,7 +761,6 @@ public final class System { * permission. This may result in a SecurityException being thrown. * If no exception is thrown, the specified property is set to the given * value. - *

    * * @param key the name of the system property. * @param value the value of the system property. @@ -801,7 +799,6 @@ public final class System { * is called with a PropertyPermission(key, "write") * permission. This may result in a SecurityException being thrown. * If no exception is thrown, the specified property is removed. - *

    * * @param key the name of the system property to be removed. * @return the previous string value of the system property, diff --git a/jdk/src/share/classes/java/lang/instrument/package.html b/jdk/src/share/classes/java/lang/instrument/package.html index e6839e52f9b..b8e34f3f7fb 100644 --- a/jdk/src/share/classes/java/lang/instrument/package.html +++ b/jdk/src/share/classes/java/lang/instrument/package.html @@ -1,5 +1,5 @@ " + - ""+ - "" + - "" + - "" + - ""; - - /** - * Version number for the format of exported properties files. - */ - private static final String EXTERNAL_XML_VERSION = "1.0"; - - @Override - public void load(Properties props, InputStream in) - throws IOException, InvalidPropertiesFormatException - { - Document doc = null; - try { - doc = getLoadingDoc(in); - } catch (SAXException saxe) { - throw new InvalidPropertiesFormatException(saxe); - } - Element propertiesElement = doc.getDocumentElement(); - String xmlVersion = propertiesElement.getAttribute("version"); - if (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) - throw new InvalidPropertiesFormatException( - "Exported Properties file format version " + xmlVersion + - " is not supported. This java installation can read" + - " versions " + EXTERNAL_XML_VERSION + " or older. You" + - " may need to install a newer version of JDK."); - importProperties(props, propertiesElement); - } - - static Document getLoadingDoc(InputStream in) - throws SAXException, IOException - { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setIgnoringElementContentWhitespace(true); - dbf.setValidating(true); - dbf.setCoalescing(true); - dbf.setIgnoringComments(true); - try { - DocumentBuilder db = dbf.newDocumentBuilder(); - db.setEntityResolver(new Resolver()); - db.setErrorHandler(new EH()); - InputSource is = new InputSource(in); - return db.parse(is); - } catch (ParserConfigurationException x) { - throw new Error(x); - } - } - - static void importProperties(Properties props, Element propertiesElement) { - NodeList entries = propertiesElement.getChildNodes(); - int numEntries = entries.getLength(); - int start = numEntries > 0 && - entries.item(0).getNodeName().equals("comment") ? 1 : 0; - for (int i=start; i e : props.entrySet()) { - final Object k = e.getKey(); - final Object v = e.getValue(); - if (k instanceof String && v instanceof String) { - Element entry = (Element)properties.appendChild( - doc.createElement("entry")); - entry.setAttribute("key", (String)k); - entry.appendChild(doc.createTextNode((String)v)); - } - } - } - emitDocument(doc, os, encoding); - } - - static void emitDocument(Document doc, OutputStream os, String encoding) - throws IOException - { - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer t = null; - try { - t = tf.newTransformer(); - t.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, PROPS_DTD_URI); - t.setOutputProperty(OutputKeys.INDENT, "yes"); - t.setOutputProperty(OutputKeys.METHOD, "xml"); - t.setOutputProperty(OutputKeys.ENCODING, encoding); - } catch (TransformerConfigurationException tce) { - assert(false); - } - DOMSource doms = new DOMSource(doc); - StreamResult sr = new StreamResult(os); - try { - t.transform(doms, sr); - } catch (TransformerException te) { - throw new IOException(te); - } - } - - private static class Resolver implements EntityResolver { - public InputSource resolveEntity(String pid, String sid) - throws SAXException - { - if (sid.equals(PROPS_DTD_URI)) { - InputSource is; - is = new InputSource(new StringReader(PROPS_DTD)); - is.setSystemId(PROPS_DTD_URI); - return is; - } - throw new SAXException("Invalid system identifier: " + sid); - } - } - - private static class EH implements ErrorHandler { - public void error(SAXParseException x) throws SAXException { - throw x; - } - public void fatalError(SAXParseException x) throws SAXException { - throw x; - } - public void warning(SAXParseException x) throws SAXException { - throw x; - } - } - -} diff --git a/jdk/test/java/util/Properties/CompatibilityTest.java b/jdk/test/java/util/Properties/CompatibilityTest.java index efd16c9bd59..46d8a10c92c 100644 --- a/jdk/test/java/util/Properties/CompatibilityTest.java +++ b/jdk/test/java/util/Properties/CompatibilityTest.java @@ -25,8 +25,6 @@ * @test * @bug 8005280 8004371 * @summary Compatibility test - * @run main CompatibilityTest - * @run main/othervm -Dsun.util.spi.XmlPropertiesProvider=jdk.internal.util.xml.BasicXmlPropertiesProvider CompatibilityTest */ import java.io.FileInputStream; diff --git a/jdk/test/java/util/Properties/ConcurrentLoadAndStoreXML.java b/jdk/test/java/util/Properties/ConcurrentLoadAndStoreXML.java index 1e439439a00..7bb187c228c 100644 --- a/jdk/test/java/util/Properties/ConcurrentLoadAndStoreXML.java +++ b/jdk/test/java/util/Properties/ConcurrentLoadAndStoreXML.java @@ -25,9 +25,6 @@ * @bug 8005281 * @summary Test that the Properties storeToXML and loadFromXML methods are * thread safe - * @run main ConcurrentLoadAndStoreXML - * @run main/othervm -Dsun.util.spi.XmlPropertiesProvider=jdk.internal.util.xml.BasicXmlPropertiesProvider ConcurrentLoadAndStoreXML - */ import java.io.*; diff --git a/jdk/test/java/util/Properties/CustomProvider.java b/jdk/test/java/util/Properties/CustomProvider.java deleted file mode 100644 index fc8ed24b0b7..00000000000 --- a/jdk/test/java/util/Properties/CustomProvider.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 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 8000354 - * @summary Test - * @compile -XDignore.symbol.file CustomProvider.java MyXmlPropertiesProvider.java - * @run main/othervm -Dsun.util.spi.XmlPropertiesProvider=MyXmlPropertiesProvider CustomProvider - */ - -import java.util.*; -import java.io.*; - -/** - * Sanity test to verify that the property sun.util.spi.XmlPropertiesProvider - * can be used to specify a custom provider for loading/storing properties - * in XML format. - */ -public class CustomProvider { - - public static void main(String[] args) throws IOException { - String provider = System.getProperty("sun.util.spi.XmlPropertiesProvider"); - assertTrue(provider != null, "sun.util.spi.XmlPropertiesProvider not set"); - - OutputStream out = new ByteArrayOutputStream(); - InputStream in = new ByteArrayInputStream(new byte[100]); - - Properties props; - - props = new Properties(); - props.loadFromXML(in); - - props = System.getProperties(); - props.storeToXML(out, "comment"); - props.storeToXML(out, "comment", "UTF-8"); - - // check that the provider's load and store methods have been invoked - - assertTrue(MyXmlPropertiesProvider.createCount() == 1, - "Provider should only be created once"); - assertTrue(MyXmlPropertiesProvider.loadCount() == 1, - "load method expected to be called once"); - assertTrue(MyXmlPropertiesProvider.storeCount() == 2, - "store method expected to be called twice"); - } - - static void assertTrue(boolean b, String msg) { - if (!b) throw new RuntimeException(msg); - } -} diff --git a/jdk/test/java/util/Properties/LoadAndStoreXML.java b/jdk/test/java/util/Properties/LoadAndStoreXML.java index 5388485e91b..53fec099da9 100644 --- a/jdk/test/java/util/Properties/LoadAndStoreXML.java +++ b/jdk/test/java/util/Properties/LoadAndStoreXML.java @@ -25,8 +25,6 @@ * @test * @bug 8000354 8000685 8004371 * @summary Basic test of storeToXML and loadToXML - * @run main LoadAndStoreXML - * @run main/othervm -Dsun.util.spi.XmlPropertiesProvider=jdk.internal.util.xml.BasicXmlPropertiesProvider LoadAndStoreXML */ import java.io.*; diff --git a/jdk/test/java/util/Properties/LoadAndStoreXMLWithDefaults.java b/jdk/test/java/util/Properties/LoadAndStoreXMLWithDefaults.java index fa96e0ad3c8..3d5cedea555 100644 --- a/jdk/test/java/util/Properties/LoadAndStoreXMLWithDefaults.java +++ b/jdk/test/java/util/Properties/LoadAndStoreXMLWithDefaults.java @@ -35,58 +35,17 @@ import java.util.Properties; */ public class LoadAndStoreXMLWithDefaults { - public static enum StoreMethod { - // Note: this case will test the default provider when available, - // and the basic provider when it's not. - PROPERTIES { - @Override - public String writeToXML(Properties p) throws IOException { - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - p.storeToXML(baos, "Test 8016344"); - return baos.toString(); - } - @Override - public Properties loadFromXML(String xml, Properties defaults) - throws IOException { - final ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes("UTF-8")); - Properties p = new Properties(defaults); - p.loadFromXML(bais); - return p; - } - }, - // Note: this case always test the basic provider, which is always available. - // so sometimes it's just a dup with the previous case... - BASICPROVIDER { - @Override - public String writeToXML(Properties p) throws IOException { - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - jdk.internal.util.xml.BasicXmlPropertiesProvider provider = - new jdk.internal.util.xml.BasicXmlPropertiesProvider(); - provider.store(p, baos, "Test 8016344", "UTF-8"); - return baos.toString(); - } - @Override - public Properties loadFromXML(String xml, Properties defaults) - throws IOException { - final ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes("UTF-8")); - Properties p = new Properties(defaults); - jdk.internal.util.xml.BasicXmlPropertiesProvider provider = - new jdk.internal.util.xml.BasicXmlPropertiesProvider(); - provider.load(p, bais); - return p; - } - }; - public abstract String writeToXML(Properties p) throws IOException; - public abstract Properties loadFromXML(String xml, Properties defaults) - throws IOException; - public String displayName() { - switch(this) { - case PROPERTIES: return "Properties.storeToXML"; - case BASICPROVIDER: return "BasicXmlPropertiesProvider.store"; - default: - throw new UnsupportedOperationException(this.name()); - } - } + static String writeToXML(Properties props) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + props.storeToXML(baos, "Test 8016344"); + return baos.toString(); + } + + static Properties loadFromXML(String xml, Properties defaults) throws IOException { + ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes("UTF-8")); + Properties props = new Properties(defaults); + props.loadFromXML(bais); + return props; } static enum Objects { OBJ1, OBJ2, OBJ3 }; @@ -106,63 +65,59 @@ public class LoadAndStoreXMLWithDefaults { p3.setProperty("p1.and.p2.and.p3.prop", "prop9-p3"); p3.setProperty("p2.and.p3.prop", "prop10-p3"); - for (StoreMethod m : StoreMethod.values()) { - System.out.println("Testing with " + m.displayName()); - Properties P1 = m.loadFromXML(m.writeToXML(p1), null); - Properties P2 = m.loadFromXML(m.writeToXML(p2), P1); - Properties P3 = m.loadFromXML(m.writeToXML(p3), P2); + Properties P1 = loadFromXML(writeToXML(p1), null); + Properties P2 = loadFromXML(writeToXML(p2), P1); + Properties P3 = loadFromXML(writeToXML(p3), P2); - testResults(m, p1, P1, p2, P2, p3, P3); + testResults(p1, P1, p2, P2, p3, P3); - // Now check that properties whose keys or values are objects - // are skipped. + // Now check that properties whose keys or values are objects + // are skipped. - System.out.println("Testing with " + m.displayName() + " and Objects"); - P1.put("p1.object.prop", Objects.OBJ1); - P1.put(Objects.OBJ1, "p1.object.prop"); - P1.put("p2.object.prop", "p2.object.prop"); - P2.put("p2.object.prop", Objects.OBJ2); - P2.put(Objects.OBJ2, "p2.object.prop"); - P3.put("p3.object.prop", Objects.OBJ3); - P3.put(Objects.OBJ3, "p3.object.prop"); + P1.put("p1.object.prop", Objects.OBJ1); + P1.put(Objects.OBJ1, "p1.object.prop"); + P1.put("p2.object.prop", "p2.object.prop"); + P2.put("p2.object.prop", Objects.OBJ2); + P2.put(Objects.OBJ2, "p2.object.prop"); + P3.put("p3.object.prop", Objects.OBJ3); + P3.put(Objects.OBJ3, "p3.object.prop"); - Properties PP1 = m.loadFromXML(m.writeToXML(P1), null); - Properties PP2 = m.loadFromXML(m.writeToXML(P2), PP1); - Properties PP3 = m.loadFromXML(m.writeToXML(P3), PP2); + Properties PP1 = loadFromXML(writeToXML(P1), null); + Properties PP2 = loadFromXML(writeToXML(P2), PP1); + Properties PP3 = loadFromXML(writeToXML(P3), PP2); - p1.setProperty("p2.object.prop", "p2.object.prop"); - try { - testResults(m, p1, PP1, p2, PP2, p3, PP3); - } finally { - p1.remove("p2.object.prop"); - } + p1.setProperty("p2.object.prop", "p2.object.prop"); + try { + testResults(p1, PP1, p2, PP2, p3, PP3); + } finally { + p1.remove("p2.object.prop"); } } - public static void testResults(StoreMethod m, Properties... pps) { + public static void testResults(Properties... pps) { for (int i=0 ; i < pps.length ; i += 2) { if (!pps[i].equals(pps[i+1])) { - System.err.println(m.displayName() +": P" + (i/2+1) + System.err.println("P" + (i/2+1) + " Reloaded properties differ from original"); System.err.println("\toriginal: " + pps[i]); System.err.println("\treloaded: " + pps[i+1]); - throw new RuntimeException(m.displayName() +": P" + (i/2+1) + throw new RuntimeException("P" + (i/2+1) + " Reloaded properties differ from original"); } if (!pps[i].keySet().equals(pps[i+1].keySet())) { - System.err.println(m.displayName() +": P" + (i/2+1) + System.err.println("P" + (i/2+1) + " Reloaded property names differ from original"); System.err.println("\toriginal: " + pps[i].keySet()); System.err.println("\treloaded: " + pps[i+1].keySet()); - throw new RuntimeException(m.displayName() +": P" + (i/2+1) + throw new RuntimeException("P" + (i/2+1) + " Reloaded property names differ from original"); } if (!pps[i].stringPropertyNames().equals(pps[i+1].stringPropertyNames())) { - System.err.println(m.displayName() +": P" + (i/2+1) + System.err.println("P" + (i/2+1) + " Reloaded string property names differ from original"); System.err.println("\toriginal: " + pps[i].stringPropertyNames()); System.err.println("\treloaded: " + pps[i+1].stringPropertyNames()); - throw new RuntimeException(m.displayName() +": P" + (i/2+1) + throw new RuntimeException("P" + (i/2+1) + " Reloaded string property names differ from original"); } } diff --git a/jdk/test/java/util/Properties/MyXmlPropertiesProvider.java b/jdk/test/java/util/Properties/MyXmlPropertiesProvider.java deleted file mode 100644 index 652fa28ac5f..00000000000 --- a/jdk/test/java/util/Properties/MyXmlPropertiesProvider.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 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. - */ - -import java.util.*; -import java.io.*; - -public class MyXmlPropertiesProvider - extends sun.util.spi.XmlPropertiesProvider -{ - private static int createCount; - private static int loadCount; - private static int storeCount; - - static int createCount() { return createCount; } - static int loadCount() { return loadCount; } - static int storeCount() { return storeCount; } - - public MyXmlPropertiesProvider() { - createCount++; - } - - @Override - public void load(Properties props, InputStream in) - throws IOException, InvalidPropertiesFormatException - { - loadCount++; - } - - @Override - public void store(Properties props, OutputStream out, - String comment, String encoding) - throws IOException - { - storeCount++; - } -} From df9743eb64629db36757820317cb12ba5b8e96a7 Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Wed, 14 May 2014 11:16:41 +0100 Subject: [PATCH 11/15] 8034170: src/share/classes/sun/net/www/protocol/http/DigestAuthentication.java Reviewed-by: chegar --- .../protocol/http/DigestAuthentication.java | 48 ++++- jdk/test/java/net/Authenticator/B8034170.java | 192 ++++++++++++++++++ 2 files changed, 231 insertions(+), 9 deletions(-) create mode 100644 jdk/test/java/net/Authenticator/B8034170.java diff --git a/jdk/src/share/classes/sun/net/www/protocol/http/DigestAuthentication.java b/jdk/src/share/classes/sun/net/www/protocol/http/DigestAuthentication.java index 8701a77562a..af954e18ee7 100644 --- a/jdk/src/share/classes/sun/net/www/protocol/http/DigestAuthentication.java +++ b/jdk/src/share/classes/sun/net/www/protocol/http/DigestAuthentication.java @@ -34,8 +34,11 @@ import java.util.StringTokenizer; import java.util.Random; import sun.net.www.HeaderParser; +import sun.net.NetProperties; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import java.security.PrivilegedAction; +import java.security.AccessController; import static sun.net.www.protocol.http.HttpURLConnection.HTTP_CONNECT; /** @@ -51,6 +54,23 @@ class DigestAuthentication extends AuthenticationInfo { private String authMethod; + private final static String compatPropName = "http.auth.digest." + + "quoteParameters"; + + // true if http.auth.digest.quoteParameters Net property is true + private static final boolean delimCompatFlag; + + static { + Boolean b = AccessController.doPrivileged( + new PrivilegedAction() { + public Boolean run() { + return NetProperties.getBoolean(compatPropName); + } + } + ); + delimCompatFlag = (b == null) ? false : b.booleanValue(); + } + // Authentication parameters defined in RFC2617. // One instance of these may be shared among several DigestAuthentication // instances as a result of a single authorization (for multiple domains) @@ -206,7 +226,7 @@ class DigestAuthentication extends AuthenticationInfo { } /** - * Reclaculates the request-digest and returns it. + * Recalculates the request-digest and returns it. * *

    Used in the common case where the requestURI is simply the * abs_path. @@ -225,7 +245,7 @@ class DigestAuthentication extends AuthenticationInfo { } /** - * Reclaculates the request-digest and returns it. + * Recalculates the request-digest and returns it. * *

    Used when the requestURI is not the abs_path. The exact * requestURI can be passed as a String. @@ -357,24 +377,34 @@ class DigestAuthentication extends AuthenticationInfo { ncfield = "\", nc=" + ncstring; } + String algoS, qopS; + + if (delimCompatFlag) { + // Put quotes around these String value parameters + algoS = ", algorithm=\"" + algorithm + "\""; + qopS = ", qop=\"auth\""; + } else { + // Don't put quotes around them, per the RFC + algoS = ", algorithm=" + algorithm; + qopS = ", qop=auth"; + } + String value = authMethod + " username=\"" + pw.getUserName() + "\", realm=\"" + realm + "\", nonce=\"" + nonce + ncfield + ", uri=\"" + uri - + "\", response=\"" + response - + "\", algorithm=" + algorithm; + + "\", response=\"" + response + "\"" + + algoS; if (opaque != null) { - value = value + ", opaque=\"" + opaque; - value = value + "\""; + value += ", opaque=\"" + opaque + "\""; } if (cnonce != null) { - value = value + ", cnonce=\"" + cnonce; - value = value + "\""; + value += ", cnonce=\"" + cnonce + "\""; } if (qop) { - value = value + ", qop=auth"; + value += qopS; } return value; } diff --git a/jdk/test/java/net/Authenticator/B8034170.java b/jdk/test/java/net/Authenticator/B8034170.java new file mode 100644 index 00000000000..3767732c2e8 --- /dev/null +++ b/jdk/test/java/net/Authenticator/B8034170.java @@ -0,0 +1,192 @@ +/* + * 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.*; +import java.net.*; +import java.util.*; + +/** + * @test + * @bug 8034170 + * @summary Digest authentication interop issue + * @run main/othervm B8034170 unquoted + * @run main/othervm -Dhttp.auth.digest.quoteParameters=true B8034170 quoted + */ + +public class B8034170 { + + static boolean expectQuotes; + + static class BasicServer extends Thread { + + ServerSocket server; + + Socket s; + InputStream is; + OutputStream os; + + static final String realm = "wallyworld"; + + String reply1 = "HTTP/1.1 401 Unauthorized\r\n"+ + "WWW-Authenticate: Digest realm=\""+realm+"\", qop=\"auth\"" + + ", nonce=\"8989de95ea2402b64d73cecdb15da255\"" + + ", opaque=\"bbfb4c9ee92ddccc73521c3e6e841ba2\"\r\n\r\n"; + + String OKreply = "HTTP/1.1 200 OK\r\n"+ + "Date: Mon, 15 Jan 2001 12:18:21 GMT\r\n" + + "Server: Apache/1.3.14 (Unix)\r\n" + + "Connection: close\r\n" + + "Content-Type: text/plain; charset=iso-8859-1\r\n" + + "Content-Length: 10\r\n\r\n"; + + String ERRreply = "HTTP/1.1 500 Internal server error\r\n"+ + "Date: Mon, 15 Jan 2001 12:18:21 GMT\r\n" + + "Server: Apache/1.3.14 (Unix)\r\n" + + "Connection: close\r\n" + + "Content-Length: 0\r\n\r\n"; + + BasicServer (ServerSocket s) { + server = s; + } + + int readAll (Socket s, byte[] buf) throws IOException { + int pos = 0; + InputStream is = s.getInputStream (); + // wait two seconds for request, as client doesn't close + // the connection + s.setSoTimeout(2000); + try { + int n; + while ((n=is.read(buf, pos, buf.length-pos)) > 0) + pos +=n; + } catch (SocketTimeoutException x) { } + return pos; + } + + public void run () { + byte[] buf = new byte[5000]; + try { + System.out.println ("Server 1: accept"); + s = server.accept (); + System.out.println ("accepted"); + os = s.getOutputStream(); + os.write (reply1.getBytes()); + readAll (s, buf); + s.close (); + + System.out.println ("Server 2: accept"); + s = server.accept (); + System.out.println ("accepted"); + os = s.getOutputStream(); + int count = readAll (s, buf); + String reply = new String(buf, 0, count); + + boolean error; + + if (expectQuotes) { + error = false; + if (!reply.contains("qop=\"auth\"")) { + System.out.println ("Expecting quoted qop. Not found"); + error = true; + } + if (!reply.contains("algorithm=\"MD5\"")) { + System.out.println ("Expecting quoted algorithm. Not found"); + error = true; + } + } else { + error = false; + if (!reply.contains("qop=auth")) { + System.out.println ("Expecting unquoted qop. Not found"); + error = true; + } + if (!reply.contains("algorithm=MD5")) { + System.out.println ("Expecting unquoted algorithm. Not found"); + error = true; + } + } + if (error) { + os.write(ERRreply.getBytes()); + os.flush(); + s.close(); + } else { + os.write((OKreply+"HelloWorld").getBytes()); + os.flush(); + s.close(); + } + } + catch (Exception e) { + System.out.println (e); + } + finished (); + } + + public synchronized void finished () { + notifyAll(); + } + + } + + static class MyAuthenticator3 extends Authenticator { + PasswordAuthentication pw; + MyAuthenticator3 () { + super (); + pw = new PasswordAuthentication ("user", "passwordNotCheckedAnyway".toCharArray()); + } + + public PasswordAuthentication getPasswordAuthentication () + { + System.out.println ("Auth called"); + return pw; + } + } + + + static void read (InputStream is) throws IOException { + int c; + System.out.println ("reading"); + while ((c=is.read()) != -1) { + System.out.write (c); + } + System.out.println (""); + System.out.println ("finished reading"); + } + + public static void main (String args[]) throws Exception { + expectQuotes = args[0].equals("quoted"); + + MyAuthenticator3 auth = new MyAuthenticator3 (); + Authenticator.setDefault (auth); + ServerSocket ss = new ServerSocket (0); + int port = ss.getLocalPort (); + BasicServer server = new BasicServer (ss); + synchronized (server) { + server.start(); + System.out.println ("client 1"); + URL url = new URL ("http://localhost:"+port+"/d1/d2/d3/foo.html"); + URLConnection urlc = url.openConnection (); + InputStream is = urlc.getInputStream (); + read (is); + is.close (); + } + } +} From 3b959b9adfe32e80053b4877fb8ee5833e7d1791 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 14 May 2014 16:40:53 +0100 Subject: [PATCH 12/15] 8043119: (props) Properties.storeToXML closes output stream Reviewed-by: lancea --- .../util/xml/PropertiesDefaultHandler.java | 2 +- .../java/util/Properties/LoadAndStoreXML.java | 76 +++++++++++++++++-- 2 files changed, 70 insertions(+), 8 deletions(-) diff --git a/jdk/src/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java b/jdk/src/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java index 8ffdb1aacd6..4589959db19 100644 --- a/jdk/src/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java +++ b/jdk/src/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java @@ -123,7 +123,7 @@ public class PropertiesDefaultHandler extends DefaultHandler { writer.writeEndElement(); writer.writeEndDocument(); - writer.close(); + writer.flush(); } catch (XMLStreamException e) { if (e.getCause() instanceof UnsupportedEncodingException) { throw (UnsupportedEncodingException) e.getCause(); diff --git a/jdk/test/java/util/Properties/LoadAndStoreXML.java b/jdk/test/java/util/Properties/LoadAndStoreXML.java index 53fec099da9..5353c645b81 100644 --- a/jdk/test/java/util/Properties/LoadAndStoreXML.java +++ b/jdk/test/java/util/Properties/LoadAndStoreXML.java @@ -23,14 +23,28 @@ /* * @test - * @bug 8000354 8000685 8004371 + * @bug 8000354 8000685 8004371 8043119 * @summary Basic test of storeToXML and loadToXML */ -import java.io.*; -import java.util.*; -import java.security.*; -import java.nio.file.*; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +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.InvalidPropertiesFormatException; +import java.util.Properties; +import java.util.PropertyPermission; public class LoadAndStoreXML { @@ -63,6 +77,50 @@ public class LoadAndStoreXML { } } + /** + * A {@code ByteArrayInputStream} that allows testing if the + * {@code close} method has been invoked. + */ + static class TestInputStream extends ByteArrayInputStream { + private boolean closed; + + TestInputStream(byte[] buf) { + super(buf); + } + + boolean isOpen() { + return !closed; + } + + public void close() throws IOException { + try { + super.close(); + } finally { + closed = true; + } + } + } + + /** + * A {@code ByteArrayOutputStream} that allows testing if the + * {@code close} method has been invoked. + */ + static class TestOutputStream extends ByteArrayOutputStream { + private boolean closed; + + boolean isOpen() { + return !closed; + } + + public void close() throws IOException { + try { + super.close(); + } finally { + closed = true; + } + } + } + /** * Sanity test that properties saved with Properties#storeToXML can be * read with Properties#loadFromXML. @@ -77,12 +135,16 @@ public class LoadAndStoreXML { props.put("k4", "\u7532\u9aa8\u6587"); props.put("k5", "/lib/jaxp.properties"); - ByteArrayOutputStream out = new ByteArrayOutputStream(); + TestOutputStream out = new TestOutputStream(); props.storeToXML(out, null, encoding); + if (!out.isOpen()) + throw new RuntimeException("OutputStream closed by storeToXML"); Properties p = new Properties(); - ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); + TestInputStream in = new TestInputStream(out.toByteArray()); p.loadFromXML(in); + if (in.isOpen()) + throw new RuntimeException("InputStream not closed by loadFromXML"); if (!p.equals(props)) { System.err.println("stored: " + props); From d0dadf23c5375462dbb716424a2b8a90e89de568 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Wed, 14 May 2014 10:52:51 -0700 Subject: [PATCH 13/15] 8041791: String.toLowerCase regression - violates Unicode standard Reviewed-by: peytoia --- .../java/lang/ConditionalSpecialCasing.java | 15 ++++++++++----- jdk/src/share/classes/java/lang/String.java | 3 +++ jdk/test/java/lang/String/ToLowerCase.java | 16 ++++++++++++---- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/jdk/src/share/classes/java/lang/ConditionalSpecialCasing.java b/jdk/src/share/classes/java/lang/ConditionalSpecialCasing.java index ff9288bab91..d57973042a9 100644 --- a/jdk/src/share/classes/java/lang/ConditionalSpecialCasing.java +++ b/jdk/src/share/classes/java/lang/ConditionalSpecialCasing.java @@ -62,6 +62,7 @@ final class ConditionalSpecialCasing { //# Conditional mappings //# ================================================================================ new Entry(0x03A3, new char[]{0x03C2}, new char[]{0x03A3}, null, FINAL_CASED), // # GREEK CAPITAL LETTER SIGMA + new Entry(0x0130, new char[]{0x0069, 0x0307}, new char[]{0x0130}, null, 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE //# ================================================================================ //# Locale-sensitive mappings @@ -77,8 +78,8 @@ final class ConditionalSpecialCasing { //# ================================================================================ //# Turkish and Azeri -// new Entry(0x0130, new char[]{0x0069}, new char[]{0x0130}, "tr", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE -// new Entry(0x0130, new char[]{0x0069}, new char[]{0x0130}, "az", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE + new Entry(0x0130, new char[]{0x0069}, new char[]{0x0130}, "tr", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE + new Entry(0x0130, new char[]{0x0069}, new char[]{0x0130}, "az", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE new Entry(0x0307, new char[]{}, new char[]{0x0307}, "tr", AFTER_I), // # COMBINING DOT ABOVE new Entry(0x0307, new char[]{}, new char[]{0x0307}, "az", AFTER_I), // # COMBINING DOT ABOVE new Entry(0x0049, new char[]{0x0131}, new char[]{0x0049}, "tr", NOT_BEFORE_DOT), // # LATIN CAPITAL LETTER I @@ -147,21 +148,25 @@ final class ConditionalSpecialCasing { private static char[] lookUpTable(String src, int index, Locale locale, boolean bLowerCasing) { HashSet set = entryTable.get(new Integer(src.codePointAt(index))); + char[] ret = null; if (set != null) { Iterator iter = set.iterator(); String currentLang = locale.getLanguage(); while (iter.hasNext()) { Entry entry = iter.next(); - String conditionLang= entry.getLanguage(); + String conditionLang = entry.getLanguage(); if (((conditionLang == null) || (conditionLang.equals(currentLang))) && isConditionMet(src, index, locale, entry.getCondition())) { - return (bLowerCasing ? entry.getLowerCase() : entry.getUpperCase()); + ret = bLowerCasing ? entry.getLowerCase() : entry.getUpperCase(); + if (conditionLang != null) { + break; + } } } } - return null; + return ret; } private static boolean isConditionMet(String src, int index, Locale locale, int condition) { diff --git a/jdk/src/share/classes/java/lang/String.java b/jdk/src/share/classes/java/lang/String.java index 120fe0c8a08..2227a6f26b7 100644 --- a/jdk/src/share/classes/java/lang/String.java +++ b/jdk/src/share/classes/java/lang/String.java @@ -2583,6 +2583,9 @@ public final class String if (cp == '\u03A3') { // GREEK CAPITAL LETTER SIGMA return toLowerCaseEx(result, i, locale, false); } + if (cp == '\u0130') { // LATIN CAPITAL LETTER I WITH DOT ABOVE + return toLowerCaseEx(result, i, locale, true); + } cp = Character.toLowerCase(cp); if (!Character.isBmpCodePoint(cp)) { return toLowerCaseEx(result, i, locale, false); diff --git a/jdk/test/java/lang/String/ToLowerCase.java b/jdk/test/java/lang/String/ToLowerCase.java index c7c43993ec9..5aebf7275e0 100644 --- a/jdk/test/java/lang/String/ToLowerCase.java +++ b/jdk/test/java/lang/String/ToLowerCase.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 @@ -23,7 +23,7 @@ /* @test - @bug 4217441 4533872 4900935 8020037 8032012 + @bug 4217441 4533872 4900935 8020037 8032012 8041791 @summary toLowerCase should lower-case Greek Sigma correctly depending on the context (final/non-final). Also it should handle Locale specific (lt, tr, and az) lowercasings and supplementary @@ -72,8 +72,10 @@ public class ToLowerCase { // I-dot tests test("\u0130", turkish, "i"); test("\u0130", az, "i"); - test("\u0130", lt, "i"); - test("\u0130", Locale.US, "i"); + test("\u0130", lt, "\u0069\u0307"); + test("\u0130", Locale.US, "\u0069\u0307"); + test("\u0130", Locale.JAPAN, "\u0069\u0307"); + test("\u0130", Locale.ROOT, "\u0069\u0307"); // Remove dot_above in the sequence I + dot_above (Turkish and Azeri) test("I\u0307", turkish, "i"); @@ -111,6 +113,12 @@ public class ToLowerCase { if (cp >= Character.MIN_HIGH_SURROGATE && cp <= Character.MAX_HIGH_SURROGATE) { continue; } + if (cp == 0x0130) { + // Although UnicodeData.txt has the lower case char as \u0069, it should be + // handled with the rules in SpecialCasing.txt, i.e., \u0069\u0307 in + // non Turkic locales. + continue; + } int lowerCase = Character.toLowerCase(cp); if (lowerCase == -1) { //Character.ERROR continue; From d395efe8f5eee3ad49ba968f813b6fc491377c72 Mon Sep 17 00:00:00 2001 From: Aleksei Efimov Date: Thu, 15 May 2014 18:18:19 +0400 Subject: [PATCH 14/15] 8043012: (tz) Support tzdata2014c Reviewed-by: okutsu, peytoia --- jdk/make/data/tzdata/VERSION | 2 +- jdk/make/data/tzdata/africa | 43 ++++++++++++++++++++ jdk/make/data/tzdata/asia | 16 -------- jdk/make/data/tzdata/europe | 4 ++ jdk/test/sun/util/calendar/zi/tzdata/VERSION | 2 +- jdk/test/sun/util/calendar/zi/tzdata/africa | 43 ++++++++++++++++++++ jdk/test/sun/util/calendar/zi/tzdata/asia | 16 -------- jdk/test/sun/util/calendar/zi/tzdata/europe | 4 ++ 8 files changed, 96 insertions(+), 34 deletions(-) diff --git a/jdk/make/data/tzdata/VERSION b/jdk/make/data/tzdata/VERSION index 1c96650f231..c735be51ca1 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. # -tzdata2014b +tzdata2014c diff --git a/jdk/make/data/tzdata/africa b/jdk/make/data/tzdata/africa index 3198e1cc209..6f1a1471e0c 100644 --- a/jdk/make/data/tzdata/africa +++ b/jdk/make/data/tzdata/africa @@ -358,11 +358,54 @@ Rule Egypt 2007 only - Sep Thu>=1 23:00s 0 - # http://www.worldtimezone.com/dst_news/dst_news_egypt02.html # +# From Ahmad El-Dardiry (2014-05-07): +# 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): +# our Egypt office confirms that the change will be at 15 May "midnight" (24:00) + +# From Paul Eggert (2014-05-13): +# Sarah El Deeb and Lee Keath of AP report that the Egyptian government says +# the change is because of blackouts in Cairo, even though Ahram Online (cited +# above) says DST had no affect on electricity consumption. The AP story says +# DST will not be observed during Ramadan. There is no information about when +# DST will end. See: +# http://abcnews.go.com/International/wireStory/el-sissi-pushes-egyptians-line-23614833 +# +# For now, guess that later transitions will use 2010's rules, and that +# Egypt will agree with Morocco (see below) about the date Ramadan starts and +# ends, though (unlike Morocco) it will switch at 00:00 standard time. In +# Egypt the spring-forward transitions are removed for 2020-2022, when the +# guessed spring-forward date falls during the estimated Ramadan, and all +# transitions removed for 2023-2038, where the estimated Ramadan falls entirely +# outside the guessed daylight-saving time. Ramadan intrudes on the guessed +# DST starting in 2039, but that's beyond our somewhat-arbitrary cutoff. + Rule Egypt 2008 only - Aug lastThu 23:00s 0 - Rule Egypt 2009 only - Aug 20 23:00s 0 - Rule Egypt 2010 only - Aug 11 0:00 0 - Rule Egypt 2010 only - Sep 10 0:00 1:00 S Rule Egypt 2010 only - Sep lastThu 23:00s 0 - +Rule Egypt 2014 only - May 15 24:00 1:00 S +Rule Egypt 2014 only - Jun 29 0:00s 0 - +Rule Egypt 2014 only - Jul 29 0:00s 1:00 S +Rule Egypt 2014 max - Sep lastThu 23:00s 0 - +Rule Egypt 2015 2019 - Apr lastFri 0:00s 1:00 S +Rule Egypt 2015 only - Jun 18 0:00s 0 - +Rule Egypt 2015 only - Jul 18 0:00s 1:00 S +Rule Egypt 2016 only - Jun 7 0:00s 0 - +Rule Egypt 2016 only - Jul 7 0:00s 1:00 S +Rule Egypt 2017 only - May 27 0:00s 0 - +Rule Egypt 2017 only - Jun 26 0:00s 1:00 S +Rule Egypt 2018 only - May 16 0:00s 0 - +Rule Egypt 2018 only - Jun 15 0:00s 1:00 S +Rule Egypt 2019 only - May 6 0:00s 0 - +Rule Egypt 2019 only - Jun 5 0:00s 1:00 S +Rule Egypt 2020 only - May 24 0:00s 1:00 S +Rule Egypt 2021 only - May 13 0:00s 1:00 S +Rule Egypt 2022 only - May 3 0:00s 1:00 S +Rule Egypt 2023 max - Apr lastFri 0:00s 1:00 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Africa/Cairo 2:05:09 - LMT 1900 Oct diff --git a/jdk/make/data/tzdata/asia b/jdk/make/data/tzdata/asia index dc3c94ba9cc..595c8ed7245 100644 --- a/jdk/make/data/tzdata/asia +++ b/jdk/make/data/tzdata/asia @@ -1370,22 +1370,6 @@ Zone Asia/Tokyo 9:18:59 - LMT 1887 Dec 31 15:00u # "Jordan will switch to winter time on Friday, October 27". # -# From Phil Pizzey (2009-04-02): -# ...I think I may have spotted an error in the timezone data for -# Jordan. -# The current (2009d) asia file shows Jordan going to daylight -# saving -# time on the last Thursday in March. -# -# Rule Jordan 2000 max - Mar lastThu 0:00s 1:00 S -# -# However timeanddate.com, which I usually find reliable, shows Jordan -# going to daylight saving time on the last Friday in March since 2002. -# Please see -# -# http://www.timeanddate.com/worldclock/timezone.html?n=11 -# - # From Steffen Thorsen (2009-04-02): # This single one might be good enough, (2009-03-24, Arabic): # diff --git a/jdk/make/data/tzdata/europe b/jdk/make/data/tzdata/europe index 2b0c5613e60..226c393a0f2 100644 --- a/jdk/make/data/tzdata/europe +++ b/jdk/make/data/tzdata/europe @@ -2989,6 +2989,10 @@ Zone Europe/Simferopol 2:16:24 - LMT 1880 # From Alexander Krivenyshev (2014-03-17): # time change at 2:00 (2am) on March 30, 2014 # http://vz.ru/news/2014/3/17/677464.html +# From Paul Eggert (2014-03-30): +# Simferopol and Sevastopol reportedly changed their central town clocks +# late the previous day, but this appears to have been ceremonial +# and the discrepancies are small enough to not worry about. 2:00 EU EE%sT 2014 Mar 30 2:00 4:00 - MSK diff --git a/jdk/test/sun/util/calendar/zi/tzdata/VERSION b/jdk/test/sun/util/calendar/zi/tzdata/VERSION index 1c96650f231..c735be51ca1 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. # -tzdata2014b +tzdata2014c diff --git a/jdk/test/sun/util/calendar/zi/tzdata/africa b/jdk/test/sun/util/calendar/zi/tzdata/africa index 3198e1cc209..6f1a1471e0c 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/africa +++ b/jdk/test/sun/util/calendar/zi/tzdata/africa @@ -358,11 +358,54 @@ Rule Egypt 2007 only - Sep Thu>=1 23:00s 0 - # http://www.worldtimezone.com/dst_news/dst_news_egypt02.html # +# From Ahmad El-Dardiry (2014-05-07): +# 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): +# our Egypt office confirms that the change will be at 15 May "midnight" (24:00) + +# From Paul Eggert (2014-05-13): +# Sarah El Deeb and Lee Keath of AP report that the Egyptian government says +# the change is because of blackouts in Cairo, even though Ahram Online (cited +# above) says DST had no affect on electricity consumption. The AP story says +# DST will not be observed during Ramadan. There is no information about when +# DST will end. See: +# http://abcnews.go.com/International/wireStory/el-sissi-pushes-egyptians-line-23614833 +# +# For now, guess that later transitions will use 2010's rules, and that +# Egypt will agree with Morocco (see below) about the date Ramadan starts and +# ends, though (unlike Morocco) it will switch at 00:00 standard time. In +# Egypt the spring-forward transitions are removed for 2020-2022, when the +# guessed spring-forward date falls during the estimated Ramadan, and all +# transitions removed for 2023-2038, where the estimated Ramadan falls entirely +# outside the guessed daylight-saving time. Ramadan intrudes on the guessed +# DST starting in 2039, but that's beyond our somewhat-arbitrary cutoff. + Rule Egypt 2008 only - Aug lastThu 23:00s 0 - Rule Egypt 2009 only - Aug 20 23:00s 0 - Rule Egypt 2010 only - Aug 11 0:00 0 - Rule Egypt 2010 only - Sep 10 0:00 1:00 S Rule Egypt 2010 only - Sep lastThu 23:00s 0 - +Rule Egypt 2014 only - May 15 24:00 1:00 S +Rule Egypt 2014 only - Jun 29 0:00s 0 - +Rule Egypt 2014 only - Jul 29 0:00s 1:00 S +Rule Egypt 2014 max - Sep lastThu 23:00s 0 - +Rule Egypt 2015 2019 - Apr lastFri 0:00s 1:00 S +Rule Egypt 2015 only - Jun 18 0:00s 0 - +Rule Egypt 2015 only - Jul 18 0:00s 1:00 S +Rule Egypt 2016 only - Jun 7 0:00s 0 - +Rule Egypt 2016 only - Jul 7 0:00s 1:00 S +Rule Egypt 2017 only - May 27 0:00s 0 - +Rule Egypt 2017 only - Jun 26 0:00s 1:00 S +Rule Egypt 2018 only - May 16 0:00s 0 - +Rule Egypt 2018 only - Jun 15 0:00s 1:00 S +Rule Egypt 2019 only - May 6 0:00s 0 - +Rule Egypt 2019 only - Jun 5 0:00s 1:00 S +Rule Egypt 2020 only - May 24 0:00s 1:00 S +Rule Egypt 2021 only - May 13 0:00s 1:00 S +Rule Egypt 2022 only - May 3 0:00s 1:00 S +Rule Egypt 2023 max - Apr lastFri 0:00s 1:00 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Africa/Cairo 2:05:09 - LMT 1900 Oct diff --git a/jdk/test/sun/util/calendar/zi/tzdata/asia b/jdk/test/sun/util/calendar/zi/tzdata/asia index dc3c94ba9cc..595c8ed7245 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/asia +++ b/jdk/test/sun/util/calendar/zi/tzdata/asia @@ -1370,22 +1370,6 @@ Zone Asia/Tokyo 9:18:59 - LMT 1887 Dec 31 15:00u # "Jordan will switch to winter time on Friday, October 27". # -# From Phil Pizzey (2009-04-02): -# ...I think I may have spotted an error in the timezone data for -# Jordan. -# The current (2009d) asia file shows Jordan going to daylight -# saving -# time on the last Thursday in March. -# -# Rule Jordan 2000 max - Mar lastThu 0:00s 1:00 S -# -# However timeanddate.com, which I usually find reliable, shows Jordan -# going to daylight saving time on the last Friday in March since 2002. -# Please see -# -# http://www.timeanddate.com/worldclock/timezone.html?n=11 -# - # From Steffen Thorsen (2009-04-02): # This single one might be good enough, (2009-03-24, Arabic): # diff --git a/jdk/test/sun/util/calendar/zi/tzdata/europe b/jdk/test/sun/util/calendar/zi/tzdata/europe index 2b0c5613e60..226c393a0f2 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/europe +++ b/jdk/test/sun/util/calendar/zi/tzdata/europe @@ -2989,6 +2989,10 @@ Zone Europe/Simferopol 2:16:24 - LMT 1880 # From Alexander Krivenyshev (2014-03-17): # time change at 2:00 (2am) on March 30, 2014 # http://vz.ru/news/2014/3/17/677464.html +# From Paul Eggert (2014-03-30): +# Simferopol and Sevastopol reportedly changed their central town clocks +# late the previous day, but this appears to have been ceremonial +# and the discrepancies are small enough to not worry about. 2:00 EU EE%sT 2014 Mar 30 2:00 4:00 - MSK From a134b62a96d53fb2ed98977cec801e0395afa377 Mon Sep 17 00:00:00 2001 From: Pavel Rappo Date: Wed, 14 May 2014 15:46:27 +0100 Subject: [PATCH 15/15] 7153400: ThreadPoolExecutor's setCorePoolSize method allows corePoolSize > maxPoolSize Reviewed-by: chegar, martin, mduigou --- .../classes/java/util/concurrent/ThreadPoolExecutor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java b/jdk/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java index 882067dfe4d..70e2ee503a6 100644 --- a/jdk/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java +++ b/jdk/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java @@ -1532,10 +1532,12 @@ public class ThreadPoolExecutor extends AbstractExecutorService { * * @param corePoolSize the new core size * @throws IllegalArgumentException if {@code corePoolSize < 0} + * or {@code corePoolSize} is greater than the {@linkplain + * #getMaximumPoolSize() maximum pool size} * @see #getCorePoolSize */ public void setCorePoolSize(int corePoolSize) { - if (corePoolSize < 0) + if (corePoolSize < 0 || maximumPoolSize < corePoolSize) throw new IllegalArgumentException(); int delta = corePoolSize - this.corePoolSize; this.corePoolSize = corePoolSize;