# HG changeset patch
# User lana
# Date 1425597802 28800
# Node ID 690957fb08621006cdff4da33d0436c4e041d160
# Parent 4f62c57aef4eb7856b8b2d138925c97492b9a6aa# Parent c4467840385788d636cdb075a820aec4d3e20b6b
Merge
diff -r 4f62c57aef4e -r 690957fb0862 jdk/make/Tools.gmk
--- a/jdk/make/Tools.gmk Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/make/Tools.gmk Thu Mar 05 15:23:22 2015 -0800
@@ -180,6 +180,8 @@
OBJECT_DIR := $(BUILDTOOLS_OUTPUTDIR)/objs/fix_empty_sec_hdr_flags, \
OUTPUT_DIR := $(BUILDTOOLS_OUTPUTDIR)/bin, \
PROGRAM := fix_empty_sec_hdr_flags))
+
+ BUILD_TOOLS_JDK += $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS)
endif
$(BUILD_TOOLS_JDK): $(BUILD_INTERIM_JIMAGE) $(COPY_JIMAGE_SERVICE_PROVIDER)
@@ -189,4 +191,3 @@
all: java-tools
endif # _TOOLS_GMK
-
diff -r 4f62c57aef4e -r 690957fb0862 jdk/make/copy/Copy-java.desktop.gmk
--- a/jdk/make/copy/Copy-java.desktop.gmk Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/make/copy/Copy-java.desktop.gmk Thu Mar 05 15:23:22 2015 -0800
@@ -100,34 +100,3 @@
TARGETS += $(PSFONTPROPFILE_TARGET_FILES)
################################################################################
-#
-# Copy cursor.properties and cursors gif files to LIB_DST_DIR
-#
-ifneq ($(OPENJDK_TARGET_OS), macosx)
- OPENJDK_TARGET_OS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/conf
-else
- OPENJDK_TARGET_OS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/macosx/conf
-endif
-
-CURSORS_DEST_DIR := $(LIB_DST_DIR)/images/cursors
-CURSORS_OPENJDK_TARGET_OS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/conf/images/cursors
-
-$(CURSORS_DEST_DIR)/cursors.properties: $(CURSORS_OPENJDK_TARGET_OS_LIB_SRC)/cursors.properties
- $(call install-file)
-
-TARGETS += $(CURSORS_DEST_DIR)/cursors.properties
-
-CURSORS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/share/conf/images/cursors
-ifeq ($(OPENJDK_TARGET_OS), windows)
- CURSORS_SRC_FILES := $(CURSORS_LIB_SRC)/invalid32x32.gif $(wildcard $(CURSORS_LIB_SRC)/win32_*.gif)
-else # OPENJDK_TARGET_OS
- CURSORS_SRC_FILES := $(CURSORS_LIB_SRC)/invalid32x32.gif $(wildcard $(CURSORS_LIB_SRC)/motif_*.gif)
-endif # OPENJDK_TARGET_OS
-CURSORS_TARGET_FILES := $(subst $(CURSORS_LIB_SRC),$(CURSORS_DEST_DIR),$(CURSORS_SRC_FILES))
-
-$(CURSORS_DEST_DIR)/%: $(CURSORS_LIB_SRC)/%
- $(call install-file)
-
-TARGETS += $(CURSORS_TARGET_FILES)
-
-################################################################################
diff -r 4f62c57aef4e -r 690957fb0862 jdk/make/gensrc/Gensrc-java.desktop.gmk
--- a/jdk/make/gensrc/Gensrc-java.desktop.gmk Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/make/gensrc/Gensrc-java.desktop.gmk Thu Mar 05 15:23:22 2015 -0800
@@ -66,8 +66,11 @@
PROP_SRC_DIRS += $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/resources
endif
+PROP_SRC_FILES := $(filter-out %cursors.properties, \
+ $(filter %.properties, $(call CacheFind, $(PROP_SRC_DIRS))))
+
$(eval $(call SetupCompileProperties,COMPILE_PROPERTIES, \
- $(filter %.properties, $(call CacheFind, $(PROP_SRC_DIRS))), ListResourceBundle))
+ $(PROP_SRC_FILES), ListResourceBundle))
GENSRC_JAVA_DESKTOP += $(COMPILE_PROPERTIES)
diff -r 4f62c57aef4e -r 690957fb0862 jdk/make/gensrc/Gensrc-java.management.gmk
--- a/jdk/make/gensrc/Gensrc-java.management.gmk Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/make/gensrc/Gensrc-java.management.gmk Thu Mar 05 15:23:22 2015 -0800
@@ -25,6 +25,9 @@
include GensrcCommon.gmk
+# Hook to include the corresponding custom file, if present.
+$(eval $(call IncludeCustomExtension, jdk, gensrc/Gensrc-java.management.gmk))
+
################################################################################
include GensrcProperties.gmk
diff -r 4f62c57aef4e -r 690957fb0862 jdk/make/lib/SoundLibraries.gmk
--- a/jdk/make/lib/SoundLibraries.gmk Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/make/lib/SoundLibraries.gmk Thu Mar 05 15:23:22 2015 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -114,38 +114,9 @@
endif # OPENJDK_TARGET_OS solaris
-ifeq ($(JVM_VARIANT_ZERO), true)
- LIBJSOUND_CFLAGS += -DX_ARCH=X_ZERO
-else
- ifeq ($(OPENJDK_TARGET_CPU), x86)
- LIBJSOUND_CFLAGS += -DX_ARCH=X_I586
- endif
-
- ifeq ($(OPENJDK_TARGET_CPU), sparc)
- LIBJSOUND_CFLAGS += -DX_ARCH=X_SPARC
- endif
-
- ifeq ($(OPENJDK_TARGET_CPU), sparcv9)
- LIBJSOUND_CFLAGS += -DX_ARCH=X_SPARCV9
+ ifeq ($(OPENJDK_TARGET_CPU), aarch64)
+ LIBJSOUND_CFLAGS += -DX_ARCH=X_AARCH64
endif
-
- ifeq ($(OPENJDK_TARGET_CPU), x86_64)
- LIBJSOUND_CFLAGS += -DX_ARCH=X_AMD64
- endif
-
- ifeq ($(OPENJDK_TARGET_CPU), arm)
- LIBJSOUND_CFLAGS += -DX_ARCH=X_ARM
- endif
-
- ifeq ($(OPENJDK_TARGET_CPU), ppc)
- LIBJSOUND_CFLAGS += -DX_ARCH=X_PPC
- endif
-
- ifeq ($(OPENJDK_TARGET_CPU), ppc64)
- LIBJSOUND_CFLAGS += -DX_ARCH=X_PPC64
- endif
-endif
-
LIBJSOUND_CFLAGS += -DEXTRA_SOUND_JNI_LIBS='"$(EXTRA_SOUND_JNI_LIBS)"'
$(eval $(call SetupNativeCompilation,BUILD_LIBJSOUND, \
diff -r 4f62c57aef4e -r 690957fb0862 jdk/make/mapfiles/libjsound/mapfile-vers
--- a/jdk/make/mapfiles/libjsound/mapfile-vers Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/make/mapfiles/libjsound/mapfile-vers Thu Mar 05 15:23:22 2015 -0800
@@ -68,7 +68,6 @@
Java_com_sun_media_sound_Platform_nGetExtraLibraries;
Java_com_sun_media_sound_Platform_nGetLibraryForFeature;
Java_com_sun_media_sound_Platform_nIsBigEndian;
- Java_com_sun_media_sound_Platform_nIsSigned8;
Java_com_sun_media_sound_PortMixer_nClose;
Java_com_sun_media_sound_PortMixer_nControlGetFloatValue;
Java_com_sun_media_sound_PortMixer_nControlGetIntValue;
diff -r 4f62c57aef4e -r 690957fb0862 jdk/make/src/classes/build/tools/module/boot.modules
--- a/jdk/make/src/classes/build/tools/module/boot.modules Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/make/src/classes/build/tools/module/boot.modules Thu Mar 05 15:23:22 2015 -0800
@@ -22,6 +22,7 @@
jdk.hprof.agent
jdk.httpserver
jdk.jfr
+jdk.management.cmm
jdk.naming.rmi
jdk.sctp
jdk.security.auth
diff -r 4f62c57aef4e -r 690957fb0862 jdk/make/test/JtregNative.gmk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/test/JtregNative.gmk Thu Mar 05 15:23:22 2015 -0800
@@ -0,0 +1,82 @@
+#
+# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+################################################################################
+# This file builds the native component of the JTReg tests for JDK.
+# It also covers the test-image part, where the built files are copied to the
+# test image.
+################################################################################
+
+default: all
+
+include $(SPEC)
+include MakeBase.gmk
+include TestFilesCompilation.gmk
+
+################################################################################
+# Targets for building the native tests themselves.
+################################################################################
+
+# Add more directories here when needed.
+BUILD_JDK_JTREG_NATIVE_SRC := \
+ $(JDK_TOPDIR)/test/native_sanity \
+ #
+
+BUILD_JDK_JTREG_OUTPUT_DIR := $(BUILD_OUTPUT)/support/test/jdk/jtreg/native
+
+BUILD_JDK_JTREG_IMAGE_DIR := $(TEST_IMAGE_DIR)/jdk/jtreg
+
+$(eval $(call SetupTestFilesCompilation, BUILD_JDK_JTREG_LIBRARIES, \
+ TYPE := LIBRARY, \
+ SOURCE_DIRS := $(BUILD_JDK_JTREG_NATIVE_SRC), \
+ OUTPUT_DIR := $(BUILD_JDK_JTREG_OUTPUT_DIR), \
+))
+
+$(eval $(call SetupTestFilesCompilation, BUILD_JDK_JTREG_EXECUTABLES, \
+ TYPE := PROGRAM, \
+ SOURCE_DIRS := $(BUILD_JDK_JTREG_NATIVE_SRC), \
+ OUTPUT_DIR := $(BUILD_JDK_JTREG_OUTPUT_DIR), \
+))
+
+build-test-jdk-jtreg-native: $(BUILD_JDK_JTREG_LIBRARIES) $(BUILD_JDK_JTREG_EXECUTABLES)
+
+
+################################################################################
+# Targets for building test-image.
+################################################################################
+
+# Copy to jdk jtreg test image
+$(eval $(call SetupCopyFiles,COPY_JDK_JTREG_NATIVE, \
+ SRC := $(BUILD_JDK_JTREG_OUTPUT_DIR), \
+ DEST := $(TEST_IMAGE_DIR)/jdk/jtreg/native, \
+ FILES := $(BUILD_JDK_JTREG_LIBRARIES) $(BUILD_JDK_JTREG_EXECUTABLES), \
+ FLATTEN := true))
+
+test-image-jdk-jtreg-native: $(COPY_JDK_JTREG_NATIVE)
+
+all: build-test-jdk-jtreg-native
+test-image: test-image-jdk-jtreg-native
+
+.PHONY: default all build-test-jdk-jtreg-native test-image-jdk-jtreg-native test-image
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/io/ObjectInputStream.java
--- a/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java Thu Mar 05 15:23:22 2015 -0800
@@ -40,6 +40,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import static java.io.ObjectStreamClass.processQueue;
+import sun.misc.Unsafe;
import sun.reflect.misc.ReflectUtil;
/**
@@ -375,6 +376,7 @@
}
if (depth == 0) {
vlist.doCallbacks();
+ freeze();
}
return obj;
} finally {
@@ -465,6 +467,7 @@
}
if (depth == 0) {
vlist.doCallbacks();
+ freeze();
}
return obj;
} finally {
@@ -2357,6 +2360,26 @@
}
}
+ private static final Unsafe UNSAFE = Unsafe.getUnsafe();
+
+ /**
+ * Performs a "freeze" action, required to adhere to final field semantics.
+ *
+ *
This method can be called unconditionally before returning the graph,
+ * from the topmost readObject call, since it is expected that the
+ * additional cost of the freeze action is negligible compared to
+ * reconstituting even the most simple graph.
+ *
+ *
Nested calls to readObject do not issue freeze actions because the
+ * sub-graph returned from a nested call is not guaranteed to be fully
+ * initialized yet (possible cycles).
+ */
+ private void freeze() {
+ // Issue a StoreStore|StoreLoad fence, which is at least sufficient
+ // to provide final-freeze semantics.
+ UNSAFE.storeFence();
+ }
+
/**
* Input stream with two modes: in default mode, inputs data written in the
* same format as DataOutputStream; in "block data" mode, inputs data
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/lang/FunctionalInterface.java
--- a/jdk/src/java.base/share/classes/java/lang/FunctionalInterface.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/FunctionalInterface.java Thu Mar 05 15:23:22 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -60,6 +60,7 @@
* @jls 4.3.2. The Class Object
* @jls 9.8 Functional Interfaces
* @jls 9.4.3 Interface Method Body
+ * @jls 9.6.4.9 @FunctionalInterface
* @since 1.8
*/
@Documented
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/lang/Override.java
--- a/jdk/src/java.base/share/classes/java/lang/Override.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/Override.java Thu Mar 05 15:23:22 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,9 @@
*
* @author Peter von der Ahé
* @author Joshua Bloch
- * @jls 9.6.1.4 @Override
+ * @jls 8.4.8 Inheritance, Overriding, and Hiding
+ * @jls 9.4.1 Inheritance and Overriding
+ * @jls 9.6.4.4 @Override
* @since 1.5
*/
@Target(ElementType.METHOD)
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/lang/SafeVarargs.java
--- a/jdk/src/java.base/share/classes/java/lang/SafeVarargs.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/SafeVarargs.java Thu Mar 05 15:23:22 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -85,7 +85,7 @@
* @since 1.7
* @jls 4.7 Reifiable Types
* @jls 8.4.1 Formal Parameters
- * @jls 9.6.3.7 @SafeVarargs
+ * @jls 9.6.4.7 @SafeVarargs
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/lang/SuppressWarnings.java
--- a/jdk/src/java.base/share/classes/java/lang/SuppressWarnings.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/SuppressWarnings.java Thu Mar 05 15:23:22 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@
* @jls 4.12.2 Variables of Reference Type
* @jls 5.1.9 Unchecked Conversion
* @jls 5.5.2 Checked Casts and Unchecked Casts
- * @jls 9.6.3.5 @SuppressWarnings
+ * @jls 9.6.4.5 @SuppressWarnings
*/
@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE})
@Retention(RetentionPolicy.SOURCE)
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/lang/annotation/Inherited.java
--- a/jdk/src/java.base/share/classes/java/lang/annotation/Inherited.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/annotation/Inherited.java Thu Mar 05 15:23:22 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,7 @@
*
* @author Joshua Bloch
* @since 1.5
- * @jls 9.6.3.3 @Inherited
+ * @jls 9.6.4.3 @Inherited
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/lang/annotation/Repeatable.java
--- a/jdk/src/java.base/share/classes/java/lang/annotation/Repeatable.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/annotation/Repeatable.java Thu Mar 05 15:23:22 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,8 +33,8 @@
* type for the repeatable annotation type.
*
* @since 1.8
- * @jls 9.6 Annotation Types
- * @jls 9.7 Annotations
+ * @jls 9.6.3 Repeatable Annotation Types
+ * @jls 9.7.5 Multiple Annotations of the Same Type
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/lang/annotation/Retention.java
--- a/jdk/src/java.base/share/classes/java/lang/annotation/Retention.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/annotation/Retention.java Thu Mar 05 15:23:22 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -38,7 +38,7 @@
*
* @author Joshua Bloch
* @since 1.5
- * @jls 9.6.3.2 @Retention
+ * @jls 9.6.4.2 @Retention
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/lang/annotation/Target.java
--- a/jdk/src/java.base/share/classes/java/lang/annotation/Target.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/annotation/Target.java Thu Mar 05 15:23:22 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -72,6 +72,7 @@
* @since 1.5
* @jls 9.6.4.1 @Target
* @jls 9.7.4 Where Annotations May Appear
+ * @jls 9.7.5 Multiple Annotations of the Same Type
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java Thu Mar 05 15:23:22 2015 -0800
@@ -436,7 +436,7 @@
}
private MethodType bindArgumentType(BoundMethodHandle mh, int pos, BasicType bt) {
- assert(mh.form == lambdaForm);
+ assert(mh.form.uncustomize() == lambdaForm);
assert(mh.form.names[1+pos].type == bt);
assert(BasicType.basicType(mh.type().parameterType(pos)) == bt);
return mh.type().dropParameterTypes(pos, pos+1);
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/math/BigDecimal.java
--- a/jdk/src/java.base/share/classes/java/math/BigDecimal.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/math/BigDecimal.java Thu Mar 05 15:23:22 2015 -0800
@@ -3740,8 +3740,8 @@
throw new ExceptionInInitializerError(ex);
}
}
- static void setIntCompactVolatile(BigDecimal bd, long val) {
- unsafe.putLongVolatile(bd, intCompactOffset, val);
+ static void setIntCompact(BigDecimal bd, long val) {
+ unsafe.putLong(bd, intCompactOffset, val);
}
static void setIntValVolatile(BigDecimal bd, BigInteger val) {
@@ -3765,7 +3765,7 @@
throw new java.io.StreamCorruptedException(message);
// [all values of scale are now allowed]
}
- UnsafeHolder.setIntCompactVolatile(this, compactValFor(intVal));
+ UnsafeHolder.setIntCompact(this, compactValFor(intVal));
}
/**
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/math/BigInteger.java
--- a/jdk/src/java.base/share/classes/java/math/BigInteger.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/math/BigInteger.java Thu Mar 05 15:23:22 2015 -0800
@@ -4368,11 +4368,11 @@
}
static void putSign(BigInteger bi, int sign) {
- unsafe.putIntVolatile(bi, signumOffset, sign);
+ unsafe.putInt(bi, signumOffset, sign);
}
static void putMag(BigInteger bi, int[] magnitude) {
- unsafe.putObjectVolatile(bi, magOffset, magnitude);
+ unsafe.putObject(bi, magOffset, magnitude);
}
}
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/nio/file/Files.java
--- a/jdk/src/java.base/share/classes/java/nio/file/Files.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/nio/file/Files.java Thu Mar 05 15:23:22 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -3427,11 +3427,8 @@
* reflect updates to the directory that occur after returning from this
* method.
*
- *
The returned stream encapsulates a {@link DirectoryStream}.
- * If timely disposal of file system resources is required, the
- * {@code try}-with-resources construct should be used to ensure that the
- * stream's {@link Stream#close close} method is invoked after the stream
- * operations are completed.
+ *
The returned stream contains a reference to an open directory.
+ * The directory is closed by closing the stream.
*
*
Operating on a closed stream behaves as if the end of stream
* has been reached. Due to read-ahead, one or more elements may be
@@ -3442,6 +3439,11 @@
* UncheckedIOException} which will be thrown from the method that caused
* the access to take place.
*
+ * @apiNote
+ * This method must be used within a try-with-resources statement or similar
+ * control structure to ensure that the stream's open directory is closed
+ * promptly after the stream's operations have completed.
+ *
* @param dir The path to the directory
*
* @return The {@code Stream} describing the content of the
@@ -3549,18 +3551,19 @@
*
When a security manager is installed and it denies access to a file
* (or directory), then it is ignored and not included in the stream.
*
- *
The returned stream encapsulates one or more {@link DirectoryStream}s.
- * If timely disposal of file system resources is required, the
- * {@code try}-with-resources construct should be used to ensure that the
- * stream's {@link Stream#close close} method is invoked after the stream
- * operations are completed. Operating on a closed stream will result in an
- * {@link java.lang.IllegalStateException}.
+ *
The returned stream contains references to one or more open directories.
+ * The directories are closed by closing the stream.
*
*
If an {@link IOException} is thrown when accessing the directory
* after this method has returned, it is wrapped in an {@link
* UncheckedIOException} which will be thrown from the method that caused
* the access to take place.
*
+ * @apiNote
+ * This method must be used within a try-with-resources statement or similar
+ * control structure to ensure that the stream's open directories are closed
+ * promptly after the stream's operations have completed.
+ *
* @param start
* the starting file
* @param maxDepth
@@ -3613,12 +3616,13 @@
*
* In other words, it visits all levels of the file tree.
*
- *
The returned stream encapsulates one or more {@link DirectoryStream}s.
- * If timely disposal of file system resources is required, the
- * {@code try}-with-resources construct should be used to ensure that the
- * stream's {@link Stream#close close} method is invoked after the stream
- * operations are completed. Operating on a closed stream will result in an
- * {@link java.lang.IllegalStateException}.
+ *
The returned stream contains references to one or more open directories.
+ * The directories are closed by closing the stream.
+ *
+ * @apiNote
+ * This method must be used within a try-with-resources statement or similar
+ * control structure to ensure that the stream's open directories are closed
+ * promptly after the stream's operations have completed.
*
* @param start
* the starting file
@@ -3658,18 +3662,19 @@
* returned by {@code walk} method, this method may be more efficient by
* avoiding redundant retrieval of the {@code BasicFileAttributes}.
*
- *
The returned stream encapsulates one or more {@link DirectoryStream}s.
- * If timely disposal of file system resources is required, the
- * {@code try}-with-resources construct should be used to ensure that the
- * stream's {@link Stream#close close} method is invoked after the stream
- * operations are completed. Operating on a closed stream will result in an
- * {@link java.lang.IllegalStateException}.
+ *
The returned stream contains references to one or more open directories.
+ * The directories are closed by closing the stream.
*
*
If an {@link IOException} is thrown when accessing the directory
* after returned from this method, it is wrapped in an {@link
* UncheckedIOException} which will be thrown from the method that caused
* the access to take place.
*
+ * @apiNote
+ * This method must be used within a try-with-resources statement or similar
+ * control structure to ensure that the stream's open directories are closed
+ * promptly after the stream's operations have completed.
+ *
* @param start
* the starting file
* @param maxDepth
@@ -3725,6 +3730,9 @@
* charset and the same line terminators as specified by {@code
* readAllLines} are supported.
*
+ *
The returned stream contains a reference to an open file. The file
+ * is closed by closing the stream.
+ *
*
After this method returns, then any subsequent I/O exception that
* occurs while reading from the file or when a malformed or unmappable byte
* sequence is read, is wrapped in an {@link UncheckedIOException} that will
@@ -3733,12 +3741,10 @@
* place. In case an {@code IOException} is thrown when closing the file,
* it is also wrapped as an {@code UncheckedIOException}.
*
- *
The returned stream encapsulates a {@link Reader}. If timely
- * disposal of file system resources is required, the try-with-resources
- * construct should be used to ensure that the stream's
- * {@link Stream#close close} method is invoked after the stream operations
- * are completed.
- *
+ * @apiNote
+ * This method must be used within a try-with-resources statement or similar
+ * control structure to ensure that the stream's open file is closed promptly
+ * after the stream's operations have completed.
*
* @param path
* the path to the file
@@ -3780,12 +3786,20 @@
* decoded into characters using the {@link StandardCharsets#UTF_8 UTF-8}
* {@link Charset charset}.
*
+ *
The returned stream contains a reference to an open file. The file
+ * is closed by closing the stream.
+ *
*
This method works as if invoking it were equivalent to evaluating the
* expression:
*
*
+ * @apiNote
+ * This method must be used within a try-with-resources statement or similar
+ * control structure to ensure that the stream's open file is closed promptly
+ * after the stream's operations have completed.
+ *
* @param path
* the path to the file
*
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/security/cert/X509CertSelector.java
--- a/jdk/src/java.base/share/classes/java/security/cert/X509CertSelector.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/security/cert/X509CertSelector.java Thu Mar 05 15:23:22 2015 -0800
@@ -2574,8 +2574,10 @@
} else {
if (maxPathLen < basicConstraints) {
if (debug != null) {
- debug.println("X509CertSelector.match: maxPathLen too small ("
- + maxPathLen + " < " + basicConstraints + ")");
+ debug.println("X509CertSelector.match: cert's maxPathLen " +
+ "is less than the min maxPathLen set by " +
+ "basicConstraints. " +
+ "(" + maxPathLen + " < " + basicConstraints + ")");
}
return false;
}
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/time/Instant.java
--- a/jdk/src/java.base/share/classes/java/time/Instant.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/time/Instant.java Thu Mar 05 15:23:22 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1229,8 +1229,14 @@
* @throws ArithmeticException if numeric overflow occurs
*/
public long toEpochMilli() {
- long millis = Math.multiplyExact(seconds, 1000);
- return millis + nanos / 1000_000;
+ if (seconds < 0 && nanos > 0) {
+ long millis = Math.multiplyExact(seconds+1, 1000);
+ long adjustment = nanos / 1000_000 - 1000;
+ return millis + adjustment;
+ } else {
+ long millis = Math.multiplyExact(seconds, 1000);
+ return millis + nanos / 1000_000;
+ }
}
//-----------------------------------------------------------------------
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/util/Arrays.java
--- a/jdk/src/java.base/share/classes/java/util/Arrays.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/util/Arrays.java Thu Mar 05 15:23:22 2015 -0800
@@ -4685,6 +4685,14 @@
*
If the generator function throws an exception, it is relayed to
* the caller and the array is left in an indeterminate state.
*
+ * @apiNote
+ * Setting a subrange of an array, using a generator function to compute
+ * each element, can be written as follows:
+ *
+ *
* @param type of elements of the array
* @param array array to be initialized
* @param generator a function accepting an index and producing the desired
@@ -4706,6 +4714,15 @@
* is thrown from {@code parallelSetAll} and the array is left in an
* indeterminate state.
*
+ * @apiNote
+ * Setting a subrange of an array, in parallel, using a generator function
+ * to compute each element, can be written as follows:
+ *
+ *
* @param type of elements of the array
* @param array array to be initialized
* @param generator a function accepting an index and producing the desired
@@ -4725,6 +4742,14 @@
*
If the generator function throws an exception, it is relayed to
* the caller and the array is left in an indeterminate state.
*
+ * @apiNote
+ * Setting a subrange of an array, using a generator function to compute
+ * each element, can be written as follows:
+ *
+ *
* @param array array to be initialized
* @param generator a function accepting an index and producing the desired
* value for that position
@@ -4745,6 +4770,15 @@
* is thrown from {@code parallelSetAll} and the array is left in an
* indeterminate state.
*
+ * @apiNote
+ * Setting a subrange of an array, in parallel, using a generator function
+ * to compute each element, can be written as follows:
+ *
+ *
* @param array array to be initialized
* @param generator a function accepting an index and producing the desired
* value for that position
@@ -4763,6 +4797,14 @@
*
If the generator function throws an exception, it is relayed to
* the caller and the array is left in an indeterminate state.
*
+ * @apiNote
+ * Setting a subrange of an array, using a generator function to compute
+ * each element, can be written as follows:
+ *
+ *
* @param array array to be initialized
* @param generator a function accepting an index and producing the desired
* value for that position
@@ -4783,6 +4825,15 @@
* is thrown from {@code parallelSetAll} and the array is left in an
* indeterminate state.
*
+ * @apiNote
+ * Setting a subrange of an array, in parallel, using a generator function
+ * to compute each element, can be written as follows:
+ *
+ *
* @param array array to be initialized
* @param generator a function accepting an index and producing the desired
* value for that position
@@ -4801,6 +4852,14 @@
*
If the generator function throws an exception, it is relayed to
* the caller and the array is left in an indeterminate state.
*
+ * @apiNote
+ * Setting a subrange of an array, using a generator function to compute
+ * each element, can be written as follows:
+ *
+ *
* @param array array to be initialized
* @param generator a function accepting an index and producing the desired
* value for that position
@@ -4821,6 +4880,15 @@
* is thrown from {@code parallelSetAll} and the array is left in an
* indeterminate state.
*
+ * @apiNote
+ * Setting a subrange of an array, in parallel, using a generator function
+ * to compute each element, can be written as follows:
+ *
+ *
* @param array array to be initialized
* @param generator a function accepting an index and producing the desired
* value for that position
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/util/regex/Matcher.java
--- a/jdk/src/java.base/share/classes/java/util/regex/Matcher.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/util/regex/Matcher.java Thu Mar 05 15:23:22 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,16 @@
package java.util.regex;
+import java.util.ConcurrentModificationException;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
import java.util.Objects;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
/**
* An engine that performs match operations on a {@linkplain java.lang.CharSequence
@@ -209,6 +218,11 @@
boolean anchoringBounds = true;
/**
+ * Number of times this matcher's state has been modified
+ */
+ int modCount;
+
+ /**
* No default constructor.
*/
Matcher() {
@@ -248,11 +262,76 @@
* @since 1.5
*/
public MatchResult toMatchResult() {
- Matcher result = new Matcher(this.parentPattern, text.toString());
- result.first = this.first;
- result.last = this.last;
- result.groups = this.groups.clone();
- return result;
+ return toMatchResult(text.toString());
+ }
+
+ private MatchResult toMatchResult(String text) {
+ return new ImmutableMatchResult(this.first,
+ this.last,
+ groupCount(),
+ this.groups.clone(),
+ text);
+ }
+
+ private static class ImmutableMatchResult implements MatchResult {
+ private final int first;
+ private final int last;
+ private final int[] groups;
+ private final int groupCount;
+ private final String text;
+
+ ImmutableMatchResult(int first, int last, int groupCount,
+ int groups[], String text)
+ {
+ this.first = first;
+ this.last = last;
+ this.groupCount = groupCount;
+ this.groups = groups;
+ this.text = text;
+ }
+
+ @Override
+ public int start() {
+ return first;
+ }
+
+ @Override
+ public int start(int group) {
+ if (group < 0 || group > groupCount)
+ throw new IndexOutOfBoundsException("No group " + group);
+ return groups[group * 2];
+ }
+
+ @Override
+ public int end() {
+ return last;
+ }
+
+ @Override
+ public int end(int group) {
+ if (group < 0 || group > groupCount)
+ throw new IndexOutOfBoundsException("No group " + group);
+ return groups[group * 2 + 1];
+ }
+
+ @Override
+ public int groupCount() {
+ return groupCount;
+ }
+
+ @Override
+ public String group() {
+ return group(0);
+ }
+
+ @Override
+ public String group(int group) {
+ if (group < 0 || group > groupCount)
+ throw new IndexOutOfBoundsException("No group " + group);
+ if ((groups[group*2] == -1) || (groups[group*2+1] == -1))
+ return null;
+ return text.subSequence(groups[group * 2], groups[group * 2 + 1]).toString();
+ }
}
/**
@@ -284,6 +363,7 @@
groups[i] = -1;
for (int i = 0; i < locals.length; i++)
locals[i] = -1;
+ modCount++;
return this;
}
@@ -308,6 +388,7 @@
lastAppendPosition = 0;
from = 0;
to = getTextLength();
+ modCount++;
return this;
}
@@ -803,6 +884,7 @@
// Append the match substitution
sb.append(result);
lastAppendPosition = last;
+ modCount++;
return this;
}
@@ -892,6 +974,7 @@
// Append the match substitution
sb.append(result);
lastAppendPosition = last;
+ modCount++;
return this;
}
@@ -1078,6 +1161,183 @@
}
/**
+ * Replaces every subsequence of the input sequence that matches the
+ * pattern with the result of applying the given replacer function to the
+ * match result of this matcher corresponding to that subsequence.
+ * Exceptions thrown by the function are relayed to the caller.
+ *
+ *
This method first resets this matcher. It then scans the input
+ * sequence looking for matches of the pattern. Characters that are not
+ * part of any match are appended directly to the result string; each match
+ * is replaced in the result by the applying the replacer function that
+ * returns a replacement string. Each replacement string may contain
+ * references to captured subsequences as in the {@link #appendReplacement
+ * appendReplacement} method.
+ *
+ *
Note that backslashes (\) and dollar signs ($) in
+ * a replacement string may cause the results to be different than if it
+ * were being treated as a literal replacement string. Dollar signs may be
+ * treated as references to captured subsequences as described above, and
+ * backslashes are used to escape literal characters in the replacement
+ * string.
+ *
+ *
Given the regular expression dog, the input
+ * "zzzdogzzzdogzzz", and the function
+ * mr -> mr.group().toUpperCase(), an invocation of this method on
+ * a matcher for that expression would yield the string
+ * "zzzDOGzzzDOGzzz".
+ *
+ *
Invoking this method changes this matcher's state. If the matcher
+ * is to be used in further matching operations then it should first be
+ * reset.
+ *
+ *
The replacer function should not modify this matcher's state during
+ * replacement. This method will, on a best-effort basis, throw a
+ * {@link java.util.ConcurrentModificationException} if such modification is
+ * detected.
+ *
+ *
The state of each match result passed to the replacer function is
+ * guaranteed to be constant only for the duration of the replacer function
+ * call and only if the replacer function does not modify this matcher's
+ * state.
+ *
+ * @implNote
+ * This implementation applies the replacer function to this matcher, which
+ * is an instance of {@code MatchResult}.
+ *
+ * @param replacer
+ * The function to be applied to the match result of this matcher
+ * that returns a replacement string.
+ * @return The string constructed by replacing each matching subsequence
+ * with the result of applying the replacer function to that
+ * matched subsequence, substituting captured subsequences as
+ * needed.
+ * @throws NullPointerException if the replacer function is null
+ * @throws ConcurrentModificationException if it is detected, on a
+ * best-effort basis, that the replacer function modified this
+ * matcher's state
+ * @since 1.9
+ */
+ public String replaceAll(Function replacer) {
+ Objects.requireNonNull(replacer);
+ reset();
+ boolean result = find();
+ if (result) {
+ StringBuilder sb = new StringBuilder();
+ do {
+ int ec = modCount;
+ String replacement = replacer.apply(this);
+ if (ec != modCount)
+ throw new ConcurrentModificationException();
+ appendReplacement(sb, replacement);
+ result = find();
+ } while (result);
+ appendTail(sb);
+ return sb.toString();
+ }
+ return text.toString();
+ }
+
+ /**
+ * Returns a stream of match results for each subsequence of the input
+ * sequence that matches the pattern. The match results occur in the
+ * same order as the matching subsequences in the input sequence.
+ *
+ *
Each match result is produced as if by {@link #toMatchResult()}.
+ *
+ *
This method does not reset this matcher. Matching starts on
+ * initiation of the terminal stream operation either at the beginning of
+ * this matcher's region, or, if the matcher has not since been reset, at
+ * the first character not matched by a previous match.
+ *
+ *
If the matcher is to be used for further matching operations after
+ * the terminal stream operation completes then it should be first reset.
+ *
+ *
This matcher's state should not be modified during execution of the
+ * returned stream's pipeline. The returned stream's source
+ * {@code Spliterator} is fail-fast and will, on a best-effort
+ * basis, throw a {@link java.util.ConcurrentModificationException} if such
+ * modification is detected.
+ *
+ * @return a sequential stream of match results.
+ * @since 1.9
+ */
+ public Stream results() {
+ class MatchResultIterator implements Iterator {
+ // -ve for call to find, 0 for not found, 1 for found
+ int state = -1;
+ // State for concurrent modification checking
+ // -1 for uninitialized
+ int expectedCount = -1;
+ // The input sequence as a string, set once only after first find
+ // Avoids repeated conversion from CharSequence for each match
+ String textAsString;
+
+ @Override
+ public MatchResult next() {
+ if (expectedCount >= 0 && expectedCount != modCount)
+ throw new ConcurrentModificationException();
+
+ if (!hasNext())
+ throw new NoSuchElementException();
+
+ state = -1;
+ return toMatchResult(textAsString);
+ }
+
+ @Override
+ public boolean hasNext() {
+ if (state >= 0)
+ return state == 1;
+
+ // Defer throwing ConcurrentModificationException to when next
+ // or forEachRemaining is called. The is consistent with other
+ // fail-fast implementations.
+ if (expectedCount >= 0 && expectedCount != modCount)
+ return true;
+
+ boolean found = find();
+ // Capture the input sequence as a string on first find
+ if (found && state < 0)
+ textAsString = text.toString();
+ state = found ? 1 : 0;
+ expectedCount = modCount;
+ return found;
+ }
+
+ @Override
+ public void forEachRemaining(Consumer super MatchResult> action) {
+ if (expectedCount >= 0 && expectedCount != modCount)
+ throw new ConcurrentModificationException();
+
+ int s = state;
+ if (s == 0)
+ return;
+
+ // Set state to report no more elements on further operations
+ state = 0;
+ expectedCount = -1;
+
+ // Perform a first find if required
+ if (s < 0 && !find())
+ return;
+
+ // Capture the input sequence as a string on first find
+ textAsString = text.toString();
+
+ do {
+ int ec = modCount;
+ action.accept(toMatchResult(textAsString));
+ if (ec != modCount)
+ throw new ConcurrentModificationException();
+ } while (find());
+ }
+ }
+ return StreamSupport.stream(Spliterators.spliteratorUnknownSize(
+ new MatchResultIterator(), Spliterator.ORDERED | Spliterator.NONNULL), false);
+ }
+
+ /**
* Replaces the first subsequence of the input sequence that matches the
* pattern with the given replacement string.
*
@@ -1123,6 +1383,79 @@
}
/**
+ * Replaces the first subsequence of the input sequence that matches the
+ * pattern with the result of applying the given replacer function to the
+ * match result of this matcher corresponding to that subsequence.
+ * Exceptions thrown by the replace function are relayed to the caller.
+ *
+ *
This method first resets this matcher. It then scans the input
+ * sequence looking for a match of the pattern. Characters that are not
+ * part of the match are appended directly to the result string; the match
+ * is replaced in the result by the applying the replacer function that
+ * returns a replacement string. The replacement string may contain
+ * references to captured subsequences as in the {@link #appendReplacement
+ * appendReplacement} method.
+ *
+ *
Note that backslashes (\) and dollar signs ($) in
+ * the replacement string may cause the results to be different than if it
+ * were being treated as a literal replacement string. Dollar signs may be
+ * treated as references to captured subsequences as described above, and
+ * backslashes are used to escape literal characters in the replacement
+ * string.
+ *
+ *
Given the regular expression dog, the input
+ * "zzzdogzzzdogzzz", and the function
+ * mr -> mr.group().toUpperCase(), an invocation of this method on
+ * a matcher for that expression would yield the string
+ * "zzzDOGzzzdogzzz".
+ *
+ *
Invoking this method changes this matcher's state. If the matcher
+ * is to be used in further matching operations then it should first be
+ * reset.
+ *
+ *
The replacer function should not modify this matcher's state during
+ * replacement. This method will, on a best-effort basis, throw a
+ * {@link java.util.ConcurrentModificationException} if such modification is
+ * detected.
+ *
+ *
The state of the match result passed to the replacer function is
+ * guaranteed to be constant only for the duration of the replacer function
+ * call and only if the replacer function does not modify this matcher's
+ * state.
+ *
+ * @implNote
+ * This implementation applies the replacer function to this matcher, which
+ * is an instance of {@code MatchResult}.
+ *
+ * @param replacer
+ * The function to be applied to the match result of this matcher
+ * that returns a replacement string.
+ * @return The string constructed by replacing the first matching
+ * subsequence with the result of applying the replacer function to
+ * the matched subsequence, substituting captured subsequences as
+ * needed.
+ * @throws NullPointerException if the replacer function is null
+ * @throws ConcurrentModificationException if it is detected, on a
+ * best-effort basis, that the replacer function modified this
+ * matcher's state
+ * @since 1.9
+ */
+ public String replaceFirst(Function replacer) {
+ Objects.requireNonNull(replacer);
+ reset();
+ if (!find())
+ return text.toString();
+ StringBuilder sb = new StringBuilder();
+ int ec = modCount;
+ String replacement = replacer.apply(this);
+ if (ec != modCount)
+ throw new ConcurrentModificationException();
+ appendReplacement(sb, replacement);
+ appendTail(sb);
+ return sb.toString();
+ }
+
+ /**
* Sets the limits of this matcher's region. The region is the part of the
* input sequence that will be searched to find a match. Invoking this
* method resets the matcher, and then sets the region to start at the
@@ -1365,6 +1698,7 @@
if (!result)
this.first = -1;
this.oldLast = this.last;
+ this.modCount++;
return result;
}
@@ -1387,6 +1721,7 @@
if (!result)
this.first = -1;
this.oldLast = this.last;
+ this.modCount++;
return result;
}
diff -r 4f62c57aef4e -r 690957fb0862 jdk/src/java.base/share/classes/java/util/stream/Collectors.java
--- a/jdk/src/java.base/share/classes/java/util/stream/Collectors.java Thu Mar 05 11:26:17 2015 -0800
+++ b/jdk/src/java.base/share/classes/java/util/stream/Collectors.java Thu Mar 05 15:23:22 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -404,6 +404,54 @@
}
/**
+ * Adapts a {@code Collector} accepting elements of type {@code U} to one
+ * accepting elements of type {@code T} by applying a flat mapping function
+ * to each input element before accumulation. The flat mapping function
+ * maps an input element to a {@link Stream stream} covering zero or more
+ * output elements that are then accumulated downstream. Each mapped stream
+ * is {@link java.util.stream.BaseStream#close() closed} after its contents
+ * have been placed downstream. (If a mapped stream is {@code null}
+ * an empty stream is used, instead.)
+ *
+ * @apiNote
+ * The {@code flatMapping()} collectors are most useful when used in a
+ * multi-level reduction, such as downstream of a {@code groupingBy} or
+ * {@code partitioningBy}. For example, given a stream of
+ * {@code Order}, to accumulate the set of line items for each customer:
+ *