提交 a10d5c9c 编写于 作者: M mullan

Merge

...@@ -224,3 +224,5 @@ c4908732fef5235f1b98cafe0ce507771ef7892c jdk8-b98 ...@@ -224,3 +224,5 @@ c4908732fef5235f1b98cafe0ce507771ef7892c jdk8-b98
5be9c5bfcfe9b2a40412b4fb364377d49de014eb jdk8-b100 5be9c5bfcfe9b2a40412b4fb364377d49de014eb jdk8-b100
6901612328239fbd471d20823113c1cf3fdaebee jdk8-b101 6901612328239fbd471d20823113c1cf3fdaebee jdk8-b101
8ed8e2b4b90e0ac9aa5b3efef51cd576a9db96a9 jdk8-b102 8ed8e2b4b90e0ac9aa5b3efef51cd576a9db96a9 jdk8-b102
e0f6039c0290b7381042a6fec3100a69a5a67e37 jdk8-b103
f1d8d15bfcb5ada858a942f8a31f6598f23214d1 jdk8-b104
# #
# Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -43,8 +43,6 @@ FILES_java = \ ...@@ -43,8 +43,6 @@ FILES_java = \
com/sun/security/auth/UserPrincipal.java \ com/sun/security/auth/UserPrincipal.java \
com/sun/security/auth/LdapPrincipal.java \ com/sun/security/auth/LdapPrincipal.java \
com/sun/security/auth/PolicyFile.java \ com/sun/security/auth/PolicyFile.java \
com/sun/security/auth/SubjectCodeSource.java \
com/sun/security/auth/PolicyParser.java \
com/sun/security/auth/PrincipalComparator.java \ com/sun/security/auth/PrincipalComparator.java \
com/sun/security/auth/callback/TextCallbackHandler.java \ com/sun/security/auth/callback/TextCallbackHandler.java \
com/sun/security/auth/callback/DialogCallbackHandler.java com/sun/security/auth/callback/DialogCallbackHandler.java
...@@ -100,7 +100,7 @@ SUNWprivate_1.1 { ...@@ -100,7 +100,7 @@ SUNWprivate_1.1 {
Java_java_io_RandomAccessFile_open; Java_java_io_RandomAccessFile_open;
Java_java_io_RandomAccessFile_read; Java_java_io_RandomAccessFile_read;
Java_java_io_RandomAccessFile_readBytes; Java_java_io_RandomAccessFile_readBytes;
Java_java_io_RandomAccessFile_seek; Java_java_io_RandomAccessFile_seek0;
Java_java_io_RandomAccessFile_setLength; Java_java_io_RandomAccessFile_setLength;
Java_java_io_RandomAccessFile_write; Java_java_io_RandomAccessFile_write;
Java_java_io_RandomAccessFile_writeBytes; Java_java_io_RandomAccessFile_writeBytes;
......
...@@ -94,4 +94,5 @@ $(JARFILE): $(LIBDIR) $(FILES_class) $(FILES_png) $(FILES_gif) $(FILES_prop) $(T ...@@ -94,4 +94,5 @@ $(JARFILE): $(LIBDIR) $(FILES_class) $(FILES_png) $(FILES_gif) $(FILES_prop) $(T
clean clobber:: clean clobber::
$(RM) $(TEMPDIR)/manifest $(JARFILE) $(RM) $(TEMPDIR)/manifest $(JARFILE)
$(RM) $(GENSRCDIR)/sun/tools/jconsole/Version.java
...@@ -1042,6 +1042,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBATTACH,\ ...@@ -1042,6 +1042,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBATTACH,\
LANG:=C,\ LANG:=C,\
OPTIMIZATION:=LOW, \ OPTIMIZATION:=LOW, \
CFLAGS:=$(CFLAGS_JDKLIB),\ CFLAGS:=$(CFLAGS_JDKLIB),\
CFLAGS_windows:=/Gy,\
MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libattach/mapfile-$(OPENJDK_TARGET_OS), \ MAPFILE:=$(JDK_TOPDIR)/makefiles/mapfiles/libattach/mapfile-$(OPENJDK_TARGET_OS), \
VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\ VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/windows/resource/version.rc,\
RC_FLAGS:=$(RC_FLAGS) \ RC_FLAGS:=$(RC_FLAGS) \
...@@ -1051,6 +1052,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBATTACH,\ ...@@ -1051,6 +1052,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBATTACH,\
LDFLAGS:=$(LDFLAGS_JDKLIB) \ LDFLAGS:=$(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN),\ $(call SET_SHARED_LIBRARY_ORIGIN),\
LDFLAGS_solaris:=-ldoor,\ LDFLAGS_solaris:=-ldoor,\
LDFLAGS_windows:=/ORDER:@$(JDK_TOPDIR)/makefiles/mapfiles/libattach/reorder-windows-$(OPENJDK_TARGET_CPU),\
LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\ LDFLAGS_SUFFIX:=$(LDFLAGS_JDKLIB_SUFFIX),\
LDFLAGS_SUFFIX_windows:=$(WIN_JAVA_LIB) advapi32.lib psapi.lib,\ LDFLAGS_SUFFIX_windows:=$(WIN_JAVA_LIB) advapi32.lib psapi.lib,\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libattach,\ OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libattach,\
......
...@@ -65,10 +65,6 @@ PROFILE_2_JARS := \ ...@@ -65,10 +65,6 @@ PROFILE_2_JARS := \
$(if $(PROFILE_2_JRE_JAR_FILES), $(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(PROFILE_2_JRE_JAR_FILES))) \ $(if $(PROFILE_2_JRE_JAR_FILES), $(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(PROFILE_2_JRE_JAR_FILES))) \
$(PROFILE_1_JARS) $(PROFILE_1_JARS)
ifneq ($(ENABLE_JFR), true)
PROFILE_3_JRE_JAR_FILES := $(filter-out jfr.jar, $(PROFILE_3_JRE_JAR_FILES))
endif
PROFILE_3_JARS := \ PROFILE_3_JARS := \
$(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(PROFILE_3_JRE_JAR_FILES)) \ $(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(PROFILE_3_JRE_JAR_FILES)) \
$(PROFILE_2_JARS) $(PROFILE_2_JARS)
...@@ -77,6 +73,10 @@ ifdef OPENJDK ...@@ -77,6 +73,10 @@ ifdef OPENJDK
FULL_JRE_JAR_FILES := $(filter-out alt-rt.jar, $(FULL_JRE_JAR_FILES)) FULL_JRE_JAR_FILES := $(filter-out alt-rt.jar, $(FULL_JRE_JAR_FILES))
endif endif
ifneq ($(ENABLE_JFR), true)
FULL_JRE_JAR_FILES := $(filter-out jfr.jar, $(FULL_JRE_JAR_FILES))
endif
FULL_JRE_JARS := \ FULL_JRE_JARS := \
$(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(FULL_JRE_JAR_FILES)) \ $(addprefix $(IMAGES_OUTPUTDIR)/lib/, $(FULL_JRE_JAR_FILES)) \
$(PROFILE_3_JARS) $(PROFILE_3_JARS)
......
jvm_attach_thread_func@4
jvm_attach_thread_func_end
jvm_attach_thread_func
jvm_attach_thread_func_end
...@@ -100,7 +100,7 @@ SUNWprivate_1.1 { ...@@ -100,7 +100,7 @@ SUNWprivate_1.1 {
Java_java_io_RandomAccessFile_open; Java_java_io_RandomAccessFile_open;
Java_java_io_RandomAccessFile_read; Java_java_io_RandomAccessFile_read;
Java_java_io_RandomAccessFile_readBytes; Java_java_io_RandomAccessFile_readBytes;
Java_java_io_RandomAccessFile_seek; Java_java_io_RandomAccessFile_seek0;
Java_java_io_RandomAccessFile_setLength; Java_java_io_RandomAccessFile_setLength;
Java_java_io_RandomAccessFile_write; Java_java_io_RandomAccessFile_write;
Java_java_io_RandomAccessFile_writeBytes; Java_java_io_RandomAccessFile_writeBytes;
......
...@@ -102,6 +102,7 @@ PROFILE_1_JRE_JAR_FILES := \ ...@@ -102,6 +102,7 @@ PROFILE_1_JRE_JAR_FILES := \
security/US_export_policy.jar \ security/US_export_policy.jar \
security/local_policy.jar security/local_policy.jar
PROFILE_2_JRE_BIN_FILES := \ PROFILE_2_JRE_BIN_FILES := \
rmid$(EXE_SUFFIX) \ rmid$(EXE_SUFFIX) \
rmiregistry$(EXE_SUFFIX) rmiregistry$(EXE_SUFFIX)
...@@ -140,7 +141,6 @@ PROFILE_3_JRE_LIB_FILES := \ ...@@ -140,7 +141,6 @@ PROFILE_3_JRE_LIB_FILES := \
PROFILE_3_JRE_OTHER_FILES := PROFILE_3_JRE_OTHER_FILES :=
PROFILE_3_JRE_JAR_FILES := \ PROFILE_3_JRE_JAR_FILES := \
jfr.jar \
management-agent.jar management-agent.jar
...@@ -253,6 +253,6 @@ FULL_JRE_JAR_FILES := \ ...@@ -253,6 +253,6 @@ FULL_JRE_JAR_FILES := \
ext/cldrdata.jar \ ext/cldrdata.jar \
ext/dnsns.jar \ ext/dnsns.jar \
ext/nashorn.jar \ ext/nashorn.jar \
ext/zipfs.jar ext/zipfs.jar \
jfr.jar
...@@ -296,7 +296,7 @@ static unichar AWTKeyToMacShortcut(jint awtKey, BOOL doShift) { ...@@ -296,7 +296,7 @@ static unichar AWTKeyToMacShortcut(jint awtKey, BOOL doShift) {
case java_awt_event_KeyEvent_VK_HELP : macKey = NSHelpFunctionKey; break; case java_awt_event_KeyEvent_VK_HELP : macKey = NSHelpFunctionKey; break;
case java_awt_event_KeyEvent_VK_TAB : macKey = NSTabCharacter; break; case java_awt_event_KeyEvent_VK_TAB : macKey = NSTabCharacter; break;
case java_awt_event_KeyEvent_VK_ENTER : macKey = NSCarriageReturnCharacter; break; case java_awt_event_KeyEvent_VK_ENTER : macKey = NSNewlineCharacter; break;
case java_awt_event_KeyEvent_VK_BACK_SPACE : macKey = NSBackspaceCharacter; break; case java_awt_event_KeyEvent_VK_BACK_SPACE : macKey = NSBackspaceCharacter; break;
case java_awt_event_KeyEvent_VK_DELETE : macKey = NSDeleteCharacter; break; case java_awt_event_KeyEvent_VK_DELETE : macKey = NSDeleteCharacter; break;
case java_awt_event_KeyEvent_VK_CLEAR : macKey = NSClearDisplayFunctionKey; break; case java_awt_event_KeyEvent_VK_CLEAR : macKey = NSClearDisplayFunctionKey; break;
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
package com.sun.media.sound; package com.sun.media.sound;
import java.util.Arrays;
import javax.sound.sampled.*; import javax.sound.sampled.*;
/** /**
...@@ -46,11 +48,11 @@ public final class DataPusher implements Runnable { ...@@ -46,11 +48,11 @@ public final class DataPusher implements Runnable {
private final AudioFormat format; private final AudioFormat format;
// stream as source data // stream as source data
private AudioInputStream ais = null; private final AudioInputStream ais;
// byte array as source data // byte array as source data
private byte[] audioData = null; private final byte[] audioData;
private int audioDataByteLength = 0; private final int audioDataByteLength;
private int pos; private int pos;
private int newPos = -1; private int newPos = -1;
private boolean looping; private boolean looping;
...@@ -67,16 +69,22 @@ public final class DataPusher implements Runnable { ...@@ -67,16 +69,22 @@ public final class DataPusher implements Runnable {
private final int BUFFER_SIZE = 16384; private final int BUFFER_SIZE = 16384;
public DataPusher(SourceDataLine sourceLine, AudioFormat format, byte[] audioData, int byteLength) { public DataPusher(SourceDataLine sourceLine, AudioFormat format, byte[] audioData, int byteLength) {
this.audioData = audioData; this(sourceLine, format, null, audioData, byteLength);
this.audioDataByteLength = byteLength;
this.format = format;
this.source = sourceLine;
} }
public DataPusher(SourceDataLine sourceLine, AudioInputStream ais) { public DataPusher(SourceDataLine sourceLine, AudioInputStream ais) {
this(sourceLine, ais.getFormat(), ais, null, 0);
}
private DataPusher(final SourceDataLine source, final AudioFormat format,
final AudioInputStream ais, final byte[] audioData,
final int audioDataByteLength) {
this.source = source;
this.format = format;
this.ais = ais; this.ais = ais;
this.format = ais.getFormat(); this.audioDataByteLength = audioDataByteLength;
this.source = sourceLine; this.audioData = audioData == null ? null : Arrays.copyOf(audioData,
audioData.length);
} }
public synchronized void start() { public synchronized void start() {
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
*/ */
package com.sun.media.sound; package com.sun.media.sound;
import java.util.Arrays;
/** /**
* A standard director who chooses performers * A standard director who chooses performers
* by there keyfrom,keyto,velfrom,velto properties. * by there keyfrom,keyto,velfrom,velto properties.
...@@ -32,17 +34,16 @@ package com.sun.media.sound; ...@@ -32,17 +34,16 @@ package com.sun.media.sound;
*/ */
public final class ModelStandardDirector implements ModelDirector { public final class ModelStandardDirector implements ModelDirector {
ModelPerformer[] performers; private final ModelPerformer[] performers;
ModelDirectedPlayer player; private final ModelDirectedPlayer player;
boolean noteOnUsed = false; private boolean noteOnUsed = false;
boolean noteOffUsed = false; private boolean noteOffUsed = false;
public ModelStandardDirector(ModelPerformer[] performers, public ModelStandardDirector(final ModelPerformer[] performers,
ModelDirectedPlayer player) { final ModelDirectedPlayer player) {
this.performers = performers; this.performers = Arrays.copyOf(performers, performers.length);
this.player = player; this.player = player;
for (int i = 0; i < performers.length; i++) { for (final ModelPerformer p : this.performers) {
ModelPerformer p = performers[i];
if (p.isReleaseTriggered()) { if (p.isReleaseTriggered()) {
noteOffUsed = true; noteOffUsed = true;
} else { } else {
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
*/ */
package com.sun.media.sound; package com.sun.media.sound;
import java.util.Arrays;
/** /**
* A standard indexed director who chooses performers * A standard indexed director who chooses performers
* by there keyfrom,keyto,velfrom,velto properties. * by there keyfrom,keyto,velfrom,velto properties.
...@@ -32,22 +34,21 @@ package com.sun.media.sound; ...@@ -32,22 +34,21 @@ package com.sun.media.sound;
*/ */
public final class ModelStandardIndexedDirector implements ModelDirector { public final class ModelStandardIndexedDirector implements ModelDirector {
ModelPerformer[] performers; private final ModelPerformer[] performers;
ModelDirectedPlayer player; private final ModelDirectedPlayer player;
boolean noteOnUsed = false; private boolean noteOnUsed = false;
boolean noteOffUsed = false; private boolean noteOffUsed = false;
// Variables needed for index // Variables needed for index
byte[][] trantables; private byte[][] trantables;
int[] counters; private int[] counters;
int[][] mat; private int[][] mat;
public ModelStandardIndexedDirector(ModelPerformer[] performers, public ModelStandardIndexedDirector(final ModelPerformer[] performers,
ModelDirectedPlayer player) { final ModelDirectedPlayer player) {
this.performers = performers; this.performers = Arrays.copyOf(performers, performers.length);
this.player = player; this.player = player;
for (int i = 0; i < performers.length; i++) { for (final ModelPerformer p : this.performers) {
ModelPerformer p = performers[i];
if (p.isReleaseTriggered()) { if (p.isReleaseTriggered()) {
noteOffUsed = true; noteOffUsed = true;
} else { } else {
......
...@@ -38,7 +38,7 @@ import javax.sound.sampled.LineEvent; ...@@ -38,7 +38,7 @@ import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.LineUnavailableException;
/** /**
* Clip implemention for the SoftMixingMixer. * Clip implementation for the SoftMixingMixer.
* *
* @author Karl Helgason * @author Karl Helgason
*/ */
...@@ -357,7 +357,9 @@ public final class SoftMixingClip extends SoftMixingDataLine implements Clip { ...@@ -357,7 +357,9 @@ public final class SoftMixingClip extends SoftMixingDataLine implements Clip {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Buffer size does not represent an integral number of sample frames!"); "Buffer size does not represent an integral number of sample frames!");
this.data = data; if (data != null) {
this.data = Arrays.copyOf(data, data.length);
}
this.offset = offset; this.offset = offset;
this.bufferSize = bufferSize; this.bufferSize = bufferSize;
this.format = format; this.format = format;
......
/* /*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -59,7 +59,7 @@ import java.io.IOException; ...@@ -59,7 +59,7 @@ import java.io.IOException;
* {@link java.lang.instrument} for a detailed description on how these agents * {@link java.lang.instrument} for a detailed description on how these agents
* are loaded and started). The {@link #loadAgentLibrary loadAgentLibrary} and * are loaded and started). The {@link #loadAgentLibrary loadAgentLibrary} and
* {@link #loadAgentPath loadAgentPath} methods are used to load agents that * {@link #loadAgentPath loadAgentPath} methods are used to load agents that
* are deployed in a dynamic library and make use of the <a * are deployed either in a dynamic library or statically linked into the VM and make use of the <a
* href="../../../../../../../../technotes/guides/jvmti/index.html">JVM Tools * href="../../../../../../../../technotes/guides/jvmti/index.html">JVM Tools
* Interface</a>. </p> * Interface</a>. </p>
* *
...@@ -298,25 +298,29 @@ public abstract class VirtualMachine { ...@@ -298,25 +298,29 @@ public abstract class VirtualMachine {
* <p> A <a href="../../../../../../../../technotes/guides/jvmti/index.html">JVM * <p> A <a href="../../../../../../../../technotes/guides/jvmti/index.html">JVM
* TI</a> client is called an <i>agent</i>. It is developed in a native language. * TI</a> client is called an <i>agent</i>. It is developed in a native language.
* A JVM TI agent is deployed in a platform specific manner but it is typically the * A JVM TI agent is deployed in a platform specific manner but it is typically the
* platform equivalent of a dynamic library. This method causes the given agent * platform equivalent of a dynamic library. Alternatively, it may be statically linked into the VM.
* library to be loaded into the target VM (if not already loaded). * This method causes the given agent library to be loaded into the target
* VM (if not already loaded or if not statically linked into the VM).
* It then causes the target VM to invoke the <code>Agent_OnAttach</code> function * It then causes the target VM to invoke the <code>Agent_OnAttach</code> function
* or, for a statically linked agent named 'L', the <code>Agent_OnAttach_L</code> function
* as specified in the * as specified in the
* <a href="../../../../../../../../technotes/guides/jvmti/index.html"> JVM Tools * <a href="../../../../../../../../technotes/guides/jvmti/index.html"> JVM Tools
* Interface</a> specification. Note that the <code>Agent_OnAttach</code> * Interface</a> specification. Note that the <code>Agent_OnAttach[_L]</code>
* function is invoked even if the agent library was loaded prior to invoking * function is invoked even if the agent library was loaded prior to invoking
* this method. * this method.
* *
* <p> The agent library provided is the name of the agent library. It is interpreted * <p> The agent library provided is the name of the agent library. It is interpreted
* in the target virtual machine in an implementation-dependent manner. Typically an * in the target virtual machine in an implementation-dependent manner. Typically an
* implementation will expand the library name into an operating system specific file * implementation will expand the library name into an operating system specific file
* name. For example, on UNIX systems, the name <tt>foo</tt> might be expanded to * name. For example, on UNIX systems, the name <tt>L</tt> might be expanded to
* <tt>libfoo.so</tt>, and located using the search path specified by the * <tt>libL.so</tt>, and located using the search path specified by the
* <tt>LD_LIBRARY_PATH</tt> environment variable.</p> * <tt>LD_LIBRARY_PATH</tt> environment variable. If the agent named 'L' is
* statically linked into the VM then the VM must export a function named
* <code>Agent_OnAttach_L</code>.</p>
* *
* <p> If the <code>Agent_OnAttach</code> function in the agent library returns * <p> If the <code>Agent_OnAttach[_L]</code> function in the agent library returns
* an error then an {@link com.sun.tools.attach.AgentInitializationException} is * an error then an {@link com.sun.tools.attach.AgentInitializationException} is
* thrown. The return value from the <code>Agent_OnAttach</code> can then be * thrown. The return value from the <code>Agent_OnAttach[_L]</code> can then be
* obtained by invoking the {@link * obtained by invoking the {@link
* com.sun.tools.attach.AgentInitializationException#returnValue() returnValue} * com.sun.tools.attach.AgentInitializationException#returnValue() returnValue}
* method on the exception. </p> * method on the exception. </p>
...@@ -325,15 +329,16 @@ public abstract class VirtualMachine { ...@@ -325,15 +329,16 @@ public abstract class VirtualMachine {
* The name of the agent library. * The name of the agent library.
* *
* @param options * @param options
* The options to provide to the <code>Agent_OnAttach</code> * The options to provide to the <code>Agent_OnAttach[_L]</code>
* function (can be <code>null</code>). * function (can be <code>null</code>).
* *
* @throws AgentLoadException * @throws AgentLoadException
* If the agent library does not exist, or cannot be loaded for * If the agent library does not exist, the agent library is not
* another reason. * statically linked with the VM, or the agent library cannot be
* loaded for another reason.
* *
* @throws AgentInitializationException * @throws AgentInitializationException
* If the <code>Agent_OnAttach</code> function returns an error * If the <code>Agent_OnAttach[_L]</code> function returns an error.
* *
* @throws IOException * @throws IOException
* If an I/O error occurs * If an I/O error occurs
...@@ -359,11 +364,12 @@ public abstract class VirtualMachine { ...@@ -359,11 +364,12 @@ public abstract class VirtualMachine {
* The name of the agent library. * The name of the agent library.
* *
* @throws AgentLoadException * @throws AgentLoadException
* If the agent library does not exist, or cannot be loaded for * If the agent library does not exist, the agent library is not
* another reason. * statically linked with the VM, or the agent library cannot be
* loaded for another reason.
* *
* @throws AgentInitializationException * @throws AgentInitializationException
* If the <code>Agent_OnAttach</code> function returns an error * If the <code>Agent_OnAttach[_L]</code> function returns an error.
* *
* @throws IOException * @throws IOException
* If an I/O error occurs * If an I/O error occurs
...@@ -383,12 +389,23 @@ public abstract class VirtualMachine { ...@@ -383,12 +389,23 @@ public abstract class VirtualMachine {
* <p> A <a href="../../../../../../../../technotes/guides/jvmti/index.html">JVM * <p> A <a href="../../../../../../../../technotes/guides/jvmti/index.html">JVM
* TI</a> client is called an <i>agent</i>. It is developed in a native language. * TI</a> client is called an <i>agent</i>. It is developed in a native language.
* A JVM TI agent is deployed in a platform specific manner but it is typically the * A JVM TI agent is deployed in a platform specific manner but it is typically the
* platform equivalent of a dynamic library. This method causes the given agent * platform equivalent of a dynamic library. Alternatively, the native
* library to be loaded into the target VM (if not already loaded). * library specified by the agentPath parameter may be statically
* It then causes the target VM to invoke the <code>Agent_OnAttach</code> function * linked with the VM. The parsing of the agentPath parameter into
* as specified in the * a statically linked library name is done in a platform
* specific manner in the VM. For example, in UNIX, an agentPath parameter
* of <code>/a/b/libL.so</code> would name a library 'L'.
*
* See the JVM TI Specification for more details.
*
* This method causes the given agent library to be loaded into the target
* VM (if not already loaded or if not statically linked into the VM).
* It then causes the target VM to invoke the <code>Agent_OnAttach</code>
* function or, for a statically linked agent named 'L', the
* <code>Agent_OnAttach_L</code> function as specified in the
* <a href="../../../../../../../../technotes/guides/jvmti/index.html"> JVM Tools * <a href="../../../../../../../../technotes/guides/jvmti/index.html"> JVM Tools
* Interface</a> specification. Note that the <code>Agent_OnAttach</code> * Interface</a> specification.
* Note that the <code>Agent_OnAttach[_L]</code>
* function is invoked even if the agent library was loaded prior to invoking * function is invoked even if the agent library was loaded prior to invoking
* this method. * this method.
* *
...@@ -396,9 +413,9 @@ public abstract class VirtualMachine { ...@@ -396,9 +413,9 @@ public abstract class VirtualMachine {
* agent library. Unlike {@link #loadAgentLibrary loadAgentLibrary}, the library name * agent library. Unlike {@link #loadAgentLibrary loadAgentLibrary}, the library name
* is not expanded in the target virtual machine. </p> * is not expanded in the target virtual machine. </p>
* *
* <p> If the <code>Agent_OnAttach</code> function in the agent library returns * <p> If the <code>Agent_OnAttach[_L]</code> function in the agent library returns
* an error then an {@link com.sun.tools.attach.AgentInitializationException} is * an error then an {@link com.sun.tools.attach.AgentInitializationException} is
* thrown. The return value from the <code>Agent_OnAttach</code> can then be * thrown. The return value from the <code>Agent_OnAttach[_L]</code> can then be
* obtained by invoking the {@link * obtained by invoking the {@link
* com.sun.tools.attach.AgentInitializationException#returnValue() returnValue} * com.sun.tools.attach.AgentInitializationException#returnValue() returnValue}
* method on the exception. </p> * method on the exception. </p>
...@@ -407,15 +424,16 @@ public abstract class VirtualMachine { ...@@ -407,15 +424,16 @@ public abstract class VirtualMachine {
* The full path of the agent library. * The full path of the agent library.
* *
* @param options * @param options
* The options to provide to the <code>Agent_OnAttach</code> * The options to provide to the <code>Agent_OnAttach[_L]</code>
* function (can be <code>null</code>). * function (can be <code>null</code>).
* *
* @throws AgentLoadException * @throws AgentLoadException
* If the agent library does not exist, or cannot be loaded for * If the agent library does not exist, the agent library is not
* another reason. * statically linked with the VM, or the agent library cannot be
* loaded for another reason.
* *
* @throws AgentInitializationException * @throws AgentInitializationException
* If the <code>Agent_OnAttach</code> function returns an error * If the <code>Agent_OnAttach[_L]</code> function returns an error.
* *
* @throws IOException * @throws IOException
* If an I/O error occurs * If an I/O error occurs
...@@ -441,11 +459,12 @@ public abstract class VirtualMachine { ...@@ -441,11 +459,12 @@ public abstract class VirtualMachine {
* The full path to the agent library. * The full path to the agent library.
* *
* @throws AgentLoadException * @throws AgentLoadException
* If the agent library does not exist, or cannot be loaded for * If the agent library does not exist, the agent library is not
* another reason. * statically linked with the VM, or the agent library cannot be
* loaded for another reason.
* *
* @throws AgentInitializationException * @throws AgentInitializationException
* If the <code>Agent_OnAttach</code> function returns an error * If the <code>Agent_OnAttach[_L]</code> function returns an error.
* *
* @throws IOException * @throws IOException
* If an I/O error occurs * If an I/O error occurs
......
...@@ -1144,7 +1144,7 @@ function contains(array, code) { ...@@ -1144,7 +1144,7 @@ function contains(array, code) {
} else { } else {
for (var index in array) { for (var index in array) {
var it = array[index]; var it = array[index];
if (func(it, index, array)) { if (func(it, String(index), array)) {
return true; return true;
} }
} }
...@@ -1244,7 +1244,7 @@ function filter(array, code) { ...@@ -1244,7 +1244,7 @@ function filter(array, code) {
var result = new Array(); var result = new Array();
for (var index in array) { for (var index in array) {
var it = array[index]; var it = array[index];
if (func(it, index, array, result)) { if (func(it, String(index), array, result)) {
result[result.length] = it; result[result.length] = it;
} }
} }
...@@ -1317,7 +1317,7 @@ function map(array, code) { ...@@ -1317,7 +1317,7 @@ function map(array, code) {
var result = new Array(); var result = new Array();
for (var index in array) { for (var index in array) {
var it = array[index]; var it = array[index];
result[result.length] = func(it, index, array, result); result[result.length] = func(it, String(index), array, result);
} }
return result; return result;
} }
......
...@@ -2426,7 +2426,8 @@ public abstract class KeyboardFocusManager ...@@ -2426,7 +2426,8 @@ public abstract class KeyboardFocusManager
focusLog.finest("Request {0}", String.valueOf(hwFocusRequest)); focusLog.finest("Request {0}", String.valueOf(hwFocusRequest));
} }
if (hwFocusRequest == null && if (hwFocusRequest == null &&
heavyweight == nativeFocusOwner) heavyweight == nativeFocusOwner &&
heavyweight.getContainingWindow() == nativeFocusedWindow)
{ {
if (descendant == currentFocusOwner) { if (descendant == currentFocusOwner) {
// Redundant request. // Redundant request.
......
/* /*
* Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -50,7 +50,15 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; ...@@ -50,7 +50,15 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
public public
class BufferedInputStream extends FilterInputStream { class BufferedInputStream extends FilterInputStream {
private static int defaultBufferSize = 8192; private static int DEFAULT_BUFFER_SIZE = 8192;
/**
* The maximum size of array to allocate.
* Some VMs reserve some header words in an array.
* Attempts to allocate larger arrays may result in
* OutOfMemoryError: Requested array size exceeds VM limit
*/
private static int MAX_BUFFER_SIZE = Integer.MAX_VALUE - 8;
/** /**
* The internal buffer array where the data is stored. When necessary, * The internal buffer array where the data is stored. When necessary,
...@@ -172,7 +180,7 @@ class BufferedInputStream extends FilterInputStream { ...@@ -172,7 +180,7 @@ class BufferedInputStream extends FilterInputStream {
* @param in the underlying input stream. * @param in the underlying input stream.
*/ */
public BufferedInputStream(InputStream in) { public BufferedInputStream(InputStream in) {
this(in, defaultBufferSize); this(in, DEFAULT_BUFFER_SIZE);
} }
/** /**
...@@ -215,8 +223,11 @@ class BufferedInputStream extends FilterInputStream { ...@@ -215,8 +223,11 @@ class BufferedInputStream extends FilterInputStream {
} else if (buffer.length >= marklimit) { } else if (buffer.length >= marklimit) {
markpos = -1; /* buffer got too big, invalidate mark */ markpos = -1; /* buffer got too big, invalidate mark */
pos = 0; /* drop buffer contents */ pos = 0; /* drop buffer contents */
} else if (buffer.length >= MAX_BUFFER_SIZE) {
throw new OutOfMemoryError("Required array size too large");
} else { /* grow buffer */ } else { /* grow buffer */
int nsz = pos * 2; int nsz = (pos <= MAX_BUFFER_SIZE - pos) ?
pos * 2 : MAX_BUFFER_SIZE;
if (nsz > marklimit) if (nsz > marklimit)
nsz = marklimit; nsz = marklimit;
byte nbuf[] = new byte[nsz]; byte nbuf[] = new byte[nsz];
......
...@@ -518,7 +518,15 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { ...@@ -518,7 +518,15 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* @exception IOException if {@code pos} is less than * @exception IOException if {@code pos} is less than
* {@code 0} or if an I/O error occurs. * {@code 0} or if an I/O error occurs.
*/ */
public native void seek(long pos) throws IOException; public void seek(long pos) throws IOException {
if (pos < 0) {
throw new IOException("Negative seek offset");
} else {
seek0(pos);
}
}
private native void seek0(long pos) throws IOException;
/** /**
* Returns the length of this file. * Returns the length of this file.
......
...@@ -1307,7 +1307,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { ...@@ -1307,7 +1307,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
* specified substring, starting at the specified index. The integer * specified substring, starting at the specified index. The integer
* returned is the smallest value {@code k} for which: * returned is the smallest value {@code k} for which:
* <blockquote><pre> * <blockquote><pre>
* k >= Math.min(fromIndex, str.length()) && * k >= Math.min(fromIndex, this.length()) &&
* this.toString().startsWith(str, k) * this.toString().startsWith(str, k)
* </pre></blockquote> * </pre></blockquote>
* If no such value of <i>k</i> exists, then -1 is returned. * If no such value of <i>k</i> exists, then -1 is returned.
...@@ -1346,7 +1346,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { ...@@ -1346,7 +1346,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
* specified substring. The integer returned is the largest value <i>k</i> * specified substring. The integer returned is the largest value <i>k</i>
* such that: * such that:
* <blockquote><pre> * <blockquote><pre>
* k <= Math.min(fromIndex, str.length()) && * k <= Math.min(fromIndex, this.length()) &&
* this.toString().startsWith(str, k) * this.toString().startsWith(str, k)
* </pre></blockquote> * </pre></blockquote>
* If no such value of <i>k</i> exists, then -1 is returned. * If no such value of <i>k</i> exists, then -1 is returned.
......
...@@ -3338,8 +3338,16 @@ public final class Class<T> implements java.io.Serializable, ...@@ -3338,8 +3338,16 @@ public final class Class<T> implements java.io.Serializable,
* @since 1.8 * @since 1.8
*/ */
public AnnotatedType getAnnotatedSuperclass() { public AnnotatedType getAnnotatedSuperclass() {
if (this == Object.class ||
isInterface() ||
isArray() ||
isPrimitive() ||
this == Void.TYPE) {
return null;
}
return TypeAnnotationParser.buildAnnotatedSuperclass(getRawTypeAnnotations(), getConstantPool(), this); return TypeAnnotationParser.buildAnnotatedSuperclass(getRawTypeAnnotations(), getConstantPool(), this);
} }
/** /**
* Returns an array of AnnotatedType objects that represent the use of types to * Returns an array of AnnotatedType objects that represent the use of types to
......
...@@ -698,11 +698,8 @@ public final class Math { ...@@ -698,11 +698,8 @@ public final class Math {
return 0; return 0;
} }
private static Random randomNumberGenerator; private static final class RandomNumberGeneratorHolder {
static final Random randomNumberGenerator = new Random();
private static synchronized Random initRNG() {
Random rnd = randomNumberGenerator;
return (rnd == null) ? (randomNumberGenerator = new Random()) : rnd;
} }
/** /**
...@@ -729,9 +726,7 @@ public final class Math { ...@@ -729,9 +726,7 @@ public final class Math {
* @see Random#nextDouble() * @see Random#nextDouble()
*/ */
public static double random() { public static double random() {
Random rnd = randomNumberGenerator; return RandomNumberGeneratorHolder.randomNumberGenerator.nextDouble();
if (rnd == null) rnd = initRNG();
return rnd.nextDouble();
} }
/** /**
......
...@@ -678,11 +678,8 @@ public final class StrictMath { ...@@ -678,11 +678,8 @@ public final class StrictMath {
return Math.round(a); return Math.round(a);
} }
private static Random randomNumberGenerator; private static final class RandomNumberGeneratorHolder {
static final Random randomNumberGenerator = new Random();
private static synchronized Random initRNG() {
Random rnd = randomNumberGenerator;
return (rnd == null) ? (randomNumberGenerator = new Random()) : rnd;
} }
/** /**
...@@ -709,9 +706,7 @@ public final class StrictMath { ...@@ -709,9 +706,7 @@ public final class StrictMath {
* @see Random#nextDouble() * @see Random#nextDouble()
*/ */
public static double random() { public static double random() {
Random rnd = randomNumberGenerator; return RandomNumberGeneratorHolder.randomNumberGenerator.nextDouble();
if (rnd == null) rnd = initRNG();
return rnd.nextDouble();
} }
/** /**
......
...@@ -2659,28 +2659,32 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> { ...@@ -2659,28 +2659,32 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
if (ys == 0) if (ys == 0)
return 1; return 1;
int sdiff = this.scale - val.scale; long sdiff = (long)this.scale - val.scale;
if (sdiff != 0) { if (sdiff != 0) {
// Avoid matching scales if the (adjusted) exponents differ // Avoid matching scales if the (adjusted) exponents differ
int xae = this.precision() - this.scale; // [-1] long xae = (long)this.precision() - this.scale; // [-1]
int yae = val.precision() - val.scale; // [-1] long yae = (long)val.precision() - val.scale; // [-1]
if (xae < yae) if (xae < yae)
return -1; return -1;
if (xae > yae) if (xae > yae)
return 1; return 1;
BigInteger rb = null; BigInteger rb = null;
if (sdiff < 0) { if (sdiff < 0) {
if ( (xs == INFLATED || // The cases sdiff <= Integer.MIN_VALUE intentionally fall through.
(xs = longMultiplyPowerTen(xs, -sdiff)) == INFLATED) && if ( sdiff > Integer.MIN_VALUE &&
(xs == INFLATED ||
(xs = longMultiplyPowerTen(xs, (int)-sdiff)) == INFLATED) &&
ys == INFLATED) { ys == INFLATED) {
rb = bigMultiplyPowerTen(-sdiff); rb = bigMultiplyPowerTen((int)-sdiff);
return rb.compareMagnitude(val.intVal); return rb.compareMagnitude(val.intVal);
} }
} else { // sdiff > 0 } else { // sdiff > 0
if ( (ys == INFLATED || // The cases sdiff > Integer.MAX_VALUE intentionally fall through.
(ys = longMultiplyPowerTen(ys, sdiff)) == INFLATED) && if ( sdiff <= Integer.MAX_VALUE &&
(ys == INFLATED ||
(ys = longMultiplyPowerTen(ys, (int)sdiff)) == INFLATED) &&
xs == INFLATED) { xs == INFLATED) {
rb = val.bigMultiplyPowerTen(sdiff); rb = val.bigMultiplyPowerTen((int)sdiff);
return this.intVal.compareMagnitude(rb); return this.intVal.compareMagnitude(rb);
} }
} }
...@@ -4545,7 +4549,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> { ...@@ -4545,7 +4549,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
if(cmp > 0) { // satisfy constraint (b) if(cmp > 0) { // satisfy constraint (b)
yscale -= 1; // [that is, divisor *= 10] yscale -= 1; // [that is, divisor *= 10]
int scl = checkScaleNonZero(preferredScale + yscale - xscale + mcp); int scl = checkScaleNonZero(preferredScale + yscale - xscale + mcp);
if (checkScaleNonZero((long) mcp + yscale) > xscale) { if (checkScaleNonZero((long) mcp + yscale - xscale) > 0) {
// assert newScale >= xscale // assert newScale >= xscale
int raise = checkScaleNonZero((long) mcp + yscale - xscale); int raise = checkScaleNonZero((long) mcp + yscale - xscale);
long scaledXs; long scaledXs;
...@@ -4626,7 +4630,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> { ...@@ -4626,7 +4630,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
// return BigDecimal object whose scale will be set to 'scl'. // return BigDecimal object whose scale will be set to 'scl'.
int scl = checkScaleNonZero(preferredScale + yscale - xscale + mcp); int scl = checkScaleNonZero(preferredScale + yscale - xscale + mcp);
BigDecimal quotient; BigDecimal quotient;
if (checkScaleNonZero((long) mcp + yscale) > xscale) { if (checkScaleNonZero((long) mcp + yscale - xscale) > 0) {
int raise = checkScaleNonZero((long) mcp + yscale - xscale); int raise = checkScaleNonZero((long) mcp + yscale - xscale);
long scaledXs; long scaledXs;
if ((scaledXs = longMultiplyPowerTen(xs, raise)) == INFLATED) { if ((scaledXs = longMultiplyPowerTen(xs, raise)) == INFLATED) {
...@@ -4673,7 +4677,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> { ...@@ -4673,7 +4677,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
// return BigDecimal object whose scale will be set to 'scl'. // return BigDecimal object whose scale will be set to 'scl'.
BigDecimal quotient; BigDecimal quotient;
int scl = checkScaleNonZero(preferredScale + yscale - xscale + mcp); int scl = checkScaleNonZero(preferredScale + yscale - xscale + mcp);
if (checkScaleNonZero((long) mcp + yscale) > xscale) { if (checkScaleNonZero((long) mcp + yscale - xscale) > 0) {
int raise = checkScaleNonZero((long) mcp + yscale - xscale); int raise = checkScaleNonZero((long) mcp + yscale - xscale);
BigInteger rb = bigMultiplyPowerTen(xs,raise); BigInteger rb = bigMultiplyPowerTen(xs,raise);
quotient = divideAndRound(rb, ys, scl, roundingMode, checkScaleNonZero(preferredScale)); quotient = divideAndRound(rb, ys, scl, roundingMode, checkScaleNonZero(preferredScale));
...@@ -4714,7 +4718,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> { ...@@ -4714,7 +4718,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
// return BigDecimal object whose scale will be set to 'scl'. // return BigDecimal object whose scale will be set to 'scl'.
BigDecimal quotient; BigDecimal quotient;
int scl = checkScaleNonZero(preferredScale + yscale - xscale + mcp); int scl = checkScaleNonZero(preferredScale + yscale - xscale + mcp);
if (checkScaleNonZero((long) mcp + yscale) > xscale) { if (checkScaleNonZero((long) mcp + yscale - xscale) > 0) {
int raise = checkScaleNonZero((long) mcp + yscale - xscale); int raise = checkScaleNonZero((long) mcp + yscale - xscale);
BigInteger rb = bigMultiplyPowerTen(xs,raise); BigInteger rb = bigMultiplyPowerTen(xs,raise);
quotient = divideAndRound(rb, ys, scl, roundingMode, checkScaleNonZero(preferredScale)); quotient = divideAndRound(rb, ys, scl, roundingMode, checkScaleNonZero(preferredScale));
...@@ -4745,7 +4749,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> { ...@@ -4745,7 +4749,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
// return BigDecimal object whose scale will be set to 'scl'. // return BigDecimal object whose scale will be set to 'scl'.
BigDecimal quotient; BigDecimal quotient;
int scl = checkScaleNonZero(preferredScale + yscale - xscale + mcp); int scl = checkScaleNonZero(preferredScale + yscale - xscale + mcp);
if (checkScaleNonZero((long) mcp + yscale) > xscale) { if (checkScaleNonZero((long) mcp + yscale - xscale) > 0) {
int raise = checkScaleNonZero((long) mcp + yscale - xscale); int raise = checkScaleNonZero((long) mcp + yscale - xscale);
BigInteger rb = bigMultiplyPowerTen(xs,raise); BigInteger rb = bigMultiplyPowerTen(xs,raise);
quotient = divideAndRound(rb, ys, scl, roundingMode, checkScaleNonZero(preferredScale)); quotient = divideAndRound(rb, ys, scl, roundingMode, checkScaleNonZero(preferredScale));
......
...@@ -2109,7 +2109,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> { ...@@ -2109,7 +2109,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
// This is a quick way to approximate the size of the result, // This is a quick way to approximate the size of the result,
// similar to doing log2[n] * exponent. This will give an upper bound // similar to doing log2[n] * exponent. This will give an upper bound
// of how big the result can be, and which algorithm to use. // of how big the result can be, and which algorithm to use.
int scaleFactor = remainingBits * exponent; long scaleFactor = (long)remainingBits * exponent;
// Use slightly different algorithms for small and large operands. // Use slightly different algorithms for small and large operands.
// See if the result will safely fit into a long. (Largest 2^63-1) // See if the result will safely fit into a long. (Largest 2^63-1)
......
...@@ -113,11 +113,18 @@ public final class IDN { ...@@ -113,11 +113,18 @@ public final class IDN {
int p = 0, q = 0; int p = 0, q = 0;
StringBuffer out = new StringBuffer(); StringBuffer out = new StringBuffer();
if (isRootLabel(input)) {
return ".";
}
while (p < input.length()) { while (p < input.length()) {
q = searchDots(input, p); q = searchDots(input, p);
out.append(toASCIIInternal(input.substring(p, q), flag)); out.append(toASCIIInternal(input.substring(p, q), flag));
if (q != (input.length())) {
// has more labels, or keep the trailing dot as at present
out.append('.');
}
p = q + 1; p = q + 1;
if (p < input.length()) out.append('.');
} }
return out.toString(); return out.toString();
...@@ -167,11 +174,18 @@ public final class IDN { ...@@ -167,11 +174,18 @@ public final class IDN {
int p = 0, q = 0; int p = 0, q = 0;
StringBuffer out = new StringBuffer(); StringBuffer out = new StringBuffer();
if (isRootLabel(input)) {
return ".";
}
while (p < input.length()) { while (p < input.length()) {
q = searchDots(input, p); q = searchDots(input, p);
out.append(toUnicodeInternal(input.substring(p, q), flag)); out.append(toUnicodeInternal(input.substring(p, q), flag));
if (q != (input.length())) {
// has more labels, or keep the trailing dot as at present
out.append('.');
}
p = q + 1; p = q + 1;
if (p < input.length()) out.append('.');
} }
return out.toString(); return out.toString();
...@@ -263,6 +277,13 @@ public final class IDN { ...@@ -263,6 +277,13 @@ public final class IDN {
dest = new StringBuffer(label); dest = new StringBuffer(label);
} }
// step 8, move forward to check the smallest number of the code points
// the length must be inside 1..63
if (dest.length() == 0) {
throw new IllegalArgumentException(
"Empty label is not a legal name");
}
// step 3 // step 3
// Verify the absence of non-LDH ASCII code points // Verify the absence of non-LDH ASCII code points
// 0..0x2c, 0x2e..0x2f, 0x3a..0x40, 0x5b..0x60, 0x7b..0x7f // 0..0x2c, 0x2e..0x2f, 0x3a..0x40, 0x5b..0x60, 0x7b..0x7f
...@@ -311,7 +332,7 @@ public final class IDN { ...@@ -311,7 +332,7 @@ public final class IDN {
// step 8 // step 8
// the length must be inside 1..63 // the length must be inside 1..63
if(dest.length() > MAX_LABEL_LENGTH){ if (dest.length() > MAX_LABEL_LENGTH) {
throw new IllegalArgumentException("The label in the input is too long"); throw new IllegalArgumentException("The label in the input is too long");
} }
...@@ -409,8 +430,7 @@ public final class IDN { ...@@ -409,8 +430,7 @@ public final class IDN {
private static int searchDots(String s, int start) { private static int searchDots(String s, int start) {
int i; int i;
for (i = start; i < s.length(); i++) { for (i = start; i < s.length(); i++) {
char c = s.charAt(i); if (isLabelSeparator(s.charAt(i))) {
if (c == '.' || c == '\u3002' || c == '\uFF0E' || c == '\uFF61') {
break; break;
} }
} }
...@@ -418,6 +438,19 @@ public final class IDN { ...@@ -418,6 +438,19 @@ public final class IDN {
return i; return i;
} }
//
// to check if a string is a root label, ".".
//
private static boolean isRootLabel(String s) {
return (s.length() == 1 && isLabelSeparator(s.charAt(0)));
}
//
// to check if a character is a label separator, i.e. a dot character.
//
private static boolean isLabelSeparator(char c) {
return (c == '.' || c == '\u3002' || c == '\uFF0E' || c == '\uFF61');
}
// //
// to check if a string only contains US-ASCII code point // to check if a string only contains US-ASCII code point
......
...@@ -50,13 +50,13 @@ import java.net.*; ...@@ -50,13 +50,13 @@ import java.net.*;
* @implNote * @implNote
* <p>You can use the {@code RMISocketFactory} class to create a server socket that * <p>You can use the {@code RMISocketFactory} class to create a server socket that
* is bound to a specific address, restricting the origin of requests. For example, * is bound to a specific address, restricting the origin of requests. For example,
* the following code implements a socket factory that binds server sockets to the * the following code implements a socket factory that binds server sockets to an IPv4
* loopback address. This restricts RMI to processing requests only from the local host. * loopback address. This restricts RMI to processing requests only from the local host.
* *
* <pre>{@code * <pre>{@code
* class LoopbackSocketFactory extends RMISocketFactory { * class LoopbackSocketFactory extends RMISocketFactory {
* public ServerSocket createServerSocket(int port) throws IOException { * public ServerSocket createServerSocket(int port) throws IOException {
* return new ServerSocket(port, 5, InetAddress.getLoopbackAddress()); * return new ServerSocket(port, 5, InetAddress.getByName("127.0.0.1"));
* } * }
* *
* public Socket createSocket(String host, int port) throws IOException { * public Socket createSocket(String host, int port) throws IOException {
...@@ -72,8 +72,8 @@ import java.net.*; ...@@ -72,8 +72,8 @@ import java.net.*;
* }</pre> * }</pre>
* *
* Set the {@code java.rmi.server.hostname} system property * Set the {@code java.rmi.server.hostname} system property
* to a host name (typically {@code localhost}) that resolves to the loopback * to {@code 127.0.0.1} to ensure that the generated stubs connect to the right
* interface to ensure that the generated stubs use the right network interface. * network interface.
* *
* @author Ann Wollrath * @author Ann Wollrath
* @author Peter Jones * @author Peter Jones
......
...@@ -107,7 +107,7 @@ public final class JapaneseEra ...@@ -107,7 +107,7 @@ public final class JapaneseEra
* The singleton instance for the 'Meiji' era (1868-09-08 - 1912-07-29) * The singleton instance for the 'Meiji' era (1868-09-08 - 1912-07-29)
* which has the value -1. * which has the value -1.
*/ */
public static final JapaneseEra MEIJI = new JapaneseEra(-1, LocalDate.of(1868, 9, 8)); public static final JapaneseEra MEIJI = new JapaneseEra(-1, LocalDate.of(1868, 1, 1));
/** /**
* The singleton instance for the 'Taisho' era (1912-07-30 - 1926-12-24) * The singleton instance for the 'Taisho' era (1912-07-30 - 1926-12-24)
* which has the value 0. * which has the value 0.
......
...@@ -888,6 +888,19 @@ public class ArrayDeque<E> extends AbstractCollection<E> ...@@ -888,6 +888,19 @@ public class ArrayDeque<E> extends AbstractCollection<E>
elements[i] = s.readObject(); elements[i] = s.readObject();
} }
/**
* Creates a <em><a href="Spliterator.html#binding">late-binding</a></em>
* and <em>fail-fast</em> {@link Spliterator} over the elements in this
* deque.
*
* <p>The {@code Spliterator} reports {@link Spliterator#SIZED},
* {@link Spliterator#SUBSIZED}, {@link Spliterator#ORDERED}, and
* {@link Spliterator#NONNULL}. Overriding implementations should document
* the reporting of additional characteristic values.
*
* @return a {@code Spliterator} over the elements in this deque
* @since 1.8
*/
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
return new DeqSpliterator<E>(this, -1, -1); return new DeqSpliterator<E>(this, -1, -1);
} }
......
...@@ -1238,6 +1238,20 @@ public class ArrayList<E> extends AbstractList<E> ...@@ -1238,6 +1238,20 @@ public class ArrayList<E> extends AbstractList<E>
} }
} }
/**
* Creates a <em><a href="Spliterator.html#binding">late-binding</a></em>
* and <em>fail-fast</em> {@link Spliterator} over the elements in this
* list.
*
* <p>The {@code Spliterator} reports {@link Spliterator#SIZED},
* {@link Spliterator#SUBSIZED}, and {@link Spliterator#ORDERED}.
* Overriding implementations should document the reporting of additional
* characteristic values.
*
* @return a {@code Spliterator} over the elements in this list
* @since 1.8
*/
@Override
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
return new ArrayListSpliterator<>(this, 0, -1, 0); return new ArrayListSpliterator<>(this, 0, -1, 0);
} }
......
...@@ -4508,7 +4508,6 @@ public class Collections { ...@@ -4508,7 +4508,6 @@ public class Collections {
} }
@Override @Override
public void sort(Comparator<? super E> c) { public void sort(Comparator<? super E> c) {
Objects.requireNonNull(c);
} }
// Override default methods in Collection // Override default methods in Collection
......
/* /*
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright 2009 Google Inc. All Rights Reserved. * Copyright 2009 Google Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
...@@ -146,7 +147,7 @@ class ComparableTimSort { ...@@ -146,7 +147,7 @@ class ComparableTimSort {
*/ */
int stackLen = (len < 120 ? 5 : int stackLen = (len < 120 ? 5 :
len < 1542 ? 10 : len < 1542 ? 10 :
len < 119151 ? 19 : 40); len < 119151 ? 24 : 40);
runBase = new int[stackLen]; runBase = new int[stackLen];
runLen = new int[stackLen]; runLen = new int[stackLen];
} }
......
...@@ -4196,7 +4196,7 @@ public final class Formatter implements Closeable, Flushable { ...@@ -4196,7 +4196,7 @@ public final class Formatter implements Closeable, Flushable {
case DateTime.CENTURY: // 'C' (00 - 99) case DateTime.CENTURY: // 'C' (00 - 99)
case DateTime.YEAR_2: // 'y' (00 - 99) case DateTime.YEAR_2: // 'y' (00 - 99)
case DateTime.YEAR_4: { // 'Y' (0000 - 9999) case DateTime.YEAR_4: { // 'Y' (0000 - 9999)
int i = t.get(ChronoField.YEAR); int i = t.get(ChronoField.YEAR_OF_ERA);
int size = 2; int size = 2;
switch (c) { switch (c) {
case DateTime.CENTURY: case DateTime.CENTURY:
......
...@@ -312,6 +312,18 @@ public class HashSet<E> ...@@ -312,6 +312,18 @@ public class HashSet<E>
} }
} }
/**
* Creates a <em><a href="Spliterator.html#binding">late-binding</a></em>
* and <em>fail-fast</em> {@link Spliterator} over the elements in this
* set.
*
* <p>The {@code Spliterator} reports {@link Spliterator#SIZED} and
* {@link Spliterator#DISTINCT}. Overriding implementations should document
* the reporting of additional characteristic values.
*
* @return a {@code Spliterator} over the elements in this set
* @since 1.8
*/
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
return new HashMap.KeySpliterator<E,Object>(map, 0, -1, 0, 0); return new HashMap.KeySpliterator<E,Object>(map, 0, -1, 0, 0);
} }
......
...@@ -129,10 +129,20 @@ import java.util.function.BiFunction; ...@@ -129,10 +129,20 @@ import java.util.function.BiFunction;
* exception for its correctness: <i>the fail-fast behavior of iterators * exception for its correctness: <i>the fail-fast behavior of iterators
* should be used only to detect bugs.</i> * should be used only to detect bugs.</i>
* *
* <p>The spliterators returned by the spliterator method of the collections
* returned by all of this class's collection view methods are
* <em><a href="Spliterator.html#binding">late-binding</a></em>,
* <em>fail-fast</em>, and additionally report {@link Spliterator#ORDERED}.
*
* <p>This class is a member of the * <p>This class is a member of the
* <a href="{@docRoot}/../technotes/guides/collections/index.html"> * <a href="{@docRoot}/../technotes/guides/collections/index.html">
* Java Collections Framework</a>. * Java Collections Framework</a>.
* *
* @implNote
* The spliterators returned by the spliterator method of the collections
* returned by all of this class's collection view methods are created from
* the iterators of the corresponding collections.
*
* @param <K> the type of keys maintained by this map * @param <K> the type of keys maintained by this map
* @param <V> the type of mapped values * @param <V> the type of mapped values
* *
......
...@@ -170,13 +170,23 @@ public class LinkedHashSet<E> ...@@ -170,13 +170,23 @@ public class LinkedHashSet<E>
} }
/** /**
* Creates a {@code Spliterator}, over the elements in this set, that * Creates a <em><a href="Spliterator.html#binding">late-binding</a></em>
* reports {@code SIZED}, {@code DISTINCT} and {@code ORDERED}. * and <em>fail-fast</em> {@code Spliterator} over the elements in this set.
* Overriding implementations are expected to document if the *
* {@code Spliterator} reports any additional and relevant characteristic * <p>The {@code Spliterator} reports {@link Spliterator#SIZED},
* values. * {@link Spliterator#DISTINCT}, and {@code ORDERED}. Implementations
* should document the reporting of additional characteristic values.
*
* @implNote
* The implementation creates a
* <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator
* from the set's {@code Iterator}. The spliterator inherits the
* <em>fail-fast</em> properties of the set's iterator.
* The created {@code Spliterator} additionally reports
* {@link Spliterator#SUBSIZED}.
* *
* @return a {@code Spliterator} over the elements in this set * @return a {@code Spliterator} over the elements in this set
* @since 1.8
*/ */
@Override @Override
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
......
...@@ -1149,6 +1149,23 @@ public class LinkedList<E> ...@@ -1149,6 +1149,23 @@ public class LinkedList<E>
linkLast((E)s.readObject()); linkLast((E)s.readObject());
} }
/**
* Creates a <em><a href="Spliterator.html#binding">late-binding</a></em>
* and <em>fail-fast</em> {@link Spliterator} over the elements in this
* list.
*
* <p>The {@code Spliterator} reports {@link Spliterator#SIZED} and
* {@link Spliterator#ORDERED}. Overriding implementations should document
* the reporting of additional characteristic values.
*
* @implNote
* The {@code Spliterator} additionally reports {@link Spliterator#SUBSIZED}
* and implements {@code trySplit} to permit limited parallelism..
*
* @return a {@code Spliterator} over the elements in this list
* @since 1.8
*/
@Override
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
return new LLSpliterator<E>(this, -1, 0); return new LLSpliterator<E>(this, -1, 0);
} }
......
...@@ -671,7 +671,7 @@ public interface List<E> extends Collection<E> { ...@@ -671,7 +671,7 @@ public interface List<E> extends Collection<E> {
* The default implementation creates a * The default implementation creates a
* <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator * <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator
* from the list's {@code Iterator}. The spliterator inherits the * from the list's {@code Iterator}. The spliterator inherits the
* <em>fail-fast</em> properties of the collection's iterator. * <em>fail-fast</em> properties of the list's iterator.
* *
* @implNote * @implNote
* The created {@code Spliterator} additionally reports * The created {@code Spliterator} additionally reports
......
...@@ -795,6 +795,19 @@ public class PriorityQueue<E> extends AbstractQueue<E> ...@@ -795,6 +795,19 @@ public class PriorityQueue<E> extends AbstractQueue<E>
heapify(); heapify();
} }
/**
* Creates a <em><a href="Spliterator.html#binding">late-binding</a></em>
* and <em>fail-fast</em> {@link Spliterator} over the elements in this
* queue.
*
* <p>The {@code Spliterator} reports {@link Spliterator#SIZED},
* {@link Spliterator#SUBSIZED}, and {@link Spliterator#NONNULL}.
* Overriding implementations should document the reporting of additional
* characteristic values.
*
* @return a {@code Spliterator} over the elements in this queue
* @since 1.8
*/
public final Spliterator<E> spliterator() { public final Spliterator<E> spliterator() {
return new PriorityQueueSpliterator<E>(this, 0, -1, 0); return new PriorityQueueSpliterator<E>(this, 0, -1, 0);
} }
......
...@@ -394,7 +394,7 @@ public interface Set<E> extends Collection<E> { ...@@ -394,7 +394,7 @@ public interface Set<E> extends Collection<E> {
* The default implementation creates a * The default implementation creates a
* <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator * <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator
* from the set's {@code Iterator}. The spliterator inherits the * from the set's {@code Iterator}. The spliterator inherits the
* <em>fail-fast</em> properties of the collection's iterator. * <em>fail-fast</em> properties of the set's iterator.
* *
* @implNote * @implNote
* The created {@code Spliterator} additionally reports * The created {@code Spliterator} additionally reports
......
...@@ -238,7 +238,7 @@ public interface SortedSet<E> extends Set<E> { ...@@ -238,7 +238,7 @@ public interface SortedSet<E> extends Set<E> {
* The default implementation creates a * The default implementation creates a
* <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator * <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator
* from the sorted set's {@code Iterator}. The spliterator inherits the * from the sorted set's {@code Iterator}. The spliterator inherits the
* <em>fail-fast</em> properties of the collection's iterator. The * <em>fail-fast</em> properties of the set's iterator. The
* spliterator's comparator is the same as the sorted set's comparator. * spliterator's comparator is the same as the sorted set's comparator.
* *
* @implNote * @implNote
......
...@@ -74,7 +74,11 @@ import java.util.function.LongConsumer; ...@@ -74,7 +74,11 @@ import java.util.function.LongConsumer;
* source prior to binding are reflected when the Spliterator is traversed. * source prior to binding are reflected when the Spliterator is traversed.
* After binding a Spliterator should, on a best-effort basis, throw * After binding a Spliterator should, on a best-effort basis, throw
* {@link ConcurrentModificationException} if structural interference is * {@link ConcurrentModificationException} if structural interference is
* detected. Spliterators that do this are called <em>fail-fast</em>. * detected. Spliterators that do this are called <em>fail-fast</em>. The
* bulk traversal method ({@link #forEachRemaining forEachRemaining()}) of a
* Spliterator may optimize traversal and check for structural interference
* after all elements have been traversed, rather than checking per-element and
* failing immediately.
* *
* <p>Spliterators can provide an estimate of the number of remaining elements * <p>Spliterators can provide an estimate of the number of remaining elements
* via the {@link #estimateSize} method. Ideally, as reflected in characteristic * via the {@link #estimateSize} method. Ideally, as reflected in characteristic
......
此差异已折叠。
/* /*
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright 2009 Google Inc. All Rights Reserved. * Copyright 2009 Google Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
...@@ -176,7 +177,7 @@ class TimSort<T> { ...@@ -176,7 +177,7 @@ class TimSort<T> {
*/ */
int stackLen = (len < 120 ? 5 : int stackLen = (len < 120 ? 5 :
len < 1542 ? 10 : len < 1542 ? 10 :
len < 119151 ? 19 : 40); len < 119151 ? 24 : 40);
runBase = new int[stackLen]; runBase = new int[stackLen];
runLen = new int[stackLen]; runLen = new int[stackLen];
} }
......
...@@ -790,8 +790,19 @@ public class TreeMap<K,V> ...@@ -790,8 +790,19 @@ public class TreeMap<K,V>
/** /**
* Returns a {@link Set} view of the keys contained in this map. * Returns a {@link Set} view of the keys contained in this map.
* The set's iterator returns the keys in ascending order. *
* The set is backed by the map, so changes to the map are * <p>The set's iterator returns the keys in ascending order.
* The set's spliterator is
* <em><a href="Spliterator.html#binding">late-binding</a></em>,
* <em>fail-fast</em>, and additionally reports {@link Spliterator#SORTED}
* and {@link Spliterator#ORDERED} with an encounter order that is ascending
* key order. The spliterator's comparator (see
* {@link java.util.Spliterator#getComparator()}) is {@code null} if
* the tree map's comparator (see {@link #comparator()}) is {@code null}.
* Otherwise, the spliterator's comparator is the same as or imposes the
* same total ordering as the tree map's comparator.
*
* <p>The set is backed by the map, so changes to the map are
* reflected in the set, and vice-versa. If the map is modified * reflected in the set, and vice-versa. If the map is modified
* while an iteration over the set is in progress (except through * while an iteration over the set is in progress (except through
* the iterator's own {@code remove} operation), the results of * the iterator's own {@code remove} operation), the results of
...@@ -823,9 +834,15 @@ public class TreeMap<K,V> ...@@ -823,9 +834,15 @@ public class TreeMap<K,V>
/** /**
* Returns a {@link Collection} view of the values contained in this map. * Returns a {@link Collection} view of the values contained in this map.
* The collection's iterator returns the values in ascending order *
* of the corresponding keys. * <p>The collection's iterator returns the values in ascending order
* The collection is backed by the map, so changes to the map are * of the corresponding keys. The collection's spliterator is
* <em><a href="Spliterator.html#binding">late-binding</a></em>,
* <em>fail-fast</em>, and additionally reports {@link Spliterator#ORDERED}
* with an encounter order that is ascending order of the corresponding
* keys.
*
* <p>The collection is backed by the map, so changes to the map are
* reflected in the collection, and vice-versa. If the map is * reflected in the collection, and vice-versa. If the map is
* modified while an iteration over the collection is in progress * modified while an iteration over the collection is in progress
* (except through the iterator's own {@code remove} operation), * (except through the iterator's own {@code remove} operation),
...@@ -843,8 +860,15 @@ public class TreeMap<K,V> ...@@ -843,8 +860,15 @@ public class TreeMap<K,V>
/** /**
* Returns a {@link Set} view of the mappings contained in this map. * Returns a {@link Set} view of the mappings contained in this map.
* The set's iterator returns the entries in ascending key order. *
* The set is backed by the map, so changes to the map are * <p>The set's iterator returns the entries in ascending key order. The
* sets's spliterator is
* <em><a href="Spliterator.html#binding">late-binding</a></em>,
* <em>fail-fast</em>, and additionally reports {@link Spliterator#SORTED} and
* {@link Spliterator#ORDERED} with an encounter order that is ascending key
* order.
*
* <p>The set is backed by the map, so changes to the map are
* reflected in the set, and vice-versa. If the map is modified * reflected in the set, and vice-versa. If the map is modified
* while an iteration over the set is in progress (except through * while an iteration over the set is in progress (except through
* the iterator's own {@code remove} operation, or through the * the iterator's own {@code remove} operation, or through the
...@@ -948,6 +972,27 @@ public class TreeMap<K,V> ...@@ -948,6 +972,27 @@ public class TreeMap<K,V>
return tailMap(fromKey, true); return tailMap(fromKey, true);
} }
@Override
public boolean replace(K key, V oldValue, V newValue) {
Entry<K,V> p = getEntry(key);
if (p!=null && Objects.equals(oldValue, p.value)) {
p.value = newValue;
return true;
}
return false;
}
@Override
public V replace(K key, V value) {
Entry<K,V> p = getEntry(key);
if (p!=null) {
V oldValue = p.value;
p.value = value;
return oldValue;
}
return null;
}
@Override @Override
public void forEach(BiConsumer<? super K, ? super V> action) { public void forEach(BiConsumer<? super K, ? super V> action) {
Objects.requireNonNull(action); Objects.requireNonNull(action);
......
...@@ -533,6 +533,25 @@ public class TreeSet<E> extends AbstractSet<E> ...@@ -533,6 +533,25 @@ public class TreeSet<E> extends AbstractSet<E>
tm.readTreeSet(size, s, PRESENT); tm.readTreeSet(size, s, PRESENT);
} }
/**
* Creates a <em><a href="Spliterator.html#binding">late-binding</a></em>
* and <em>fail-fast</em> {@link Spliterator} over the elements in this
* set.
*
* <p>The {@code Spliterator} reports {@link Spliterator#SIZED},
* {@link Spliterator#DISTINCT}, {@link Spliterator#SORTED}, and
* {@link Spliterator#ORDERED}. Overriding implementations should document
* the reporting of additional characteristic values.
*
* <p>The spliterator's comparator (see
* {@link java.util.Spliterator#getComparator()}) is {@code null} if
* the tree set's comparator (see {@link #comparator()}) is {@code null}.
* Otherwise, the spliterator's comparator is the same as or imposes the
* same total ordering as the tree set's comparator.
*
* @return a {@code Spliterator} over the elements in this set
* @since 1.8
*/
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
return TreeMap.keySpliteratorFor(m); return TreeMap.keySpliteratorFor(m);
} }
......
...@@ -1323,6 +1323,19 @@ public class Vector<E> ...@@ -1323,6 +1323,19 @@ public class Vector<E>
modCount++; modCount++;
} }
/**
* Creates a <em><a href="Spliterator.html#binding">late-binding</a></em>
* and <em>fail-fast</em> {@link Spliterator} over the elements in this
* list.
*
* <p>The {@code Spliterator} reports {@link Spliterator#SIZED},
* {@link Spliterator#SUBSIZED}, and {@link Spliterator#ORDERED}.
* Overriding implementations should document the reporting of additional
* characteristic values.
*
* @return a {@code Spliterator} over the elements in this list
* @since 1.8
*/
@Override @Override
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
return new VectorSpliterator<>(this, null, 0, -1, 0); return new VectorSpliterator<>(this, null, 0, -1, 0);
......
...@@ -757,12 +757,8 @@ public class ArrayBlockingQueue<E> extends AbstractQueue<E> ...@@ -757,12 +757,8 @@ public class ArrayBlockingQueue<E> extends AbstractQueue<E>
* Returns an iterator over the elements in this queue in proper sequence. * Returns an iterator over the elements in this queue in proper sequence.
* The elements will be returned in order from first (head) to last (tail). * The elements will be returned in order from first (head) to last (tail).
* *
* <p>The returned iterator is a "weakly consistent" iterator that * <p>The returned iterator is
* will never throw {@link java.util.ConcurrentModificationException * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* ConcurrentModificationException}, and guarantees to traverse
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
* *
* @return an iterator over the elements in this queue in proper sequence * @return an iterator over the elements in this queue in proper sequence
*/ */
...@@ -1396,9 +1392,26 @@ public class ArrayBlockingQueue<E> extends AbstractQueue<E> ...@@ -1396,9 +1392,26 @@ public class ArrayBlockingQueue<E> extends AbstractQueue<E>
// } // }
} }
/**
* Returns a {@link Spliterator} over the elements in this queue.
*
* <p>The returned spliterator is
* <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
*
* <p>The {@code Spliterator} reports {@link Spliterator#CONCURRENT},
* {@link Spliterator#ORDERED}, and {@link Spliterator#NONNULL}.
*
* @implNote
* The {@code Spliterator} implements {@code trySplit} to permit limited
* parallelism.
*
* @return a {@code Spliterator} over the elements in this queue
* @since 1.8
*/
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
return Spliterators.spliterator return Spliterators.spliterator
(this, Spliterator.ORDERED | Spliterator.NONNULL | (this, Spliterator.ORDERED | Spliterator.NONNULL |
Spliterator.CONCURRENT); Spliterator.CONCURRENT);
} }
} }
...@@ -43,7 +43,6 @@ import java.util.AbstractMap; ...@@ -43,7 +43,6 @@ import java.util.AbstractMap;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
import java.util.ConcurrentModificationException;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.Hashtable; import java.util.Hashtable;
...@@ -94,14 +93,14 @@ import java.util.stream.Stream; ...@@ -94,14 +93,14 @@ import java.util.stream.Stream;
* that key reporting the updated value.) For aggregate operations * that key reporting the updated value.) For aggregate operations
* such as {@code putAll} and {@code clear}, concurrent retrievals may * such as {@code putAll} and {@code clear}, concurrent retrievals may
* reflect insertion or removal of only some entries. Similarly, * reflect insertion or removal of only some entries. Similarly,
* Iterators and Enumerations return elements reflecting the state of * Iterators, Spliterators and Enumerations return elements reflecting the
* the hash table at some point at or since the creation of the * state of the hash table at some point at or since the creation of the
* iterator/enumeration. They do <em>not</em> throw {@link * iterator/enumeration. They do <em>not</em> throw {@link
* ConcurrentModificationException}. However, iterators are designed * java.util.ConcurrentModificationException ConcurrentModificationException}.
* to be used by only one thread at a time. Bear in mind that the * However, iterators are designed to be used by only one thread at a time.
* results of aggregate status methods including {@code size}, {@code * Bear in mind that the results of aggregate status methods including
* isEmpty}, and {@code containsValue} are typically useful only when * {@code size}, {@code isEmpty}, and {@code containsValue} are typically
* a map is not undergoing concurrent updates in other threads. * useful only when a map is not undergoing concurrent updates in other threads.
* Otherwise the results of these methods reflect transient states * Otherwise the results of these methods reflect transient states
* that may be adequate for monitoring or estimation purposes, but not * that may be adequate for monitoring or estimation purposes, but not
* for program control. * for program control.
...@@ -1200,11 +1199,11 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V> ...@@ -1200,11 +1199,11 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
* operations. It does not support the {@code add} or * operations. It does not support the {@code add} or
* {@code addAll} operations. * {@code addAll} operations.
* *
* <p>The view's {@code iterator} is a "weakly consistent" iterator * <p>The view's iterators and spliterators are
* that will never throw {@link ConcurrentModificationException}, * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* and guarantees to traverse elements as they existed upon *
* construction of the iterator, and may (but is not guaranteed to) * <p>The view's {@code spliterator} reports {@link Spliterator#CONCURRENT},
* reflect any modifications subsequent to construction. * {@link Spliterator#DISTINCT}, and {@link Spliterator#NONNULL}.
* *
* @return the set view * @return the set view
*/ */
...@@ -1223,11 +1222,11 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V> ...@@ -1223,11 +1222,11 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
* {@code retainAll}, and {@code clear} operations. It does not * {@code retainAll}, and {@code clear} operations. It does not
* support the {@code add} or {@code addAll} operations. * support the {@code add} or {@code addAll} operations.
* *
* <p>The view's {@code iterator} is a "weakly consistent" iterator * <p>The view's iterators and spliterators are
* that will never throw {@link ConcurrentModificationException}, * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* and guarantees to traverse elements as they existed upon *
* construction of the iterator, and may (but is not guaranteed to) * <p>The view's {@code spliterator} reports {@link Spliterator#CONCURRENT}
* reflect any modifications subsequent to construction. * and {@link Spliterator#NONNULL}.
* *
* @return the collection view * @return the collection view
*/ */
...@@ -1245,11 +1244,11 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V> ...@@ -1245,11 +1244,11 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
* {@code removeAll}, {@code retainAll}, and {@code clear} * {@code removeAll}, {@code retainAll}, and {@code clear}
* operations. * operations.
* *
* <p>The view's {@code iterator} is a "weakly consistent" iterator * <p>The view's iterators and spliterators are
* that will never throw {@link ConcurrentModificationException}, * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* and guarantees to traverse elements as they existed upon *
* construction of the iterator, and may (but is not guaranteed to) * <p>The view's {@code spliterator} reports {@link Spliterator#CONCURRENT},
* reflect any modifications subsequent to construction. * {@link Spliterator#DISTINCT}, and {@link Spliterator#NONNULL}.
* *
* @return the set view * @return the set view
*/ */
...@@ -4308,12 +4307,12 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V> ...@@ -4308,12 +4307,12 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
// implementations below rely on concrete classes supplying these // implementations below rely on concrete classes supplying these
// abstract methods // abstract methods
/** /**
* Returns a "weakly consistent" iterator that will never * Returns an iterator over the elements in this collection.
* throw {@link ConcurrentModificationException}, and *
* guarantees to traverse elements as they existed upon * <p>The returned iterator is
* construction of the iterator, and may (but is not * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* guaranteed to) reflect any modifications subsequent to *
* construction. * @return an iterator over the elements in this collection
*/ */
public abstract Iterator<E> iterator(); public abstract Iterator<E> iterator();
public abstract boolean contains(Object o); public abstract boolean contains(Object o);
......
...@@ -55,12 +55,8 @@ import java.util.function.Consumer; ...@@ -55,12 +55,8 @@ import java.util.function.Consumer;
* Like most other concurrent collection implementations, this class * Like most other concurrent collection implementations, this class
* does not permit the use of {@code null} elements. * does not permit the use of {@code null} elements.
* *
* <p>Iterators are <i>weakly consistent</i>, returning elements * <p>Iterators and spliterators are
* reflecting the state of the deque at some point at or since the * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* creation of the iterator. They do <em>not</em> throw {@link
* java.util.ConcurrentModificationException
* ConcurrentModificationException}, and may proceed concurrently with
* other operations.
* *
* <p>Beware that, unlike in most collections, the {@code size} method * <p>Beware that, unlike in most collections, the {@code size} method
* is <em>NOT</em> a constant-time operation. Because of the * is <em>NOT</em> a constant-time operation. Because of the
...@@ -1290,12 +1286,8 @@ public class ConcurrentLinkedDeque<E> ...@@ -1290,12 +1286,8 @@ public class ConcurrentLinkedDeque<E>
* Returns an iterator over the elements in this deque in proper sequence. * Returns an iterator over the elements in this deque in proper sequence.
* The elements will be returned in order from first (head) to last (tail). * The elements will be returned in order from first (head) to last (tail).
* *
* <p>The returned iterator is a "weakly consistent" iterator that * <p>The returned iterator is
* will never throw {@link java.util.ConcurrentModificationException * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* ConcurrentModificationException}, and guarantees to traverse
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
* *
* @return an iterator over the elements in this deque in proper sequence * @return an iterator over the elements in this deque in proper sequence
*/ */
...@@ -1308,12 +1300,8 @@ public class ConcurrentLinkedDeque<E> ...@@ -1308,12 +1300,8 @@ public class ConcurrentLinkedDeque<E>
* sequential order. The elements will be returned in order from * sequential order. The elements will be returned in order from
* last (tail) to first (head). * last (tail) to first (head).
* *
* <p>The returned iterator is a "weakly consistent" iterator that * <p>The returned iterator is
* will never throw {@link java.util.ConcurrentModificationException * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* ConcurrentModificationException}, and guarantees to traverse
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
* *
* @return an iterator over the elements in this deque in reverse order * @return an iterator over the elements in this deque in reverse order
*/ */
...@@ -1493,6 +1481,22 @@ public class ConcurrentLinkedDeque<E> ...@@ -1493,6 +1481,22 @@ public class ConcurrentLinkedDeque<E>
} }
} }
/**
* Returns a {@link Spliterator} over the elements in this deque.
*
* <p>The returned spliterator is
* <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
*
* <p>The {@code Spliterator} reports {@link Spliterator#CONCURRENT},
* {@link Spliterator#ORDERED}, and {@link Spliterator#NONNULL}.
*
* @implNote
* The {@code Spliterator} implements {@code trySplit} to permit limited
* parallelism.
*
* @return a {@code Spliterator} over the elements in this deque
* @since 1.8
*/
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
return new CLDSpliterator<E>(this); return new CLDSpliterator<E>(this);
} }
...@@ -1500,6 +1504,8 @@ public class ConcurrentLinkedDeque<E> ...@@ -1500,6 +1504,8 @@ public class ConcurrentLinkedDeque<E>
/** /**
* Saves this deque to a stream (that is, serializes it). * Saves this deque to a stream (that is, serializes it).
* *
* @param s the stream
* @throws java.io.IOException if an I/O error occurs
* @serialData All of the elements (each an {@code E}) in * @serialData All of the elements (each an {@code E}) in
* the proper order, followed by a null * the proper order, followed by a null
*/ */
...@@ -1522,6 +1528,10 @@ public class ConcurrentLinkedDeque<E> ...@@ -1522,6 +1528,10 @@ public class ConcurrentLinkedDeque<E>
/** /**
* Reconstitutes this deque from a stream (that is, deserializes it). * Reconstitutes this deque from a stream (that is, deserializes it).
* @param s the stream
* @throws ClassNotFoundException if the class of a serialized object
* could not be found
* @throws java.io.IOException if an I/O error occurs
*/ */
private void readObject(java.io.ObjectInputStream s) private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException { throws java.io.IOException, ClassNotFoundException {
......
...@@ -654,12 +654,8 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E> ...@@ -654,12 +654,8 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
* Returns an iterator over the elements in this queue in proper sequence. * Returns an iterator over the elements in this queue in proper sequence.
* The elements will be returned in order from first (head) to last (tail). * The elements will be returned in order from first (head) to last (tail).
* *
* <p>The returned iterator is a "weakly consistent" iterator that * <p>The returned iterator is
* will never throw {@link java.util.ConcurrentModificationException * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* ConcurrentModificationException}, and guarantees to traverse
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
* *
* @return an iterator over the elements in this queue in proper sequence * @return an iterator over the elements in this queue in proper sequence
*/ */
...@@ -749,6 +745,8 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E> ...@@ -749,6 +745,8 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
/** /**
* Saves this queue to a stream (that is, serializes it). * Saves this queue to a stream (that is, serializes it).
* *
* @param s the stream
* @throws java.io.IOException if an I/O error occurs
* @serialData All of the elements (each an {@code E}) in * @serialData All of the elements (each an {@code E}) in
* the proper order, followed by a null * the proper order, followed by a null
*/ */
...@@ -771,6 +769,10 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E> ...@@ -771,6 +769,10 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
/** /**
* Reconstitutes this queue from a stream (that is, deserializes it). * Reconstitutes this queue from a stream (that is, deserializes it).
* @param s the stream
* @throws ClassNotFoundException if the class of a serialized object
* could not be found
* @throws java.io.IOException if an I/O error occurs
*/ */
private void readObject(java.io.ObjectInputStream s) private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException { throws java.io.IOException, ClassNotFoundException {
...@@ -881,6 +883,23 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E> ...@@ -881,6 +883,23 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
} }
} }
/**
* Returns a {@link Spliterator} over the elements in this queue.
*
* <p>The returned spliterator is
* <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
*
* <p>The {@code Spliterator} reports {@link Spliterator#CONCURRENT},
* {@link Spliterator#ORDERED}, and {@link Spliterator#NONNULL}.
*
* @implNote
* The {@code Spliterator} implements {@code trySplit} to permit limited
* parallelism.
*
* @return a {@code Spliterator} over the elements in this queue
* @since 1.8
*/
@Override
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
return new CLQSpliterator<E>(this); return new CLQSpliterator<E>(this);
} }
......
...@@ -120,11 +120,8 @@ public interface ConcurrentNavigableMap<K,V> ...@@ -120,11 +120,8 @@ public interface ConcurrentNavigableMap<K,V>
* operations. It does not support the {@code add} or {@code addAll} * operations. It does not support the {@code add} or {@code addAll}
* operations. * operations.
* *
* <p>The view's {@code iterator} is a "weakly consistent" iterator * <p>The view's iterators and spliterators are
* that will never throw {@link ConcurrentModificationException}, * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* and guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed to)
* reflect any modifications subsequent to construction.
* *
* @return a navigable set view of the keys in this map * @return a navigable set view of the keys in this map
*/ */
...@@ -141,11 +138,8 @@ public interface ConcurrentNavigableMap<K,V> ...@@ -141,11 +138,8 @@ public interface ConcurrentNavigableMap<K,V>
* operations. It does not support the {@code add} or {@code addAll} * operations. It does not support the {@code add} or {@code addAll}
* operations. * operations.
* *
* <p>The view's {@code iterator} is a "weakly consistent" iterator * <p>The view's iterators and spliterators are
* that will never throw {@link ConcurrentModificationException}, * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* and guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed to)
* reflect any modifications subsequent to construction.
* *
* <p>This method is equivalent to method {@code navigableKeySet}. * <p>This method is equivalent to method {@code navigableKeySet}.
* *
...@@ -164,11 +158,8 @@ public interface ConcurrentNavigableMap<K,V> ...@@ -164,11 +158,8 @@ public interface ConcurrentNavigableMap<K,V>
* operations. It does not support the {@code add} or {@code addAll} * operations. It does not support the {@code add} or {@code addAll}
* operations. * operations.
* *
* <p>The view's {@code iterator} is a "weakly consistent" iterator * <p>The view's iterators and spliterators are
* that will never throw {@link ConcurrentModificationException}, * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* and guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed to)
* reflect any modifications subsequent to construction.
* *
* @return a reverse order navigable set view of the keys in this map * @return a reverse order navigable set view of the keys in this map
*/ */
......
...@@ -71,12 +71,13 @@ import java.util.function.Function; ...@@ -71,12 +71,13 @@ import java.util.function.Function;
* {@code containsKey}, {@code get}, {@code put} and * {@code containsKey}, {@code get}, {@code put} and
* {@code remove} operations and their variants. Insertion, removal, * {@code remove} operations and their variants. Insertion, removal,
* update, and access operations safely execute concurrently by * update, and access operations safely execute concurrently by
* multiple threads. Iterators are <i>weakly consistent</i>, returning * multiple threads.
* elements reflecting the state of the map at some point at or since *
* the creation of the iterator. They do <em>not</em> throw {@link * <p>Iterators and spliterators are
* java.util.ConcurrentModificationException ConcurrentModificationException}, * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* and may proceed concurrently with other operations. Ascending key ordered *
* views and their iterators are faster than descending ones. * <p>Ascending key ordered views and their iterators are faster than
* descending ones.
* *
* <p>All {@code Map.Entry} pairs returned by methods in this class * <p>All {@code Map.Entry} pairs returned by methods in this class
* and its views represent snapshots of mappings at the time they were * and its views represent snapshots of mappings at the time they were
...@@ -1804,8 +1805,18 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V> ...@@ -1804,8 +1805,18 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
/** /**
* Returns a {@link NavigableSet} view of the keys contained in this map. * Returns a {@link NavigableSet} view of the keys contained in this map.
* The set's iterator returns the keys in ascending order. *
* The set is backed by the map, so changes to the map are * <p>The set's iterator returns the keys in ascending order.
* The set's spliterator additionally reports {@link Spliterator#CONCURRENT},
* {@link Spliterator#NONNULL}, {@link Spliterator#SORTED} and
* {@link Spliterator#ORDERED}, with an encounter order that is ascending
* key order. The spliterator's comparator (see
* {@link java.util.Spliterator#getComparator()}) is {@code null} if
* the map's comparator (see {@link #comparator()}) is {@code null}.
* Otherwise, the spliterator's comparator is the same as or imposes the
* same total ordering as the map's comparator.
*
* <p>The set is backed by the map, so changes to the map are
* reflected in the set, and vice-versa. The set supports element * reflected in the set, and vice-versa. The set supports element
* removal, which removes the corresponding mapping from the map, * removal, which removes the corresponding mapping from the map,
* via the {@code Iterator.remove}, {@code Set.remove}, * via the {@code Iterator.remove}, {@code Set.remove},
...@@ -1813,11 +1824,8 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V> ...@@ -1813,11 +1824,8 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
* operations. It does not support the {@code add} or {@code addAll} * operations. It does not support the {@code add} or {@code addAll}
* operations. * operations.
* *
* <p>The view's {@code iterator} is a "weakly consistent" iterator that * <p>The view's iterators and spliterators are
* will never throw {@link java.util.ConcurrentModificationException * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* ConcurrentModificationException}, and guarantees to traverse elements
* as they existed upon construction of the iterator, and may (but is not
* guaranteed to) reflect any modifications subsequent to construction.
* *
* <p>This method is equivalent to method {@code navigableKeySet}. * <p>This method is equivalent to method {@code navigableKeySet}.
* *
...@@ -1835,9 +1843,13 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V> ...@@ -1835,9 +1843,13 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
/** /**
* Returns a {@link Collection} view of the values contained in this map. * Returns a {@link Collection} view of the values contained in this map.
* The collection's iterator returns the values in ascending order * <p>The collection's iterator returns the values in ascending order
* of the corresponding keys. * of the corresponding keys. The collections's spliterator additionally
* The collection is backed by the map, so changes to the map are * reports {@link Spliterator#CONCURRENT}, {@link Spliterator#NONNULL} and
* {@link Spliterator#ORDERED}, with an encounter order that is ascending
* order of the corresponding keys.
*
* <p>The collection is backed by the map, so changes to the map are
* reflected in the collection, and vice-versa. The collection * reflected in the collection, and vice-versa. The collection
* supports element removal, which removes the corresponding * supports element removal, which removes the corresponding
* mapping from the map, via the {@code Iterator.remove}, * mapping from the map, via the {@code Iterator.remove},
...@@ -1845,11 +1857,8 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V> ...@@ -1845,11 +1857,8 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
* {@code retainAll} and {@code clear} operations. It does not * {@code retainAll} and {@code clear} operations. It does not
* support the {@code add} or {@code addAll} operations. * support the {@code add} or {@code addAll} operations.
* *
* <p>The view's {@code iterator} is a "weakly consistent" iterator that * <p>The view's iterators and spliterators are
* will never throw {@link java.util.ConcurrentModificationException * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* ConcurrentModificationException}, and guarantees to traverse elements
* as they existed upon construction of the iterator, and may (but is not
* guaranteed to) reflect any modifications subsequent to construction.
*/ */
public Collection<V> values() { public Collection<V> values() {
Values<V> vs = values; Values<V> vs = values;
...@@ -1858,8 +1867,14 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V> ...@@ -1858,8 +1867,14 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
/** /**
* Returns a {@link Set} view of the mappings contained in this map. * Returns a {@link Set} view of the mappings contained in this map.
* The set's iterator returns the entries in ascending key order. *
* The set is backed by the map, so changes to the map are * <p>The set's iterator returns the entries in ascending key order. The
* set's spliterator additionally reports {@link Spliterator#CONCURRENT},
* {@link Spliterator#NONNULL}, {@link Spliterator#SORTED} and
* {@link Spliterator#ORDERED}, with an encounter order that is ascending
* key order.
*
* <p>The set is backed by the map, so changes to the map are
* reflected in the set, and vice-versa. The set supports element * reflected in the set, and vice-versa. The set supports element
* removal, which removes the corresponding mapping from the map, * removal, which removes the corresponding mapping from the map,
* via the {@code Iterator.remove}, {@code Set.remove}, * via the {@code Iterator.remove}, {@code Set.remove},
...@@ -1867,15 +1882,12 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V> ...@@ -1867,15 +1882,12 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
* operations. It does not support the {@code add} or * operations. It does not support the {@code add} or
* {@code addAll} operations. * {@code addAll} operations.
* *
* <p>The view's {@code iterator} is a "weakly consistent" iterator that * <p>The view's iterators and spliterators are
* will never throw {@link java.util.ConcurrentModificationException * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* ConcurrentModificationException}, and guarantees to traverse elements
* as they existed upon construction of the iterator, and may (but is not
* guaranteed to) reflect any modifications subsequent to construction.
* *
* <p>The {@code Map.Entry} elements returned by * <p>The {@code Map.Entry} elements traversed by the {@code iterator}
* {@code iterator.next()} do <em>not</em> support the * or {@code spliterator} do <em>not</em> support the {@code setValue}
* {@code setValue} operation. * operation.
* *
* @return a set view of the mappings contained in this map, * @return a set view of the mappings contained in this map,
* sorted in ascending key order * sorted in ascending key order
......
...@@ -57,12 +57,12 @@ import java.util.Spliterator; ...@@ -57,12 +57,12 @@ import java.util.Spliterator;
* cost for the {@code contains}, {@code add}, and {@code remove} * cost for the {@code contains}, {@code add}, and {@code remove}
* operations and their variants. Insertion, removal, and access * operations and their variants. Insertion, removal, and access
* operations safely execute concurrently by multiple threads. * operations safely execute concurrently by multiple threads.
* Iterators are <i>weakly consistent</i>, returning elements *
* reflecting the state of the set at some point at or since the * <p>Iterators and spliterators are
* creation of the iterator. They do <em>not</em> throw {@link * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* java.util.ConcurrentModificationException}, and may proceed *
* concurrently with other operations. Ascending ordered views and * <p>Ascending ordered views and their iterators are faster than
* their iterators are faster than descending ones. * descending ones.
* *
* <p>Beware that, unlike in most collections, the {@code size} * <p>Beware that, unlike in most collections, the {@code size}
* method is <em>not</em> a constant-time operation. Because of the * method is <em>not</em> a constant-time operation. Because of the
...@@ -480,6 +480,24 @@ public class ConcurrentSkipListSet<E> ...@@ -480,6 +480,24 @@ public class ConcurrentSkipListSet<E>
return new ConcurrentSkipListSet<E>(m.descendingMap()); return new ConcurrentSkipListSet<E>(m.descendingMap());
} }
/**
* Returns a {@link Spliterator} over the elements in this set.
*
* <p>The {@code Spliterator} reports {@link Spliterator#CONCURRENT},
* {@link Spliterator#NONNULL}, {@link Spliterator#DISTINCT},
* {@link Spliterator#SORTED} and {@link Spliterator#ORDERED}, with an
* encounter order that is ascending order. Overriding implementations
* should document the reporting of additional characteristic values.
*
* <p>The spliterator's comparator (see
* {@link java.util.Spliterator#getComparator()}) is {@code null} if
* the set's comparator (see {@link #comparator()}) is {@code null}.
* Otherwise, the spliterator's comparator is the same as or imposes the
* same total ordering as the set's comparator.
*
* @return a {@code Spliterator} over the elements in this set
* @since 1.8
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
if (m instanceof ConcurrentSkipListMap) if (m instanceof ConcurrentSkipListMap)
......
...@@ -952,6 +952,8 @@ public class CopyOnWriteArrayList<E> ...@@ -952,6 +952,8 @@ public class CopyOnWriteArrayList<E>
/** /**
* Saves this list to a stream (that is, serializes it). * Saves this list to a stream (that is, serializes it).
* *
* @param s the stream
* @throws java.io.IOException if an I/O error occurs
* @serialData The length of the array backing the list is emitted * @serialData The length of the array backing the list is emitted
* (int), followed by all of its elements (each an Object) * (int), followed by all of its elements (each an Object)
* in the proper order. * in the proper order.
...@@ -972,6 +974,10 @@ public class CopyOnWriteArrayList<E> ...@@ -972,6 +974,10 @@ public class CopyOnWriteArrayList<E>
/** /**
* Reconstitutes this list from a stream (that is, deserializes it). * Reconstitutes this list from a stream (that is, deserializes it).
* @param s the stream
* @throws ClassNotFoundException if the class of a serialized object
* could not be found
* @throws java.io.IOException if an I/O error occurs
*/ */
private void readObject(java.io.ObjectInputStream s) private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException { throws java.io.IOException, ClassNotFoundException {
...@@ -1092,15 +1098,29 @@ public class CopyOnWriteArrayList<E> ...@@ -1092,15 +1098,29 @@ public class CopyOnWriteArrayList<E>
* *
* @throws IndexOutOfBoundsException {@inheritDoc} * @throws IndexOutOfBoundsException {@inheritDoc}
*/ */
public ListIterator<E> listIterator(final int index) { public ListIterator<E> listIterator(int index) {
Object[] elements = getArray(); Object[] elements = getArray();
int len = elements.length; int len = elements.length;
if (index<0 || index>len) if (index < 0 || index > len)
throw new IndexOutOfBoundsException("Index: "+index); throw new IndexOutOfBoundsException("Index: "+index);
return new COWIterator<E>(elements, index); return new COWIterator<E>(elements, index);
} }
/**
* Returns a {@link Spliterator} over the elements in this list.
*
* <p>The {@code Spliterator} reports {@link Spliterator#IMMUTABLE},
* {@link Spliterator#ORDERED}, {@link Spliterator#SIZED}, and
* {@link Spliterator#SUBSIZED}.
*
* <p>The spliterator provides a snapshot of the state of the list
* when the spliterator was constructed. No synchronization is needed while
* operating on the spliterator.
*
* @return a {@code Spliterator} over the elements in this list
* @since 1.8
*/
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
return Spliterators.spliterator return Spliterators.spliterator
(getArray(), Spliterator.IMMUTABLE | Spliterator.ORDERED); (getArray(), Spliterator.IMMUTABLE | Spliterator.ORDERED);
...@@ -1257,7 +1277,7 @@ public class CopyOnWriteArrayList<E> ...@@ -1257,7 +1277,7 @@ public class CopyOnWriteArrayList<E>
// only call this holding l's lock // only call this holding l's lock
private void rangeCheck(int index) { private void rangeCheck(int index) {
if (index<0 || index>=size) if (index < 0 || index >= size)
throw new IndexOutOfBoundsException("Index: "+index+ throw new IndexOutOfBoundsException("Index: "+index+
",Size: "+size); ",Size: "+size);
} }
...@@ -1304,7 +1324,7 @@ public class CopyOnWriteArrayList<E> ...@@ -1304,7 +1324,7 @@ public class CopyOnWriteArrayList<E>
lock.lock(); lock.lock();
try { try {
checkForComodification(); checkForComodification();
if (index<0 || index>size) if (index < 0 || index > size)
throw new IndexOutOfBoundsException(); throw new IndexOutOfBoundsException();
l.add(index+offset, element); l.add(index+offset, element);
expectedArray = l.getArray(); expectedArray = l.getArray();
...@@ -1361,12 +1381,12 @@ public class CopyOnWriteArrayList<E> ...@@ -1361,12 +1381,12 @@ public class CopyOnWriteArrayList<E>
} }
} }
public ListIterator<E> listIterator(final int index) { public ListIterator<E> listIterator(int index) {
final ReentrantLock lock = l.lock; final ReentrantLock lock = l.lock;
lock.lock(); lock.lock();
try { try {
checkForComodification(); checkForComodification();
if (index<0 || index>size) if (index < 0 || index > size)
throw new IndexOutOfBoundsException("Index: "+index+ throw new IndexOutOfBoundsException("Index: "+index+
", Size: "+size); ", Size: "+size);
return new COWSubListIterator<E>(l, index, offset, size); return new COWSubListIterator<E>(l, index, offset, size);
...@@ -1380,7 +1400,7 @@ public class CopyOnWriteArrayList<E> ...@@ -1380,7 +1400,7 @@ public class CopyOnWriteArrayList<E>
lock.lock(); lock.lock();
try { try {
checkForComodification(); checkForComodification();
if (fromIndex<0 || toIndex>size) if (fromIndex < 0 || toIndex > size)
throw new IndexOutOfBoundsException(); throw new IndexOutOfBoundsException();
return new COWSubList<E>(l, fromIndex + offset, return new COWSubList<E>(l, fromIndex + offset,
toIndex + offset); toIndex + offset);
...@@ -1580,6 +1600,7 @@ public class CopyOnWriteArrayList<E> ...@@ -1580,6 +1600,7 @@ public class CopyOnWriteArrayList<E>
return Spliterators.spliterator return Spliterators.spliterator
(a, lo, hi, Spliterator.IMMUTABLE | Spliterator.ORDERED); (a, lo, hi, Spliterator.IMMUTABLE | Spliterator.ORDERED);
} }
} }
private static class COWSubListIterator<E> implements ListIterator<E> { private static class COWSubListIterator<E> implements ListIterator<E> {
......
...@@ -404,6 +404,21 @@ public class CopyOnWriteArraySet<E> extends AbstractSet<E> ...@@ -404,6 +404,21 @@ public class CopyOnWriteArraySet<E> extends AbstractSet<E>
al.forEach(action); al.forEach(action);
} }
/**
* Returns a {@link Spliterator} over the elements in this set in the order
* in which these elements were added.
*
* <p>The {@code Spliterator} reports {@link Spliterator#IMMUTABLE},
* {@link Spliterator#DISTINCT}, {@link Spliterator#SIZED}, and
* {@link Spliterator#SUBSIZED}.
*
* <p>The spliterator provides a snapshot of the state of the set
* when the spliterator was constructed. No synchronization is needed while
* operating on the spliterator.
*
* @return a {@code Spliterator} over the elements in this set
* @since 1.8
*/
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
return Spliterators.spliterator return Spliterators.spliterator
(al.getArray(), Spliterator.IMMUTABLE | Spliterator.DISTINCT); (al.getArray(), Spliterator.IMMUTABLE | Spliterator.DISTINCT);
......
...@@ -512,12 +512,8 @@ public class DelayQueue<E extends Delayed> extends AbstractQueue<E> ...@@ -512,12 +512,8 @@ public class DelayQueue<E extends Delayed> extends AbstractQueue<E>
* unexpired) in this queue. The iterator does not return the * unexpired) in this queue. The iterator does not return the
* elements in any particular order. * elements in any particular order.
* *
* <p>The returned iterator is a "weakly consistent" iterator that * <p>The returned iterator is
* will never throw {@link java.util.ConcurrentModificationException * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* ConcurrentModificationException}, and guarantees to traverse
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
* *
* @return an iterator over the elements in this queue * @return an iterator over the elements in this queue
*/ */
......
...@@ -1008,12 +1008,8 @@ public class LinkedBlockingDeque<E> ...@@ -1008,12 +1008,8 @@ public class LinkedBlockingDeque<E>
* Returns an iterator over the elements in this deque in proper sequence. * Returns an iterator over the elements in this deque in proper sequence.
* The elements will be returned in order from first (head) to last (tail). * The elements will be returned in order from first (head) to last (tail).
* *
* <p>The returned iterator is a "weakly consistent" iterator that * <p>The returned iterator is
* will never throw {@link java.util.ConcurrentModificationException * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* ConcurrentModificationException}, and guarantees to traverse
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
* *
* @return an iterator over the elements in this deque in proper sequence * @return an iterator over the elements in this deque in proper sequence
*/ */
...@@ -1026,12 +1022,8 @@ public class LinkedBlockingDeque<E> ...@@ -1026,12 +1022,8 @@ public class LinkedBlockingDeque<E>
* sequential order. The elements will be returned in order from * sequential order. The elements will be returned in order from
* last (tail) to first (head). * last (tail) to first (head).
* *
* <p>The returned iterator is a "weakly consistent" iterator that * <p>The returned iterator is
* will never throw {@link java.util.ConcurrentModificationException * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* ConcurrentModificationException}, and guarantees to traverse
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
* *
* @return an iterator over the elements in this deque in reverse order * @return an iterator over the elements in this deque in reverse order
*/ */
...@@ -1270,6 +1262,22 @@ public class LinkedBlockingDeque<E> ...@@ -1270,6 +1262,22 @@ public class LinkedBlockingDeque<E>
} }
} }
/**
* Returns a {@link Spliterator} over the elements in this deque.
*
* <p>The returned spliterator is
* <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
*
* <p>The {@code Spliterator} reports {@link Spliterator#CONCURRENT},
* {@link Spliterator#ORDERED}, and {@link Spliterator#NONNULL}.
*
* @implNote
* The {@code Spliterator} implements {@code trySplit} to permit limited
* parallelism.
*
* @return a {@code Spliterator} over the elements in this deque
* @since 1.8
*/
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
return new LBDSpliterator<E>(this); return new LBDSpliterator<E>(this);
} }
...@@ -1277,6 +1285,8 @@ public class LinkedBlockingDeque<E> ...@@ -1277,6 +1285,8 @@ public class LinkedBlockingDeque<E>
/** /**
* Saves this deque to a stream (that is, serializes it). * Saves this deque to a stream (that is, serializes it).
* *
* @param s the stream
* @throws java.io.IOException if an I/O error occurs
* @serialData The capacity (int), followed by elements (each an * @serialData The capacity (int), followed by elements (each an
* {@code Object}) in the proper order, followed by a null * {@code Object}) in the proper order, followed by a null
*/ */
...@@ -1299,6 +1309,10 @@ public class LinkedBlockingDeque<E> ...@@ -1299,6 +1309,10 @@ public class LinkedBlockingDeque<E>
/** /**
* Reconstitutes this deque from a stream (that is, deserializes it). * Reconstitutes this deque from a stream (that is, deserializes it).
* @param s the stream
* @throws ClassNotFoundException if the class of a serialized object
* could not be found
* @throws java.io.IOException if an I/O error occurs
*/ */
private void readObject(java.io.ObjectInputStream s) private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException { throws java.io.IOException, ClassNotFoundException {
......
...@@ -766,12 +766,8 @@ public class LinkedBlockingQueue<E> extends AbstractQueue<E> ...@@ -766,12 +766,8 @@ public class LinkedBlockingQueue<E> extends AbstractQueue<E>
* Returns an iterator over the elements in this queue in proper sequence. * Returns an iterator over the elements in this queue in proper sequence.
* The elements will be returned in order from first (head) to last (tail). * The elements will be returned in order from first (head) to last (tail).
* *
* <p>The returned iterator is a "weakly consistent" iterator that * <p>The returned iterator is
* will never throw {@link java.util.ConcurrentModificationException * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* ConcurrentModificationException}, and guarantees to traverse
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
* *
* @return an iterator over the elements in this queue in proper sequence * @return an iterator over the elements in this queue in proper sequence
*/ */
...@@ -973,6 +969,22 @@ public class LinkedBlockingQueue<E> extends AbstractQueue<E> ...@@ -973,6 +969,22 @@ public class LinkedBlockingQueue<E> extends AbstractQueue<E>
} }
} }
/**
* Returns a {@link Spliterator} over the elements in this queue.
*
* <p>The returned spliterator is
* <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
*
* <p>The {@code Spliterator} reports {@link Spliterator#CONCURRENT},
* {@link Spliterator#ORDERED}, and {@link Spliterator#NONNULL}.
*
* @implNote
* The {@code Spliterator} implements {@code trySplit} to permit limited
* parallelism.
*
* @return a {@code Spliterator} over the elements in this queue
* @since 1.8
*/
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
return new LBQSpliterator<E>(this); return new LBQSpliterator<E>(this);
} }
...@@ -980,6 +992,8 @@ public class LinkedBlockingQueue<E> extends AbstractQueue<E> ...@@ -980,6 +992,8 @@ public class LinkedBlockingQueue<E> extends AbstractQueue<E>
/** /**
* Saves this queue to a stream (that is, serializes it). * Saves this queue to a stream (that is, serializes it).
* *
* @param s the stream
* @throws java.io.IOException if an I/O error occurs
* @serialData The capacity is emitted (int), followed by all of * @serialData The capacity is emitted (int), followed by all of
* its elements (each an {@code Object}) in the proper order, * its elements (each an {@code Object}) in the proper order,
* followed by a null * followed by a null
...@@ -1005,6 +1019,10 @@ public class LinkedBlockingQueue<E> extends AbstractQueue<E> ...@@ -1005,6 +1019,10 @@ public class LinkedBlockingQueue<E> extends AbstractQueue<E>
/** /**
* Reconstitutes this queue from a stream (that is, deserializes it). * Reconstitutes this queue from a stream (that is, deserializes it).
* @param s the stream
* @throws ClassNotFoundException if the class of a serialized object
* could not be found
* @throws java.io.IOException if an I/O error occurs
*/ */
private void readObject(java.io.ObjectInputStream s) private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException { throws java.io.IOException, ClassNotFoundException {
......
...@@ -40,6 +40,7 @@ import java.util.Collection; ...@@ -40,6 +40,7 @@ import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Queue; import java.util.Queue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport; import java.util.concurrent.locks.LockSupport;
import java.util.Spliterator; import java.util.Spliterator;
import java.util.Spliterators; import java.util.Spliterators;
...@@ -1018,6 +1019,22 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E> ...@@ -1018,6 +1019,22 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E>
} }
} }
/**
* Returns a {@link Spliterator} over the elements in this queue.
*
* <p>The returned spliterator is
* <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
*
* <p>The {@code Spliterator} reports {@link Spliterator#CONCURRENT},
* {@link Spliterator#ORDERED}, and {@link Spliterator#NONNULL}.
*
* @implNote
* The {@code Spliterator} implements {@code trySplit} to permit limited
* parallelism.
*
* @return a {@code Spliterator} over the elements in this queue
* @since 1.8
*/
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
return new LTQSpliterator<E>(this); return new LTQSpliterator<E>(this);
} }
...@@ -1301,12 +1318,8 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E> ...@@ -1301,12 +1318,8 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E>
* Returns an iterator over the elements in this queue in proper sequence. * Returns an iterator over the elements in this queue in proper sequence.
* The elements will be returned in order from first (head) to last (tail). * The elements will be returned in order from first (head) to last (tail).
* *
* <p>The returned iterator is a "weakly consistent" iterator that * <p>The returned iterator is
* will never throw {@link java.util.ConcurrentModificationException * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* ConcurrentModificationException}, and guarantees to traverse
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
* *
* @return an iterator over the elements in this queue in proper sequence * @return an iterator over the elements in this queue in proper sequence
*/ */
...@@ -1407,6 +1420,8 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E> ...@@ -1407,6 +1420,8 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E>
/** /**
* Saves this queue to a stream (that is, serializes it). * Saves this queue to a stream (that is, serializes it).
* *
* @param s the stream
* @throws java.io.IOException if an I/O error occurs
* @serialData All of the elements (each an {@code E}) in * @serialData All of the elements (each an {@code E}) in
* the proper order, followed by a null * the proper order, followed by a null
*/ */
...@@ -1421,6 +1436,10 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E> ...@@ -1421,6 +1436,10 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E>
/** /**
* Reconstitutes this queue from a stream (that is, deserializes it). * Reconstitutes this queue from a stream (that is, deserializes it).
* @param s the stream
* @throws ClassNotFoundException if the class of a serialized object
* could not be found
* @throws java.io.IOException if an I/O error occurs
*/ */
private void readObject(java.io.ObjectInputStream s) private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException { throws java.io.IOException, ClassNotFoundException {
......
...@@ -864,12 +864,8 @@ public class PriorityBlockingQueue<E> extends AbstractQueue<E> ...@@ -864,12 +864,8 @@ public class PriorityBlockingQueue<E> extends AbstractQueue<E>
* Returns an iterator over the elements in this queue. The * Returns an iterator over the elements in this queue. The
* iterator does not return the elements in any particular order. * iterator does not return the elements in any particular order.
* *
* <p>The returned iterator is a "weakly consistent" iterator that * <p>The returned iterator is
* will never throw {@link java.util.ConcurrentModificationException * <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
* ConcurrentModificationException}, and guarantees to traverse
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
* *
* @return an iterator over the elements in this queue * @return an iterator over the elements in this queue
*/ */
...@@ -915,6 +911,9 @@ public class PriorityBlockingQueue<E> extends AbstractQueue<E> ...@@ -915,6 +911,9 @@ public class PriorityBlockingQueue<E> extends AbstractQueue<E>
* For compatibility with previous version of this class, elements * For compatibility with previous version of this class, elements
* are first copied to a java.util.PriorityQueue, which is then * are first copied to a java.util.PriorityQueue, which is then
* serialized. * serialized.
*
* @param s the stream
* @throws java.io.IOException if an I/O error occurs
*/ */
private void writeObject(java.io.ObjectOutputStream s) private void writeObject(java.io.ObjectOutputStream s)
throws java.io.IOException { throws java.io.IOException {
...@@ -932,6 +931,10 @@ public class PriorityBlockingQueue<E> extends AbstractQueue<E> ...@@ -932,6 +931,10 @@ public class PriorityBlockingQueue<E> extends AbstractQueue<E>
/** /**
* Reconstitutes this queue from a stream (that is, deserializes it). * Reconstitutes this queue from a stream (that is, deserializes it).
* @param s the stream
* @throws ClassNotFoundException if the class of a serialized object
* could not be found
* @throws java.io.IOException if an I/O error occurs
*/ */
private void readObject(java.io.ObjectInputStream s) private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException { throws java.io.IOException, ClassNotFoundException {
...@@ -1005,6 +1008,21 @@ public class PriorityBlockingQueue<E> extends AbstractQueue<E> ...@@ -1005,6 +1008,21 @@ public class PriorityBlockingQueue<E> extends AbstractQueue<E>
} }
} }
/**
* Returns a {@link Spliterator} over the elements in this queue.
*
* <p>The returned spliterator is
* <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
*
* <p>The {@code Spliterator} reports {@link Spliterator#SIZED} and
* {@link Spliterator#NONNULL}.
*
* @implNote
* The {@code Spliterator} additionally reports {@link Spliterator#SUBSIZED}.
*
* @return a {@code Spliterator} over the elements in this queue
* @since 1.8
*/
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
return new PBQSpliterator<E>(this, null, 0, -1); return new PBQSpliterator<E>(this, null, 0, -1);
} }
......
...@@ -219,7 +219,7 @@ import java.util.stream.StreamSupport; ...@@ -219,7 +219,7 @@ import java.util.stream.StreamSupport;
* *
* <tr><th>&nbsp;</th></tr> * <tr><th>&nbsp;</th></tr>
* <tr align="left"><th colspan="2" id="unicode">Classes for Unicode scripts, blocks, categories and binary properties</th></tr> * <tr align="left"><th colspan="2" id="unicode">Classes for Unicode scripts, blocks, categories and binary properties</th></tr>
* * <tr><td valign="top" headers="construct unicode">{@code \p{IsLatin}}</td> * <tr><td valign="top" headers="construct unicode">{@code \p{IsLatin}}</td>
* <td headers="matches">A Latin&nbsp;script character (<a href="#usc">script</a>)</td></tr> * <td headers="matches">A Latin&nbsp;script character (<a href="#usc">script</a>)</td></tr>
* <tr><td valign="top" headers="construct unicode">{@code \p{InGreek}}</td> * <tr><td valign="top" headers="construct unicode">{@code \p{InGreek}}</td>
* <td headers="matches">A character in the Greek&nbsp;block (<a href="#ubc">block</a>)</td></tr> * <td headers="matches">A character in the Greek&nbsp;block (<a href="#ubc">block</a>)</td></tr>
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册