# HG changeset patch # User lana # Date 1305595174 25200 # Node ID af3ed4dd299767af59009d7a293279488c3d73ed # Parent 51a9096f67992b43559fc6e4a9c5dde3574f5605# Parent 4608ed0204d20766e98678fada53d3d8efc3b5c8 Merge diff -r 51a9096f6799 -r af3ed4dd2997 jdk/make/com/sun/nio/sctp/FILES_java.gmk --- a/jdk/make/com/sun/nio/sctp/FILES_java.gmk Mon May 16 18:17:26 2011 -0700 +++ b/jdk/make/com/sun/nio/sctp/FILES_java.gmk Mon May 16 18:19:34 2011 -0700 @@ -38,7 +38,7 @@ com/sun/nio/sctp/SctpMultiChannel.java \ com/sun/nio/sctp/SctpServerChannel.java \ com/sun/nio/sctp/SctpSocketOption.java \ - com/sun/nio/sctp/SctpStandardSocketOption.java \ + com/sun/nio/sctp/SctpStandardSocketOptions.java \ com/sun/nio/sctp/SendFailedNotification.java \ com/sun/nio/sctp/ShutdownNotification.java \ \ diff -r 51a9096f6799 -r af3ed4dd2997 jdk/make/java/management/mapfile-vers --- a/jdk/make/java/management/mapfile-vers Mon May 16 18:17:26 2011 -0700 +++ b/jdk/make/java/management/mapfile-vers Mon May 16 18:19:34 2011 -0700 @@ -49,6 +49,7 @@ Java_sun_management_Flag_setStringValue; Java_sun_management_GarbageCollectorImpl_getCollectionCount; Java_sun_management_GarbageCollectorImpl_getCollectionTime; + Java_sun_management_GarbageCollectorImpl_setNotificationEnabled; Java_sun_management_GcInfoBuilder_fillGcAttributeInfo; Java_sun_management_GcInfoBuilder_getLastGcInfo0; Java_sun_management_GcInfoBuilder_getNumGcExtAttributes; diff -r 51a9096f6799 -r af3ed4dd2997 jdk/make/java/nio/FILES_java.gmk --- a/jdk/make/java/nio/FILES_java.gmk Mon May 16 18:17:26 2011 -0700 +++ b/jdk/make/java/nio/FILES_java.gmk Mon May 16 18:19:34 2011 -0700 @@ -71,7 +71,7 @@ java/nio/charset/CoderMalfunctionError.java \ java/nio/charset/CodingErrorAction.java \ java/nio/charset/MalformedInputException.java \ - java/nio/charset/StandardCharset.java \ + java/nio/charset/StandardCharsets.java \ java/nio/charset/UnmappableCharacterException.java \ \ java/nio/charset/spi/CharsetProvider.java \ @@ -116,7 +116,7 @@ java/nio/file/SimpleFileVisitor.java \ java/nio/file/StandardCopyOption.java \ java/nio/file/StandardOpenOption.java \ - java/nio/file/StandardWatchEventKind.java \ + java/nio/file/StandardWatchEventKinds.java \ java/nio/file/TempFileHelper.java \ java/nio/file/WatchEvent.java \ java/nio/file/WatchKey.java \ diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/com/sun/management/GarbageCollectionNotificationInfo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/management/GarbageCollectionNotificationInfo.java Mon May 16 18:19:34 2011 -0700 @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2011, 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.management; + +import javax.management.Notification; +import javax.management.openmbean.CompositeData; +import javax.management.openmbean.CompositeDataView; +import javax.management.openmbean.CompositeType; +import java.util.Collection; +import java.util.Collections; +import sun.management.GarbageCollectionNotifInfoCompositeData; + +/** + * The information about a garbage collection + * + *

