提交 1e210c7c 编写于 作者: L lana

Merge

...@@ -226,3 +226,5 @@ c4908732fef5235f1b98cafe0ce507771ef7892c jdk8-b98 ...@@ -226,3 +226,5 @@ c4908732fef5235f1b98cafe0ce507771ef7892c jdk8-b98
8ed8e2b4b90e0ac9aa5b3efef51cd576a9db96a9 jdk8-b102 8ed8e2b4b90e0ac9aa5b3efef51cd576a9db96a9 jdk8-b102
e0f6039c0290b7381042a6fec3100a69a5a67e37 jdk8-b103 e0f6039c0290b7381042a6fec3100a69a5a67e37 jdk8-b103
f1d8d15bfcb5ada858a942f8a31f6598f23214d1 jdk8-b104 f1d8d15bfcb5ada858a942f8a31f6598f23214d1 jdk8-b104
1fe211ae3d2b8cc2dfc4f58d9a6eb96418679672 jdk8-b105
c817276bd870dfe1dcc3a3dbbc092436b6907f75 jdk8-b106
# #
# 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
...@@ -292,8 +292,11 @@ endif ...@@ -292,8 +292,11 @@ endif
JVMCFG_DIR := $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR) JVMCFG_DIR := $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)
JVMCFG := $(JVMCFG_DIR)/jvm.cfg JVMCFG := $(JVMCFG_DIR)/jvm.cfg
# To do: should this also support -zeroshark?
ifeq ($(OPENJDK_TARGET_CPU_BITS),32) ifeq ($(OPENJDK_TARGET_CPU_BITS),64)
COPY_JVM_CFG_FILE := true
else
# On 32-bit machines we have three potential VMs: client, server and minimal. # On 32-bit machines we have three potential VMs: client, server and minimal.
# Historically we usually have both client and server and so that is what the # Historically we usually have both client and server and so that is what the
# committed jvm.cfg expects (including platform specific ergonomics switches # committed jvm.cfg expects (including platform specific ergonomics switches
...@@ -302,16 +305,21 @@ ifeq ($(OPENJDK_TARGET_CPU_BITS),32) ...@@ -302,16 +305,21 @@ ifeq ($(OPENJDK_TARGET_CPU_BITS),32)
# The main problem is deciding whether to use aliases for the VMs that are not # The main problem is deciding whether to use aliases for the VMs that are not
# present and the current position is that we add aliases for client and server, but # present and the current position is that we add aliases for client and server, but
# not for minimal. # not for minimal.
# To do: should this also support, -zero and -zeroshark?
CLIENT_AND_SERVER := $(and $(findstring true,$(JVM_VARIANT_SERVER)),$(findstring true,$(JVM_VARIANT_CLIENT))) CLIENT_AND_SERVER := $(and $(findstring true,$(JVM_VARIANT_SERVER)),$(findstring true,$(JVM_VARIANT_CLIENT)))
ifeq ($(CLIENT_AND_SERVER), true) ifeq ($(CLIENT_AND_SERVER), true)
# Use the committed jvm.cfg for this 32 bit setup (the minimal COPY_JVM_CFG_FILE := true
# VM is already KNOWN on platforms that potentially support it) else
# For zero, the default jvm.cfg file is sufficient
ifeq ($(JVM_VARIANT_ZERO), true)
COPY_JVM_CFG_FILE := true
endif
endif
endif
ifeq ($(COPY_JVM_CFG_FILE), true)
$(JVMCFG): $(JVMCFG_SRC) $(JVMCFG): $(JVMCFG_SRC)
$(call install-file) $(call install-file)
else else
$(JVMCFG): $(JVMCFG):
$(MKDIR) -p $(@D) $(MKDIR) -p $(@D)
$(RM) $(@) $(RM) $(@)
...@@ -338,12 +346,6 @@ ifeq ($(OPENJDK_TARGET_CPU_BITS),32) ...@@ -338,12 +346,6 @@ ifeq ($(OPENJDK_TARGET_CPU_BITS),32)
endif endif
endif endif
endif endif
endif
else
# Use the default jvm.cfg for this 64 bit setup.
$(JVMCFG): $(JVMCFG_SRC)
$(call install-file)
endif endif
COPY_FILES += $(JVMCFG) COPY_FILES += $(JVMCFG)
......
...@@ -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)
......
...@@ -87,6 +87,7 @@ class KQueueArrayWrapper { ...@@ -87,6 +87,7 @@ class KQueueArrayWrapper {
private int incomingInterruptFD; private int incomingInterruptFD;
static { static {
IOUtil.load();
initStructSizes(); initStructSizes();
String datamodel = java.security.AccessController.doPrivileged( String datamodel = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("sun.arch.data.model") new sun.security.action.GetPropertyAction("sun.arch.data.model")
......
...@@ -246,9 +246,4 @@ class KQueueSelectorImpl ...@@ -246,9 +246,4 @@ class KQueueSelectorImpl
} }
return this; return this;
} }
static {
Util.load();
}
} }
...@@ -28,6 +28,12 @@ ...@@ -28,6 +28,12 @@
#include "util.h" #include "util.h"
#include "SDE.h" #include "SDE.h"
#ifdef __APPLE__
/* use setjmp/longjmp versions that do not save/restore the signal mask */
#define setjmp _setjmp
#define longjmp _longjmp
#endif
/** /**
* This SourceDebugExtension code does not * This SourceDebugExtension code does not
* allow concurrent translation - due to caching method. * allow concurrent translation - due to caching method.
......
/* /*
* 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
......
/* /*
* 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];
......
...@@ -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();
} }
/** /**
......
...@@ -29,7 +29,6 @@ import java.io.File; ...@@ -29,7 +29,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.security.AccessControlException;
import java.util.Arrays; import java.util.Arrays;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -1033,9 +1032,9 @@ public final class ProcessBuilder ...@@ -1033,9 +1032,9 @@ public final class ProcessBuilder
// Can not disclose the fail reason for read-protected files. // Can not disclose the fail reason for read-protected files.
try { try {
security.checkRead(prog); security.checkRead(prog);
} catch (AccessControlException ace) { } catch (SecurityException se) {
exceptionInfo = ""; exceptionInfo = "";
cause = ace; cause = se;
} }
} }
// It's much easier for us to create a high-quality error // It's much easier for us to create a high-quality error
......
...@@ -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)
......
...@@ -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
......
...@@ -27,7 +27,6 @@ package java.util; ...@@ -27,7 +27,6 @@ package java.util;
import java.io.Serializable; import java.io.Serializable;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InvalidObjectException;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.BiFunction; import java.util.function.BiFunction;
...@@ -35,6 +34,7 @@ import java.util.function.Consumer; ...@@ -35,6 +34,7 @@ import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.function.UnaryOperator; import java.util.function.UnaryOperator;
import java.util.stream.IntStream;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
...@@ -1148,7 +1148,16 @@ public class Collections { ...@@ -1148,7 +1148,16 @@ public class Collections {
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
return (Spliterator<E>)c.spliterator(); return (Spliterator<E>)c.spliterator();
} }
@SuppressWarnings("unchecked")
@Override
public Stream<E> stream() {
return (Stream<E>)c.stream();
}
@SuppressWarnings("unchecked")
@Override
public Stream<E> parallelStream() {
return (Stream<E>)c.parallelStream();
}
} }
/** /**
...@@ -2009,8 +2018,8 @@ public class Collections { ...@@ -2009,8 +2018,8 @@ public class Collections {
* through the returned collection.<p> * through the returned collection.<p>
* *
* It is imperative that the user manually synchronize on the returned * It is imperative that the user manually synchronize on the returned
* collection when traversing it via {@link Iterator} or * collection when traversing it via {@link Iterator}, {@link Spliterator}
* {@link Spliterator}: * or {@link Stream}:
* <pre> * <pre>
* Collection c = Collections.synchronizedCollection(myCollection); * Collection c = Collections.synchronizedCollection(myCollection);
* ... * ...
...@@ -2120,6 +2129,14 @@ public class Collections { ...@@ -2120,6 +2129,14 @@ public class Collections {
public Spliterator<E> spliterator() { public Spliterator<E> spliterator() {
return c.spliterator(); // Must be manually synched by user! return c.spliterator(); // Must be manually synched by user!
} }
@Override
public Stream<E> stream() {
return c.stream(); // Must be manually synched by user!
}
@Override
public Stream<E> parallelStream() {
return c.parallelStream(); // Must be manually synched by user!
}
private void writeObject(ObjectOutputStream s) throws IOException { private void writeObject(ObjectOutputStream s) throws IOException {
synchronized (mutex) {s.defaultWriteObject();} synchronized (mutex) {s.defaultWriteObject();}
} }
...@@ -3172,6 +3189,10 @@ public class Collections { ...@@ -3172,6 +3189,10 @@ public class Collections {
} }
@Override @Override
public Spliterator<E> spliterator() {return c.spliterator();} public Spliterator<E> spliterator() {return c.spliterator();}
@Override
public Stream<E> stream() {return c.stream();}
@Override
public Stream<E> parallelStream() {return c.parallelStream();}
} }
/** /**
...@@ -5096,6 +5117,22 @@ public class Collections { ...@@ -5096,6 +5117,22 @@ public class Collections {
") > toIndex(" + toIndex + ")"); ") > toIndex(" + toIndex + ")");
return new CopiesList<>(toIndex - fromIndex, element); return new CopiesList<>(toIndex - fromIndex, element);
} }
// Override default methods in Collection
@Override
public Stream<E> stream() {
return IntStream.range(0, n).mapToObj(i -> element);
}
@Override
public Stream<E> parallelStream() {
return IntStream.range(0, n).parallel().mapToObj(i -> element);
}
@Override
public Spliterator<E> spliterator() {
return stream().spliterator();
}
} }
/** /**
...@@ -5503,6 +5540,10 @@ public class Collections { ...@@ -5503,6 +5540,10 @@ public class Collections {
@Override @Override
public Spliterator<E> spliterator() {return s.spliterator();} public Spliterator<E> spliterator() {return s.spliterator();}
@Override
public Stream<E> stream() {return s.stream();}
@Override
public Stream<E> parallelStream() {return s.parallelStream();}
private static final long serialVersionUID = 2454657854757543876L; private static final long serialVersionUID = 2454657854757543876L;
...@@ -5568,10 +5609,14 @@ public class Collections { ...@@ -5568,10 +5609,14 @@ public class Collections {
@Override @Override
public void forEach(Consumer<? super E> action) {q.forEach(action);} public void forEach(Consumer<? super E> action) {q.forEach(action);}
@Override @Override
public Spliterator<E> spliterator() {return q.spliterator();}
@Override
public boolean removeIf(Predicate<? super E> filter) { public boolean removeIf(Predicate<? super E> filter) {
return q.removeIf(filter); return q.removeIf(filter);
} }
@Override
public Spliterator<E> spliterator() {return q.spliterator();}
@Override
public Stream<E> stream() {return q.stream();}
@Override
public Stream<E> parallelStream() {return q.parallelStream();}
} }
} }
/* /*
* 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];
} }
......
...@@ -199,7 +199,7 @@ public interface Comparator<T> { ...@@ -199,7 +199,7 @@ public interface Comparator<T> {
* composed using following code, * composed using following code,
* *
* <pre>{@code * <pre>{@code
* Comparator<String> cmp = Comparator.comparing(String::length) * Comparator<String> cmp = Comparator.comparingInt(String::length)
* .thenComparing(String.CASE_INSENSITIVE_ORDER); * .thenComparing(String.CASE_INSENSITIVE_ORDER);
* }</pre> * }</pre>
* *
...@@ -270,18 +270,18 @@ public interface Comparator<T> { ...@@ -270,18 +270,18 @@ public interface Comparator<T> {
* extracts a {@code int} sort key. * extracts a {@code int} sort key.
* *
* @implSpec This default implementation behaves as if {@code * @implSpec This default implementation behaves as if {@code
* thenComparing(comparing(keyExtractor))}. * thenComparing(comparingInt(keyExtractor))}.
* *
* @param keyExtractor the function used to extract the integer sort key * @param keyExtractor the function used to extract the integer sort key
* @return a lexicographic-order comparator composed of this and then the * @return a lexicographic-order comparator composed of this and then the
* {@code int} sort key * {@code int} sort key
* @throws NullPointerException if the argument is null. * @throws NullPointerException if the argument is null.
* @see #comparing(ToIntFunction) * @see #comparingInt(ToIntFunction)
* @see #thenComparing(Comparator) * @see #thenComparing(Comparator)
* @since 1.8 * @since 1.8
*/ */
default Comparator<T> thenComparing(ToIntFunction<? super T> keyExtractor) { default Comparator<T> thenComparingInt(ToIntFunction<? super T> keyExtractor) {
return thenComparing(comparing(keyExtractor)); return thenComparing(comparingInt(keyExtractor));
} }
/** /**
...@@ -289,18 +289,18 @@ public interface Comparator<T> { ...@@ -289,18 +289,18 @@ public interface Comparator<T> {
* extracts a {@code long} sort key. * extracts a {@code long} sort key.
* *
* @implSpec This default implementation behaves as if {@code * @implSpec This default implementation behaves as if {@code
* thenComparing(comparing(keyExtractor))}. * thenComparing(comparingLong(keyExtractor))}.
* *
* @param keyExtractor the function used to extract the long sort key * @param keyExtractor the function used to extract the long sort key
* @return a lexicographic-order comparator composed of this and then the * @return a lexicographic-order comparator composed of this and then the
* {@code long} sort key * {@code long} sort key
* @throws NullPointerException if the argument is null. * @throws NullPointerException if the argument is null.
* @see #comparing(ToLongFunction) * @see #comparingLong(ToLongFunction)
* @see #thenComparing(Comparator) * @see #thenComparing(Comparator)
* @since 1.8 * @since 1.8
*/ */
default Comparator<T> thenComparing(ToLongFunction<? super T> keyExtractor) { default Comparator<T> thenComparingLong(ToLongFunction<? super T> keyExtractor) {
return thenComparing(comparing(keyExtractor)); return thenComparing(comparingLong(keyExtractor));
} }
/** /**
...@@ -308,18 +308,18 @@ public interface Comparator<T> { ...@@ -308,18 +308,18 @@ public interface Comparator<T> {
* extracts a {@code double} sort key. * extracts a {@code double} sort key.
* *
* @implSpec This default implementation behaves as if {@code * @implSpec This default implementation behaves as if {@code
* thenComparing(comparing(keyExtractor))}. * thenComparing(comparingDouble(keyExtractor))}.
* *
* @param keyExtractor the function used to extract the double sort key * @param keyExtractor the function used to extract the double sort key
* @return a lexicographic-order comparator composed of this and then the * @return a lexicographic-order comparator composed of this and then the
* {@code double} sort key * {@code double} sort key
* @throws NullPointerException if the argument is null. * @throws NullPointerException if the argument is null.
* @see #comparing(ToDoubleFunction) * @see #comparingDouble(ToDoubleFunction)
* @see #thenComparing(Comparator) * @see #thenComparing(Comparator)
* @since 1.8 * @since 1.8
*/ */
default Comparator<T> thenComparing(ToDoubleFunction<? super T> keyExtractor) { default Comparator<T> thenComparingDouble(ToDoubleFunction<? super T> keyExtractor) {
return thenComparing(comparing(keyExtractor)); return thenComparing(comparingDouble(keyExtractor));
} }
/** /**
...@@ -484,7 +484,7 @@ public interface Comparator<T> { ...@@ -484,7 +484,7 @@ public interface Comparator<T> {
* @throws NullPointerException if the argument is null * @throws NullPointerException if the argument is null
* @since 1.8 * @since 1.8
*/ */
public static <T> Comparator<T> comparing(ToIntFunction<? super T> keyExtractor) { public static <T> Comparator<T> comparingInt(ToIntFunction<? super T> keyExtractor) {
Objects.requireNonNull(keyExtractor); Objects.requireNonNull(keyExtractor);
return (Comparator<T> & Serializable) return (Comparator<T> & Serializable)
(c1, c2) -> Integer.compare(keyExtractor.applyAsInt(c1), keyExtractor.applyAsInt(c2)); (c1, c2) -> Integer.compare(keyExtractor.applyAsInt(c1), keyExtractor.applyAsInt(c2));
...@@ -505,7 +505,7 @@ public interface Comparator<T> { ...@@ -505,7 +505,7 @@ public interface Comparator<T> {
* @throws NullPointerException if the argument is null * @throws NullPointerException if the argument is null
* @since 1.8 * @since 1.8
*/ */
public static <T> Comparator<T> comparing(ToLongFunction<? super T> keyExtractor) { public static <T> Comparator<T> comparingLong(ToLongFunction<? super T> keyExtractor) {
Objects.requireNonNull(keyExtractor); Objects.requireNonNull(keyExtractor);
return (Comparator<T> & Serializable) return (Comparator<T> & Serializable)
(c1, c2) -> Long.compare(keyExtractor.applyAsLong(c1), keyExtractor.applyAsLong(c2)); (c1, c2) -> Long.compare(keyExtractor.applyAsLong(c1), keyExtractor.applyAsLong(c2));
...@@ -526,7 +526,7 @@ public interface Comparator<T> { ...@@ -526,7 +526,7 @@ public interface Comparator<T> {
* @throws NullPointerException if the argument is null * @throws NullPointerException if the argument is null
* @since 1.8 * @since 1.8
*/ */
public static<T> Comparator<T> comparing(ToDoubleFunction<? super T> keyExtractor) { public static<T> Comparator<T> comparingDouble(ToDoubleFunction<? super T> keyExtractor) {
Objects.requireNonNull(keyExtractor); Objects.requireNonNull(keyExtractor);
return (Comparator<T> & Serializable) return (Comparator<T> & Serializable)
(c1, c2) -> Double.compare(keyExtractor.applyAsDouble(c1), keyExtractor.applyAsDouble(c2)); (c1, c2) -> Double.compare(keyExtractor.applyAsDouble(c1), keyExtractor.applyAsDouble(c2));
......
此差异已折叠。
/* /*
* 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];
} }
......
...@@ -972,6 +972,27 @@ public class TreeMap<K,V> ...@@ -972,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);
......
...@@ -226,7 +226,11 @@ public class StampedLock implements java.io.Serializable { ...@@ -226,7 +226,11 @@ public class StampedLock implements java.io.Serializable {
* incoming reader arrives while read lock is held but there is a * incoming reader arrives while read lock is held but there is a
* queued writer, this incoming reader is queued. (This rule is * queued writer, this incoming reader is queued. (This rule is
* responsible for some of the complexity of method acquireRead, * responsible for some of the complexity of method acquireRead,
* but without it, the lock becomes highly unfair.) * but without it, the lock becomes highly unfair.) Method release
* does not (and sometimes cannot) itself wake up cowaiters. This
* is done by the primary thread, but helped by any other threads
* with nothing better to do in methods acquireRead and
* acquireWrite.
* *
* These rules apply to threads actually queued. All tryLock forms * These rules apply to threads actually queued. All tryLock forms
* opportunistically try to acquire locks regardless of preference * opportunistically try to acquire locks regardless of preference
...@@ -267,11 +271,14 @@ public class StampedLock implements java.io.Serializable { ...@@ -267,11 +271,14 @@ public class StampedLock implements java.io.Serializable {
/** Number of processors, for spin control */ /** Number of processors, for spin control */
private static final int NCPU = Runtime.getRuntime().availableProcessors(); private static final int NCPU = Runtime.getRuntime().availableProcessors();
/** Maximum number of retries before blocking on acquisition */ /** Maximum number of retries before enqueuing on acquisition */
private static final int SPINS = (NCPU > 1) ? 1 << 6 : 0; private static final int SPINS = (NCPU > 1) ? 1 << 6 : 0;
/** Maximum number of retries before blocking at head on acquisition */
private static final int HEAD_SPINS = (NCPU > 1) ? 1 << 10 : 0;
/** Maximum number of retries before re-blocking */ /** Maximum number of retries before re-blocking */
private static final int MAX_HEAD_SPINS = (NCPU > 1) ? 1 << 12 : 0; private static final int MAX_HEAD_SPINS = (NCPU > 1) ? 1 << 16 : 0;
/** The period for yielding when waiting for overflow spinlock */ /** The period for yielding when waiting for overflow spinlock */
private static final int OVERFLOW_YIELD_RATE = 7; // must be power 2 - 1 private static final int OVERFLOW_YIELD_RATE = 7; // must be power 2 - 1
...@@ -415,8 +422,8 @@ public class StampedLock implements java.io.Serializable { ...@@ -415,8 +422,8 @@ public class StampedLock implements java.io.Serializable {
* @return a stamp that can be used to unlock or convert mode * @return a stamp that can be used to unlock or convert mode
*/ */
public long readLock() { public long readLock() {
long s, next; // bypass acquireRead on fully unlocked case only long s = state, next; // bypass acquireRead on common uncontended case
return ((((s = state) & ABITS) == 0L && return ((whead == wtail && (s & ABITS) < RFULL &&
U.compareAndSwapLong(this, STATE, s, next = s + RUNIT)) ? U.compareAndSwapLong(this, STATE, s, next = s + RUNIT)) ?
next : acquireRead(false, 0L)); next : acquireRead(false, 0L));
} }
...@@ -1012,18 +1019,9 @@ public class StampedLock implements java.io.Serializable { ...@@ -1012,18 +1019,9 @@ public class StampedLock implements java.io.Serializable {
if (t.status <= 0) if (t.status <= 0)
q = t; q = t;
} }
if (q != null) { if (q != null && (w = q.thread) != null)
for (WNode r = q;;) { // release co-waiters too
if ((w = r.thread) != null) {
r.thread = null;
U.unpark(w); U.unpark(w);
} }
if ((r = q.cowait) == null)
break;
U.compareAndSwapObject(q, WCOWAIT, r, r.cowait);
}
}
}
} }
/** /**
...@@ -1038,22 +1036,22 @@ public class StampedLock implements java.io.Serializable { ...@@ -1038,22 +1036,22 @@ public class StampedLock implements java.io.Serializable {
private long acquireWrite(boolean interruptible, long deadline) { private long acquireWrite(boolean interruptible, long deadline) {
WNode node = null, p; WNode node = null, p;
for (int spins = -1;;) { // spin while enqueuing for (int spins = -1;;) { // spin while enqueuing
long s, ns; long m, s, ns;
if (((s = state) & ABITS) == 0L) { if ((m = (s = state) & ABITS) == 0L) {
if (U.compareAndSwapLong(this, STATE, s, ns = s + WBIT)) if (U.compareAndSwapLong(this, STATE, s, ns = s + WBIT))
return ns; return ns;
} }
else if (spins < 0)
spins = (m == WBIT && wtail == whead) ? SPINS : 0;
else if (spins > 0) { else if (spins > 0) {
if (LockSupport.nextSecondarySeed() >= 0) if (LockSupport.nextSecondarySeed() >= 0)
--spins; --spins;
} }
else if ((p = wtail) == null) { // initialize queue else if ((p = wtail) == null) { // initialize queue
WNode h = new WNode(WMODE, null); WNode hd = new WNode(WMODE, null);
if (U.compareAndSwapObject(this, WHEAD, null, h)) if (U.compareAndSwapObject(this, WHEAD, null, hd))
wtail = h; wtail = hd;
} }
else if (spins < 0)
spins = (p == whead) ? SPINS : 0;
else if (node == null) else if (node == null)
node = new WNode(WMODE, p); node = new WNode(WMODE, p);
else if (node.prev != p) else if (node.prev != p)
...@@ -1064,14 +1062,18 @@ public class StampedLock implements java.io.Serializable { ...@@ -1064,14 +1062,18 @@ public class StampedLock implements java.io.Serializable {
} }
} }
for (int spins = SPINS;;) { for (int spins = -1;;) {
WNode np, pp; int ps; long s, ns; Thread w; WNode h, np, pp; int ps;
while ((np = node.prev) != p && np != null) if ((h = whead) == p) {
(p = np).next = node; // stale if (spins < 0)
if (whead == p) { spins = HEAD_SPINS;
else if (spins < MAX_HEAD_SPINS)
spins <<= 1;
for (int k = spins;;) { // spin at head for (int k = spins;;) { // spin at head
long s, ns;
if (((s = state) & ABITS) == 0L) { if (((s = state) & ABITS) == 0L) {
if (U.compareAndSwapLong(this, STATE, s, ns = s+WBIT)) { if (U.compareAndSwapLong(this, STATE, s,
ns = s + WBIT)) {
whead = node; whead = node;
node.prev = null; node.prev = null;
return ns; return ns;
...@@ -1081,10 +1083,21 @@ public class StampedLock implements java.io.Serializable { ...@@ -1081,10 +1083,21 @@ public class StampedLock implements java.io.Serializable {
--k <= 0) --k <= 0)
break; break;
} }
if (spins < MAX_HEAD_SPINS)
spins <<= 1;
} }
if ((ps = p.status) == 0) else if (h != null) { // help release stale waiters
WNode c; Thread w;
while ((c = h.cowait) != null) {
if (U.compareAndSwapObject(h, WCOWAIT, c, c.cowait) &&
(w = c.thread) != null)
U.unpark(w);
}
}
if (whead == h) {
if ((np = node.prev) != p) {
if (np != null)
(p = np).next = node; // stale
}
else if ((ps = p.status) == 0)
U.compareAndSwapInt(p, WSTATUS, 0, WAITING); U.compareAndSwapInt(p, WSTATUS, 0, WAITING);
else if (ps == CANCELLED) { else if (ps == CANCELLED) {
if ((pp = p.prev) != null) { if ((pp = p.prev) != null) {
...@@ -1099,11 +1112,11 @@ public class StampedLock implements java.io.Serializable { ...@@ -1099,11 +1112,11 @@ public class StampedLock implements java.io.Serializable {
else if ((time = deadline - System.nanoTime()) <= 0L) else if ((time = deadline - System.nanoTime()) <= 0L)
return cancelWaiter(node, node, false); return cancelWaiter(node, node, false);
Thread wt = Thread.currentThread(); Thread wt = Thread.currentThread();
U.putObject(wt, PARKBLOCKER, this); // emulate LockSupport.park U.putObject(wt, PARKBLOCKER, this);
node.thread = wt; node.thread = wt;
if (node.prev == p && p.status == WAITING && // recheck if (p.status < 0 && (p != h || (state & ABITS) != 0L) &&
(p != whead || (state & ABITS) != 0L)) whead == h && node.prev == p)
U.park(false, time); U.park(false, time); // emulate LockSupport.park
node.thread = null; node.thread = null;
U.putObject(wt, PARKBLOCKER, null); U.putObject(wt, PARKBLOCKER, null);
if (interruptible && Thread.interrupted()) if (interruptible && Thread.interrupted())
...@@ -1111,6 +1124,7 @@ public class StampedLock implements java.io.Serializable { ...@@ -1111,6 +1124,7 @@ public class StampedLock implements java.io.Serializable {
} }
} }
} }
}
/** /**
* See above for explanation. * See above for explanation.
...@@ -1122,115 +1136,134 @@ public class StampedLock implements java.io.Serializable { ...@@ -1122,115 +1136,134 @@ public class StampedLock implements java.io.Serializable {
* @return next state, or INTERRUPTED * @return next state, or INTERRUPTED
*/ */
private long acquireRead(boolean interruptible, long deadline) { private long acquireRead(boolean interruptible, long deadline) {
WNode node = null, group = null, p; WNode node = null, p;
for (int spins = -1;;) { for (int spins = -1;;) {
for (;;) { WNode h;
long s, m, ns; WNode h, q; Thread w; // anti-barging guard if ((h = whead) == (p = wtail)) {
if (group == null && (h = whead) != null && for (long m, s, ns;;) {
(q = h.next) != null && q.mode != RMODE)
break;
if ((m = (s = state) & ABITS) < RFULL ? if ((m = (s = state) & ABITS) < RFULL ?
U.compareAndSwapLong(this, STATE, s, ns = s + RUNIT) : U.compareAndSwapLong(this, STATE, s, ns = s + RUNIT) :
(m < WBIT && (ns = tryIncReaderOverflow(s)) != 0L)) { (m < WBIT && (ns = tryIncReaderOverflow(s)) != 0L))
if (group != null) { // help release others return ns;
for (WNode r = group;;) { else if (m >= WBIT) {
if ((w = r.thread) != null) { if (spins > 0) {
r.thread = null; if (LockSupport.nextSecondarySeed() >= 0)
U.unpark(w); --spins;
} }
if ((r = group.cowait) == null) else {
if (spins == 0) {
WNode nh = whead, np = wtail;
if ((nh == h && np == p) || (h = nh) != (p = np))
break; break;
U.compareAndSwapObject(group, WCOWAIT, r, r.cowait);
} }
spins = SPINS;
} }
return ns;
} }
if (m >= WBIT)
break;
} }
if (spins > 0) {
if (LockSupport.nextSecondarySeed() >= 0)
--spins;
} }
else if ((p = wtail) == null) { if (p == null) { // initialize queue
WNode h = new WNode(WMODE, null); WNode hd = new WNode(WMODE, null);
if (U.compareAndSwapObject(this, WHEAD, null, h)) if (U.compareAndSwapObject(this, WHEAD, null, hd))
wtail = h; wtail = hd;
} }
else if (spins < 0)
spins = (p == whead) ? SPINS : 0;
else if (node == null) else if (node == null)
node = new WNode(WMODE, p); node = new WNode(RMODE, p);
else if (node.prev != p) else if (h == p || p.mode != RMODE) {
if (node.prev != p)
node.prev = p; node.prev = p;
else if (p.mode == RMODE && p != whead) { else if (U.compareAndSwapObject(this, WTAIL, p, node)) {
WNode pp = p.prev; // become co-waiter with group p p.next = node;
if (pp != null && p == wtail && break;
U.compareAndSwapObject(p, WCOWAIT, }
node.cowait = p.cowait, node)) { }
node.thread = Thread.currentThread(); else if (!U.compareAndSwapObject(p, WCOWAIT,
for (long time;;) { node.cowait = p.cowait, node))
node.cowait = null;
else {
for (;;) {
WNode pp, c; Thread w;
if ((h = whead) != null && (c = h.cowait) != null &&
U.compareAndSwapObject(h, WCOWAIT, c, c.cowait) &&
(w = c.thread) != null) // help release
U.unpark(w);
if (h == (pp = p.prev) || h == p || pp == null) {
long m, s, ns;
do {
if ((m = (s = state) & ABITS) < RFULL ?
U.compareAndSwapLong(this, STATE, s,
ns = s + RUNIT) :
(m < WBIT &&
(ns = tryIncReaderOverflow(s)) != 0L))
return ns;
} while (m < WBIT);
}
if (whead == h && p.prev == pp) {
long time;
if (pp == null || h == p || p.status > 0) {
node = null; // throw away
break;
}
if (deadline == 0L) if (deadline == 0L)
time = 0L; time = 0L;
else if ((time = deadline - System.nanoTime()) <= 0L) else if ((time = deadline - System.nanoTime()) <= 0L)
return cancelWaiter(node, p, false); return cancelWaiter(node, p, false);
if (node.thread == null)
break;
if (p.prev != pp || p.status == CANCELLED ||
p == whead || p.prev != pp) {
node.thread = null;
break;
}
Thread wt = Thread.currentThread(); Thread wt = Thread.currentThread();
U.putObject(wt, PARKBLOCKER, this); U.putObject(wt, PARKBLOCKER, this);
if (node.thread == null) // must recheck node.thread = wt;
break; if ((h != pp || (state & ABITS) == WBIT) &&
whead == h && p.prev == pp)
U.park(false, time); U.park(false, time);
node.thread = null;
U.putObject(wt, PARKBLOCKER, null); U.putObject(wt, PARKBLOCKER, null);
if (interruptible && Thread.interrupted()) if (interruptible && Thread.interrupted())
return cancelWaiter(node, p, true); return cancelWaiter(node, p, true);
} }
group = p;
} }
node = null; // throw away
}
else if (U.compareAndSwapObject(this, WTAIL, p, node)) {
p.next = node;
break;
} }
} }
for (int spins = SPINS;;) { for (int spins = -1;;) {
WNode np, pp, r; int ps; long m, s, ns; Thread w; WNode h, np, pp; int ps;
while ((np = node.prev) != p && np != null) if ((h = whead) == p) {
(p = np).next = node; if (spins < 0)
if (whead == p) { spins = HEAD_SPINS;
for (int k = spins;;) { else if (spins < MAX_HEAD_SPINS)
if ((m = (s = state) & ABITS) != WBIT) { spins <<= 1;
if (m < RFULL ? for (int k = spins;;) { // spin at head
U.compareAndSwapLong(this, STATE, s, ns = s + RUNIT): long m, s, ns;
(ns = tryIncReaderOverflow(s)) != 0L) { if ((m = (s = state) & ABITS) < RFULL ?
U.compareAndSwapLong(this, STATE, s, ns = s + RUNIT) :
(m < WBIT && (ns = tryIncReaderOverflow(s)) != 0L)) {
WNode c; Thread w;
whead = node; whead = node;
node.prev = null; node.prev = null;
while ((r = node.cowait) != null) { while ((c = node.cowait) != null) {
if (U.compareAndSwapObject(node, WCOWAIT, if (U.compareAndSwapObject(node, WCOWAIT,
r, r.cowait) && c, c.cowait) &&
(w = r.thread) != null) { (w = c.thread) != null)
r.thread = null; U.unpark(w);
U.unpark(w); // release co-waiter
}
} }
return ns; return ns;
} }
} else if (m >= WBIT &&
else if (LockSupport.nextSecondarySeed() >= 0 && LockSupport.nextSecondarySeed() >= 0 && --k <= 0)
--k <= 0)
break; break;
} }
if (spins < MAX_HEAD_SPINS)
spins <<= 1;
} }
if ((ps = p.status) == 0) else if (h != null) {
WNode c; Thread w;
while ((c = h.cowait) != null) {
if (U.compareAndSwapObject(h, WCOWAIT, c, c.cowait) &&
(w = c.thread) != null)
U.unpark(w);
}
}
if (whead == h) {
if ((np = node.prev) != p) {
if (np != null)
(p = np).next = node; // stale
}
else if ((ps = p.status) == 0)
U.compareAndSwapInt(p, WSTATUS, 0, WAITING); U.compareAndSwapInt(p, WSTATUS, 0, WAITING);
else if (ps == CANCELLED) { else if (ps == CANCELLED) {
if ((pp = p.prev) != null) { if ((pp = p.prev) != null) {
...@@ -1247,8 +1280,9 @@ public class StampedLock implements java.io.Serializable { ...@@ -1247,8 +1280,9 @@ public class StampedLock implements java.io.Serializable {
Thread wt = Thread.currentThread(); Thread wt = Thread.currentThread();
U.putObject(wt, PARKBLOCKER, this); U.putObject(wt, PARKBLOCKER, this);
node.thread = wt; node.thread = wt;
if (node.prev == p && p.status == WAITING && if (p.status < 0 &&
(p != whead || (state & ABITS) != WBIT)) (p != h || (state & ABITS) == WBIT) &&
whead == h && node.prev == p)
U.park(false, time); U.park(false, time);
node.thread = null; node.thread = null;
U.putObject(wt, PARKBLOCKER, null); U.putObject(wt, PARKBLOCKER, null);
...@@ -1257,6 +1291,7 @@ public class StampedLock implements java.io.Serializable { ...@@ -1257,6 +1291,7 @@ public class StampedLock implements java.io.Serializable {
} }
} }
} }
}
/** /**
* If node non-null, forces cancel status and unsplices it from * If node non-null, forces cancel status and unsplices it from
...@@ -1278,22 +1313,19 @@ public class StampedLock implements java.io.Serializable { ...@@ -1278,22 +1313,19 @@ public class StampedLock implements java.io.Serializable {
if (node != null && group != null) { if (node != null && group != null) {
Thread w; Thread w;
node.status = CANCELLED; node.status = CANCELLED;
node.thread = null;
// unsplice cancelled nodes from group // unsplice cancelled nodes from group
for (WNode p = group, q; (q = p.cowait) != null;) { for (WNode p = group, q; (q = p.cowait) != null;) {
if (q.status == CANCELLED) if (q.status == CANCELLED) {
U.compareAndSwapObject(p, WNEXT, q, q.next); U.compareAndSwapObject(p, WCOWAIT, q, q.cowait);
p = group; // restart
}
else else
p = q; p = q;
} }
if (group == node) { if (group == node) {
WNode r; // detach and wake up uncancelled co-waiters for (WNode r = group.cowait; r != null; r = r.cowait) {
while ((r = node.cowait) != null) { if ((w = r.thread) != null)
if (U.compareAndSwapObject(node, WCOWAIT, r, r.cowait) && U.unpark(w); // wake up uncancelled co-waiters
(w = r.thread) != null) {
r.thread = null;
U.unpark(w);
}
} }
for (WNode pred = node.prev; pred != null; ) { // unsplice for (WNode pred = node.prev; pred != null; ) { // unsplice
WNode succ, pp; // find valid successor WNode succ, pp; // find valid successor
......
...@@ -32,6 +32,7 @@ import java.security.*; ...@@ -32,6 +32,7 @@ import java.security.*;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import sun.misc.JarIndex;
import sun.security.util.ManifestDigester; import sun.security.util.ManifestDigester;
import sun.security.util.ManifestEntryVerifier; import sun.security.util.ManifestEntryVerifier;
import sun.security.util.SignatureFileVerifier; import sun.security.util.SignatureFileVerifier;
...@@ -139,7 +140,8 @@ class JarVerifier { ...@@ -139,7 +140,8 @@ class JarVerifier {
return; return;
} }
if (uname.equals(JarFile.MANIFEST_NAME)) { if (uname.equals(JarFile.MANIFEST_NAME) ||
uname.equals(JarIndex.INDEX_NAME)) {
return; return;
} }
......
...@@ -457,13 +457,15 @@ public class Logger { ...@@ -457,13 +457,15 @@ public class Logger {
* of the subsystem, such as java.net * of the subsystem, such as java.net
* or javax.swing * or javax.swing
* @param resourceBundleName name of ResourceBundle to be used for localizing * @param resourceBundleName name of ResourceBundle to be used for localizing
* messages for this logger. May be <CODE>null</CODE> if none of * messages for this logger. May be {@code null}
* the messages require localization. * if none of the messages require localization.
* @return a suitable Logger * @return a suitable Logger
* @throws MissingResourceException if the resourceBundleName is non-null and * @throws MissingResourceException if the resourceBundleName is non-null and
* no corresponding resource can be found. * no corresponding resource can be found.
* @throws IllegalArgumentException if the Logger already exists and uses * @throws IllegalArgumentException if the Logger already exists and uses
* a different resource bundle name. * a different resource bundle name; or if
* {@code resourceBundleName} is {@code null} but the named
* logger has a resource bundle set.
* @throws NullPointerException if the name is null. * @throws NullPointerException if the name is null.
*/ */
...@@ -1731,10 +1733,6 @@ public class Logger { ...@@ -1731,10 +1733,6 @@ public class Logger {
// Synchronized to prevent races in setting the fields. // Synchronized to prevent races in setting the fields.
private synchronized void setupResourceInfo(String name, private synchronized void setupResourceInfo(String name,
Class<?> callersClass) { Class<?> callersClass) {
if (name == null) {
return;
}
if (resourceBundleName != null) { if (resourceBundleName != null) {
// this Logger already has a ResourceBundle // this Logger already has a ResourceBundle
...@@ -1748,6 +1746,10 @@ public class Logger { ...@@ -1748,6 +1746,10 @@ public class Logger {
resourceBundleName + " != " + name); resourceBundleName + " != " + name);
} }
if (name == null) {
return;
}
setCallersClassLoaderRef(callersClass); setCallersClassLoaderRef(callersClass);
if (findResourceBundle(name, true) == null) { if (findResourceBundle(name, true) == null) {
// We've failed to find an expected ResourceBundle. // We've failed to find an expected ResourceBundle.
......
...@@ -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>
...@@ -4456,16 +4456,16 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -4456,16 +4456,16 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
groups[groupIndex+1] = i; groups[groupIndex+1] = i;
groups[groupIndex] = i - k; groups[groupIndex] = i - k;
} }
i = i - k;
return true; return true;
} }
// backing off // backing off
i = i - k;
if (capture) { if (capture) {
groups[groupIndex+1] = i; groups[groupIndex+1] = i;
groups[groupIndex] = i - k; groups[groupIndex] = i - k;
} }
i = i - k;
j--; j--;
} }
break; break;
} }
...@@ -4883,7 +4883,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -4883,7 +4883,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
int k = matcher.groups[groupIndex+1]; int k = matcher.groups[groupIndex+1];
int groupSize = k - j; int groupSize = k - j;
// If the referenced group didn't match, neither can this // If the referenced group didn't match, neither can this
if (j < 0) if (j < 0)
return false; return false;
...@@ -4893,7 +4892,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -4893,7 +4892,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
matcher.hitEnd = true; matcher.hitEnd = true;
return false; return false;
} }
// Check each new char to make sure it matches what the group // Check each new char to make sure it matches what the group
// referenced matched last time around // referenced matched last time around
for (int index=0; index<groupSize; index++) for (int index=0; index<groupSize; index++)
......
...@@ -137,6 +137,11 @@ public final class Collectors { ...@@ -137,6 +137,11 @@ public final class Collectors {
return (u,v) -> { throw new IllegalStateException(String.format("Duplicate key %s", u)); }; return (u,v) -> { throw new IllegalStateException(String.format("Duplicate key %s", u)); };
} }
@SuppressWarnings("unchecked")
private static <I, R> Function<I, R> castingIdentity() {
return i -> (R) i;
}
/** /**
* Simple implementation class for {@code Collector}. * Simple implementation class for {@code Collector}.
* *
...@@ -166,7 +171,7 @@ public final class Collectors { ...@@ -166,7 +171,7 @@ public final class Collectors {
BiConsumer<A, T> accumulator, BiConsumer<A, T> accumulator,
BinaryOperator<A> combiner, BinaryOperator<A> combiner,
Set<Characteristics> characteristics) { Set<Characteristics> characteristics) {
this(supplier, accumulator, combiner, i -> (R) i, characteristics); this(supplier, accumulator, combiner, castingIdentity(), characteristics);
} }
@Override @Override
...@@ -209,7 +214,7 @@ public final class Collectors { ...@@ -209,7 +214,7 @@ public final class Collectors {
*/ */
public static <T, C extends Collection<T>> public static <T, C extends Collection<T>>
Collector<T, ?, C> toCollection(Supplier<C> collectionFactory) { Collector<T, ?, C> toCollection(Supplier<C> collectionFactory) {
return new CollectorImpl<>(collectionFactory, Collection::add, return new CollectorImpl<>(collectionFactory, Collection<T>::add,
(r1, r2) -> { r1.addAll(r2); return r1; }, (r1, r2) -> { r1.addAll(r2); return r1; },
CH_ID); CH_ID);
} }
...@@ -1046,30 +1051,23 @@ public final class Collectors { ...@@ -1046,30 +1051,23 @@ public final class Collectors {
public static <T, D, A> public static <T, D, A>
Collector<T, ?, Map<Boolean, D>> partitioningBy(Predicate<? super T> predicate, Collector<T, ?, Map<Boolean, D>> partitioningBy(Predicate<? super T> predicate,
Collector<? super T, A, D> downstream) { Collector<? super T, A, D> downstream) {
@SuppressWarnings("unchecked") BiConsumer<A, ? super T> downstreamAccumulator = downstream.accumulator();
BiConsumer<D, ? super T> downstreamAccumulator = (BiConsumer<D, ? super T>) downstream.accumulator(); BiConsumer<Partition<A>, T> accumulator = (result, t) ->
BiConsumer<Map<Boolean, A>, T> accumulator = (result, t) -> { downstreamAccumulator.accept(predicate.test(t) ? result.forTrue : result.forFalse, t);
Partition<D> asPartition = ((Partition<D>) result);
downstreamAccumulator.accept(predicate.test(t) ? asPartition.forTrue : asPartition.forFalse, t);
};
BinaryOperator<A> op = downstream.combiner(); BinaryOperator<A> op = downstream.combiner();
BinaryOperator<Map<Boolean, A>> merger = (m1, m2) -> { BinaryOperator<Partition<A>> merger = (left, right) ->
Partition<A> left = (Partition<A>) m1; new Partition<>(op.apply(left.forTrue, right.forTrue),
Partition<A> right = (Partition<A>) m2;
return new Partition<>(op.apply(left.forTrue, right.forTrue),
op.apply(left.forFalse, right.forFalse)); op.apply(left.forFalse, right.forFalse));
}; Supplier<Partition<A>> supplier = () ->
Supplier<Map<Boolean, A>> supplier = () -> new Partition<>(downstream.supplier().get(), new Partition<>(downstream.supplier().get(),
downstream.supplier().get()); downstream.supplier().get());
if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) { if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) {
return new CollectorImpl<>(supplier, accumulator, merger, CH_ID); return new CollectorImpl<>(supplier, accumulator, merger, CH_ID);
} }
else { else {
Function<Map<Boolean, A>, Map<Boolean, D>> finisher = (Map<Boolean, A> par) -> { Function<Partition<A>, Map<Boolean, D>> finisher = par ->
Partition<A> asAPartition = (Partition<A>) par; new Partition<>(downstream.finisher().apply(par.forTrue),
return new Partition<>(downstream.finisher().apply(asAPartition.forTrue), downstream.finisher().apply(par.forFalse));
downstream.finisher().apply(asAPartition.forFalse));
};
return new CollectorImpl<>(supplier, accumulator, merger, finisher, CH_NOID); return new CollectorImpl<>(supplier, accumulator, merger, finisher, CH_NOID);
} }
} }
......
...@@ -101,7 +101,7 @@ final class DistinctOps { ...@@ -101,7 +101,7 @@ final class DistinctOps {
if (StreamOpFlag.DISTINCT.isKnown(flags)) { if (StreamOpFlag.DISTINCT.isKnown(flags)) {
return sink; return sink;
} else if (StreamOpFlag.SORTED.isKnown(flags)) { } else if (StreamOpFlag.SORTED.isKnown(flags)) {
return new Sink.ChainedReference<T>(sink) { return new Sink.ChainedReference<T, T>(sink) {
boolean seenNull; boolean seenNull;
T lastSeen; T lastSeen;
...@@ -132,7 +132,7 @@ final class DistinctOps { ...@@ -132,7 +132,7 @@ final class DistinctOps {
} }
}; };
} else { } else {
return new Sink.ChainedReference<T>(sink) { return new Sink.ChainedReference<T, T>(sink) {
Set<T> seen; Set<T> seen;
@Override @Override
......
...@@ -191,7 +191,7 @@ abstract class DoublePipeline<E_IN> ...@@ -191,7 +191,7 @@ abstract class DoublePipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<Double> opWrapSink(int flags, Sink<Double> sink) { Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedDouble(sink) { return new Sink.ChainedDouble<Double>(sink) {
@Override @Override
public void accept(double t) { public void accept(double t) {
downstream.accept(mapper.applyAsDouble(t)); downstream.accept(mapper.applyAsDouble(t));
...@@ -208,9 +208,8 @@ abstract class DoublePipeline<E_IN> ...@@ -208,9 +208,8 @@ abstract class DoublePipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<Double> opWrapSink(int flags, Sink<U> sink) { Sink<Double> opWrapSink(int flags, Sink<U> sink) {
return new Sink.ChainedDouble(sink) { return new Sink.ChainedDouble<U>(sink) {
@Override @Override
@SuppressWarnings("unchecked")
public void accept(double t) { public void accept(double t) {
downstream.accept(mapper.apply(t)); downstream.accept(mapper.apply(t));
} }
...@@ -226,7 +225,7 @@ abstract class DoublePipeline<E_IN> ...@@ -226,7 +225,7 @@ abstract class DoublePipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<Double> opWrapSink(int flags, Sink<Integer> sink) { Sink<Double> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedDouble(sink) { return new Sink.ChainedDouble<Integer>(sink) {
@Override @Override
public void accept(double t) { public void accept(double t) {
downstream.accept(mapper.applyAsInt(t)); downstream.accept(mapper.applyAsInt(t));
...@@ -243,7 +242,7 @@ abstract class DoublePipeline<E_IN> ...@@ -243,7 +242,7 @@ abstract class DoublePipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<Double> opWrapSink(int flags, Sink<Long> sink) { Sink<Double> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedDouble(sink) { return new Sink.ChainedDouble<Long>(sink) {
@Override @Override
public void accept(double t) { public void accept(double t) {
downstream.accept(mapper.applyAsLong(t)); downstream.accept(mapper.applyAsLong(t));
...@@ -259,7 +258,7 @@ abstract class DoublePipeline<E_IN> ...@@ -259,7 +258,7 @@ abstract class DoublePipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
@Override @Override
Sink<Double> opWrapSink(int flags, Sink<Double> sink) { Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedDouble(sink) { return new Sink.ChainedDouble<Double>(sink) {
@Override @Override
public void begin(long size) { public void begin(long size) {
downstream.begin(-1); downstream.begin(-1);
...@@ -296,7 +295,7 @@ abstract class DoublePipeline<E_IN> ...@@ -296,7 +295,7 @@ abstract class DoublePipeline<E_IN>
StreamOpFlag.NOT_SIZED) { StreamOpFlag.NOT_SIZED) {
@Override @Override
Sink<Double> opWrapSink(int flags, Sink<Double> sink) { Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedDouble(sink) { return new Sink.ChainedDouble<Double>(sink) {
@Override @Override
public void begin(long size) { public void begin(long size) {
downstream.begin(-1); downstream.begin(-1);
...@@ -319,7 +318,7 @@ abstract class DoublePipeline<E_IN> ...@@ -319,7 +318,7 @@ abstract class DoublePipeline<E_IN>
0) { 0) {
@Override @Override
Sink<Double> opWrapSink(int flags, Sink<Double> sink) { Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedDouble(sink) { return new Sink.ChainedDouble<Double>(sink) {
@Override @Override
public void accept(double t) { public void accept(double t) {
consumer.accept(t); consumer.accept(t);
......
...@@ -189,9 +189,8 @@ abstract class IntPipeline<E_IN> ...@@ -189,9 +189,8 @@ abstract class IntPipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<Integer> opWrapSink(int flags, Sink<Long> sink) { Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedInt(sink) { return new Sink.ChainedInt<Long>(sink) {
@Override @Override
@SuppressWarnings("unchecked")
public void accept(int t) { public void accept(int t) {
downstream.accept((long) t); downstream.accept((long) t);
} }
...@@ -206,9 +205,8 @@ abstract class IntPipeline<E_IN> ...@@ -206,9 +205,8 @@ abstract class IntPipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<Integer> opWrapSink(int flags, Sink<Double> sink) { Sink<Integer> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedInt(sink) { return new Sink.ChainedInt<Double>(sink) {
@Override @Override
@SuppressWarnings("unchecked")
public void accept(int t) { public void accept(int t) {
downstream.accept((double) t); downstream.accept((double) t);
} }
...@@ -229,7 +227,7 @@ abstract class IntPipeline<E_IN> ...@@ -229,7 +227,7 @@ abstract class IntPipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) { Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedInt(sink) { return new Sink.ChainedInt<Integer>(sink) {
@Override @Override
public void accept(int t) { public void accept(int t) {
downstream.accept(mapper.applyAsInt(t)); downstream.accept(mapper.applyAsInt(t));
...@@ -246,9 +244,8 @@ abstract class IntPipeline<E_IN> ...@@ -246,9 +244,8 @@ abstract class IntPipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<Integer> opWrapSink(int flags, Sink<U> sink) { Sink<Integer> opWrapSink(int flags, Sink<U> sink) {
return new Sink.ChainedInt(sink) { return new Sink.ChainedInt<U>(sink) {
@Override @Override
@SuppressWarnings("unchecked")
public void accept(int t) { public void accept(int t) {
downstream.accept(mapper.apply(t)); downstream.accept(mapper.apply(t));
} }
...@@ -264,7 +261,7 @@ abstract class IntPipeline<E_IN> ...@@ -264,7 +261,7 @@ abstract class IntPipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<Integer> opWrapSink(int flags, Sink<Long> sink) { Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedInt(sink) { return new Sink.ChainedInt<Long>(sink) {
@Override @Override
public void accept(int t) { public void accept(int t) {
downstream.accept(mapper.applyAsLong(t)); downstream.accept(mapper.applyAsLong(t));
...@@ -281,7 +278,7 @@ abstract class IntPipeline<E_IN> ...@@ -281,7 +278,7 @@ abstract class IntPipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<Integer> opWrapSink(int flags, Sink<Double> sink) { Sink<Integer> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedInt(sink) { return new Sink.ChainedInt<Double>(sink) {
@Override @Override
public void accept(int t) { public void accept(int t) {
downstream.accept(mapper.applyAsDouble(t)); downstream.accept(mapper.applyAsDouble(t));
...@@ -297,7 +294,7 @@ abstract class IntPipeline<E_IN> ...@@ -297,7 +294,7 @@ abstract class IntPipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
@Override @Override
Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) { Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedInt(sink) { return new Sink.ChainedInt<Integer>(sink) {
@Override @Override
public void begin(long size) { public void begin(long size) {
downstream.begin(-1); downstream.begin(-1);
...@@ -334,7 +331,7 @@ abstract class IntPipeline<E_IN> ...@@ -334,7 +331,7 @@ abstract class IntPipeline<E_IN>
StreamOpFlag.NOT_SIZED) { StreamOpFlag.NOT_SIZED) {
@Override @Override
Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) { Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedInt(sink) { return new Sink.ChainedInt<Integer>(sink) {
@Override @Override
public void begin(long size) { public void begin(long size) {
downstream.begin(-1); downstream.begin(-1);
...@@ -357,7 +354,7 @@ abstract class IntPipeline<E_IN> ...@@ -357,7 +354,7 @@ abstract class IntPipeline<E_IN>
0) { 0) {
@Override @Override
Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) { Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedInt(sink) { return new Sink.ChainedInt<Integer>(sink) {
@Override @Override
public void accept(int t) { public void accept(int t) {
consumer.accept(t); consumer.accept(t);
......
...@@ -186,7 +186,7 @@ abstract class LongPipeline<E_IN> ...@@ -186,7 +186,7 @@ abstract class LongPipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<Long> opWrapSink(int flags, Sink<Double> sink) { Sink<Long> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedLong(sink) { return new Sink.ChainedLong<Double>(sink) {
@Override @Override
public void accept(long t) { public void accept(long t) {
downstream.accept((double) t); downstream.accept((double) t);
...@@ -208,9 +208,8 @@ abstract class LongPipeline<E_IN> ...@@ -208,9 +208,8 @@ abstract class LongPipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<Long> opWrapSink(int flags, Sink<Long> sink) { Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedLong(sink) { return new Sink.ChainedLong<Long>(sink) {
@Override @Override
@SuppressWarnings("unchecked")
public void accept(long t) { public void accept(long t) {
downstream.accept(mapper.applyAsLong(t)); downstream.accept(mapper.applyAsLong(t));
} }
...@@ -226,9 +225,8 @@ abstract class LongPipeline<E_IN> ...@@ -226,9 +225,8 @@ abstract class LongPipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<Long> opWrapSink(int flags, Sink<U> sink) { Sink<Long> opWrapSink(int flags, Sink<U> sink) {
return new Sink.ChainedLong(sink) { return new Sink.ChainedLong<U>(sink) {
@Override @Override
@SuppressWarnings("unchecked")
public void accept(long t) { public void accept(long t) {
downstream.accept(mapper.apply(t)); downstream.accept(mapper.apply(t));
} }
...@@ -244,9 +242,8 @@ abstract class LongPipeline<E_IN> ...@@ -244,9 +242,8 @@ abstract class LongPipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<Long> opWrapSink(int flags, Sink<Integer> sink) { Sink<Long> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedLong(sink) { return new Sink.ChainedLong<Integer>(sink) {
@Override @Override
@SuppressWarnings("unchecked")
public void accept(long t) { public void accept(long t) {
downstream.accept(mapper.applyAsInt(t)); downstream.accept(mapper.applyAsInt(t));
} }
...@@ -262,7 +259,7 @@ abstract class LongPipeline<E_IN> ...@@ -262,7 +259,7 @@ abstract class LongPipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<Long> opWrapSink(int flags, Sink<Double> sink) { Sink<Long> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedLong(sink) { return new Sink.ChainedLong<Double>(sink) {
@Override @Override
public void accept(long t) { public void accept(long t) {
downstream.accept(mapper.applyAsDouble(t)); downstream.accept(mapper.applyAsDouble(t));
...@@ -278,7 +275,7 @@ abstract class LongPipeline<E_IN> ...@@ -278,7 +275,7 @@ abstract class LongPipeline<E_IN>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
@Override @Override
Sink<Long> opWrapSink(int flags, Sink<Long> sink) { Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedLong(sink) { return new Sink.ChainedLong<Long>(sink) {
@Override @Override
public void begin(long size) { public void begin(long size) {
downstream.begin(-1); downstream.begin(-1);
...@@ -315,7 +312,7 @@ abstract class LongPipeline<E_IN> ...@@ -315,7 +312,7 @@ abstract class LongPipeline<E_IN>
StreamOpFlag.NOT_SIZED) { StreamOpFlag.NOT_SIZED) {
@Override @Override
Sink<Long> opWrapSink(int flags, Sink<Long> sink) { Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedLong(sink) { return new Sink.ChainedLong<Long>(sink) {
@Override @Override
public void begin(long size) { public void begin(long size) {
downstream.begin(-1); downstream.begin(-1);
...@@ -338,7 +335,7 @@ abstract class LongPipeline<E_IN> ...@@ -338,7 +335,7 @@ abstract class LongPipeline<E_IN>
0) { 0) {
@Override @Override
Sink<Long> opWrapSink(int flags, Sink<Long> sink) { Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedLong(sink) { return new Sink.ChainedLong<Long>(sink) {
@Override @Override
public void accept(long t) { public void accept(long t) {
consumer.accept(t); consumer.accept(t);
......
...@@ -163,17 +163,16 @@ abstract class ReferencePipeline<P_IN, P_OUT> ...@@ -163,17 +163,16 @@ abstract class ReferencePipeline<P_IN, P_OUT>
StreamOpFlag.NOT_SIZED) { StreamOpFlag.NOT_SIZED) {
@Override @Override
Sink<P_OUT> opWrapSink(int flags, Sink<P_OUT> sink) { Sink<P_OUT> opWrapSink(int flags, Sink<P_OUT> sink) {
return new Sink.ChainedReference<P_OUT>(sink) { return new Sink.ChainedReference<P_OUT, P_OUT>(sink) {
@Override @Override
public void begin(long size) { public void begin(long size) {
downstream.begin(-1); downstream.begin(-1);
} }
@Override @Override
@SuppressWarnings("unchecked")
public void accept(P_OUT u) { public void accept(P_OUT u) {
if (predicate.test(u)) if (predicate.test(u))
downstream.accept((Object) u); downstream.accept(u);
} }
}; };
} }
...@@ -188,7 +187,7 @@ abstract class ReferencePipeline<P_IN, P_OUT> ...@@ -188,7 +187,7 @@ abstract class ReferencePipeline<P_IN, P_OUT>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<P_OUT> opWrapSink(int flags, Sink<R> sink) { Sink<P_OUT> opWrapSink(int flags, Sink<R> sink) {
return new Sink.ChainedReference<P_OUT>(sink) { return new Sink.ChainedReference<P_OUT, R>(sink) {
@Override @Override
public void accept(P_OUT u) { public void accept(P_OUT u) {
downstream.accept(mapper.apply(u)); downstream.accept(mapper.apply(u));
...@@ -205,7 +204,7 @@ abstract class ReferencePipeline<P_IN, P_OUT> ...@@ -205,7 +204,7 @@ abstract class ReferencePipeline<P_IN, P_OUT>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<P_OUT> opWrapSink(int flags, Sink<Integer> sink) { Sink<P_OUT> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedReference<P_OUT>(sink) { return new Sink.ChainedReference<P_OUT, Integer>(sink) {
@Override @Override
public void accept(P_OUT u) { public void accept(P_OUT u) {
downstream.accept(mapper.applyAsInt(u)); downstream.accept(mapper.applyAsInt(u));
...@@ -222,7 +221,7 @@ abstract class ReferencePipeline<P_IN, P_OUT> ...@@ -222,7 +221,7 @@ abstract class ReferencePipeline<P_IN, P_OUT>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<P_OUT> opWrapSink(int flags, Sink<Long> sink) { Sink<P_OUT> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedReference<P_OUT>(sink) { return new Sink.ChainedReference<P_OUT, Long>(sink) {
@Override @Override
public void accept(P_OUT u) { public void accept(P_OUT u) {
downstream.accept(mapper.applyAsLong(u)); downstream.accept(mapper.applyAsLong(u));
...@@ -239,7 +238,7 @@ abstract class ReferencePipeline<P_IN, P_OUT> ...@@ -239,7 +238,7 @@ abstract class ReferencePipeline<P_IN, P_OUT>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override @Override
Sink<P_OUT> opWrapSink(int flags, Sink<Double> sink) { Sink<P_OUT> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedReference<P_OUT>(sink) { return new Sink.ChainedReference<P_OUT, Double>(sink) {
@Override @Override
public void accept(P_OUT u) { public void accept(P_OUT u) {
downstream.accept(mapper.applyAsDouble(u)); downstream.accept(mapper.applyAsDouble(u));
...@@ -257,14 +256,13 @@ abstract class ReferencePipeline<P_IN, P_OUT> ...@@ -257,14 +256,13 @@ abstract class ReferencePipeline<P_IN, P_OUT>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
@Override @Override
Sink<P_OUT> opWrapSink(int flags, Sink<R> sink) { Sink<P_OUT> opWrapSink(int flags, Sink<R> sink) {
return new Sink.ChainedReference<P_OUT>(sink) { return new Sink.ChainedReference<P_OUT, R>(sink) {
@Override @Override
public void begin(long size) { public void begin(long size) {
downstream.begin(-1); downstream.begin(-1);
} }
@Override @Override
@SuppressWarnings("unchecked")
public void accept(P_OUT u) { public void accept(P_OUT u) {
// We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
Stream<? extends R> result = mapper.apply(u); Stream<? extends R> result = mapper.apply(u);
...@@ -284,7 +282,7 @@ abstract class ReferencePipeline<P_IN, P_OUT> ...@@ -284,7 +282,7 @@ abstract class ReferencePipeline<P_IN, P_OUT>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
@Override @Override
Sink<P_OUT> opWrapSink(int flags, Sink<Integer> sink) { Sink<P_OUT> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedReference<P_OUT>(sink) { return new Sink.ChainedReference<P_OUT, Integer>(sink) {
IntConsumer downstreamAsInt = downstream::accept; IntConsumer downstreamAsInt = downstream::accept;
@Override @Override
public void begin(long size) { public void begin(long size) {
...@@ -311,7 +309,7 @@ abstract class ReferencePipeline<P_IN, P_OUT> ...@@ -311,7 +309,7 @@ abstract class ReferencePipeline<P_IN, P_OUT>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
@Override @Override
Sink<P_OUT> opWrapSink(int flags, Sink<Double> sink) { Sink<P_OUT> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedReference<P_OUT>(sink) { return new Sink.ChainedReference<P_OUT, Double>(sink) {
DoubleConsumer downstreamAsDouble = downstream::accept; DoubleConsumer downstreamAsDouble = downstream::accept;
@Override @Override
public void begin(long size) { public void begin(long size) {
...@@ -338,7 +336,7 @@ abstract class ReferencePipeline<P_IN, P_OUT> ...@@ -338,7 +336,7 @@ abstract class ReferencePipeline<P_IN, P_OUT>
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) { StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
@Override @Override
Sink<P_OUT> opWrapSink(int flags, Sink<Long> sink) { Sink<P_OUT> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedReference<P_OUT>(sink) { return new Sink.ChainedReference<P_OUT, Long>(sink) {
LongConsumer downstreamAsLong = downstream::accept; LongConsumer downstreamAsLong = downstream::accept;
@Override @Override
public void begin(long size) { public void begin(long size) {
...@@ -364,9 +362,8 @@ abstract class ReferencePipeline<P_IN, P_OUT> ...@@ -364,9 +362,8 @@ abstract class ReferencePipeline<P_IN, P_OUT>
0) { 0) {
@Override @Override
Sink<P_OUT> opWrapSink(int flags, Sink<P_OUT> sink) { Sink<P_OUT> opWrapSink(int flags, Sink<P_OUT> sink) {
return new Sink.ChainedReference<P_OUT>(sink) { return new Sink.ChainedReference<P_OUT, P_OUT>(sink) {
@Override @Override
@SuppressWarnings("unchecked")
public void accept(P_OUT u) { public void accept(P_OUT u) {
tee.accept(u); tee.accept(u);
downstream.accept(u); downstream.accept(u);
...@@ -495,6 +492,7 @@ abstract class ReferencePipeline<P_IN, P_OUT> ...@@ -495,6 +492,7 @@ abstract class ReferencePipeline<P_IN, P_OUT>
} }
@Override @Override
@SuppressWarnings("unchecked")
public final <R, A> R collect(Collector<? super P_OUT, A, ? extends R> collector) { public final <R, A> R collect(Collector<? super P_OUT, A, ? extends R> collector) {
A container; A container;
if (isParallel() if (isParallel()
......
...@@ -241,11 +241,10 @@ interface Sink<T> extends Consumer<T> { ...@@ -241,11 +241,10 @@ interface Sink<T> extends Consumer<T> {
* implementation of the {@code accept()} method must call the correct * implementation of the {@code accept()} method must call the correct
* {@code accept()} method on the downstream {@code Sink}. * {@code accept()} method on the downstream {@code Sink}.
*/ */
static abstract class ChainedReference<T> implements Sink<T> { static abstract class ChainedReference<T, E_OUT> implements Sink<T> {
@SuppressWarnings("rawtypes") protected final Sink<? super E_OUT> downstream;
protected final Sink downstream;
public ChainedReference(Sink downstream) { public ChainedReference(Sink<? super E_OUT> downstream) {
this.downstream = Objects.requireNonNull(downstream); this.downstream = Objects.requireNonNull(downstream);
} }
...@@ -274,11 +273,10 @@ interface Sink<T> extends Consumer<T> { ...@@ -274,11 +273,10 @@ interface Sink<T> extends Consumer<T> {
* The implementation of the {@code accept()} method must call the correct * The implementation of the {@code accept()} method must call the correct
* {@code accept()} method on the downstream {@code Sink}. * {@code accept()} method on the downstream {@code Sink}.
*/ */
static abstract class ChainedInt implements Sink.OfInt { static abstract class ChainedInt<E_OUT> implements Sink.OfInt {
@SuppressWarnings("rawtypes") protected final Sink<? super E_OUT> downstream;
protected final Sink downstream;
public ChainedInt(Sink downstream) { public ChainedInt(Sink<? super E_OUT> downstream) {
this.downstream = Objects.requireNonNull(downstream); this.downstream = Objects.requireNonNull(downstream);
} }
...@@ -307,11 +305,10 @@ interface Sink<T> extends Consumer<T> { ...@@ -307,11 +305,10 @@ interface Sink<T> extends Consumer<T> {
* The implementation of the {@code accept()} method must call the correct * The implementation of the {@code accept()} method must call the correct
* {@code accept()} method on the downstream {@code Sink}. * {@code accept()} method on the downstream {@code Sink}.
*/ */
static abstract class ChainedLong implements Sink.OfLong { static abstract class ChainedLong<E_OUT> implements Sink.OfLong {
@SuppressWarnings("rawtypes") protected final Sink<? super E_OUT> downstream;
protected final Sink downstream;
public ChainedLong(Sink downstream) { public ChainedLong(Sink<? super E_OUT> downstream) {
this.downstream = Objects.requireNonNull(downstream); this.downstream = Objects.requireNonNull(downstream);
} }
...@@ -340,11 +337,10 @@ interface Sink<T> extends Consumer<T> { ...@@ -340,11 +337,10 @@ interface Sink<T> extends Consumer<T> {
* The implementation of the {@code accept()} method must call the correct * The implementation of the {@code accept()} method must call the correct
* {@code accept()} method on the downstream {@code Sink}. * {@code accept()} method on the downstream {@code Sink}.
*/ */
static abstract class ChainedDouble implements Sink.OfDouble { static abstract class ChainedDouble<E_OUT> implements Sink.OfDouble {
@SuppressWarnings("rawtypes") protected final Sink<? super E_OUT> downstream;
protected final Sink downstream;
public ChainedDouble(Sink downstream) { public ChainedDouble(Sink<? super E_OUT> downstream) {
this.downstream = Objects.requireNonNull(downstream); this.downstream = Objects.requireNonNull(downstream);
} }
......
...@@ -96,6 +96,11 @@ final class SliceOps { ...@@ -96,6 +96,11 @@ final class SliceOps {
} }
} }
@SuppressWarnings("unchecked")
private static <T> IntFunction<T[]> castingArray() {
return size -> (T[]) new Object[size];
}
/** /**
* Appends a "slice" operation to the provided stream. The slice operation * Appends a "slice" operation to the provided stream. The slice operation
* may be may be skip-only, limit-only, or skip-and-limit. * may be may be skip-only, limit-only, or skip-and-limit.
...@@ -111,7 +116,7 @@ final class SliceOps { ...@@ -111,7 +116,7 @@ final class SliceOps {
if (skip < 0) if (skip < 0)
throw new IllegalArgumentException("Skip must be non-negative: " + skip); throw new IllegalArgumentException("Skip must be non-negative: " + skip);
return new ReferencePipeline.StatefulOp<T,T>(upstream, StreamShape.REFERENCE, return new ReferencePipeline.StatefulOp<T, T>(upstream, StreamShape.REFERENCE,
flags(limit)) { flags(limit)) {
Spliterator<T> unorderedSkipLimitSpliterator(Spliterator<T> s, Spliterator<T> unorderedSkipLimitSpliterator(Spliterator<T> s,
long skip, long limit, long sizeIfKnown) { long skip, long limit, long sizeIfKnown) {
...@@ -146,7 +151,7 @@ final class SliceOps { ...@@ -146,7 +151,7 @@ final class SliceOps {
// cancellation will be more aggressive cancelling later tasks // cancellation will be more aggressive cancelling later tasks
// if the target slice size has been reached from a given task, // if the target slice size has been reached from a given task,
// cancellation should also clear local results if any // cancellation should also clear local results if any
return new SliceTask<>(this, helper, spliterator, i -> (T[]) new Object[i], skip, limit). return new SliceTask<>(this, helper, spliterator, castingArray(), skip, limit).
invoke().spliterator(); invoke().spliterator();
} }
} }
...@@ -182,7 +187,7 @@ final class SliceOps { ...@@ -182,7 +187,7 @@ final class SliceOps {
@Override @Override
Sink<T> opWrapSink(int flags, Sink<T> sink) { Sink<T> opWrapSink(int flags, Sink<T> sink) {
return new Sink.ChainedReference<T>(sink) { return new Sink.ChainedReference<T, T>(sink) {
long n = skip; long n = skip;
long m = limit >= 0 ? limit : Long.MAX_VALUE; long m = limit >= 0 ? limit : Long.MAX_VALUE;
...@@ -291,7 +296,7 @@ final class SliceOps { ...@@ -291,7 +296,7 @@ final class SliceOps {
@Override @Override
Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) { Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
return new Sink.ChainedInt(sink) { return new Sink.ChainedInt<Integer>(sink) {
long n = skip; long n = skip;
long m = limit >= 0 ? limit : Long.MAX_VALUE; long m = limit >= 0 ? limit : Long.MAX_VALUE;
...@@ -400,7 +405,7 @@ final class SliceOps { ...@@ -400,7 +405,7 @@ final class SliceOps {
@Override @Override
Sink<Long> opWrapSink(int flags, Sink<Long> sink) { Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
return new Sink.ChainedLong(sink) { return new Sink.ChainedLong<Long>(sink) {
long n = skip; long n = skip;
long m = limit >= 0 ? limit : Long.MAX_VALUE; long m = limit >= 0 ? limit : Long.MAX_VALUE;
...@@ -509,7 +514,7 @@ final class SliceOps { ...@@ -509,7 +514,7 @@ final class SliceOps {
@Override @Override
Sink<Double> opWrapSink(int flags, Sink<Double> sink) { Sink<Double> opWrapSink(int flags, Sink<Double> sink) {
return new Sink.ChainedDouble(sink) { return new Sink.ChainedDouble<Double>(sink) {
long n = skip; long n = skip;
long m = limit >= 0 ? limit : Long.MAX_VALUE; long m = limit >= 0 ? limit : Long.MAX_VALUE;
...@@ -560,13 +565,13 @@ final class SliceOps { ...@@ -560,13 +565,13 @@ final class SliceOps {
private volatile boolean completed; private volatile boolean completed;
SliceTask(AbstractPipeline<?, P_OUT, ?> op, SliceTask(AbstractPipeline<P_OUT, P_OUT, ?> op,
PipelineHelper<P_OUT> helper, PipelineHelper<P_OUT> helper,
Spliterator<P_IN> spliterator, Spliterator<P_IN> spliterator,
IntFunction<P_OUT[]> generator, IntFunction<P_OUT[]> generator,
long offset, long size) { long offset, long size) {
super(helper, spliterator); super(helper, spliterator);
this.op = (AbstractPipeline<P_OUT, P_OUT, ?>) op; this.op = op;
this.generator = generator; this.generator = generator;
this.targetOffset = offset; this.targetOffset = offset;
this.targetSize = size; this.targetSize = size;
......
...@@ -129,7 +129,7 @@ final class SortedOps { ...@@ -129,7 +129,7 @@ final class SortedOps {
} }
@Override @Override
public Sink<T> opWrapSink(int flags, Sink sink) { public Sink<T> opWrapSink(int flags, Sink<T> sink) {
Objects.requireNonNull(sink); Objects.requireNonNull(sink);
// If the input is already naturally sorted and this operation // If the input is already naturally sorted and this operation
...@@ -280,12 +280,12 @@ final class SortedOps { ...@@ -280,12 +280,12 @@ final class SortedOps {
/** /**
* {@link ForkJoinTask} for implementing sort on SIZED reference streams. * {@link ForkJoinTask} for implementing sort on SIZED reference streams.
*/ */
private static final class SizedRefSortingSink<T> extends Sink.ChainedReference<T> { private static final class SizedRefSortingSink<T> extends Sink.ChainedReference<T, T> {
private final Comparator<? super T> comparator; private final Comparator<? super T> comparator;
private T[] array; private T[] array;
private int offset; private int offset;
SizedRefSortingSink(Sink<T> sink, Comparator<? super T> comparator) { SizedRefSortingSink(Sink<? super T> sink, Comparator<? super T> comparator) {
super(sink); super(sink);
this.comparator = comparator; this.comparator = comparator;
} }
...@@ -320,11 +320,11 @@ final class SortedOps { ...@@ -320,11 +320,11 @@ final class SortedOps {
/** /**
* {@link Sink} for implementing sort on reference streams. * {@link Sink} for implementing sort on reference streams.
*/ */
private static final class RefSortingSink<T> extends Sink.ChainedReference<T> { private static final class RefSortingSink<T> extends Sink.ChainedReference<T, T> {
private final Comparator<? super T> comparator; private final Comparator<? super T> comparator;
private ArrayList<T> list; private ArrayList<T> list;
RefSortingSink(Sink<T> sink, Comparator<? super T> comparator) { RefSortingSink(Sink<? super T> sink, Comparator<? super T> comparator) {
super(sink); super(sink);
this.comparator = comparator; this.comparator = comparator;
} }
...@@ -352,11 +352,11 @@ final class SortedOps { ...@@ -352,11 +352,11 @@ final class SortedOps {
/** /**
* {@link Sink} for implementing sort on SIZED int streams. * {@link Sink} for implementing sort on SIZED int streams.
*/ */
private static final class SizedIntSortingSink extends Sink.ChainedInt { private static final class SizedIntSortingSink extends Sink.ChainedInt<Integer> {
private int[] array; private int[] array;
private int offset; private int offset;
SizedIntSortingSink(Sink downstream) { SizedIntSortingSink(Sink<? super Integer> downstream) {
super(downstream); super(downstream);
} }
...@@ -386,10 +386,10 @@ final class SortedOps { ...@@ -386,10 +386,10 @@ final class SortedOps {
/** /**
* {@link Sink} for implementing sort on int streams. * {@link Sink} for implementing sort on int streams.
*/ */
private static final class IntSortingSink extends Sink.ChainedInt { private static final class IntSortingSink extends Sink.ChainedInt<Integer> {
private SpinedBuffer.OfInt b; private SpinedBuffer.OfInt b;
IntSortingSink(Sink sink) { IntSortingSink(Sink<? super Integer> sink) {
super(sink); super(sink);
} }
...@@ -417,11 +417,11 @@ final class SortedOps { ...@@ -417,11 +417,11 @@ final class SortedOps {
/** /**
* {@link Sink} for implementing sort on SIZED long streams. * {@link Sink} for implementing sort on SIZED long streams.
*/ */
private static final class SizedLongSortingSink extends Sink.ChainedLong { private static final class SizedLongSortingSink extends Sink.ChainedLong<Long> {
private long[] array; private long[] array;
private int offset; private int offset;
SizedLongSortingSink(Sink downstream) { SizedLongSortingSink(Sink<? super Long> downstream) {
super(downstream); super(downstream);
} }
...@@ -451,10 +451,10 @@ final class SortedOps { ...@@ -451,10 +451,10 @@ final class SortedOps {
/** /**
* {@link Sink} for implementing sort on long streams. * {@link Sink} for implementing sort on long streams.
*/ */
private static final class LongSortingSink extends Sink.ChainedLong { private static final class LongSortingSink extends Sink.ChainedLong<Long> {
private SpinedBuffer.OfLong b; private SpinedBuffer.OfLong b;
LongSortingSink(Sink sink) { LongSortingSink(Sink<? super Long> sink) {
super(sink); super(sink);
} }
...@@ -482,11 +482,11 @@ final class SortedOps { ...@@ -482,11 +482,11 @@ final class SortedOps {
/** /**
* {@link Sink} for implementing sort on SIZED double streams. * {@link Sink} for implementing sort on SIZED double streams.
*/ */
private static final class SizedDoubleSortingSink extends Sink.ChainedDouble { private static final class SizedDoubleSortingSink extends Sink.ChainedDouble<Double> {
private double[] array; private double[] array;
private int offset; private int offset;
SizedDoubleSortingSink(Sink downstream) { SizedDoubleSortingSink(Sink<? super Double> downstream) {
super(downstream); super(downstream);
} }
...@@ -516,10 +516,10 @@ final class SortedOps { ...@@ -516,10 +516,10 @@ final class SortedOps {
/** /**
* {@link Sink} for implementing sort on double streams. * {@link Sink} for implementing sort on double streams.
*/ */
private static final class DoubleSortingSink extends Sink.ChainedDouble { private static final class DoubleSortingSink extends Sink.ChainedDouble<Double> {
private SpinedBuffer.OfDouble b; private SpinedBuffer.OfDouble b;
DoubleSortingSink(Sink sink) { DoubleSortingSink(Sink<? super Double> sink) {
super(sink); super(sink);
} }
......
...@@ -663,6 +663,9 @@ class ZipOutputStream extends DeflaterOutputStream implements ZipConstants { ...@@ -663,6 +663,9 @@ class ZipOutputStream extends DeflaterOutputStream implements ZipConstants {
while (off + 4 <= len) { while (off + 4 <= len) {
int tag = get16(extra, off); int tag = get16(extra, off);
int sz = get16(extra, off + 2); int sz = get16(extra, off + 2);
if (sz < 0 || (off + 4 + sz) > len) {
break;
}
if (tag == EXTID_EXTT || tag == EXTID_ZIP64) { if (tag == EXTID_EXTT || tag == EXTID_ZIP64) {
skipped += (sz + 4); skipped += (sz + 4);
} }
...@@ -684,11 +687,18 @@ class ZipOutputStream extends DeflaterOutputStream implements ZipConstants { ...@@ -684,11 +687,18 @@ class ZipOutputStream extends DeflaterOutputStream implements ZipConstants {
while (off + 4 <= len) { while (off + 4 <= len) {
int tag = get16(extra, off); int tag = get16(extra, off);
int sz = get16(extra, off + 2); int sz = get16(extra, off + 2);
if (sz < 0 || (off + 4 + sz) > len) {
writeBytes(extra, off, len - off);
return;
}
if (tag != EXTID_EXTT && tag != EXTID_ZIP64) { if (tag != EXTID_EXTT && tag != EXTID_ZIP64) {
writeBytes(extra, off, sz + 4); writeBytes(extra, off, sz + 4);
} }
off += (sz + 4); off += (sz + 4);
} }
if (off < len) {
writeBytes(extra, off, len - off);
}
} }
} }
......
/* /*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 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
...@@ -293,6 +293,7 @@ public final class SNIHostName extends SNIServerName { ...@@ -293,6 +293,7 @@ public final class SNIHostName extends SNIServerName {
* the <a href="{@docRoot}/java/util/regex/Pattern.html#sum"> * the <a href="{@docRoot}/java/util/regex/Pattern.html#sum">
* regular expression pattern</a> * regular expression pattern</a>
* representing the hostname(s) to match * representing the hostname(s) to match
* @return a {@code SNIMatcher} object for {@code SNIHostName}s
* @throws NullPointerException if {@code regex} is * @throws NullPointerException if {@code regex} is
* {@code null} * {@code null}
* @throws java.util.regex.PatternSyntaxException if the regular expression's * @throws java.util.regex.PatternSyntaxException if the regular expression's
......
/* /*
* Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 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
...@@ -40,7 +40,7 @@ import java.net.Socket; ...@@ -40,7 +40,7 @@ import java.net.Socket;
* <UL> * <UL>
* <LI> determine the set of aliases that are available for negotiations * <LI> determine the set of aliases that are available for negotiations
* based on the criteria presented, * based on the criteria presented,
* <LI> select the <ITALIC> best alias </ITALIC> based on * <LI> select the <i> best alias</i> based on
* the criteria presented, and * the criteria presented, and
* <LI> obtain the corresponding key material for given aliases. * <LI> obtain the corresponding key material for given aliases.
* </UL> * </UL>
......
...@@ -197,8 +197,7 @@ public final class KerberosPrincipal ...@@ -197,8 +197,7 @@ public final class KerberosPrincipal
* {@code KerberosPrincipal} and the two * {@code KerberosPrincipal} and the two
* {@code KerberosPrincipal} instances are equivalent. * {@code KerberosPrincipal} instances are equivalent.
* More formally two {@code KerberosPrincipal} instances are equal * More formally two {@code KerberosPrincipal} instances are equal
* if the values returned by {@code getName()} are equal and the * if the values returned by {@code getName()} are equal.
* values returned by {@code getNameType()} are equal.
* *
* @param other the Object to compare to * @param other the Object to compare to
* @return true if the Object passed in represents the same principal * @return true if the Object passed in represents the same principal
...@@ -211,15 +210,10 @@ public final class KerberosPrincipal ...@@ -211,15 +210,10 @@ public final class KerberosPrincipal
if (! (other instanceof KerberosPrincipal)) { if (! (other instanceof KerberosPrincipal)) {
return false; return false;
} else { }
String myFullName = getName(); String myFullName = getName();
String otherFullName = ((KerberosPrincipal) other).getName(); String otherFullName = ((KerberosPrincipal) other).getName();
if (nameType == ((KerberosPrincipal)other).nameType && return myFullName.equals(otherFullName);
myFullName.equals(otherFullName)) {
return true;
}
}
return false;
} }
/** /**
......
...@@ -193,9 +193,4 @@ abstract class AbstractPollSelectorImpl ...@@ -193,9 +193,4 @@ abstract class AbstractPollSelectorImpl
if (!selch.isOpen() && !selch.isRegistered()) if (!selch.isOpen() && !selch.isRegistered())
((SelChImpl)selch).kill(); ((SelChImpl)selch).kill();
} }
static {
Util.load();
}
} }
...@@ -1138,7 +1138,7 @@ class DatagramChannelImpl ...@@ -1138,7 +1138,7 @@ class DatagramChannelImpl
throws IOException; throws IOException;
static { static {
Util.load(); IOUtil.load();
initIDs(); initIDs();
} }
......
...@@ -1162,7 +1162,7 @@ public class FileChannelImpl ...@@ -1162,7 +1162,7 @@ public class FileChannelImpl
private static native long initIDs(); private static native long initIDs();
static { static {
Util.load(); IOUtil.load();
allocationGranularity = initIDs(); allocationGranularity = initIDs();
} }
......
...@@ -347,9 +347,23 @@ public class IOUtil { ...@@ -347,9 +347,23 @@ public class IOUtil {
static native void initIDs(); static native void initIDs();
/**
* Used to trigger loading of native libraries
*/
public static void load() { }
static { static {
// Note that IOUtil.initIDs is called from within Util.load. java.security.AccessController.doPrivileged(
Util.load(); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("net");
System.loadLibrary("nio");
return null;
}
});
initIDs();
IOV_MAX = iovMax(); IOV_MAX = iovMax();
} }
......
...@@ -582,7 +582,7 @@ public class Net { ...@@ -582,7 +582,7 @@ public class Net {
private static native void initIDs(); private static native void initIDs();
static { static {
Util.load(); IOUtil.load();
initIDs(); initIDs();
} }
......
...@@ -416,7 +416,7 @@ class ServerSocketChannelImpl ...@@ -416,7 +416,7 @@ class ServerSocketChannelImpl
private static native void initIDs(); private static native void initIDs();
static { static {
Util.load(); IOUtil.load();
initIDs(); initIDs();
nd = new SocketDispatcher(); nd = new SocketDispatcher();
} }
......
...@@ -1024,7 +1024,7 @@ class SocketChannelImpl ...@@ -1024,7 +1024,7 @@ class SocketChannelImpl
throws IOException; throws IOException;
static { static {
Util.load(); IOUtil.load();
nd = new SocketDispatcher(); nd = new SocketDispatcher();
} }
......
...@@ -401,30 +401,4 @@ public class Util { ...@@ -401,30 +401,4 @@ public class Util {
return bugLevel.equals(bl); return bugLevel.equals(bl);
} }
// -- Initialization --
private static boolean loaded = false;
public static void load() {
synchronized (Util.class) {
if (loaded)
return;
loaded = true;
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("net");
System.loadLibrary("nio");
return null;
}
});
// IOUtil must be initialized; Its native methods are called from
// other places in native nio code so they must be set up.
IOUtil.initIDs();
}
}
} }
/* /*
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2004, 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
...@@ -268,8 +268,13 @@ public class ConnectDialog extends InternalDialog ...@@ -268,8 +268,13 @@ public class ConnectDialog extends InternalDialog
public void revalidate() { public void revalidate() {
// Adjust some colors // Adjust some colors
Color disabledForeground = UIManager.getColor("Label.disabledForeground");
if (disabledForeground == null) {
// fall back for Nimbus that doesn't support 'Label.disabledForeground'
disabledForeground = UIManager.getColor("Label.disabledText");
}
hintTextColor = hintTextColor =
ensureContrast(UIManager.getColor("Label.disabledForeground"), ensureContrast(disabledForeground,
UIManager.getColor("Panel.background")); UIManager.getColor("Panel.background"));
disabledTableCellColor = disabledTableCellColor =
ensureContrast(new Color(0x808080), ensureContrast(new Color(0x808080),
......
...@@ -858,6 +858,10 @@ public class JConsole extends JFrame ...@@ -858,6 +858,10 @@ public class JConsole extends JFrame
try { try {
updateInterval = Integer.parseInt(arg.substring(10)) * updateInterval = Integer.parseInt(arg.substring(10)) *
1000; 1000;
if (updateInterval <= 0) {
usage();
return;
}
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
usage(); usage();
return; return;
......
/* /*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 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
...@@ -146,7 +146,6 @@ final public class Messages { ...@@ -146,7 +146,6 @@ final public class Messages {
public static String HELP_ABOUT_DIALOG_MASTHEAD_ACCESSIBLE_NAME; public static String HELP_ABOUT_DIALOG_MASTHEAD_ACCESSIBLE_NAME;
public static String HELP_ABOUT_DIALOG_MASTHEAD_TITLE; public static String HELP_ABOUT_DIALOG_MASTHEAD_TITLE;
public static String HELP_ABOUT_DIALOG_TITLE; public static String HELP_ABOUT_DIALOG_TITLE;
public static String HELP_ABOUT_DIALOG_USER_GUIDE_LINK;
public static String HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL; public static String HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL;
public static String HELP_MENU_ABOUT_TITLE; public static String HELP_MENU_ABOUT_TITLE;
public static String HELP_MENU_USER_GUIDE_TITLE; public static String HELP_MENU_USER_GUIDE_TITLE;
...@@ -272,6 +271,7 @@ final public class Messages { ...@@ -272,6 +271,7 @@ final public class Messages {
public static String THREADS; public static String THREADS;
public static String THREAD_TAB_THREAD_INFO_ACCESSIBLE_NAME; public static String THREAD_TAB_THREAD_INFO_ACCESSIBLE_NAME;
public static String THREAD_TAB_THREAD_PLOTTER_ACCESSIBLE_NAME; public static String THREAD_TAB_THREAD_PLOTTER_ACCESSIBLE_NAME;
public static String THREAD_TAB_INITIAL_STACK_TRACE_MESSAGE;
public static String THRESHOLD; public static String THRESHOLD;
public static String TILE; public static String TILE;
public static String TIME_RANGE_COLON; public static String TIME_RANGE_COLON;
......
/* /*
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2004, 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
...@@ -337,6 +337,13 @@ public class Plotter extends JComponent ...@@ -337,6 +337,13 @@ public class Plotter extends JComponent
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
int width = getWidth()-rightMargin-leftMargin-10;
int height = getHeight()-topMargin-bottomMargin;
if (width <= 0 || height <= 0) {
// not enough room to paint anything
return;
}
Color oldColor = g.getColor(); Color oldColor = g.getColor();
Font oldFont = g.getFont(); Font oldFont = g.getFont();
Color fg = getForeground(); Color fg = getForeground();
......
...@@ -595,6 +595,8 @@ class ThreadTab extends Tab implements ActionListener, DocumentListener, ListSel ...@@ -595,6 +595,8 @@ class ThreadTab extends Tab implements ActionListener, DocumentListener, ListSel
setBorder(thinEmptyBorder); setBorder(thinEmptyBorder);
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
textArea.setText(Messages.THREAD_TAB_INITIAL_STACK_TRACE_MESSAGE);
addListSelectionListener(ThreadTab.this); addListSelectionListener(ThreadTab.this);
setCellRenderer(new DefaultListCellRenderer() { setCellRenderer(new DefaultListCellRenderer() {
public Component getListCellRendererComponent(JList<?> list, Object value, int index, public Component getListCellRendererComponent(JList<?> list, Object value, int index,
......
...@@ -153,9 +153,11 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener { ...@@ -153,9 +153,11 @@ public class VMPanel extends JTabbedPane implements PropertyChangeListener {
// in order to reserve space for the connect toggle. // in order to reserve space for the connect toggle.
public void setUI(TabbedPaneUI ui) { public void setUI(TabbedPaneUI ui) {
Insets insets = (Insets) UIManager.getLookAndFeelDefaults().get("TabbedPane.tabAreaInsets"); Insets insets = (Insets) UIManager.getLookAndFeelDefaults().get("TabbedPane.tabAreaInsets");
if (insets != null) {
insets = (Insets) insets.clone(); insets = (Insets) insets.clone();
insets.right += connectedIcon24.getIconWidth() + 8; insets.right += connectedIcon24.getIconWidth() + 8;
UIManager.put("TabbedPane.tabAreaInsets", insets); UIManager.put("TabbedPane.tabAreaInsets", insets);
}
super.setUI(ui); super.setUI(ui);
} }
......
...@@ -104,7 +104,6 @@ HELP_ABOUT_DIALOG_JAVA_VERSION=Java VM version:<br>{0} ...@@ -104,7 +104,6 @@ HELP_ABOUT_DIALOG_JAVA_VERSION=Java VM version:<br>{0}
HELP_ABOUT_DIALOG_MASTHEAD_ACCESSIBLE_NAME=Masthead Graphic HELP_ABOUT_DIALOG_MASTHEAD_ACCESSIBLE_NAME=Masthead Graphic
HELP_ABOUT_DIALOG_MASTHEAD_TITLE=About JConsole HELP_ABOUT_DIALOG_MASTHEAD_TITLE=About JConsole
HELP_ABOUT_DIALOG_TITLE=JConsole: About HELP_ABOUT_DIALOG_TITLE=JConsole: About
HELP_ABOUT_DIALOG_USER_GUIDE_LINK=JConsole &User Guide:<br>{0}
HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL=http://docs.oracle.com/javase/{0}/docs/technotes/guides/management/jconsole.html HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL=http://docs.oracle.com/javase/{0}/docs/technotes/guides/management/jconsole.html
HELP_MENU_ABOUT_TITLE=&About JConsole HELP_MENU_ABOUT_TITLE=&About JConsole
HELP_MENU_USER_GUIDE_TITLE=Online &User Guide HELP_MENU_USER_GUIDE_TITLE=Online &User Guide
...@@ -230,6 +229,7 @@ SUMMARY_TAB_VM_VERSION={0} version {1} ...@@ -230,6 +229,7 @@ SUMMARY_TAB_VM_VERSION={0} version {1}
THREADS=Threads THREADS=Threads
THREAD_TAB_THREAD_INFO_ACCESSIBLE_NAME=Thread Information THREAD_TAB_THREAD_INFO_ACCESSIBLE_NAME=Thread Information
THREAD_TAB_THREAD_PLOTTER_ACCESSIBLE_NAME=Chart for number of threads. THREAD_TAB_THREAD_PLOTTER_ACCESSIBLE_NAME=Chart for number of threads.
THREAD_TAB_INITIAL_STACK_TRACE_MESSAGE=[No thread selected]
THRESHOLD=Threshold THRESHOLD=Threshold
TILE=&Tile TILE=&Tile
TIME_RANGE_COLON=&Time Range: TIME_RANGE_COLON=&Time Range:
......
...@@ -104,7 +104,6 @@ HELP_ABOUT_DIALOG_JAVA_VERSION=Java VM\u30D0\u30FC\u30B8\u30E7\u30F3:<br>{0} ...@@ -104,7 +104,6 @@ HELP_ABOUT_DIALOG_JAVA_VERSION=Java VM\u30D0\u30FC\u30B8\u30E7\u30F3:<br>{0}
HELP_ABOUT_DIALOG_MASTHEAD_ACCESSIBLE_NAME=\u30DE\u30B9\u30C8\u30D8\u30C3\u30C9\u56F3\u5F62 HELP_ABOUT_DIALOG_MASTHEAD_ACCESSIBLE_NAME=\u30DE\u30B9\u30C8\u30D8\u30C3\u30C9\u56F3\u5F62
HELP_ABOUT_DIALOG_MASTHEAD_TITLE=JConsole\u306B\u3064\u3044\u3066 HELP_ABOUT_DIALOG_MASTHEAD_TITLE=JConsole\u306B\u3064\u3044\u3066
HELP_ABOUT_DIALOG_TITLE=JConsole: \u8A73\u7D30 HELP_ABOUT_DIALOG_TITLE=JConsole: \u8A73\u7D30
HELP_ABOUT_DIALOG_USER_GUIDE_LINK=JConsole\u30E6\u30FC\u30B6\u30FC\u30FB\u30AC\u30A4\u30C9(&U):<br>{0}
HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL=http://docs.oracle.com/javase/{0}/docs/technotes/guides/management/jconsole.html HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL=http://docs.oracle.com/javase/{0}/docs/technotes/guides/management/jconsole.html
HELP_MENU_ABOUT_TITLE=JConsole\u306B\u3064\u3044\u3066(&A) HELP_MENU_ABOUT_TITLE=JConsole\u306B\u3064\u3044\u3066(&A)
HELP_MENU_USER_GUIDE_TITLE=\u30AA\u30F3\u30E9\u30A4\u30F3\u30FB\u30E6\u30FC\u30B6\u30FC\u30FB\u30AC\u30A4\u30C9(&U) HELP_MENU_USER_GUIDE_TITLE=\u30AA\u30F3\u30E9\u30A4\u30F3\u30FB\u30E6\u30FC\u30B6\u30FC\u30FB\u30AC\u30A4\u30C9(&U)
......
此差异已折叠。
...@@ -9,3 +9,6 @@ othervm.dirs=java/awt java/beans java/rmi javax/accessibility javax/imageio java ...@@ -9,3 +9,6 @@ othervm.dirs=java/awt java/beans java/rmi javax/accessibility javax/imageio java
# Tests that cannot run concurrently # Tests that cannot run concurrently
exclusiveAccess.dirs=java/rmi/Naming java/util/Currency java/util/prefs sun/management/jmxremote sun/tools/jstatd sun/security/mscapi exclusiveAccess.dirs=java/rmi/Naming java/util/Currency java/util/prefs sun/management/jmxremote sun/tools/jstatd sun/security/mscapi
# Group definitions
groups=TEST.groups [closed/TEST.groups]
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册