+ * A garbage collection notification is emitted by {@link GarbageCollectorMXBean} + * when the Java virtual machine completes a garbage collection action + * The notification emitted will contain the garbage collection notification + * information about the status of the memory: + * + *

  • The name of the garbage collector used perform the collection.
  • + *
  • The action performed by the garbage collector.
  • + *
  • The cause of the garbage collection action.
  • + *
  • A {@link GcInfo} object containing some statistics about the GC cycle + (start time, end time) and the memory usage before and after + the GC cycle.
  • + * + * + *

    + * A {@link CompositeData CompositeData} representing + * the {@code GarbageCollectionNotificationInfo} object + * is stored in the + * {@linkplain javax.management.Notification#setUserData userdata} + * of a {@linkplain javax.management.Notification notification}. + * The {@link #from from} method is provided to convert from + * a {@code CompositeData} to a {@code GarbageCollectionNotificationInfo} + * object. For example: + * + *

    + *      Notification notif;
    + *
    + *      // receive the notification emitted by a GarbageCollectorMXBean and set to notif
    + *      ...
    + *
    + *      String notifType = notif.getType();
    + *      if (notifType.equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) {
    + *          // retrieve the garbage collection notification information
    + *          CompositeData cd = (CompositeData) notif.getUserData();
    + *          GarbageCollectionNotificationInfo info = GarbageCollectionNotificationInfo.from(cd);
    + *          ....
    + *      }
    + * 
    + * + *

    + * The type of the notification emitted by a {@code GarbageCollectorMXBean} is: + *

    + **/ + +public class GarbageCollectionNotificationInfo implements CompositeDataView { + + private final String gcName; + private final String gcAction; + private final String gcCause; + private final GcInfo gcInfo; + private final CompositeData cdata; + + /** + * Notification type denoting that + * the Java virtual machine has completed a garbage collection cycle. + * This notification is emitted by a {@link GarbageCollectorMXBean}. + * The value of this notification type is + * {@code com.sun.management.gc.notification}. + */ + public static final String GARBAGE_COLLECTION_NOTIFICATION = + "com.sun.management.gc.notification"; + + /** + * Constructs a {@code GarbageCollectionNotificationInfo} object. + * + * @param gcName The name of the garbage collector used to perform the collection + * @param gcAction The name of the action performed by the garbage collector + * @param gcCause The cause the garbage collection action + * @param gcInfo a GcInfo object providing statistics about the GC cycle + */ + public GarbageCollectionNotificationInfo(String gcName, + String gcAction, + String gcCause, + GcInfo gcInfo) { + if (gcName == null) { + throw new NullPointerException("Null gcName"); + } + if (gcAction == null) { + throw new NullPointerException("Null gcAction"); + } + if (gcCause == null) { + throw new NullPointerException("Null gcCause"); + } + this.gcName = gcName; + this.gcAction = gcAction; + this.gcCause = gcCause; + this.gcInfo = gcInfo; + this.cdata = new GarbageCollectionNotifInfoCompositeData(this); + } + + GarbageCollectionNotificationInfo(CompositeData cd) { + GarbageCollectionNotifInfoCompositeData.validateCompositeData(cd); + + this.gcName = GarbageCollectionNotifInfoCompositeData.getGcName(cd); + this.gcAction = GarbageCollectionNotifInfoCompositeData.getGcAction(cd); + this.gcCause = GarbageCollectionNotifInfoCompositeData.getGcCause(cd); + this.gcInfo = GarbageCollectionNotifInfoCompositeData.getGcInfo(cd); + this.cdata = cd; + } + + /** + * Returns the name of the garbage collector used to perform the collection + * + * @return the name of the garbage collector used to perform the collection + */ + public String getGcName() { + return gcName; + } + + /** + * Returns the action of the performed by the garbage collector + * + * @return the the action of the performed by the garbage collector + */ + public String getGcAction() { + return gcAction; + } + + /** + * Returns the cause the garbage collection + * + * @return the the cause the garbage collection + */ + public String getGcCause() { + return gcCause; + } + + /** + * Returns the GC information related to the last garbage collection + * + * @return the GC information related to the + * last garbage collection + */ + public GcInfo getGcInfo() { + return gcInfo; + } + + /** + * Returns a {@code GarbageCollectionNotificationInfo} object represented by the + * given {@code CompositeData}. + * The given {@code CompositeData} must contain + * the following attributes: + *
    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Attribute NameType
    gcName{@code java.lang.String}
    gcAction{@code java.lang.String}
    gcCause{@code java.lang.String}
    gcInfo{@code javax.management.openmbean.CompositeData}
    + *
    + * + * @param cd {@code CompositeData} representing a + * {@code GarbageCollectionNotificationInfo} + * + * @throws IllegalArgumentException if {@code cd} does not + * represent a {@code GarbaageCollectionNotificationInfo} object. + * + * @return a {@code GarbageCollectionNotificationInfo} object represented + * by {@code cd} if {@code cd} is not {@code null}; + * {@code null} otherwise. + */ + public static GarbageCollectionNotificationInfo from(CompositeData cd) { + if (cd == null) { + return null; + } + + if (cd instanceof GarbageCollectionNotifInfoCompositeData) { + return ((GarbageCollectionNotifInfoCompositeData) cd).getGarbageCollectionNotifInfo(); + } else { + return new GarbageCollectionNotificationInfo(cd); + } + } + + public CompositeData toCompositeData(CompositeType ct) { + return cdata; + } + +} diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/com/sun/nio/sctp/MessageInfo.java --- a/jdk/src/share/classes/com/sun/nio/sctp/MessageInfo.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/com/sun/nio/sctp/MessageInfo.java Mon May 16 18:19:34 2011 -0700 @@ -179,7 +179,7 @@ * completely received. For messages being sent {@code true} indicates that * the message is complete, {@code false} indicates that the message is not * complete. How the send channel interprets this value depends on the value - * of its {@link SctpStandardSocketOption#SCTP_EXPLICIT_COMPLETE + * of its {@link SctpStandardSocketOptions#SCTP_EXPLICIT_COMPLETE * SCTP_EXPLICIT_COMPLETE} socket option. * * @return {@code true} if, and only if, the message is complete @@ -192,7 +192,7 @@ *

    For messages being sent {@code true} indicates that * the message is complete, {@code false} indicates that the message is not * complete. How the send channel interprets this value depends on the value - * of its {@link SctpStandardSocketOption#SCTP_EXPLICIT_COMPLETE + * of its {@link SctpStandardSocketOptions#SCTP_EXPLICIT_COMPLETE * SCTP_EXPLICIT_COMPLETE} socket option. * * @param complete diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/com/sun/nio/sctp/SctpChannel.java --- a/jdk/src/share/classes/com/sun/nio/sctp/SctpChannel.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/com/sun/nio/sctp/SctpChannel.java Mon May 16 18:19:34 2011 -0700 @@ -65,55 +65,55 @@ * Description * * - * {@link SctpStandardSocketOption#SCTP_DISABLE_FRAGMENTS + * {@link SctpStandardSocketOptions#SCTP_DISABLE_FRAGMENTS * SCTP_DISABLE_FRAGMENTS} * Enables or disables message fragmentation * * - * {@link SctpStandardSocketOption#SCTP_EXPLICIT_COMPLETE + * {@link SctpStandardSocketOptions#SCTP_EXPLICIT_COMPLETE * SCTP_EXPLICIT_COMPLETE} * Enables or disables explicit message completion * * - * {@link SctpStandardSocketOption#SCTP_FRAGMENT_INTERLEAVE + * {@link SctpStandardSocketOptions#SCTP_FRAGMENT_INTERLEAVE * SCTP_FRAGMENT_INTERLEAVE} * Controls how the presentation of messages occur for the message * receiver * * - * {@link SctpStandardSocketOption#SCTP_INIT_MAXSTREAMS + * {@link SctpStandardSocketOptions#SCTP_INIT_MAXSTREAMS * SCTP_INIT_MAXSTREAMS} * The maximum number of streams requested by the local endpoint during * association initialization * * - * {@link SctpStandardSocketOption#SCTP_NODELAY SCTP_NODELAY} + * {@link SctpStandardSocketOptions#SCTP_NODELAY SCTP_NODELAY} * Enables or disable a Nagle-like algorithm * * - * {@link SctpStandardSocketOption#SCTP_PRIMARY_ADDR + * {@link SctpStandardSocketOptions#SCTP_PRIMARY_ADDR * SCTP_PRIMARY_ADDR} * Requests that the local SCTP stack use the given peer address as the * association primary * * - * {@link SctpStandardSocketOption#SCTP_SET_PEER_PRIMARY_ADDR + * {@link SctpStandardSocketOptions#SCTP_SET_PEER_PRIMARY_ADDR * SCTP_SET_PEER_PRIMARY_ADDR} * Requests that the peer mark the enclosed address as the association * primary * * - * {@link SctpStandardSocketOption#SO_SNDBUF + * {@link SctpStandardSocketOptions#SO_SNDBUF * SO_SNDBUF} * The size of the socket send buffer * * - * {@link SctpStandardSocketOption#SO_RCVBUF + * {@link SctpStandardSocketOptions#SO_RCVBUF * SO_RCVBUF} * The size of the socket receive buffer * * - * {@link SctpStandardSocketOption#SO_LINGER + * {@link SctpStandardSocketOptions#SO_LINGER * SO_LINGER} * Linger on close if data is present (when configured in blocking mode * only) @@ -449,7 +449,7 @@ *

    This is a convience method and is equivalent to evaluating the * following expression: *

    -     * setOption(SctpStandardSocketOption.SCTP_INIT_MAXSTREAMS, SctpStandardSocketOption.InitMaxStreams.create(maxInStreams, maxOutStreams))
    +     * setOption(SctpStandardSocketOptions.SCTP_INIT_MAXSTREAMS, SctpStandardSocketOption.InitMaxStreams.create(maxInStreams, maxOutStreams))
          *  .connect(remote);
          * 
    * @@ -651,7 +651,7 @@ * @throws IOException * If an I/O error occurs * - * @see SctpStandardSocketOption + * @see SctpStandardSocketOptions */ public abstract T getOption(SctpSocketOption name) throws IOException; @@ -680,7 +680,7 @@ * @throws IOException * If an I/O error occurs * - * @see SctpStandardSocketOption + * @see SctpStandardSocketOptions */ public abstract SctpChannel setOption(SctpSocketOption name, T value) throws IOException; @@ -731,7 +731,7 @@ * MessageInfo} will return {@code false}, and more invocations of this * method will be necessary to completely consume the messgae. Only * one message at a time will be partially delivered in any stream. The - * socket option {@link SctpStandardSocketOption#SCTP_FRAGMENT_INTERLEAVE + * socket option {@link SctpStandardSocketOptions#SCTP_FRAGMENT_INTERLEAVE * SCTP_FRAGMENT_INTERLEAVE} controls various aspects of what interlacing of * messages occurs. * @@ -804,7 +804,7 @@ * and sufficient room becomes available, then the remaining bytes in the * given byte buffer are transmitted as a single message. Sending a message * is atomic unless explicit message completion {@link - * SctpStandardSocketOption#SCTP_EXPLICIT_COMPLETE SCTP_EXPLICIT_COMPLETE} + * SctpStandardSocketOptions#SCTP_EXPLICIT_COMPLETE SCTP_EXPLICIT_COMPLETE} * socket option is enabled on this channel's socket. * *

    The message is transferred from the byte buffer as if by a regular diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/com/sun/nio/sctp/SctpMultiChannel.java --- a/jdk/src/share/classes/com/sun/nio/sctp/SctpMultiChannel.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/com/sun/nio/sctp/SctpMultiChannel.java Mon May 16 18:19:34 2011 -0700 @@ -69,55 +69,55 @@ * Description * * - * {@link SctpStandardSocketOption#SCTP_DISABLE_FRAGMENTS + * {@link SctpStandardSocketOptions#SCTP_DISABLE_FRAGMENTS * SCTP_DISABLE_FRAGMENTS} * Enables or disables message fragmentation * * - * {@link SctpStandardSocketOption#SCTP_EXPLICIT_COMPLETE + * {@link SctpStandardSocketOptions#SCTP_EXPLICIT_COMPLETE * SCTP_EXPLICIT_COMPLETE} * Enables or disables explicit message completion * * - * {@link SctpStandardSocketOption#SCTP_FRAGMENT_INTERLEAVE + * {@link SctpStandardSocketOptions#SCTP_FRAGMENT_INTERLEAVE * SCTP_FRAGMENT_INTERLEAVE} * Controls how the presentation of messages occur for the message * receiver * * - * {@link SctpStandardSocketOption#SCTP_INIT_MAXSTREAMS + * {@link SctpStandardSocketOptions#SCTP_INIT_MAXSTREAMS * SCTP_INIT_MAXSTREAMS} * The maximum number of streams requested by the local endpoint during * association initialization * * - * {@link SctpStandardSocketOption#SCTP_NODELAY SCTP_NODELAY} + * {@link SctpStandardSocketOptions#SCTP_NODELAY SCTP_NODELAY} * Enables or disable a Nagle-like algorithm * * - * {@link SctpStandardSocketOption#SCTP_PRIMARY_ADDR + * {@link SctpStandardSocketOptions#SCTP_PRIMARY_ADDR * SCTP_PRIMARY_ADDR} * Requests that the local SCTP stack use the given peer address as the * association primary * * - * {@link SctpStandardSocketOption#SCTP_SET_PEER_PRIMARY_ADDR + * {@link SctpStandardSocketOptions#SCTP_SET_PEER_PRIMARY_ADDR * SCTP_SET_PEER_PRIMARY_ADDR} * Requests that the peer mark the enclosed address as the association * primary * * - * {@link SctpStandardSocketOption#SO_SNDBUF + * {@link SctpStandardSocketOptions#SO_SNDBUF * SO_SNDBUF} * The size of the socket send buffer * * - * {@link SctpStandardSocketOption#SO_RCVBUF + * {@link SctpStandardSocketOptions#SO_RCVBUF * SO_RCVBUF} * The size of the socket receive buffer * * - * {@link SctpStandardSocketOption#SO_LINGER + * {@link SctpStandardSocketOptions#SO_LINGER * SO_LINGER} * Linger on close if data is present (when configured in blocking mode * only) @@ -450,7 +450,7 @@ * @throws IOException * If an I/O error occurs * - * @see SctpStandardSocketOption + * @see SctpStandardSocketOptions */ public abstract T getOption(SctpSocketOption name, Association association) @@ -489,7 +489,7 @@ * @throws IOException * If an I/O error occurs * - * @see SctpStandardSocketOption + * @see SctpStandardSocketOptions */ public abstract SctpMultiChannel setOption(SctpSocketOption name, T value, @@ -542,7 +542,7 @@ * MessageInfo} will return {@code false}, and more invocations of this * method will be necessary to completely consume the messgae. Only * one message at a time will be partially delivered in any stream. The - * socket option {@link SctpStandardSocketOption#SCTP_FRAGMENT_INTERLEAVE + * socket option {@link SctpStandardSocketOptions#SCTP_FRAGMENT_INTERLEAVE * SCTP_FRAGMENT_INTERLEAVE} controls various aspects of what interlacing of * messages occurs. * @@ -635,14 +635,14 @@ * underlying output buffer, then the remaining bytes in the given byte * buffer are transmitted as a single message. Sending a message * is atomic unless explicit message completion {@link - * SctpStandardSocketOption#SCTP_EXPLICIT_COMPLETE SCTP_EXPLICIT_COMPLETE} + * SctpStandardSocketOptions#SCTP_EXPLICIT_COMPLETE SCTP_EXPLICIT_COMPLETE} * socket option is enabled on this channel's socket. * *

    If this channel is in non-blocking mode, there is sufficient room * in the underlying output buffer, and an implicit association setup is * required, then the remaining bytes in the given byte buffer are * transmitted as a single message, subject to {@link - * SctpStandardSocketOption#SCTP_EXPLICIT_COMPLETE SCTP_EXPLICIT_COMPLETE}. + * SctpStandardSocketOptions#SCTP_EXPLICIT_COMPLETE SCTP_EXPLICIT_COMPLETE}. * If for any reason the message cannot * be delivered an {@link AssociationChangeNotification association * changed} notification is put on the SCTP stack with its {@code event} parameter set diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/com/sun/nio/sctp/SctpServerChannel.java --- a/jdk/src/share/classes/com/sun/nio/sctp/SctpServerChannel.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/com/sun/nio/sctp/SctpServerChannel.java Mon May 16 18:19:34 2011 -0700 @@ -53,7 +53,7 @@ * Description * * - * {@link SctpStandardSocketOption#SCTP_INIT_MAXSTREAMS + * {@link SctpStandardSocketOptions#SCTP_INIT_MAXSTREAMS * SCTP_INIT_MAXSTREAMS} * The maximum number of streams requested by the local endpoint during * association initialization @@ -360,7 +360,7 @@ * @throws IOException * If an I/O error occurs * - * @see SctpStandardSocketOption + * @see SctpStandardSocketOptions */ public abstract T getOption(SctpSocketOption name) throws IOException; @@ -388,7 +388,7 @@ * @throws IOException * If an I/O error occurs * - * @see SctpStandardSocketOption + * @see SctpStandardSocketOptions */ public abstract SctpServerChannel setOption(SctpSocketOption name, T value) diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/com/sun/nio/sctp/SctpSocketOption.java --- a/jdk/src/share/classes/com/sun/nio/sctp/SctpSocketOption.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/com/sun/nio/sctp/SctpSocketOption.java Mon May 16 18:19:34 2011 -0700 @@ -33,6 +33,6 @@ * * @since 1.7 * - * @see SctpStandardSocketOption + * @see SctpStandardSocketOptions */ public interface SctpSocketOption extends SocketOption { } diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/com/sun/nio/sctp/SctpStandardSocketOption.java --- a/jdk/src/share/classes/com/sun/nio/sctp/SctpStandardSocketOption.java Mon May 16 18:17:26 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,419 +0,0 @@ -/* - * Copyright (c) 2009, 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.nio.sctp; - -import java.net.SocketAddress; -import sun.nio.ch.SctpStdSocketOption; - -/** - * SCTP channels supports the socket options defined by this class - * (as well as those listed in the particular channel class) and may support - * additional Implementation specific socket options. - * - * @since 1.7 - */ -public class SctpStandardSocketOption { - private SctpStandardSocketOption() {} - /** - * Enables or disables message fragmentation. - * - *

    The value of this socket option is a {@code Boolean} that represents - * whether the option is enabled or disabled. If enabled no SCTP message - * fragmentation will be performed. Instead if a message being sent - * exceeds the current PMTU size, the message will NOT be sent and - * an error will be indicated to the user. - * - *

    It is implementation specific whether or not this option is - * supported. - */ - public static final SctpSocketOption SCTP_DISABLE_FRAGMENTS = new - SctpStdSocketOption("SCTP_DISABLE_FRAGMENTS", Boolean.class, - sun.nio.ch.SctpStdSocketOption.SCTP_DISABLE_FRAGMENTS); - - /** - * Enables or disables explicit message completion. - * - *

    The value of this socket option is a {@code Boolean} that represents - * whether the option is enabled or disabled. When this option is enabled, - * the {@code send} method may be invoked multiple times to a send message. - * The {@code isComplete} parameter of the {@link MessageInfo} must only - * be set to {@code true} for the final send to indicate that the message is - * complete. If this option is disabled then each individual {@code send} - * invocation is considered complete. - * - *

    The default value of the option is {@code false} indicating that the - * option is disabled. It is implementation specific whether or not this - * option is supported. - */ - public static final SctpSocketOption SCTP_EXPLICIT_COMPLETE = new - SctpStdSocketOption("SCTP_EXPLICIT_COMPLETE", Boolean.class, - sun.nio.ch.SctpStdSocketOption.SCTP_EXPLICIT_COMPLETE); - - /** - * Fragmented interleave controls how the presentation of messages occur - * for the message receiver. There are three levels of fragment interleave - * defined. Two of the levels effect {@link SctpChannel}, while - * {@link SctpMultiChannel} is effected by all three levels. - * - *

    This option takes an {@code Integer} value. It can be set to a value - * of {@code 0}, {@code 1} or {@code 2}. - * - *

    Setting the three levels provides the following receiver - * interactions: - * - *

    {@code level 0} - Prevents the interleaving of any messages. This - * means that when a partial delivery begins, no other messages will be - * received except the message being partially delivered. If another message - * arrives on a different stream (or association) that could be delivered, - * it will be blocked waiting for the user to read all of the partially - * delivered message. - * - *

    {@code level 1} - Allows interleaving of messages that are from - * different associations. For {@code SctpChannel}, level 0 and - * level 1 have the same meaning since an {@code SctpChannel} always - * receives messages from the same association. Note that setting an {@code - * SctpMultiChannel} to this level may cause multiple partial - * delivers from different associations but for any given association, only - * one message will be delivered until all parts of a message have been - * delivered. This means that one large message, being read with an - * association identification of "X", will block other messages from - * association "X" from being delivered. - * - *

    {@code level 2} - Allows complete interleaving of messages. This - * level requires that the sender carefully observe not only the peer - * {@code Association} but also must pay careful attention to the stream - * number. With this option enabled a partially delivered message may begin - * being delivered for association "X" stream "Y" and the next subsequent - * receive may return a message from association "X" stream "Z". Note that - * no other messages would be delivered for association "X" stream "Y" - * until all of stream "Y"'s partially delivered message was read. - * Note that this option effects both channel types. Also note that - * for an {@code SctpMultiChannel} not only may another streams - * message from the same association be delivered from the next receive, - * some other associations message may be delivered upon the next receive. - * - *

    It is implementation specific whether or not this option is - * supported. - */ - public static final SctpSocketOption SCTP_FRAGMENT_INTERLEAVE = - new SctpStdSocketOption("SCTP_FRAGMENT_INTERLEAVE", - Integer.class, - sun.nio.ch.SctpStdSocketOption.SCTP_FRAGMENT_INTERLEAVE); - - /** - * The maximum number of streams requested by the local endpoint during - * association initialization. - * - *

    The value of this socket option is an {@link - * SctpStandardSocketOption.InitMaxStreams InitMaxStreams}, that represents - * the maximum number of inbound and outbound streams that an association - * on the channel is prepared to support. - * - *

    For an {@link SctpChannel} this option may only be used to - * change the number of inbound/outbound streams prior to connecting. - * - *

    For an {@link SctpMultiChannel} this option determines - * the maximum number of inbound/outbound streams new associations setup - * on the channel will be prepared to support. - * - *

    For an {@link SctpServerChannel} this option determines the - * maximum number of inbound/outbound streams accepted sockets will - * negotiate with their connecting peer. - * - *

    In all cases the value set by this option is used in the negotiation - * of new associations setup on the channel's socket and the actual - * maximum number of inbound/outbound streams that have been negotiated - * with the peer can be retrieved from the appropriate {@link - * Association}. The {@code Association} can be retrieved from the - * {@link AssociationChangeNotification.AssocChangeEvent#COMM_UP COMM_UP} - * {@link AssociationChangeNotification} belonging to that association. - * - *

    This value is bounded by the actual implementation. In other - * words the user may be able to support more streams than the Operating - * System. In such a case, the Operating System limit may override the - * value requested by the user. The default value of 0 indicates to use - * the endpoints default value. - */ - public static final SctpSocketOption - SCTP_INIT_MAXSTREAMS = - new SctpStdSocketOption( - "SCTP_INIT_MAXSTREAMS", SctpStandardSocketOption.InitMaxStreams.class); - - /** - * Enables or disables a Nagle-like algorithm. - * - *

    The value of this socket option is a {@code Boolean} that represents - * whether the option is enabled or disabled. SCTP uses an algorithm like - * The Nagle Algorithm to coalesce short segments and - * improve network efficiency. - */ - public static final SctpSocketOption SCTP_NODELAY = - new SctpStdSocketOption("SCTP_NODELAY", Boolean.class, - sun.nio.ch.SctpStdSocketOption.SCTP_NODELAY); - - /** - * Requests that the local SCTP stack use the given peer address as - * the association primary. - * - *

    The value of this socket option is a {@code SocketAddress} - * that represents the peer address that the local SCTP stack should use as - * the association primary. The address must be one of the association - * peer's addresses. - * - *

    An {@code SctpMultiChannel} can control more than one - * association, the association parameter must be given when setting or - * retrieving this option. - * - *

    Since {@code SctpChannel} only controls one association, - * the association parameter is not required and this option can be - * set or queried directly. - */ - public static final SctpSocketOption SCTP_PRIMARY_ADDR = - new SctpStdSocketOption - ("SCTP_PRIMARY_ADDR", SocketAddress.class); - - /** - * Requests that the peer mark the enclosed address as the association - * primary. - * - *

    The value of this socket option is a {@code SocketAddress} - * that represents the local address that the peer should use as its - * primary address. The given address must be one of the association's - * locally bound addresses. - * - *

    An {@code SctpMultiChannel} can control more than one - * association, the association parameter must be given when setting or - * retrieving this option. - * - *

    Since {@code SctpChannel} only controls one association, - * the association parameter is not required and this option can be - * queried directly. - * - *

    Note, this is a set only option and cannot be retrieved by {@code - * getOption}. It is implementation specific whether or not this - * option is supported. - */ - public static final SctpSocketOption SCTP_SET_PEER_PRIMARY_ADDR = - new SctpStdSocketOption - ("SCTP_SET_PEER_PRIMARY_ADDR", SocketAddress.class); - - /** - * The size of the socket send buffer. - * - *

    The value of this socket option is an {@code Integer} that is the - * size of the socket send buffer in bytes. The socket send buffer is an - * output buffer used by the networking implementation. It may need to be - * increased for high-volume connections. The value of the socket option is - * a hint to the implementation to size the buffer and the actual - * size may differ. The socket option can be queried to retrieve the actual - * size. - * - *

    For {@code SctpChannel}, this controls the amount of data - * the SCTP stack may have waiting in internal buffers to be sent. This - * option therefore bounds the maximum size of data that can be sent in a - * single send call. - * - *

    For {@code SctpMultiChannel}, the effect is the same as for {@code - * SctpChannel}, except that it applies to all associations. The option - * applies to each association's window size separately. - * - *

    An implementation allows this socket option to be set before the - * socket is bound or connected. Whether an implementation allows the - * socket send buffer to be changed after the socket is bound is system - * dependent. - */ - public static final SctpSocketOption SO_SNDBUF = - new SctpStdSocketOption("SO_SNDBUF", Integer.class, - sun.nio.ch.SctpStdSocketOption.SO_SNDBUF); - - /** - * The size of the socket receive buffer. - * - *

    The value of this socket option is an {@code Integer} that is the - * size of the socket receive buffer in bytes. The socket receive buffer is - * an input buffer used by the networking implementation. It may need to be - * increased for high-volume connections or decreased to limit the possible - * backlog of incoming data. The value of the socket option is a - * hint to the implementation to size the buffer and the actual - * size may differ. - * - *

    For {@code SctpChannel}, this controls the receiver window size. - * - *

    For {@code SctpMultiChannel}, the meaning is implementation - * dependent. It might control the receive buffer for each association bound - * to the socket descriptor or it might control the receive buffer for the - * whole socket. - * - *

    An implementation allows this socket option to be set before the - * socket is bound or connected. Whether an implementation allows the - * socket receive buffer to be changed after the socket is bound is system - * dependent. - */ - public static final SctpSocketOption SO_RCVBUF = - new SctpStdSocketOption("SO_RCVBUF", Integer.class, - sun.nio.ch.SctpStdSocketOption.SO_RCVBUF); - - /** - * Linger on close if data is present. - * - *

    The value of this socket option is an {@code Integer} that controls - * the action taken when unsent data is queued on the socket and a method - * to close the socket is invoked. If the value of the socket option is zero - * or greater, then it represents a timeout value, in seconds, known as the - * linger interval. The linger interval is the timeout for the - * {@code close} method to block while the operating system attempts to - * transmit the unsent data or it decides that it is unable to transmit the - * data. If the value of the socket option is less than zero then the option - * is disabled. In that case the {@code close} method does not wait until - * unsent data is transmitted; if possible the operating system will transmit - * any unsent data before the connection is closed. - * - *

    This socket option is intended for use with sockets that are configured - * in {@link java.nio.channels.SelectableChannel#isBlocking() blocking} mode - * only. The behavior of the {@code close} method when this option is - * enabled on a non-blocking socket is not defined. - * - *

    The initial value of this socket option is a negative value, meaning - * that the option is disabled. The option may be enabled, or the linger - * interval changed, at any time. The maximum value of the linger interval - * is system dependent. Setting the linger interval to a value that is - * greater than its maximum value causes the linger interval to be set to - * its maximum value. - */ - public static final SctpSocketOption SO_LINGER = - new SctpStdSocketOption("SO_LINGER", Integer.class, - sun.nio.ch.SctpStdSocketOption.SO_LINGER); - - /** - * This class is used to set the maximum number of inbound/outbound streams - * used by the local endpoint during association initialization. An - * instance of this class is used to set the {@link - * SctpStandardSocketOption#SCTP_INIT_MAXSTREAMS SCTP_INIT_MAXSTREAMS} - * socket option. - * - * @since 1.7 - */ - public static class InitMaxStreams { - private int maxInStreams; - private int maxOutStreams; - - private InitMaxStreams(int maxInStreams, int maxOutStreams) { - this.maxInStreams = maxInStreams; - this.maxOutStreams = maxOutStreams; - } - - /** - * Creates an InitMaxStreams instance. - * - * @param maxInStreams - * The maximum number of inbound streams, where - * {@code 0 <= maxInStreams <= 65536} - * - * @param maxOutStreams - * The maximum number of outbound streams, where - * {@code 0 <= maxOutStreams <= 65536} - * - * @return An {@code InitMaxStreams} instance - * - * @throws IllegalArgumentException - * If an argument is outside of specified bounds - */ - public static InitMaxStreams create - (int maxInStreams, int maxOutStreams) { - if (maxOutStreams < 0 || maxOutStreams > 65535) - throw new IllegalArgumentException( - "Invalid maxOutStreams value"); - if (maxInStreams < 0 || maxInStreams > 65535) - throw new IllegalArgumentException( - "Invalid maxInStreams value"); - - return new InitMaxStreams(maxInStreams, maxOutStreams); - } - - /** - * Returns the maximum number of inbound streams. - * - * @return Maximum inbound streams - */ - public int maxInStreams() { - return maxInStreams; - } - - /** - * Returns the maximum number of outbound streams. - * - * @return Maximum outbound streams - */ - public int maxOutStreams() { - return maxOutStreams; - } - - /** - * Returns a string representation of this init max streams, including - * the maximum in and out bound streams. - * - * @return A string representation of this init max streams - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(super.toString()).append(" ["); - sb.append("maxInStreams:").append(maxInStreams); - sb.append("maxOutStreams:").append(maxOutStreams).append("]"); - return sb.toString(); - } - - /** - * Returns true if the specified object is another {@code InitMaxStreams} - * instance with the same number of in and out bound streams. - * - * @param obj - * The object to be compared with this init max streams - * - * @return true if the specified object is another - * {@code InitMaxStreams} instance with the same number of in - * and out bound streams - */ - @Override - public boolean equals(Object obj) { - if (obj != null && obj instanceof InitMaxStreams) { - InitMaxStreams that = (InitMaxStreams) obj; - if (this.maxInStreams == that.maxInStreams && - this.maxOutStreams == that.maxOutStreams) - return true; - } - return false; - } - - /** - * Returns a hash code value for this init max streams. - */ - @Override - public int hashCode() { - int hash = 7 ^ maxInStreams ^ maxOutStreams; - return hash; - } - } -} diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/com/sun/nio/sctp/SctpStandardSocketOptions.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/nio/sctp/SctpStandardSocketOptions.java Mon May 16 18:19:34 2011 -0700 @@ -0,0 +1,419 @@ +/* + * Copyright (c) 2009, 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.nio.sctp; + +import java.net.SocketAddress; +import sun.nio.ch.SctpStdSocketOption; + +/** + * SCTP channels supports the socket options defined by this class + * (as well as those listed in the particular channel class) and may support + * additional Implementation specific socket options. + * + * @since 1.7 + */ +public class SctpStandardSocketOptions { + private SctpStandardSocketOptions() {} + /** + * Enables or disables message fragmentation. + * + *

    The value of this socket option is a {@code Boolean} that represents + * whether the option is enabled or disabled. If enabled no SCTP message + * fragmentation will be performed. Instead if a message being sent + * exceeds the current PMTU size, the message will NOT be sent and + * an error will be indicated to the user. + * + *

    It is implementation specific whether or not this option is + * supported. + */ + public static final SctpSocketOption SCTP_DISABLE_FRAGMENTS = new + SctpStdSocketOption("SCTP_DISABLE_FRAGMENTS", Boolean.class, + sun.nio.ch.SctpStdSocketOption.SCTP_DISABLE_FRAGMENTS); + + /** + * Enables or disables explicit message completion. + * + *

    The value of this socket option is a {@code Boolean} that represents + * whether the option is enabled or disabled. When this option is enabled, + * the {@code send} method may be invoked multiple times to a send message. + * The {@code isComplete} parameter of the {@link MessageInfo} must only + * be set to {@code true} for the final send to indicate that the message is + * complete. If this option is disabled then each individual {@code send} + * invocation is considered complete. + * + *

    The default value of the option is {@code false} indicating that the + * option is disabled. It is implementation specific whether or not this + * option is supported. + */ + public static final SctpSocketOption SCTP_EXPLICIT_COMPLETE = new + SctpStdSocketOption("SCTP_EXPLICIT_COMPLETE", Boolean.class, + sun.nio.ch.SctpStdSocketOption.SCTP_EXPLICIT_COMPLETE); + + /** + * Fragmented interleave controls how the presentation of messages occur + * for the message receiver. There are three levels of fragment interleave + * defined. Two of the levels effect {@link SctpChannel}, while + * {@link SctpMultiChannel} is effected by all three levels. + * + *

    This option takes an {@code Integer} value. It can be set to a value + * of {@code 0}, {@code 1} or {@code 2}. + * + *

    Setting the three levels provides the following receiver + * interactions: + * + *

    {@code level 0} - Prevents the interleaving of any messages. This + * means that when a partial delivery begins, no other messages will be + * received except the message being partially delivered. If another message + * arrives on a different stream (or association) that could be delivered, + * it will be blocked waiting for the user to read all of the partially + * delivered message. + * + *

    {@code level 1} - Allows interleaving of messages that are from + * different associations. For {@code SctpChannel}, level 0 and + * level 1 have the same meaning since an {@code SctpChannel} always + * receives messages from the same association. Note that setting an {@code + * SctpMultiChannel} to this level may cause multiple partial + * delivers from different associations but for any given association, only + * one message will be delivered until all parts of a message have been + * delivered. This means that one large message, being read with an + * association identification of "X", will block other messages from + * association "X" from being delivered. + * + *

    {@code level 2} - Allows complete interleaving of messages. This + * level requires that the sender carefully observe not only the peer + * {@code Association} but also must pay careful attention to the stream + * number. With this option enabled a partially delivered message may begin + * being delivered for association "X" stream "Y" and the next subsequent + * receive may return a message from association "X" stream "Z". Note that + * no other messages would be delivered for association "X" stream "Y" + * until all of stream "Y"'s partially delivered message was read. + * Note that this option effects both channel types. Also note that + * for an {@code SctpMultiChannel} not only may another streams + * message from the same association be delivered from the next receive, + * some other associations message may be delivered upon the next receive. + * + *

    It is implementation specific whether or not this option is + * supported. + */ + public static final SctpSocketOption SCTP_FRAGMENT_INTERLEAVE = + new SctpStdSocketOption("SCTP_FRAGMENT_INTERLEAVE", + Integer.class, + sun.nio.ch.SctpStdSocketOption.SCTP_FRAGMENT_INTERLEAVE); + + /** + * The maximum number of streams requested by the local endpoint during + * association initialization. + * + *

    The value of this socket option is an {@link + * SctpStandardSocketOptions.InitMaxStreams InitMaxStreams}, that represents + * the maximum number of inbound and outbound streams that an association + * on the channel is prepared to support. + * + *

    For an {@link SctpChannel} this option may only be used to + * change the number of inbound/outbound streams prior to connecting. + * + *

    For an {@link SctpMultiChannel} this option determines + * the maximum number of inbound/outbound streams new associations setup + * on the channel will be prepared to support. + * + *

    For an {@link SctpServerChannel} this option determines the + * maximum number of inbound/outbound streams accepted sockets will + * negotiate with their connecting peer. + * + *

    In all cases the value set by this option is used in the negotiation + * of new associations setup on the channel's socket and the actual + * maximum number of inbound/outbound streams that have been negotiated + * with the peer can be retrieved from the appropriate {@link + * Association}. The {@code Association} can be retrieved from the + * {@link AssociationChangeNotification.AssocChangeEvent#COMM_UP COMM_UP} + * {@link AssociationChangeNotification} belonging to that association. + * + *

    This value is bounded by the actual implementation. In other + * words the user may be able to support more streams than the Operating + * System. In such a case, the Operating System limit may override the + * value requested by the user. The default value of 0 indicates to use + * the endpoints default value. + */ + public static final SctpSocketOption + SCTP_INIT_MAXSTREAMS = + new SctpStdSocketOption( + "SCTP_INIT_MAXSTREAMS", SctpStandardSocketOptions.InitMaxStreams.class); + + /** + * Enables or disables a Nagle-like algorithm. + * + *

    The value of this socket option is a {@code Boolean} that represents + * whether the option is enabled or disabled. SCTP uses an algorithm like + * The Nagle Algorithm to coalesce short segments and + * improve network efficiency. + */ + public static final SctpSocketOption SCTP_NODELAY = + new SctpStdSocketOption("SCTP_NODELAY", Boolean.class, + sun.nio.ch.SctpStdSocketOption.SCTP_NODELAY); + + /** + * Requests that the local SCTP stack use the given peer address as + * the association primary. + * + *

    The value of this socket option is a {@code SocketAddress} + * that represents the peer address that the local SCTP stack should use as + * the association primary. The address must be one of the association + * peer's addresses. + * + *

    An {@code SctpMultiChannel} can control more than one + * association, the association parameter must be given when setting or + * retrieving this option. + * + *

    Since {@code SctpChannel} only controls one association, + * the association parameter is not required and this option can be + * set or queried directly. + */ + public static final SctpSocketOption SCTP_PRIMARY_ADDR = + new SctpStdSocketOption + ("SCTP_PRIMARY_ADDR", SocketAddress.class); + + /** + * Requests that the peer mark the enclosed address as the association + * primary. + * + *

    The value of this socket option is a {@code SocketAddress} + * that represents the local address that the peer should use as its + * primary address. The given address must be one of the association's + * locally bound addresses. + * + *

    An {@code SctpMultiChannel} can control more than one + * association, the association parameter must be given when setting or + * retrieving this option. + * + *

    Since {@code SctpChannel} only controls one association, + * the association parameter is not required and this option can be + * queried directly. + * + *

    Note, this is a set only option and cannot be retrieved by {@code + * getOption}. It is implementation specific whether or not this + * option is supported. + */ + public static final SctpSocketOption SCTP_SET_PEER_PRIMARY_ADDR = + new SctpStdSocketOption + ("SCTP_SET_PEER_PRIMARY_ADDR", SocketAddress.class); + + /** + * The size of the socket send buffer. + * + *

    The value of this socket option is an {@code Integer} that is the + * size of the socket send buffer in bytes. The socket send buffer is an + * output buffer used by the networking implementation. It may need to be + * increased for high-volume connections. The value of the socket option is + * a hint to the implementation to size the buffer and the actual + * size may differ. The socket option can be queried to retrieve the actual + * size. + * + *

    For {@code SctpChannel}, this controls the amount of data + * the SCTP stack may have waiting in internal buffers to be sent. This + * option therefore bounds the maximum size of data that can be sent in a + * single send call. + * + *

    For {@code SctpMultiChannel}, the effect is the same as for {@code + * SctpChannel}, except that it applies to all associations. The option + * applies to each association's window size separately. + * + *

    An implementation allows this socket option to be set before the + * socket is bound or connected. Whether an implementation allows the + * socket send buffer to be changed after the socket is bound is system + * dependent. + */ + public static final SctpSocketOption SO_SNDBUF = + new SctpStdSocketOption("SO_SNDBUF", Integer.class, + sun.nio.ch.SctpStdSocketOption.SO_SNDBUF); + + /** + * The size of the socket receive buffer. + * + *

    The value of this socket option is an {@code Integer} that is the + * size of the socket receive buffer in bytes. The socket receive buffer is + * an input buffer used by the networking implementation. It may need to be + * increased for high-volume connections or decreased to limit the possible + * backlog of incoming data. The value of the socket option is a + * hint to the implementation to size the buffer and the actual + * size may differ. + * + *

    For {@code SctpChannel}, this controls the receiver window size. + * + *

    For {@code SctpMultiChannel}, the meaning is implementation + * dependent. It might control the receive buffer for each association bound + * to the socket descriptor or it might control the receive buffer for the + * whole socket. + * + *

    An implementation allows this socket option to be set before the + * socket is bound or connected. Whether an implementation allows the + * socket receive buffer to be changed after the socket is bound is system + * dependent. + */ + public static final SctpSocketOption SO_RCVBUF = + new SctpStdSocketOption("SO_RCVBUF", Integer.class, + sun.nio.ch.SctpStdSocketOption.SO_RCVBUF); + + /** + * Linger on close if data is present. + * + *

    The value of this socket option is an {@code Integer} that controls + * the action taken when unsent data is queued on the socket and a method + * to close the socket is invoked. If the value of the socket option is zero + * or greater, then it represents a timeout value, in seconds, known as the + * linger interval. The linger interval is the timeout for the + * {@code close} method to block while the operating system attempts to + * transmit the unsent data or it decides that it is unable to transmit the + * data. If the value of the socket option is less than zero then the option + * is disabled. In that case the {@code close} method does not wait until + * unsent data is transmitted; if possible the operating system will transmit + * any unsent data before the connection is closed. + * + *

    This socket option is intended for use with sockets that are configured + * in {@link java.nio.channels.SelectableChannel#isBlocking() blocking} mode + * only. The behavior of the {@code close} method when this option is + * enabled on a non-blocking socket is not defined. + * + *

    The initial value of this socket option is a negative value, meaning + * that the option is disabled. The option may be enabled, or the linger + * interval changed, at any time. The maximum value of the linger interval + * is system dependent. Setting the linger interval to a value that is + * greater than its maximum value causes the linger interval to be set to + * its maximum value. + */ + public static final SctpSocketOption SO_LINGER = + new SctpStdSocketOption("SO_LINGER", Integer.class, + sun.nio.ch.SctpStdSocketOption.SO_LINGER); + + /** + * This class is used to set the maximum number of inbound/outbound streams + * used by the local endpoint during association initialization. An + * instance of this class is used to set the {@link + * SctpStandardSocketOptions#SCTP_INIT_MAXSTREAMS SCTP_INIT_MAXSTREAMS} + * socket option. + * + * @since 1.7 + */ + public static class InitMaxStreams { + private int maxInStreams; + private int maxOutStreams; + + private InitMaxStreams(int maxInStreams, int maxOutStreams) { + this.maxInStreams = maxInStreams; + this.maxOutStreams = maxOutStreams; + } + + /** + * Creates an InitMaxStreams instance. + * + * @param maxInStreams + * The maximum number of inbound streams, where + * {@code 0 <= maxInStreams <= 65536} + * + * @param maxOutStreams + * The maximum number of outbound streams, where + * {@code 0 <= maxOutStreams <= 65536} + * + * @return An {@code InitMaxStreams} instance + * + * @throws IllegalArgumentException + * If an argument is outside of specified bounds + */ + public static InitMaxStreams create + (int maxInStreams, int maxOutStreams) { + if (maxOutStreams < 0 || maxOutStreams > 65535) + throw new IllegalArgumentException( + "Invalid maxOutStreams value"); + if (maxInStreams < 0 || maxInStreams > 65535) + throw new IllegalArgumentException( + "Invalid maxInStreams value"); + + return new InitMaxStreams(maxInStreams, maxOutStreams); + } + + /** + * Returns the maximum number of inbound streams. + * + * @return Maximum inbound streams + */ + public int maxInStreams() { + return maxInStreams; + } + + /** + * Returns the maximum number of outbound streams. + * + * @return Maximum outbound streams + */ + public int maxOutStreams() { + return maxOutStreams; + } + + /** + * Returns a string representation of this init max streams, including + * the maximum in and out bound streams. + * + * @return A string representation of this init max streams + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(super.toString()).append(" ["); + sb.append("maxInStreams:").append(maxInStreams); + sb.append("maxOutStreams:").append(maxOutStreams).append("]"); + return sb.toString(); + } + + /** + * Returns true if the specified object is another {@code InitMaxStreams} + * instance with the same number of in and out bound streams. + * + * @param obj + * The object to be compared with this init max streams + * + * @return true if the specified object is another + * {@code InitMaxStreams} instance with the same number of in + * and out bound streams + */ + @Override + public boolean equals(Object obj) { + if (obj != null && obj instanceof InitMaxStreams) { + InitMaxStreams that = (InitMaxStreams) obj; + if (this.maxInStreams == that.maxInStreams && + this.maxOutStreams == that.maxOutStreams) + return true; + } + return false; + } + + /** + * Returns a hash code value for this init max streams. + */ + @Override + public int hashCode() { + int hash = 7 ^ maxInStreams ^ maxOutStreams; + return hash; + } + } +} diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/lang/SafeVarargs.java --- a/jdk/src/share/classes/java/lang/SafeVarargs.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/lang/SafeVarargs.java Mon May 16 18:19:34 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ * constructor does not perform potentially unsafe operations on its * varargs parameter. Applying this annotation to a method or * constructor suppresses unchecked warnings about a - * non-reifiable variable-arity (vararg) type and suppresses + * non-reifiable variable arity (vararg) type and suppresses * unchecked warnings about parameterized array creation at call * sites. * @@ -41,11 +41,10 @@ * additional usage restrictions on this annotation type; it is a * compile-time error if a method or constructor declaration is * annotated with a {@code @SafeVarargs} annotation, and either: - *

      - *
    • the declaration is a fixed-arity method or constructor + *
    • the declaration is a fixed arity method or constructor * - *
    • the declaration is a variable-arity method that is neither + *
    • the declaration is a variable arity method that is neither * {@code static} nor {@code final}. * *
    @@ -55,15 +54,28 @@ * *
      * - *
    • The variable-arity parameter has a reifiable element type, + *
    • The variable arity parameter has a reifiable element type, * which includes primitive types, {@code Object}, and {@code String}. * (The unchecked warnings this annotation type suppresses already do * not occur for a reifiable element type.) * *
    • The body of the method or constructor declaration performs * potentially unsafe operations, such as an assignment to an element - * of the variable-arity parameter's array that generates an unchecked - * warning. + * of the variable arity parameter's array that generates an unchecked + * warning. Some unsafe operations do not trigger an unchecked + * warning. For example, the aliasing in + * + *
      + * @SafeVarargs // Not actually safe!
      + * static void m(List<String>... stringLists) {
      + *   Object[] array = stringLists;
      + *   List<Integer> tmpList = Arrays.asList(42);
      + *   array[0] = tmpList; // Semantically invalid, but compiles without warnings
      + *   String s = stringLists[0].get(0); // Oh no, ClassCastException at runtime!
      + * }
      + * 
      + * + * leads to a {@code ClassCastException} at runtime. * *

      Future versions of the platform may mandate compiler errors for * such unsafe operations. diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/lang/Throwable.java --- a/jdk/src/share/classes/java/lang/Throwable.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/lang/Throwable.java Mon May 16 18:19:34 2011 -0700 @@ -336,7 +336,10 @@ * Disabling of suppression should only occur in exceptional * circumstances where special requirements exist, such as a * virtual machine reusing exception objects under low-memory - * situations. + * situations. Circumstances where a given exception object is + * repeatedly caught and rethrown, such as to implement control + * flow between two sub-systems, is another situation where + * immutable throwable objects would be appropriate. * * @param message the detail message. * @param cause the cause. (A {@code null} value is permitted, @@ -423,6 +426,18 @@ * {@link #Throwable(String,Throwable)}, this method cannot be called * even once. * + *

      An example of using this method on a legacy throwable type + * without other support for setting the cause is: + * + *

      +     * try {
      +     *     lowLevelOp();
      +     * } catch (LowLevelException le) {
      +     *     throw (HighLevelException)
      +     *           new HighLevelException().initCause(le); // Legacy constructor
      +     * }
      +     * 
      + * * @param cause the cause (which is saved for later retrieval by the * {@link #getCause()} method). (A {@code null} value is * permitted, and indicates that the cause is nonexistent or @@ -788,7 +803,8 @@ * this throwable is permitted to return a zero-length array from this * method. Generally speaking, the array returned by this method will * contain one element for every frame that would be printed by - * {@code printStackTrace}. + * {@code printStackTrace}. Writes to the returned array do not + * affect future calls to this method. * * @return an array of stack trace elements representing the stack trace * pertaining to this throwable. @@ -971,8 +987,8 @@ /** * Appends the specified exception to the exceptions that were * suppressed in order to deliver this exception. This method is - * typically called (automatically and implicitly) by the {@code - * try}-with-resources statement. + * thread-safe and typically called (automatically and implicitly) + * by the {@code try}-with-resources statement. * *

      The suppression behavior is enabled unless disabled * {@linkplain #Throwable(String, Throwable, boolean, boolean) via @@ -1043,7 +1059,9 @@ * * If no exceptions were suppressed or {@linkplain * #Throwable(String, Throwable, boolean, boolean) suppression is - * disabled}, an empty array is returned. + * disabled}, an empty array is returned. This method is + * thread-safe. Writes to the returned array do not affect future + * calls to this method. * * @return an array containing all of the exceptions that were * suppressed to deliver this exception. diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/net/SocketOption.java --- a/jdk/src/share/classes/java/net/SocketOption.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/net/SocketOption.java Mon May 16 18:19:34 2011 -0700 @@ -38,7 +38,7 @@ * * @since 1.7 * - * @see StandardSocketOption + * @see StandardSocketOptions */ public interface SocketOption { diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/net/StandardSocketOption.java --- a/jdk/src/share/classes/java/net/StandardSocketOption.java Mon May 16 18:17:26 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,367 +0,0 @@ -/* - * Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package java.net; - -/** - * Defines the standard socket options. - * - *

      The {@link SocketOption#name name} of each socket option defined by this - * class is its field name. - * - *

      In this release, the socket options defined here are used by {@link - * java.nio.channels.NetworkChannel network} channels in the {@link - * java.nio.channels channels} package. - * - * @since 1.7 - */ - -public final class StandardSocketOption { - private StandardSocketOption() { } - - // -- SOL_SOCKET -- - - /** - * Allow transmission of broadcast datagrams. - * - *

      The value of this socket option is a {@code Boolean} that represents - * whether the option is enabled or disabled. The option is specific to - * datagram-oriented sockets sending to {@link java.net.Inet4Address IPv4} - * broadcast addresses. When the socket option is enabled then the socket - * can be used to send broadcast datagrams. - * - *

      The initial value of this socket option is {@code FALSE}. The socket - * option may be enabled or disabled at any time. Some operating systems may - * require that the Java virtual machine be started with implementation - * specific privileges to enable this option or send broadcast datagrams. - * - * @see RFC 929: - * Broadcasting Internet Datagrams - * @see DatagramSocket#setBroadcast - */ - public static final SocketOption SO_BROADCAST = - new StdSocketOption("SO_BROADCAST", Boolean.class); - - /** - * Keep connection alive. - * - *

      The value of this socket option is a {@code Boolean} that represents - * whether the option is enabled or disabled. When the {@code SO_KEEPALIVE} - * option is enabled the operating system may use a keep-alive - * mechanism to periodically probe the other end of a connection when the - * connection is otherwise idle. The exact semantics of the keep alive - * mechanism is system dependent and therefore unspecified. - * - *

      The initial value of this socket option is {@code FALSE}. The socket - * option may be enabled or disabled at any time. - * - * @see RFC 1122 - * Requirements for Internet Hosts -- Communication Layers - * @see Socket#setKeepAlive - */ - public static final SocketOption SO_KEEPALIVE = - new StdSocketOption("SO_KEEPALIVE", Boolean.class); - - /** - * The size of the socket send buffer. - * - *

      The value of this socket option is an {@code Integer} that is the - * size of the socket send buffer in bytes. The socket send buffer is an - * output buffer used by the networking implementation. It may need to be - * increased for high-volume connections. The value of the socket option is - * a hint to the implementation to size the buffer and the actual - * size may differ. The socket option can be queried to retrieve the actual - * size. - * - *

      For datagram-oriented sockets, the size of the send buffer may limit - * the size of the datagrams that may be sent by the socket. Whether - * datagrams larger than the buffer size are sent or discarded is system - * dependent. - * - *

      The initial/default size of the socket send buffer and the range of - * allowable values is system dependent although a negative size is not - * allowed. An attempt to set the socket send buffer to larger than its - * maximum size causes it to be set to its maximum size. - * - *

      An implementation allows this socket option to be set before the - * socket is bound or connected. Whether an implementation allows the - * socket send buffer to be changed after the socket is bound is system - * dependent. - * - * @see Socket#setSendBufferSize - */ - public static final SocketOption SO_SNDBUF = - new StdSocketOption("SO_SNDBUF", Integer.class); - - - /** - * The size of the socket receive buffer. - * - *

      The value of this socket option is an {@code Integer} that is the - * size of the socket receive buffer in bytes. The socket receive buffer is - * an input buffer used by the networking implementation. It may need to be - * increased for high-volume connections or decreased to limit the possible - * backlog of incoming data. The value of the socket option is a - * hint to the implementation to size the buffer and the actual - * size may differ. - * - *

      For datagram-oriented sockets, the size of the receive buffer may - * limit the size of the datagrams that can be received. Whether datagrams - * larger than the buffer size can be received is system dependent. - * Increasing the socket receive buffer may be important for cases where - * datagrams arrive in bursts faster than they can be processed. - * - *

      In the case of stream-oriented sockets and the TCP/IP protocol, the - * size of the socket receive buffer may be used when advertising the size - * of the TCP receive window to the remote peer. - * - *

      The initial/default size of the socket receive buffer and the range - * of allowable values is system dependent although a negative size is not - * allowed. An attempt to set the socket receive buffer to larger than its - * maximum size causes it to be set to its maximum size. - * - *

      An implementation allows this socket option to be set before the - * socket is bound or connected. Whether an implementation allows the - * socket receive buffer to be changed after the socket is bound is system - * dependent. - * - * @see RFC 1323: TCP - * Extensions for High Performance - * @see Socket#setReceiveBufferSize - * @see ServerSocket#setReceiveBufferSize - */ - public static final SocketOption SO_RCVBUF = - new StdSocketOption("SO_RCVBUF", Integer.class); - - /** - * Re-use address. - * - *

      The value of this socket option is a {@code Boolean} that represents - * whether the option is enabled or disabled. The exact semantics of this - * socket option are socket type and system dependent. - * - *

      In the case of stream-oriented sockets, this socket option will - * usually determine whether the socket can be bound to a socket address - * when a previous connection involving that socket address is in the - * TIME_WAIT state. On implementations where the semantics differ, - * and the socket option is not required to be enabled in order to bind the - * socket when a previous connection is in this state, then the - * implementation may choose to ignore this option. - * - *

      For datagram-oriented sockets the socket option is used to allow - * multiple programs bind to the same address. This option should be enabled - * when the socket is to be used for Internet Protocol (IP) multicasting. - * - *

      An implementation allows this socket option to be set before the - * socket is bound or connected. Changing the value of this socket option - * after the socket is bound has no effect. The default value of this - * socket option is system dependent. - * - * @see RFC 793: Transmission - * Control Protocol - * @see ServerSocket#setReuseAddress - */ - public static final SocketOption SO_REUSEADDR = - new StdSocketOption("SO_REUSEADDR", Boolean.class); - - /** - * Linger on close if data is present. - * - *

      The value of this socket option is an {@code Integer} that controls - * the action taken when unsent data is queued on the socket and a method - * to close the socket is invoked. If the value of the socket option is zero - * or greater, then it represents a timeout value, in seconds, known as the - * linger interval. The linger interval is the timeout for the - * {@code close} method to block while the operating system attempts to - * transmit the unsent data or it decides that it is unable to transmit the - * data. If the value of the socket option is less than zero then the option - * is disabled. In that case the {@code close} method does not wait until - * unsent data is transmitted; if possible the operating system will transmit - * any unsent data before the connection is closed. - * - *

      This socket option is intended for use with sockets that are configured - * in {@link java.nio.channels.SelectableChannel#isBlocking() blocking} mode - * only. The behavior of the {@code close} method when this option is - * enabled on a non-blocking socket is not defined. - * - *

      The initial value of this socket option is a negative value, meaning - * that the option is disabled. The option may be enabled, or the linger - * interval changed, at any time. The maximum value of the linger interval - * is system dependent. Setting the linger interval to a value that is - * greater than its maximum value causes the linger interval to be set to - * its maximum value. - * - * @see Socket#setSoLinger - */ - public static final SocketOption SO_LINGER = - new StdSocketOption("SO_LINGER", Integer.class); - - - // -- IPPROTO_IP -- - - /** - * The Type of Service (ToS) octet in the Internet Protocol (IP) header. - * - *

      The value of this socket option is an {@code Integer} representing - * the value of the ToS octet in IP packets sent by sockets to an {@link - * StandardProtocolFamily#INET IPv4} socket. The interpretation of the ToS - * octet is network specific and is not defined by this class. Further - * information on the ToS octet can be found in RFC 1349 and RFC 2474. The value - * of the socket option is a hint. An implementation may ignore the - * value, or ignore specific values. - * - *

      The initial/default value of the TOS field in the ToS octet is - * implementation specific but will typically be {@code 0}. For - * datagram-oriented sockets the option may be configured at any time after - * the socket has been bound. The new value of the octet is used when sending - * subsequent datagrams. It is system dependent whether this option can be - * queried or changed prior to binding the socket. - * - *

      The behavior of this socket option on a stream-oriented socket, or an - * {@link StandardProtocolFamily#INET6 IPv6} socket, is not defined in this - * release. - * - * @see DatagramSocket#setTrafficClass - */ - public static final SocketOption IP_TOS = - new StdSocketOption("IP_TOS", Integer.class); - - /** - * The network interface for Internet Protocol (IP) multicast datagrams. - * - *

      The value of this socket option is a {@link NetworkInterface} that - * represents the outgoing interface for multicast datagrams sent by the - * datagram-oriented socket. For {@link StandardProtocolFamily#INET6 IPv6} - * sockets then it is system dependent whether setting this option also - * sets the outgoing interface for multlicast datagrams sent to IPv4 - * addresses. - * - *

      The initial/default value of this socket option may be {@code null} - * to indicate that outgoing interface will be selected by the operating - * system, typically based on the network routing tables. An implementation - * allows this socket option to be set after the socket is bound. Whether - * the socket option can be queried or changed prior to binding the socket - * is system dependent. - * - * @see java.nio.channels.MulticastChannel - * @see MulticastSocket#setInterface - */ - public static final SocketOption IP_MULTICAST_IF = - new StdSocketOption("IP_MULTICAST_IF", NetworkInterface.class); - - /** - * The time-to-live for Internet Protocol (IP) multicast datagrams. - * - *

      The value of this socket option is an {@code Integer} in the range - * 0 <= value <= 255. It is used to control - * the scope of multicast datagrams sent by the datagram-oriented socket. - * In the case of an {@link StandardProtocolFamily#INET IPv4} socket - * the option is the time-to-live (TTL) on multicast datagrams sent by the - * socket. Datagrams with a TTL of zero are not transmitted on the network - * but may be delivered locally. In the case of an {@link - * StandardProtocolFamily#INET6 IPv6} socket the option is the - * hop limit which is number of hops that the datagram can - * pass through before expiring on the network. For IPv6 sockets it is - * system dependent whether the option also sets the time-to-live - * on multicast datagrams sent to IPv4 addresses. - * - *

      The initial/default value of the time-to-live setting is typically - * {@code 1}. An implementation allows this socket option to be set after - * the socket is bound. Whether the socket option can be queried or changed - * prior to binding the socket is system dependent. - * - * @see java.nio.channels.MulticastChannel - * @see MulticastSocket#setTimeToLive - */ - public static final SocketOption IP_MULTICAST_TTL = - new StdSocketOption("IP_MULTICAST_TTL", Integer.class); - - /** - * Loopback for Internet Protocol (IP) multicast datagrams. - * - *

      The value of this socket option is a {@code Boolean} that controls - * the loopback of multicast datagrams. The value of the socket - * option represents if the option is enabled or disabled. - * - *

      The exact semantics of this socket options are system dependent. - * In particular, it is system dependent whether the loopback applies to - * multicast datagrams sent from the socket or received by the socket. - * For {@link StandardProtocolFamily#INET6 IPv6} sockets then it is - * system dependent whether the option also applies to multicast datagrams - * sent to IPv4 addresses. - * - *

      The initial/default value of this socket option is {@code TRUE}. An - * implementation allows this socket option to be set after the socket is - * bound. Whether the socket option can be queried or changed prior to - * binding the socket is system dependent. - * - * @see java.nio.channels.MulticastChannel - * @see MulticastSocket#setLoopbackMode - */ - public static final SocketOption IP_MULTICAST_LOOP = - new StdSocketOption("IP_MULTICAST_LOOP", Boolean.class); - - - // -- IPPROTO_TCP -- - - /** - * Disable the Nagle algorithm. - * - *

      The value of this socket option is a {@code Boolean} that represents - * whether the option is enabled or disabled. The socket option is specific to - * stream-oriented sockets using the TCP/IP protocol. TCP/IP uses an algorithm - * known as The Nagle Algorithm to coalesce short segments and - * improve network efficiency. - * - *

      The default value of this socket option is {@code FALSE}. The - * socket option should only be enabled in cases where it is known that the - * coalescing impacts performance. The socket option may be enabled at any - * time. In other words, the Nagle Algorithm can be disabled. Once the option - * is enabled, it is system dependent whether it can be subsequently - * disabled. If it cannot, then invoking the {@code setOption} method to - * disable the option has no effect. - * - * @see RFC 1122: - * Requirements for Internet Hosts -- Communication Layers - * @see Socket#setTcpNoDelay - */ - public static final SocketOption TCP_NODELAY = - new StdSocketOption("TCP_NODELAY", Boolean.class); - - - private static class StdSocketOption implements SocketOption { - private final String name; - private final Class type; - StdSocketOption(String name, Class type) { - this.name = name; - this.type = type; - } - @Override public String name() { return name; } - @Override public Class type() { return type; } - @Override public String toString() { return name; } - } -} diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/net/StandardSocketOptions.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/java/net/StandardSocketOptions.java Mon May 16 18:19:34 2011 -0700 @@ -0,0 +1,367 @@ +/* + * Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.net; + +/** + * Defines the standard socket options. + * + *

      The {@link SocketOption#name name} of each socket option defined by this + * class is its field name. + * + *

      In this release, the socket options defined here are used by {@link + * java.nio.channels.NetworkChannel network} channels in the {@link + * java.nio.channels channels} package. + * + * @since 1.7 + */ + +public final class StandardSocketOptions { + private StandardSocketOptions() { } + + // -- SOL_SOCKET -- + + /** + * Allow transmission of broadcast datagrams. + * + *

      The value of this socket option is a {@code Boolean} that represents + * whether the option is enabled or disabled. The option is specific to + * datagram-oriented sockets sending to {@link java.net.Inet4Address IPv4} + * broadcast addresses. When the socket option is enabled then the socket + * can be used to send broadcast datagrams. + * + *

      The initial value of this socket option is {@code FALSE}. The socket + * option may be enabled or disabled at any time. Some operating systems may + * require that the Java virtual machine be started with implementation + * specific privileges to enable this option or send broadcast datagrams. + * + * @see RFC 929: + * Broadcasting Internet Datagrams + * @see DatagramSocket#setBroadcast + */ + public static final SocketOption SO_BROADCAST = + new StdSocketOption("SO_BROADCAST", Boolean.class); + + /** + * Keep connection alive. + * + *

      The value of this socket option is a {@code Boolean} that represents + * whether the option is enabled or disabled. When the {@code SO_KEEPALIVE} + * option is enabled the operating system may use a keep-alive + * mechanism to periodically probe the other end of a connection when the + * connection is otherwise idle. The exact semantics of the keep alive + * mechanism is system dependent and therefore unspecified. + * + *

      The initial value of this socket option is {@code FALSE}. The socket + * option may be enabled or disabled at any time. + * + * @see RFC 1122 + * Requirements for Internet Hosts -- Communication Layers + * @see Socket#setKeepAlive + */ + public static final SocketOption SO_KEEPALIVE = + new StdSocketOption("SO_KEEPALIVE", Boolean.class); + + /** + * The size of the socket send buffer. + * + *

      The value of this socket option is an {@code Integer} that is the + * size of the socket send buffer in bytes. The socket send buffer is an + * output buffer used by the networking implementation. It may need to be + * increased for high-volume connections. The value of the socket option is + * a hint to the implementation to size the buffer and the actual + * size may differ. The socket option can be queried to retrieve the actual + * size. + * + *

      For datagram-oriented sockets, the size of the send buffer may limit + * the size of the datagrams that may be sent by the socket. Whether + * datagrams larger than the buffer size are sent or discarded is system + * dependent. + * + *

      The initial/default size of the socket send buffer and the range of + * allowable values is system dependent although a negative size is not + * allowed. An attempt to set the socket send buffer to larger than its + * maximum size causes it to be set to its maximum size. + * + *

      An implementation allows this socket option to be set before the + * socket is bound or connected. Whether an implementation allows the + * socket send buffer to be changed after the socket is bound is system + * dependent. + * + * @see Socket#setSendBufferSize + */ + public static final SocketOption SO_SNDBUF = + new StdSocketOption("SO_SNDBUF", Integer.class); + + + /** + * The size of the socket receive buffer. + * + *

      The value of this socket option is an {@code Integer} that is the + * size of the socket receive buffer in bytes. The socket receive buffer is + * an input buffer used by the networking implementation. It may need to be + * increased for high-volume connections or decreased to limit the possible + * backlog of incoming data. The value of the socket option is a + * hint to the implementation to size the buffer and the actual + * size may differ. + * + *

      For datagram-oriented sockets, the size of the receive buffer may + * limit the size of the datagrams that can be received. Whether datagrams + * larger than the buffer size can be received is system dependent. + * Increasing the socket receive buffer may be important for cases where + * datagrams arrive in bursts faster than they can be processed. + * + *

      In the case of stream-oriented sockets and the TCP/IP protocol, the + * size of the socket receive buffer may be used when advertising the size + * of the TCP receive window to the remote peer. + * + *

      The initial/default size of the socket receive buffer and the range + * of allowable values is system dependent although a negative size is not + * allowed. An attempt to set the socket receive buffer to larger than its + * maximum size causes it to be set to its maximum size. + * + *

      An implementation allows this socket option to be set before the + * socket is bound or connected. Whether an implementation allows the + * socket receive buffer to be changed after the socket is bound is system + * dependent. + * + * @see RFC 1323: TCP + * Extensions for High Performance + * @see Socket#setReceiveBufferSize + * @see ServerSocket#setReceiveBufferSize + */ + public static final SocketOption SO_RCVBUF = + new StdSocketOption("SO_RCVBUF", Integer.class); + + /** + * Re-use address. + * + *

      The value of this socket option is a {@code Boolean} that represents + * whether the option is enabled or disabled. The exact semantics of this + * socket option are socket type and system dependent. + * + *

      In the case of stream-oriented sockets, this socket option will + * usually determine whether the socket can be bound to a socket address + * when a previous connection involving that socket address is in the + * TIME_WAIT state. On implementations where the semantics differ, + * and the socket option is not required to be enabled in order to bind the + * socket when a previous connection is in this state, then the + * implementation may choose to ignore this option. + * + *

      For datagram-oriented sockets the socket option is used to allow + * multiple programs bind to the same address. This option should be enabled + * when the socket is to be used for Internet Protocol (IP) multicasting. + * + *

      An implementation allows this socket option to be set before the + * socket is bound or connected. Changing the value of this socket option + * after the socket is bound has no effect. The default value of this + * socket option is system dependent. + * + * @see RFC 793: Transmission + * Control Protocol + * @see ServerSocket#setReuseAddress + */ + public static final SocketOption SO_REUSEADDR = + new StdSocketOption("SO_REUSEADDR", Boolean.class); + + /** + * Linger on close if data is present. + * + *

      The value of this socket option is an {@code Integer} that controls + * the action taken when unsent data is queued on the socket and a method + * to close the socket is invoked. If the value of the socket option is zero + * or greater, then it represents a timeout value, in seconds, known as the + * linger interval. The linger interval is the timeout for the + * {@code close} method to block while the operating system attempts to + * transmit the unsent data or it decides that it is unable to transmit the + * data. If the value of the socket option is less than zero then the option + * is disabled. In that case the {@code close} method does not wait until + * unsent data is transmitted; if possible the operating system will transmit + * any unsent data before the connection is closed. + * + *

      This socket option is intended for use with sockets that are configured + * in {@link java.nio.channels.SelectableChannel#isBlocking() blocking} mode + * only. The behavior of the {@code close} method when this option is + * enabled on a non-blocking socket is not defined. + * + *

      The initial value of this socket option is a negative value, meaning + * that the option is disabled. The option may be enabled, or the linger + * interval changed, at any time. The maximum value of the linger interval + * is system dependent. Setting the linger interval to a value that is + * greater than its maximum value causes the linger interval to be set to + * its maximum value. + * + * @see Socket#setSoLinger + */ + public static final SocketOption SO_LINGER = + new StdSocketOption("SO_LINGER", Integer.class); + + + // -- IPPROTO_IP -- + + /** + * The Type of Service (ToS) octet in the Internet Protocol (IP) header. + * + *

      The value of this socket option is an {@code Integer} representing + * the value of the ToS octet in IP packets sent by sockets to an {@link + * StandardProtocolFamily#INET IPv4} socket. The interpretation of the ToS + * octet is network specific and is not defined by this class. Further + * information on the ToS octet can be found in RFC 1349 and RFC 2474. The value + * of the socket option is a hint. An implementation may ignore the + * value, or ignore specific values. + * + *

      The initial/default value of the TOS field in the ToS octet is + * implementation specific but will typically be {@code 0}. For + * datagram-oriented sockets the option may be configured at any time after + * the socket has been bound. The new value of the octet is used when sending + * subsequent datagrams. It is system dependent whether this option can be + * queried or changed prior to binding the socket. + * + *

      The behavior of this socket option on a stream-oriented socket, or an + * {@link StandardProtocolFamily#INET6 IPv6} socket, is not defined in this + * release. + * + * @see DatagramSocket#setTrafficClass + */ + public static final SocketOption IP_TOS = + new StdSocketOption("IP_TOS", Integer.class); + + /** + * The network interface for Internet Protocol (IP) multicast datagrams. + * + *

      The value of this socket option is a {@link NetworkInterface} that + * represents the outgoing interface for multicast datagrams sent by the + * datagram-oriented socket. For {@link StandardProtocolFamily#INET6 IPv6} + * sockets then it is system dependent whether setting this option also + * sets the outgoing interface for multlicast datagrams sent to IPv4 + * addresses. + * + *

      The initial/default value of this socket option may be {@code null} + * to indicate that outgoing interface will be selected by the operating + * system, typically based on the network routing tables. An implementation + * allows this socket option to be set after the socket is bound. Whether + * the socket option can be queried or changed prior to binding the socket + * is system dependent. + * + * @see java.nio.channels.MulticastChannel + * @see MulticastSocket#setInterface + */ + public static final SocketOption IP_MULTICAST_IF = + new StdSocketOption("IP_MULTICAST_IF", NetworkInterface.class); + + /** + * The time-to-live for Internet Protocol (IP) multicast datagrams. + * + *

      The value of this socket option is an {@code Integer} in the range + * 0 <= value <= 255. It is used to control + * the scope of multicast datagrams sent by the datagram-oriented socket. + * In the case of an {@link StandardProtocolFamily#INET IPv4} socket + * the option is the time-to-live (TTL) on multicast datagrams sent by the + * socket. Datagrams with a TTL of zero are not transmitted on the network + * but may be delivered locally. In the case of an {@link + * StandardProtocolFamily#INET6 IPv6} socket the option is the + * hop limit which is number of hops that the datagram can + * pass through before expiring on the network. For IPv6 sockets it is + * system dependent whether the option also sets the time-to-live + * on multicast datagrams sent to IPv4 addresses. + * + *

      The initial/default value of the time-to-live setting is typically + * {@code 1}. An implementation allows this socket option to be set after + * the socket is bound. Whether the socket option can be queried or changed + * prior to binding the socket is system dependent. + * + * @see java.nio.channels.MulticastChannel + * @see MulticastSocket#setTimeToLive + */ + public static final SocketOption IP_MULTICAST_TTL = + new StdSocketOption("IP_MULTICAST_TTL", Integer.class); + + /** + * Loopback for Internet Protocol (IP) multicast datagrams. + * + *

      The value of this socket option is a {@code Boolean} that controls + * the loopback of multicast datagrams. The value of the socket + * option represents if the option is enabled or disabled. + * + *

      The exact semantics of this socket options are system dependent. + * In particular, it is system dependent whether the loopback applies to + * multicast datagrams sent from the socket or received by the socket. + * For {@link StandardProtocolFamily#INET6 IPv6} sockets then it is + * system dependent whether the option also applies to multicast datagrams + * sent to IPv4 addresses. + * + *

      The initial/default value of this socket option is {@code TRUE}. An + * implementation allows this socket option to be set after the socket is + * bound. Whether the socket option can be queried or changed prior to + * binding the socket is system dependent. + * + * @see java.nio.channels.MulticastChannel + * @see MulticastSocket#setLoopbackMode + */ + public static final SocketOption IP_MULTICAST_LOOP = + new StdSocketOption("IP_MULTICAST_LOOP", Boolean.class); + + + // -- IPPROTO_TCP -- + + /** + * Disable the Nagle algorithm. + * + *

      The value of this socket option is a {@code Boolean} that represents + * whether the option is enabled or disabled. The socket option is specific to + * stream-oriented sockets using the TCP/IP protocol. TCP/IP uses an algorithm + * known as The Nagle Algorithm to coalesce short segments and + * improve network efficiency. + * + *

      The default value of this socket option is {@code FALSE}. The + * socket option should only be enabled in cases where it is known that the + * coalescing impacts performance. The socket option may be enabled at any + * time. In other words, the Nagle Algorithm can be disabled. Once the option + * is enabled, it is system dependent whether it can be subsequently + * disabled. If it cannot, then invoking the {@code setOption} method to + * disable the option has no effect. + * + * @see RFC 1122: + * Requirements for Internet Hosts -- Communication Layers + * @see Socket#setTcpNoDelay + */ + public static final SocketOption TCP_NODELAY = + new StdSocketOption("TCP_NODELAY", Boolean.class); + + + private static class StdSocketOption implements SocketOption { + private final String name; + private final Class type; + StdSocketOption(String name, Class type) { + this.name = name; + this.type = type; + } + @Override public String name() { return name; } + @Override public Class type() { return type; } + @Override public String toString() { return name; } + } +} diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java --- a/jdk/src/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java Mon May 16 18:19:34 2011 -0700 @@ -58,11 +58,11 @@ * Description * * - * {@link java.net.StandardSocketOption#SO_RCVBUF SO_RCVBUF} + * {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} * The size of the socket receive buffer * * - * {@link java.net.StandardSocketOption#SO_REUSEADDR SO_REUSEADDR} + * {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} * Re-use address * * diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java --- a/jdk/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java Mon May 16 18:19:34 2011 -0700 @@ -68,23 +68,23 @@ * Description * * - * {@link java.net.StandardSocketOption#SO_SNDBUF SO_SNDBUF} + * {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} * The size of the socket send buffer * * - * {@link java.net.StandardSocketOption#SO_RCVBUF SO_RCVBUF} + * {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} * The size of the socket receive buffer * * - * {@link java.net.StandardSocketOption#SO_KEEPALIVE SO_KEEPALIVE} + * {@link java.net.StandardSocketOptions#SO_KEEPALIVE SO_KEEPALIVE} * Keep connection alive * * - * {@link java.net.StandardSocketOption#SO_REUSEADDR SO_REUSEADDR} + * {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} * Re-use address * * - * {@link java.net.StandardSocketOption#TCP_NODELAY TCP_NODELAY} + * {@link java.net.StandardSocketOptions#TCP_NODELAY TCP_NODELAY} * Disable the Nagle algorithm * * diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/nio/channels/DatagramChannel.java --- a/jdk/src/share/classes/java/nio/channels/DatagramChannel.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/nio/channels/DatagramChannel.java Mon May 16 18:19:34 2011 -0700 @@ -63,37 +63,37 @@ * Description * * - * {@link java.net.StandardSocketOption#SO_SNDBUF SO_SNDBUF} + * {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} * The size of the socket send buffer * * - * {@link java.net.StandardSocketOption#SO_RCVBUF SO_RCVBUF} + * {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} * The size of the socket receive buffer * * - * {@link java.net.StandardSocketOption#SO_REUSEADDR SO_REUSEADDR} + * {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} * Re-use address * * - * {@link java.net.StandardSocketOption#SO_BROADCAST SO_BROADCAST} + * {@link java.net.StandardSocketOptions#SO_BROADCAST SO_BROADCAST} * Allow transmission of broadcast datagrams * * - * {@link java.net.StandardSocketOption#IP_TOS IP_TOS} + * {@link java.net.StandardSocketOptions#IP_TOS IP_TOS} * The Type of Service (ToS) octet in the Internet Protocol (IP) header * * - * {@link java.net.StandardSocketOption#IP_MULTICAST_IF IP_MULTICAST_IF} + * {@link java.net.StandardSocketOptions#IP_MULTICAST_IF IP_MULTICAST_IF} * The network interface for Internet Protocol (IP) multicast datagrams * * - * {@link java.net.StandardSocketOption#IP_MULTICAST_TTL + * {@link java.net.StandardSocketOptions#IP_MULTICAST_TTL * IP_MULTICAST_TTL} * The time-to-live for Internet Protocol (IP) multicast * datagrams * * - * {@link java.net.StandardSocketOption#IP_MULTICAST_LOOP + * {@link java.net.StandardSocketOptions#IP_MULTICAST_LOOP * IP_MULTICAST_LOOP} * Loopback for Internet Protocol (IP) multicast datagrams * diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/nio/channels/MulticastChannel.java --- a/jdk/src/share/classes/java/nio/channels/MulticastChannel.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/nio/channels/MulticastChannel.java Mon May 16 18:19:34 2011 -0700 @@ -30,7 +30,7 @@ import java.io.IOException; import java.net.ProtocolFamily; // javadoc import java.net.StandardProtocolFamily; // javadoc -import java.net.StandardSocketOption; // javadoc +import java.net.StandardSocketOptions; // javadoc /** * A network channel that supports Internet Protocol (IP) multicasting. @@ -93,7 +93,7 @@ * a specific address, rather than the wildcard address then it is implementation * specific if multicast datagrams are received by the socket.

    • * - *
    • The {@link StandardSocketOption#SO_REUSEADDR SO_REUSEADDR} option should be + *

    • The {@link StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} option should be * enabled prior to {@link NetworkChannel#bind binding} the socket. This is * required to allow multiple members of the group to bind to the same * address.

    • @@ -107,9 +107,9 @@ * NetworkInterface ni = NetworkInterface.getByName("hme0"); * * DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET) - * .setOption(StandardSocketOption.SO_REUSEADDR, true) + * .setOption(StandardSocketOptions.SO_REUSEADDR, true) * .bind(new InetSocketAddress(5000)) - * .setOption(StandardSocketOption.IP_MULTICAST_IF, ni); + * .setOption(StandardSocketOptions.IP_MULTICAST_IF, ni); * * InetAddress group = InetAddress.getByName("225.4.5.6"); * diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/nio/channels/NetworkChannel.java --- a/jdk/src/share/classes/java/nio/channels/NetworkChannel.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/nio/channels/NetworkChannel.java Mon May 16 18:19:34 2011 -0700 @@ -124,7 +124,7 @@ * @throws IOException * If an I/O error occurs * - * @see java.net.StandardSocketOption + * @see java.net.StandardSocketOptions */ NetworkChannel setOption(SocketOption name, T value) throws IOException; @@ -144,7 +144,7 @@ * @throws IOException * If an I/O error occurs * - * @see java.net.StandardSocketOption + * @see java.net.StandardSocketOptions */ T getOption(SocketOption name) throws IOException; diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/nio/channels/ServerSocketChannel.java --- a/jdk/src/share/classes/java/nio/channels/ServerSocketChannel.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/nio/channels/ServerSocketChannel.java Mon May 16 18:19:34 2011 -0700 @@ -52,11 +52,11 @@ * Description * * - * {@link java.net.StandardSocketOption#SO_RCVBUF SO_RCVBUF} + * {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} * The size of the socket receive buffer * * - * {@link java.net.StandardSocketOption#SO_REUSEADDR SO_REUSEADDR} + * {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} * Re-use address * * diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/nio/channels/SocketChannel.java --- a/jdk/src/share/classes/java/nio/channels/SocketChannel.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/nio/channels/SocketChannel.java Mon May 16 18:19:34 2011 -0700 @@ -72,28 +72,28 @@ * Description * * - * {@link java.net.StandardSocketOption#SO_SNDBUF SO_SNDBUF} + * {@link java.net.StandardSocketOptions#SO_SNDBUF SO_SNDBUF} * The size of the socket send buffer * * - * {@link java.net.StandardSocketOption#SO_RCVBUF SO_RCVBUF} + * {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} * The size of the socket receive buffer * * - * {@link java.net.StandardSocketOption#SO_KEEPALIVE SO_KEEPALIVE} + * {@link java.net.StandardSocketOptions#SO_KEEPALIVE SO_KEEPALIVE} * Keep connection alive * * - * {@link java.net.StandardSocketOption#SO_REUSEADDR SO_REUSEADDR} + * {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} * Re-use address * * - * {@link java.net.StandardSocketOption#SO_LINGER SO_LINGER} + * {@link java.net.StandardSocketOptions#SO_LINGER SO_LINGER} * Linger on close if data is present (when configured in blocking mode * only) * * - * {@link java.net.StandardSocketOption#TCP_NODELAY TCP_NODELAY} + * {@link java.net.StandardSocketOptions#TCP_NODELAY TCP_NODELAY} * Disable the Nagle algorithm * * diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/nio/charset/Charset.java --- a/jdk/src/share/classes/java/nio/charset/Charset.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/nio/charset/Charset.java Mon May 16 18:19:34 2011 -0700 @@ -215,7 +215,7 @@ * determined during virtual-machine startup and typically depends upon the * locale and charset being used by the underlying operating system.

      * - *

      The {@link StandardCharset} class defines constants for each of the + *

      The {@link StandardCharsets} class defines constants for each of the * standard charsets. * *

      Terminology

      diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/nio/charset/StandardCharset.java --- a/jdk/src/share/classes/java/nio/charset/StandardCharset.java Mon May 16 18:17:26 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package java.nio.charset; - -/** - * Constant definitions for the standard {@link Charset Charsets}. These - * charsets are guaranteed to be available on every implementation of the Java - * platform. - * - * @see Standard Charsets - * @since 1.7 - */ -public final class StandardCharset { - - private StandardCharset() { - throw new AssertionError("No java.nio.charset.StandardCharset instances for you!"); - } - /** - * Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the - * Unicode character set - */ - public static final Charset US_ASCII = Charset.forName("US-ASCII"); - /** - * ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1 - */ - public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); - /** - * Eight-bit UCS Transformation Format - */ - public static final Charset UTF_8 = Charset.forName("UTF-8"); - /** - * Sixteen-bit UCS Transformation Format, big-endian byte order - */ - public static final Charset UTF_16BE = Charset.forName("UTF-16BE"); - /** - * Sixteen-bit UCS Transformation Format, little-endian byte order - */ - public static final Charset UTF_16LE = Charset.forName("UTF-16LE"); - /** - * Sixteen-bit UCS Transformation Format, byte order identified by an - * optional byte-order mark - */ - public static final Charset UTF_16 = Charset.forName("UTF-16"); -} diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/nio/charset/StandardCharsets.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/java/nio/charset/StandardCharsets.java Mon May 16 18:19:34 2011 -0700 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package java.nio.charset; + +/** + * Constant definitions for the standard {@link Charset Charsets}. These + * charsets are guaranteed to be available on every implementation of the Java + * platform. + * + * @see Standard Charsets + * @since 1.7 + */ +public final class StandardCharsets { + + private StandardCharsets() { + throw new AssertionError("No java.nio.charset.StandardCharsets instances for you!"); + } + /** + * Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the + * Unicode character set + */ + public static final Charset US_ASCII = Charset.forName("US-ASCII"); + /** + * ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1 + */ + public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); + /** + * Eight-bit UCS Transformation Format + */ + public static final Charset UTF_8 = Charset.forName("UTF-8"); + /** + * Sixteen-bit UCS Transformation Format, big-endian byte order + */ + public static final Charset UTF_16BE = Charset.forName("UTF-16BE"); + /** + * Sixteen-bit UCS Transformation Format, little-endian byte order + */ + public static final Charset UTF_16LE = Charset.forName("UTF-16LE"); + /** + * Sixteen-bit UCS Transformation Format, byte order identified by an + * optional byte-order mark + */ + public static final Charset UTF_16 = Charset.forName("UTF-16"); +} diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/nio/file/Path.java --- a/jdk/src/share/classes/java/nio/file/Path.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/nio/file/Path.java Mon May 16 18:19:34 2011 -0700 @@ -72,7 +72,7 @@ * directory and is UTF-8 encoded. *
        *     Path path = FileSystems.getDefault().getPath("logs", "access.log");
      - *     BufferReader reader = Files.newBufferedReader(path, StandardCharset.UTF_8);
      + *     BufferReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8);
        * 
      * *

      Interoperability

      @@ -609,11 +609,11 @@ * directory can be watched. The {@code events} parameter is the events to * register and may contain the following events: *
        - *
      • {@link StandardWatchEventKind#ENTRY_CREATE ENTRY_CREATE} - + *
      • {@link StandardWatchEventKinds#ENTRY_CREATE ENTRY_CREATE} - * entry created or moved into the directory
      • - *
      • {@link StandardWatchEventKind#ENTRY_DELETE ENTRY_DELETE} - + *
      • {@link StandardWatchEventKinds#ENTRY_DELETE ENTRY_DELETE} - * entry deleted or moved out of the directory
      • - *
      • {@link StandardWatchEventKind#ENTRY_MODIFY ENTRY_MODIFY} - + *
      • {@link StandardWatchEventKinds#ENTRY_MODIFY ENTRY_MODIFY} - * entry in directory was modified
      • *
      * @@ -622,7 +622,7 @@ * that locates the directory entry that is created, deleted, or modified. * *

      The set of events may include additional implementation specific - * event that are not defined by the enum {@link StandardWatchEventKind} + * event that are not defined by the enum {@link StandardWatchEventKinds} * *

      The {@code modifiers} parameter specifies modifiers that * qualify how the directory is registered. This release does not define any diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/nio/file/StandardWatchEventKind.java --- a/jdk/src/share/classes/java/nio/file/StandardWatchEventKind.java Mon May 16 18:17:26 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package java.nio.file; - -/** - * Defines the standard event kinds. - * - * @since 1.7 - */ - -public final class StandardWatchEventKind { - private StandardWatchEventKind() { } - - /** - * A special event to indicate that events may have been lost or - * discarded. - * - *

      The {@link WatchEvent#context context} for this event is - * implementation specific and may be {@code null}. The event {@link - * WatchEvent#count count} may be greater than {@code 1}. - * - * @see WatchService - */ - public static final WatchEvent.Kind OVERFLOW = - new StdWatchEventKind("OVERFLOW", Void.class); - - /** - * Directory entry created. - * - *

      When a directory is registered for this event then the {@link WatchKey} - * is queued when it is observed that an entry is created in the directory - * or renamed into the directory. The event {@link WatchEvent#count count} - * for this event is always {@code 1}. - */ - public static final WatchEvent.Kind ENTRY_CREATE = - new StdWatchEventKind("ENTRY_CREATE", Path.class); - - /** - * Directory entry deleted. - * - *

      When a directory is registered for this event then the {@link WatchKey} - * is queued when it is observed that an entry is deleted or renamed out of - * the directory. The event {@link WatchEvent#count count} for this event - * is always {@code 1}. - */ - public static final WatchEvent.Kind ENTRY_DELETE = - new StdWatchEventKind("ENTRY_DELETE", Path.class); - - /** - * Directory entry modified. - * - *

      When a directory is registered for this event then the {@link WatchKey} - * is queued when it is observed that an entry in the directory has been - * modified. The event {@link WatchEvent#count count} for this event is - * {@code 1} or greater. - */ - public static final WatchEvent.Kind ENTRY_MODIFY = - new StdWatchEventKind("ENTRY_MODIFY", Path.class); - - private static class StdWatchEventKind implements WatchEvent.Kind { - private final String name; - private final Class type; - StdWatchEventKind(String name, Class type) { - this.name = name; - this.type = type; - } - @Override public String name() { return name; } - @Override public Class type() { return type; } - @Override public String toString() { return name; } - } -} diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/nio/file/StandardWatchEventKinds.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/java/nio/file/StandardWatchEventKinds.java Mon May 16 18:19:34 2011 -0700 @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.nio.file; + +/** + * Defines the standard event kinds. + * + * @since 1.7 + */ + +public final class StandardWatchEventKinds { + private StandardWatchEventKinds() { } + + /** + * A special event to indicate that events may have been lost or + * discarded. + * + *

      The {@link WatchEvent#context context} for this event is + * implementation specific and may be {@code null}. The event {@link + * WatchEvent#count count} may be greater than {@code 1}. + * + * @see WatchService + */ + public static final WatchEvent.Kind OVERFLOW = + new StdWatchEventKind("OVERFLOW", Object.class); + + /** + * Directory entry created. + * + *

      When a directory is registered for this event then the {@link WatchKey} + * is queued when it is observed that an entry is created in the directory + * or renamed into the directory. The event {@link WatchEvent#count count} + * for this event is always {@code 1}. + */ + public static final WatchEvent.Kind ENTRY_CREATE = + new StdWatchEventKind("ENTRY_CREATE", Path.class); + + /** + * Directory entry deleted. + * + *

      When a directory is registered for this event then the {@link WatchKey} + * is queued when it is observed that an entry is deleted or renamed out of + * the directory. The event {@link WatchEvent#count count} for this event + * is always {@code 1}. + */ + public static final WatchEvent.Kind ENTRY_DELETE = + new StdWatchEventKind("ENTRY_DELETE", Path.class); + + /** + * Directory entry modified. + * + *

      When a directory is registered for this event then the {@link WatchKey} + * is queued when it is observed that an entry in the directory has been + * modified. The event {@link WatchEvent#count count} for this event is + * {@code 1} or greater. + */ + public static final WatchEvent.Kind ENTRY_MODIFY = + new StdWatchEventKind("ENTRY_MODIFY", Path.class); + + private static class StdWatchEventKind implements WatchEvent.Kind { + private final String name; + private final Class type; + StdWatchEventKind(String name, Class type) { + this.name = name; + this.type = type; + } + @Override public String name() { return name; } + @Override public Class type() { return type; } + @Override public String toString() { return name; } + } +} diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/nio/file/WatchEvent.java --- a/jdk/src/share/classes/java/nio/file/WatchEvent.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/nio/file/WatchEvent.java Mon May 16 18:19:34 2011 -0700 @@ -50,7 +50,7 @@ * An event kind, for the purposes of identification. * * @since 1.7 - * @see StandardWatchEventKind + * @see StandardWatchEventKinds */ public static interface Kind { /** @@ -98,9 +98,9 @@ /** * Returns the context for the event. * - *

      In the case of {@link StandardWatchEventKind#ENTRY_CREATE ENTRY_CREATE}, - * {@link StandardWatchEventKind#ENTRY_DELETE ENTRY_DELETE}, and {@link - * StandardWatchEventKind#ENTRY_MODIFY ENTRY_MODIFY} events the context is + *

      In the case of {@link StandardWatchEventKinds#ENTRY_CREATE ENTRY_CREATE}, + * {@link StandardWatchEventKinds#ENTRY_DELETE ENTRY_DELETE}, and {@link + * StandardWatchEventKinds#ENTRY_MODIFY ENTRY_MODIFY} events the context is * a {@code Path} that is the {@link Path#relativize relative} path between * the directory registered with the watch service, and the entry that is * created, deleted, or modified. diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/nio/file/WatchService.java --- a/jdk/src/share/classes/java/nio/file/WatchService.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/nio/file/WatchService.java Mon May 16 18:19:34 2011 -0700 @@ -68,7 +68,7 @@ * of events that it may accumulate. Where an implementation knowingly * discards events then it arranges for the key's {@link WatchKey#pollEvents * pollEvents} method to return an element with an event type of {@link - * StandardWatchEventKind#OVERFLOW OVERFLOW}. This event can be used by the + * StandardWatchEventKinds#OVERFLOW OVERFLOW}. This event can be used by the * consumer as a trigger to re-examine the state of the object. * *

      When an event is reported to indicate that a file in a watched directory @@ -87,7 +87,7 @@ * are detected, their timeliness, and whether their ordering is preserved are * highly implementation specific. For example, when a file in a watched * directory is modified then it may result in a single {@link - * StandardWatchEventKind#ENTRY_MODIFY ENTRY_MODIFY} event in some + * StandardWatchEventKinds#ENTRY_MODIFY ENTRY_MODIFY} event in some * implementations but several events in other implementations. Short-lived * files (meaning files that are deleted very quickly after they are created) * may not be detected by primitive implementations that periodically poll the diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/nio/file/Watchable.java --- a/jdk/src/share/classes/java/nio/file/Watchable.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/nio/file/Watchable.java Mon May 16 18:19:34 2011 -0700 @@ -53,7 +53,7 @@ * those specified by the {@code events} and {@code modifiers} parameters. * Changing the event set does not cause pending events for the object to be * discarded. Objects are automatically registered for the {@link - * StandardWatchEventKind#OVERFLOW OVERFLOW} event. This event is not + * StandardWatchEventKinds#OVERFLOW OVERFLOW} event. This event is not * required to be present in the array of events. * *

      Otherwise the file system object has not yet been registered with the diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/sql/BatchUpdateException.java --- a/jdk/src/share/classes/java/sql/BatchUpdateException.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/sql/BatchUpdateException.java Mon May 16 18:19:34 2011 -0700 @@ -89,7 +89,7 @@ * The cause is not initialized, and may subsequently be * initialized by a call to the * {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code - * is intialized to 0. + * is initialized to 0. *

      * * @param reason a description of the exception @@ -188,7 +188,7 @@ * @since 1.6 */ public BatchUpdateException(Throwable cause) { - this(null, null, 0, null, cause); + this((cause == null ? null : cause.toString()), null, 0, null, cause); } /** @@ -214,7 +214,7 @@ * @since 1.6 */ public BatchUpdateException(int []updateCounts , Throwable cause) { - this(null, null, 0, updateCounts, cause); + this((cause == null ? null : cause.toString()), null, 0, updateCounts, cause); } /** diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/util/Formatter.java --- a/jdk/src/share/classes/java/util/Formatter.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/util/Formatter.java Mon May 16 18:19:34 2011 -0700 @@ -826,7 +826,7 @@ * *

    • Float and Double * - *
    • BigDecimal + *
    • BigDecimal * * * @@ -1362,7 +1362,7 @@ * precision is not provided, then all of the digits as returned by {@link * Double#toHexString(double)} will be output. * - *

      BigDecimal + *

      BigDecimal * *

      The following conversions may be applied {@link java.math.BigDecimal * BigDecimal}. @@ -1372,7 +1372,7 @@ * {@code 'e'} * '\u0065' * Requires the output to be formatted using computerized scientific notation. The computerized scientific notation. The localization algorithm is applied. * *

      The formatting of the magnitude m depends upon its value. @@ -1427,11 +1427,11 @@ * *

      If m is greater than or equal to 10-4 but less * than 10precision then it is represented in decimal format. + * href="#bdecimal">decimal format. * *

      If m is less than 10-4 or greater than or equal to * 10precision, then it is represented in computerized scientific notation. + * href="#bscientific">computerized scientific notation. * *

      The total number of significant digits in m is equal to the * precision. If the precision is not specified, then the default value is @@ -1447,7 +1447,7 @@ * * {@code 'f'} * '\u0066' - * Requires the output to be formatted using decimal + * Requires the output to be formatted using decimal * format. The localization algorithm is * applied. * diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/util/concurrent/Phaser.java --- a/jdk/src/share/classes/java/util/concurrent/Phaser.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/util/concurrent/Phaser.java Mon May 16 18:19:34 2011 -0700 @@ -159,7 +159,7 @@ * void runTasks(List tasks) { * final Phaser phaser = new Phaser(1); // "1" to register self * // create and start threads - * for (Runnable task : tasks) { + * for (final Runnable task : tasks) { * phaser.register(); * new Thread() { * public void run() { diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/util/concurrent/locks/LockSupport.java --- a/jdk/src/share/classes/java/util/concurrent/locks/LockSupport.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/util/concurrent/locks/LockSupport.java Mon May 16 18:19:34 2011 -0700 @@ -275,10 +275,14 @@ * snapshot -- the thread may have since unblocked or blocked on a * different blocker object. * + * @param t the thread * @return the blocker + * @throws NullPointerException if argument is null * @since 1.6 */ public static Object getBlocker(Thread t) { + if (t == null) + throw new NullPointerException(); return unsafe.getObjectVolatile(t, parkBlockerOffset); } diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/util/logging/LogManager.java --- a/jdk/src/share/classes/java/util/logging/LogManager.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/util/logging/LogManager.java Mon May 16 18:19:34 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2011, 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 @@ -342,12 +342,35 @@ // already been created with the given name it is returned. // Otherwise a new logger instance is created and registered // in the LogManager global namespace. + + // This method will always return a non-null Logger object. + // Synchronization is not required here. All synchronization for + // adding a new Logger object is handled by addLogger(). Logger demandLogger(String name) { Logger result = getLogger(name); if (result == null) { - result = new Logger(name, null); - addLogger(result); - result = getLogger(name); + // only allocate the new logger once + Logger newLogger = new Logger(name, null); + do { + if (addLogger(newLogger)) { + // We successfully added the new Logger that we + // created above so return it without refetching. + return newLogger; + } + + // We didn't add the new Logger that we created above + // because another thread added a Logger with the same + // name after our null check above and before our call + // to addLogger(). We have to refetch the Logger because + // addLogger() returns a boolean instead of the Logger + // reference itself. However, if the thread that created + // the other Logger is not holding a strong reference to + // the other Logger, then it is possible for the other + // Logger to be GC'ed after we saw it in addLogger() and + // before we can refetch it. If it has been GC'ed then + // we'll just loop around and try again. + result = getLogger(name); + } while (result == null); } return result; } diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/util/logging/Logger.java --- a/jdk/src/share/classes/java/util/logging/Logger.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/util/logging/Logger.java Mon May 16 18:19:34 2011 -0700 @@ -310,7 +310,20 @@ * @return a suitable Logger * @throws NullPointerException if the name is null. */ - public static synchronized Logger getLogger(String name) { + + // Synchronization is not required here. All synchronization for + // adding a new Logger object is handled by LogManager.addLogger(). + public static Logger getLogger(String name) { + // This method is intentionally not a wrapper around a call + // to getLogger(name, resourceBundleName). If it were then + // this sequence: + // + // getLogger("Foo", "resourceBundleForFoo"); + // getLogger("Foo"); + // + // would throw an IllegalArgumentException in the second call + // because the wrapper would result in an attempt to replace + // the existing "resourceBundleForFoo" with null. LogManager manager = LogManager.getLogManager(); return manager.demandLogger(name); } @@ -355,7 +368,10 @@ * a different resource bundle name. * @throws NullPointerException if the name is null. */ - public static synchronized Logger getLogger(String name, String resourceBundleName) { + + // Synchronization is not required here. All synchronization for + // adding a new Logger object is handled by LogManager.addLogger(). + public static Logger getLogger(String name, String resourceBundleName) { LogManager manager = LogManager.getLogManager(); Logger result = manager.demandLogger(name); if (result.resourceBundleName == null) { @@ -417,7 +433,10 @@ * @throws MissingResourceException if the resourceBundleName is non-null and * no corresponding resource can be found. */ - public static synchronized Logger getAnonymousLogger(String resourceBundleName) { + + // Synchronization is not required here. All synchronization for + // adding a new anonymous Logger object is handled by doSetParent(). + public static Logger getAnonymousLogger(String resourceBundleName) { LogManager manager = LogManager.getLogManager(); // cleanup some Loggers that have been GC'ed manager.drainLoggerRefQueueBounded(); diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/util/regex/Pattern.java --- a/jdk/src/share/classes/java/util/regex/Pattern.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/util/regex/Pattern.java Mon May 16 18:19:34 2011 -0700 @@ -213,7 +213,7 @@ * A character in the Greek block (block) * \p{Lu} * An uppercase letter (category) - * \p{isAlphabetic} + * \p{IsAlphabetic} * An alphabetic character (binary property) * \p{Sc} * A currency symbol diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/util/zip/ZipCoder.java --- a/jdk/src/share/classes/java/util/zip/ZipCoder.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/util/zip/ZipCoder.java Mon May 16 18:19:34 2011 -0700 @@ -28,7 +28,7 @@ import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; -import java.nio.charset.StandardCharset; +import java.nio.charset.StandardCharsets; import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; import java.nio.charset.CoderResult; @@ -107,7 +107,7 @@ if (isUTF8) return getBytes(s); if (utf8 == null) - utf8 = new ZipCoder(StandardCharset.UTF_8); + utf8 = new ZipCoder(StandardCharsets.UTF_8); return utf8.getBytes(s); } @@ -116,7 +116,7 @@ if (isUTF8) return toString(ba, len); if (utf8 == null) - utf8 = new ZipCoder(StandardCharset.UTF_8); + utf8 = new ZipCoder(StandardCharsets.UTF_8); return utf8.toString(ba, len); } @@ -132,7 +132,7 @@ private ZipCoder(Charset cs) { this.cs = cs; - this.isUTF8 = cs.name().equals(StandardCharset.UTF_8.name()); + this.isUTF8 = cs.name().equals(StandardCharsets.UTF_8.name()); } static ZipCoder get(Charset charset) { diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/util/zip/ZipFile.java --- a/jdk/src/share/classes/java/util/zip/ZipFile.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/util/zip/ZipFile.java Mon May 16 18:19:34 2011 -0700 @@ -31,7 +31,7 @@ import java.io.EOFException; import java.io.File; import java.nio.charset.Charset; -import java.nio.charset.StandardCharset; +import java.nio.charset.StandardCharsets; import java.util.ArrayDeque; import java.util.Deque; import java.util.Enumeration; @@ -141,7 +141,7 @@ * @since 1.3 */ public ZipFile(File file, int mode) throws IOException { - this(file, mode, StandardCharset.UTF_8); + this(file, mode, StandardCharsets.UTF_8); } /** diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/util/zip/ZipInputStream.java --- a/jdk/src/share/classes/java/util/zip/ZipInputStream.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/util/zip/ZipInputStream.java Mon May 16 18:19:34 2011 -0700 @@ -30,7 +30,7 @@ import java.io.EOFException; import java.io.PushbackInputStream; import java.nio.charset.Charset; -import java.nio.charset.StandardCharset; +import java.nio.charset.StandardCharsets; import static java.util.zip.ZipConstants64.*; /** @@ -76,7 +76,7 @@ * @param in the actual input stream */ public ZipInputStream(InputStream in) { - this(in, StandardCharset.UTF_8); + this(in, StandardCharsets.UTF_8); } /** diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/java/util/zip/ZipOutputStream.java --- a/jdk/src/share/classes/java/util/zip/ZipOutputStream.java Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/java/util/zip/ZipOutputStream.java Mon May 16 18:19:34 2011 -0700 @@ -28,7 +28,7 @@ import java.io.OutputStream; import java.io.IOException; import java.nio.charset.Charset; -import java.nio.charset.StandardCharset; +import java.nio.charset.StandardCharsets; import java.util.Vector; import java.util.HashSet; import static java.util.zip.ZipConstants64.*; @@ -101,7 +101,7 @@ * @param out the actual output stream */ public ZipOutputStream(OutputStream out) { - this(out, StandardCharset.UTF_8); + this(out, StandardCharsets.UTF_8); } /** diff -r 51a9096f6799 -r af3ed4dd2997 jdk/src/share/classes/javax/management/loading/package.html --- a/jdk/src/share/classes/javax/management/loading/package.html Mon May 16 18:17:26 2011 -0700 +++ b/jdk/src/share/classes/javax/management/loading/package.html Mon May 16 18:19:34 2011 -0700 @@ -2,7 +2,7 @@ javax.management.loading package