From d7a27bad031cef22e3037addef8092dc210c44d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Fri, 25 Nov 2016 14:20:24 +0100 Subject: [PATCH 001/142] 8170322: Specialized functions convert booleans to numbers Reviewed-by: jlaskey, attila --- .../internal/tools/nasgen/MemberInfo.java | 20 ++++++++- .../tools/nasgen/MethodGenerator.java | 1 + .../nasgen/ScriptClassInfoCollector.java | 6 +++ .../tools/nasgen/StringConstants.java | 7 +--- .../nashorn/internal/objects/NativeArray.java | 37 ++-------------- .../internal/objects/NativeString.java | 30 +------------ .../annotations/SpecializedFunction.java | 10 +++++ .../internal/runtime/CompiledFunction.java | 16 ++++++- .../internal/runtime/Specialization.java | 23 ++++++++-- nashorn/test/script/basic/JDK-8170322.js | 42 +++++++++++++++++++ 10 files changed, 118 insertions(+), 74 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8170322.js diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java index c5f4c49ff83..c5cb0b5de1f 100644 --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java @@ -29,7 +29,6 @@ import static jdk.nashorn.internal.tools.nasgen.StringConstants.OBJECT_DESC; import static jdk.nashorn.internal.tools.nasgen.StringConstants.OBJ_PKG; import static jdk.nashorn.internal.tools.nasgen.StringConstants.RUNTIME_PKG; import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTS_PKG; -import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTOBJECT_DESC; import static jdk.nashorn.internal.tools.nasgen.StringConstants.STRING_DESC; import static jdk.nashorn.internal.tools.nasgen.StringConstants.TYPE_SYMBOL; @@ -111,6 +110,8 @@ public final class MemberInfo implements Cloneable { private boolean isOptimistic; + private boolean convertsNumericArgs; + /** * @return the kind */ @@ -171,6 +172,23 @@ public final class MemberInfo implements Cloneable { this.isOptimistic = isOptimistic; } + /** + * Check if this function converts arguments for numeric parameters to numbers + * so it's safe to pass booleans as 0 and 1 + * @return true if it is safe to convert arguments to numbers + */ + public boolean convertsNumericArgs() { + return convertsNumericArgs; + } + + /** + * Tag this as a function that converts arguments for numeric params to numbers + * @param convertsNumericArgs if true args can be safely converted to numbers + */ + public void setConvertsNumericArgs(final boolean convertsNumericArgs) { + this.convertsNumericArgs = convertsNumericArgs; + } + /** * Get the SpecializedFunction guard for specializations, i.e. optimistic * builtins diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java index bb361cc693a..e69f03644df 100644 --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java @@ -412,6 +412,7 @@ public class MethodGenerator extends MethodVisitor { visitLdcInsn(linkLogicClass); } visitInsn(mi.isOptimistic() ? ICONST_1 : ICONST_0); + visitInsn(mi.convertsNumericArgs() ? ICONST_1 : ICONST_0); visitMethodInsn(INVOKESPECIAL, SPECIALIZATION_TYPE, INIT, ctor, false); arrayStore(TYPE_SPECIALIZATION); } diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfoCollector.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfoCollector.java index 4a14d80ea4e..a39204d3b3e 100644 --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfoCollector.java +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfoCollector.java @@ -210,6 +210,7 @@ public class ScriptClassInfoCollector extends ClassVisitor { private Where where; private boolean isSpecializedConstructor; private boolean isOptimistic; + private boolean convertsNumericArgs; private Type linkLogicClass = MethodGenerator.EMPTY_LINK_LOGIC_TYPE; @Override @@ -238,6 +239,10 @@ public class ScriptClassInfoCollector extends ClassVisitor { case "linkLogic": this.linkLogicClass = (Type)annotationValue; break; + case "convertsNumericArgs": + assert annoKind == Kind.SPECIALIZED_FUNCTION; + this.convertsNumericArgs = (Boolean)annotationValue; + break; default: break; } @@ -298,6 +303,7 @@ public class ScriptClassInfoCollector extends ClassVisitor { memInfo.setLinkLogicClass(linkLogicClass); memInfo.setIsSpecializedConstructor(isSpecializedConstructor); memInfo.setIsOptimistic(isOptimistic); + memInfo.setConvertsNumericArgs(convertsNumericArgs); } }; } diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/StringConstants.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/StringConstants.java index 428cece8a3f..2dc560af98b 100644 --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/StringConstants.java +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/StringConstants.java @@ -45,7 +45,6 @@ public interface StringConstants { // standard jdk types, methods static final Type TYPE_METHODHANDLE = Type.getType(MethodHandle.class); - static final Type TYPE_METHODHANDLE_ARRAY = Type.getType(MethodHandle[].class); static final Type TYPE_SPECIALIZATION = Type.getType("L" + RUNTIME_PKG + "Specialization;"); static final Type TYPE_SPECIALIZATION_ARRAY = Type.getType("[L" + RUNTIME_PKG + "Specialization;"); static final Type TYPE_OBJECT = Type.getType(Object.class); @@ -60,13 +59,11 @@ public interface StringConstants { static final String INIT = ""; static final String DEFAULT_INIT_DESC = Type.getMethodDescriptor(Type.VOID_TYPE); - static final String METHODHANDLE_TYPE = TYPE_METHODHANDLE.getInternalName(); static final String SPECIALIZATION_TYPE = TYPE_SPECIALIZATION.getInternalName(); - static final String SPECIALIZATION_INIT2 = Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_METHODHANDLE, Type.getType(boolean.class)); - static final String SPECIALIZATION_INIT3 = Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_METHODHANDLE, TYPE_CLASS, Type.getType(boolean.class)); + static final String SPECIALIZATION_INIT2 = Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_METHODHANDLE, Type.BOOLEAN_TYPE, Type.BOOLEAN_TYPE); + static final String SPECIALIZATION_INIT3 = Type.getMethodDescriptor(Type.VOID_TYPE, TYPE_METHODHANDLE, TYPE_CLASS, Type.BOOLEAN_TYPE, Type.BOOLEAN_TYPE); static final String OBJECT_TYPE = TYPE_OBJECT.getInternalName(); static final String OBJECT_DESC = TYPE_OBJECT.getDescriptor(); - static final String STRING_TYPE = TYPE_STRING.getInternalName(); static final String STRING_DESC = TYPE_STRING.getDescriptor(); static final String OBJECT_ARRAY_DESC = Type.getDescriptor(Object[].class); static final String ARRAYLIST_TYPE = TYPE_ARRAYLIST.getInternalName(); diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java index 357689a2f89..ac7a7d58ae9 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java @@ -61,7 +61,6 @@ import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.OptimisticBuiltins; import jdk.nashorn.internal.runtime.PropertyDescriptor; import jdk.nashorn.internal.runtime.PropertyMap; -import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.Undefined; @@ -748,7 +747,7 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin * @param arg argument * @return resulting NativeArray */ - @SpecializedFunction(linkLogic=ConcatLinkLogic.class) + @SpecializedFunction(linkLogic=ConcatLinkLogic.class, convertsNumericArgs = false) public static NativeArray concat(final Object self, final int arg) { final ContinuousArrayData newData = getContinuousArrayDataCCE(self, Integer.class).copy(); //get at least an integer data copy of this data newData.fastPush(arg); //add an integer to its end @@ -762,21 +761,7 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin * @param arg argument * @return resulting NativeArray */ - @SpecializedFunction(linkLogic=ConcatLinkLogic.class) - public static NativeArray concat(final Object self, final long arg) { - final ContinuousArrayData newData = getContinuousArrayDataCCE(self, Long.class).copy(); //get at least a long array data copy of this data - newData.fastPush(arg); //add a long at the end - return new NativeArray(newData); - } - - /** - * ECMA 15.4.4.4 Array.prototype.concat ( [ item1 [ , item2 [ , ... ] ] ] ) - * - * @param self self reference - * @param arg argument - * @return resulting NativeArray - */ - @SpecializedFunction(linkLogic=ConcatLinkLogic.class) + @SpecializedFunction(linkLogic=ConcatLinkLogic.class, convertsNumericArgs = false) public static NativeArray concat(final Object self, final double arg) { final ContinuousArrayData newData = getContinuousArrayDataCCE(self, Double.class).copy(); //get at least a number array data copy of this data newData.fastPush(arg); //add a double at the end @@ -980,7 +965,7 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin * @param arg a primitive to push * @return array length after push */ - @SpecializedFunction(linkLogic=PushLinkLogic.class) + @SpecializedFunction(linkLogic=PushLinkLogic.class, convertsNumericArgs = false) public static double push(final Object self, final int arg) { return getContinuousArrayDataCCE(self, Integer.class).fastPush(arg); } @@ -994,21 +979,7 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin * @param arg a primitive to push * @return array length after push */ - @SpecializedFunction(linkLogic=PushLinkLogic.class) - public static double push(final Object self, final long arg) { - return getContinuousArrayDataCCE(self, Long.class).fastPush(arg); - } - - /** - * ECMA 15.4.4.7 Array.prototype.push (args...) - * - * Primitive specialization, {@link LinkLogic} - * - * @param self self reference - * @param arg a primitive to push - * @return array length after push - */ - @SpecializedFunction(linkLogic=PushLinkLogic.class) + @SpecializedFunction(linkLogic=PushLinkLogic.class, convertsNumericArgs = false) public static double push(final Object self, final double arg) { return getContinuousArrayDataCCE(self, Double.class).fastPush(arg); } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeString.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeString.java index d91ffa49471..25320ea541b 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeString.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeString.java @@ -538,17 +538,6 @@ public final class NativeString extends ScriptObject implements OptimisticBuilti return charCodeAt(self, (int)pos); //toInt pos is ok } - /** - * ECMA 15.5.4.5 String.prototype.charCodeAt (pos) - specialized version for long position - * @param self self reference - * @param pos position in string - * @return number representing charcode at position - */ - @SpecializedFunction(linkLogic=CharCodeAtLinkLogic.class) - public static int charCodeAt(final Object self, final long pos) { - return charCodeAt(self, (int)pos); - } - /** * ECMA 15.5.4.5 String.prototype.charCodeAt (pos) - specialized version for int position * @param self self reference @@ -1176,24 +1165,7 @@ public final class NativeString extends ScriptObject implements OptimisticBuilti } /** - * ECMA 15.5.2.1 new String ( [ value ] ) - special version with exactly one {@code int} arg - * - * Constructor - * - * @param newObj is this constructor invoked with the new operator - * @param self self reference - * @param arg the arg - * - * @return new NativeString containing the string representation of the arg - */ - @SpecializedFunction(isConstructor=true) - public static Object constructor(final boolean newObj, final Object self, final long arg) { - final String str = Long.toString(arg); - return newObj ? newObj(str) : str; - } - - /** - * ECMA 15.5.2.1 new String ( [ value ] ) - special version with exactly one {@code int} arg + * ECMA 15.5.2.1 new String ( [ value ] ) - special version with exactly one {@code double} arg * * Constructor * diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/annotations/SpecializedFunction.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/annotations/SpecializedFunction.java index cf6daaf4fed..b6aeaa9ebd4 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/annotations/SpecializedFunction.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/annotations/SpecializedFunction.java @@ -215,4 +215,14 @@ public @interface SpecializedFunction { * @return whether this function can throw {@link UnwarrantedOptimismException}. */ boolean isOptimistic() default false; + + /** + * Is it safe to convert non-numeric arguments to numbers for this function's primitive numeric parameters? + * This is true for many built-in functions which expect numeric arguments, but not for those that + * expect generic arguments and just have specializations with numeric params to avoid boxing overhead. + * The default value is {@code true} because that is by far the most common case. + * + * @return true if it is safe to convert arguments to numbers + */ + boolean convertsNumericArgs() default true; } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/CompiledFunction.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/CompiledFunction.java index 05d0ab9dadf..d8627397556 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/CompiledFunction.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/CompiledFunction.java @@ -152,6 +152,10 @@ final class CompiledFunction { return null; } + boolean convertsNumericArgs() { + return isSpecialization() && specialization.convertsNumericArgs(); + } + int getFlags() { return flags; } @@ -388,10 +392,18 @@ final class CompiledFunction { int narrowWeightDelta = 0; int widenWeightDelta = 0; final int minParamsCount = Math.min(Math.min(thisParamCount, otherParamCount), callSiteParamCount); + final boolean convertsNumericArgs = cf.convertsNumericArgs(); for(int i = 0; i < minParamsCount; ++i) { - final int callSiteParamWeight = getParamType(i, callSiteType, csVarArg).getWeight(); + final Type callSiteParamType = getParamType(i, callSiteType, csVarArg); + final Type thisParamType = getParamType(i, thisType, thisVarArg); + if (!convertsNumericArgs && callSiteParamType.isBoolean() && thisParamType.isNumeric()) { + // When an argument is converted to number by a function it is safe to "widen" booleans to numeric types. + // However, we must avoid this conversion for generic functions such as Array.prototype.push. + return false; + } + final int callSiteParamWeight = callSiteParamType.getWeight(); // Delta is negative for narrowing, positive for widening - final int thisParamWeightDelta = getParamType(i, thisType, thisVarArg).getWeight() - callSiteParamWeight; + final int thisParamWeightDelta = thisParamType.getWeight() - callSiteParamWeight; final int otherParamWeightDelta = getParamType(i, otherType, otherVarArg).getWeight() - callSiteParamWeight; // Only count absolute values of narrowings narrowWeightDelta += Math.max(-thisParamWeightDelta, 0) - Math.max(-otherParamWeightDelta, 0); diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Specialization.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Specialization.java index 9807cc61e84..0a037695e29 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Specialization.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Specialization.java @@ -36,6 +36,7 @@ public final class Specialization { private final MethodHandle mh; private final Class linkLogicClass; private final boolean isOptimistic; + private final boolean convertsNumericArgs; /** * Constructor @@ -43,7 +44,7 @@ public final class Specialization { * @param mh invoker method handler */ public Specialization(final MethodHandle mh) { - this(mh, false); + this(mh, false, true); } /** @@ -52,9 +53,10 @@ public final class Specialization { * @param mh invoker method handler * @param isOptimistic is this an optimistic native method, i.e. can it throw {@link UnwarrantedOptimismException} * which would have to lead to a relink and return value processing + * @param convertsNumericArgs true if it is safe to convert arguments to numbers */ - public Specialization(final MethodHandle mh, final boolean isOptimistic) { - this(mh, null, isOptimistic); + public Specialization(final MethodHandle mh, final boolean isOptimistic, final boolean convertsNumericArgs) { + this(mh, null, isOptimistic, convertsNumericArgs); } /** @@ -65,10 +67,13 @@ public final class Specialization { * if this can be linked on its first encounter, which is needed as per our standard linker semantics * @param isOptimistic is this an optimistic native method, i.e. can it throw {@link UnwarrantedOptimismException} * which would have to lead to a relink and return value processing + * @param convertsNumericArgs true if it is safe to convert arguments to numbers */ - public Specialization(final MethodHandle mh, final Class linkLogicClass, final boolean isOptimistic) { + public Specialization(final MethodHandle mh, final Class linkLogicClass, + final boolean isOptimistic, final boolean convertsNumericArgs) { this.mh = mh; this.isOptimistic = isOptimistic; + this.convertsNumericArgs = convertsNumericArgs; if (linkLogicClass != null) { //null out the "empty" link logic class for optimization purposes //we only use the empty instance because we can't default class annotations @@ -110,5 +115,15 @@ public final class Specialization { return isOptimistic; } + /** + * Check if this function converts arguments for numeric parameters to numbers + * so it's safe to pass booleans as 0 and 1 + * + * @return true if it is safe to convert arguments to numbers + */ + public boolean convertsNumericArgs() { + return convertsNumericArgs; + } + } diff --git a/nashorn/test/script/basic/JDK-8170322.js b/nashorn/test/script/basic/JDK-8170322.js new file mode 100644 index 00000000000..45ee26557a8 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8170322.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8170322: Specialized functions convert booleans to numbers + * + * @test + * @run + */ + +var array = []; +array.push(true); +array.push(false); + +Assert.assertTrue([].concat(true)[0] === true); +Assert.assertTrue([].concat(false)[0] === false); + +Assert.assertTrue(array[0] === true); +Assert.assertTrue(array[1] === false); + +Assert.assertTrue("foo".charAt(false) === 'f'); +Assert.assertTrue("foo".charAt(true) === 'o'); From 27b7ab8b27a5548ed4cd823d35c8190a594bfdd1 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Mon, 28 Nov 2016 09:20:13 +0100 Subject: [PATCH 002/142] 8031567: Better model for storing source revision information Reviewed-by: erikj --- nashorn/.hgignore | 1 - 1 file changed, 1 deletion(-) diff --git a/nashorn/.hgignore b/nashorn/.hgignore index 92acdd9d019..28d612d25e7 100644 --- a/nashorn/.hgignore +++ b/nashorn/.hgignore @@ -1,6 +1,5 @@ syntax: glob -^.hgtip build/* dist/* /nbproject/private/ From b58f0c97b964d80baf1b58be078cc74b9aca2b52 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Mon, 28 Nov 2016 09:20:13 +0100 Subject: [PATCH 003/142] 8031567: Better model for storing source revision information Reviewed-by: erikj --- .hgignore | 3 +- make/CreateHgtipFiles.gmk | 55 ---------------- make/Images.gmk | 10 +-- make/Main.gmk | 22 +++---- make/SourceRevision.gmk | 132 ++++++++++++++++++++++++++++++++++++++ make/common/MakeBase.gmk | 39 +++-------- 6 files changed, 155 insertions(+), 106 deletions(-) delete mode 100644 make/CreateHgtipFiles.gmk create mode 100644 make/SourceRevision.gmk diff --git a/.hgignore b/.hgignore index 9aab81ce35d..023de87e688 100644 --- a/.hgignore +++ b/.hgignore @@ -3,8 +3,7 @@ ^.idea/ nbproject/private/ ^webrev -^.hgtip -^.bridge2 +^.src-rev$ ^.jib/ .DS_Store .metadata/ diff --git a/make/CreateHgtipFiles.gmk b/make/CreateHgtipFiles.gmk deleted file mode 100644 index 61e7be17ac5..00000000000 --- a/make/CreateHgtipFiles.gmk +++ /dev/null @@ -1,55 +0,0 @@ -# -# Copyright (c) 2016, 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. -# - -default: all - -include $(SPEC) -include MakeBase.gmk - -define SetupCreateHgtip - - $$(strip $1)/$(HGTIP_FILENAME): FRC - $(HG) tip --repository $$(strip $1) --template '{node|short}\n' > $$@.tmp - if [ ! -f $$@ ] || [ "`$(CAT) $$@`" != "`$(CAT) $$@.tmp`" ]; then \ - $(MV) $$@.tmp $$@ ; \ - else \ - $(RM) $$@.tmp ; \ - fi - - TARGETS += $$(strip $1)/$(HGTIP_FILENAME) - -endef - -# Only try to create the tips if finding an actual hg repository. This will be -# false if building from a source bundle. -$(foreach r, $(call FindAllReposAbs), \ - $(if $(wildcard $r/.hg), $(eval $(call SetupCreateHgtip, $r))) \ -) - -all: $(TARGETS) - -FRC: - -.PHONY: all diff --git a/make/Images.gmk b/make/Images.gmk index f9bc0e243d6..bff0f5762a8 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -77,7 +77,7 @@ endef define create-info-file $(if $(JDK_ARCH_ABI_PROP_NAME), \ $(call info-file-item, "SUN_ARCH_ABI", "$(JDK_ARCH_ABI_PROP_NAME)")) - $(call info-file-item, "SOURCE", "$(strip $(ALL_SOURCE_TIPS))") + $(call info-file-item, "SOURCE", "$(strip $(SOURCE_REVISION))") endef # Param 1 - The file containing the MODULES list @@ -95,12 +95,12 @@ endef # Create a variable dependency file common for all release info files. INFO_FILE_VARDEPS := $(call DependOnVariable, create-info-file) -ALL_SOURCE_TIPS = $(shell \ - if [ -f $(SUPPORT_OUTPUTDIR)/source_tips ] ; then \ - $(CAT) $(SUPPORT_OUTPUTDIR)/source_tips ; \ +SOURCE_REVISION = $(shell \ + if [ -f $(SOURCE_REVISION_TRACKER) ] ; then \ + $(CAT) $(SOURCE_REVISION_TRACKER) ; \ fi) -$(BASE_RELEASE_FILE): $(INFO_FILE_VARDEPS) $(SUPPORT_OUTPUTDIR)/source_tips +$(BASE_RELEASE_FILE): $(INFO_FILE_VARDEPS) $(SOURCE_REVISION_TRACKER) $(info-file) ################################################################################ diff --git a/make/Main.gmk b/make/Main.gmk index 60c705d011d..d5d0802d70f 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -284,16 +284,11 @@ ALL_TARGETS += $(JMOD_TARGETS) ################################################################################ # Images targets -# Stores the tips for each repository. This file is be used when constructing -# the jdk image and can be used to track the exact sources used to build that -# image. -source-tips: $(SUPPORT_OUTPUTDIR)/source_tips -$(SUPPORT_OUTPUTDIR)/source_tips: FRC - $(call MakeDir, $(@D)) - $(call GetSourceTips) +store-source-revision: + +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f SourceRevision.gmk store-source-revision) -create-hgtip-files: - +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateHgtipFiles.gmk) +create-source-revision-tracker: + +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f SourceRevision.gmk create-source-revision-tracker) BOOTCYCLE_TARGET := product-images bootcycle-images: @@ -332,7 +327,7 @@ mac-bundles-jdk: exploded-image-optimize: +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ExplodedImageOptimize.gmk) -ALL_TARGETS += source-tips create-hgtip-files bootcycle-images zip-security \ +ALL_TARGETS += store-source-revision create-source-revision-tracker bootcycle-images zip-security \ zip-source jrtfs-jar jdk-image jre-image \ symbols-image profiles mac-bundles-jdk \ exploded-image-optimize @@ -684,10 +679,11 @@ else java.base-jmod jdk-image jre-image: generate-link-opt-data endif - jdk-image: jmods zip-source source-tips demos samples jrtfs-jar - jre-image: jmods source-tips jrtfs-jar + jdk-image: jmods zip-source create-source-revision-tracker demos samples \ + jrtfs-jar + jre-image: jmods create-source-revision-tracker jrtfs-jar - profiles: jmods zip-source source-tips jrtfs-jar + profiles: jmods zip-source create-source-revision-tracker jrtfs-jar mac-bundles-jdk: jdk-image jre-image diff --git a/make/SourceRevision.gmk b/make/SourceRevision.gmk new file mode 100644 index 00000000000..bcc5dd6aa57 --- /dev/null +++ b/make/SourceRevision.gmk @@ -0,0 +1,132 @@ +# +# Copyright (c) 2016, 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. +# + +default: all + +include $(SPEC) +include MakeBase.gmk + +################################################################################ +# Keep track of what source revision is used to create the build, by creating +# a tracker file in the output directory. This tracker file is included in the +# image, and can be used to recreate the source revision used. +# +# We're either building directly from a mercurial forest, and if so, use the +# current revision from mercurial. Otherwise, we are building from a source +# bundle. As a part of creating this source bundle, the current mercurial +# revisions of all repos will be stored in a file in the top dir, which is then +# used when creating the tracker file. + +STORED_SOURCE_REVISION := $(TOPDIR)/.src-rev + +# Are we using mercurial? +ifneq ($(and $(HG), $(wildcard $(TOPDIR)/.hg)), ) + + # Verify that the entire forest is consistent + $(foreach repo, $(call FindAllReposRel), \ + $(if $(wildcard $(TOPDIR)/$(repo)/.hg),, \ + $(error Inconsistent revision control: $(repo) is missing .hg directory)) \ + ) + + # Replace "." with "_top" and "/" with "-" + MakeFilenameFromRepo = \ + $(strip $(subst .,top, $(subst /,-, $1))) + + ################################################################################ + # SetupGetRevisionForRepo defines a make rule for creating a file containing + # the name of the repository and the output of "hg id" for that repository. + # Argument 1 is the relative path to the repository from the top dir. + # + SetupGetRevisionForRepo = $(NamedParamsMacroTemplate) + define SetupGetRevisionForRepoBody + $1_REPO_PATH := $$(TOPDIR)/$$(strip $1) + $1_FILENAME := $$(call MakeFilenameFromRepo, $1) + + $$(SUPPORT_OUTPUTDIR)/src-rev/$$($1_FILENAME): FRC + $(call MakeDir $$(@D)) + $(ECHO) $$(strip $1):`$(HG) id -i --repository $$($1_REPO_PATH)` > $$@ + + REPO_REVISIONS += $$(SUPPORT_OUTPUTDIR)/src-rev/$$($1_FILENAME) + endef + + # Setup rules for all repos. This makes sure all the "hg id" calls are made + # in parallel. + $(foreach repo, $(call FindAllReposRel), \ + $(eval $(call SetupGetRevisionForRepo, $(repo))) \ + ) + + # Create a complete source revision output file from all repos + # Param 1: The output file + define CreateSourceRevisionFile + $1: $$(REPO_REVISIONS) + $(call MakeDir $$(@D)) + $$(ECHO) `$$(CAT) $$(REPO_REVISIONS)` > $$@.tmp + if [ ! -f $$@ ] || [ "`$$(CAT) $$@`" != "`$$(CAT) $$@.tmp`" ]; then \ + $$(MV) $$@.tmp $$@ ; \ + else \ + $$(RM) $$@.tmp ; \ + fi + endef + + $(eval $(call CreateSourceRevisionFile, $(STORED_SOURCE_REVISION))) + + store-source-revision: $(STORED_SOURCE_REVISION) + + $(eval $(call CreateSourceRevisionFile, $(SOURCE_REVISION_TRACKER))) + + create-source-revision-tracker: $(SOURCE_REVISION_TRACKER) + +else + # Not using HG + + ifneq ($(wildcard $(STORED_SOURCE_REVISION)), ) + # We have a stored source revision (.src-rev) + + store-source-revision: + $(call LogWarn, Warning: No mercurial configuration present, not updating .src-rev) + + $(SOURCE_REVISION_TRACKER): $(STORED_SOURCE_REVISION) + $(install-file) + + create-source-revision-tracker: $(SOURCE_REVISION_TRACKER) + else + # We don't have a stored source revision. Can't do anything, really. + + store-source-revision: + $(call LogWarn, Error: No mercurial configuration present, cannot create .src-rev) + exit 2 + + create-source-revision-tracker: + $(call LogWarn, Error: No mercurial configuration present and no .src-rev) + exit 2 + endif + +endif + +all: store-source-revision create-source-revision-tracker + +FRC: # Force target + +.PHONY: all store-source-revision create-source-revision-tracker diff --git a/make/common/MakeBase.gmk b/make/common/MakeBase.gmk index 9c2a3f135d1..c1e5022567d 100644 --- a/make/common/MakeBase.gmk +++ b/make/common/MakeBase.gmk @@ -337,44 +337,21 @@ else # HAS_FILE_FUNCTION = false endif # HAS_FILE_FUNCTION ################################################################################ -# The source tips can come from the Mercurial repository, or in the files -# $(HGTIP_FILENAME) which contains the tip but is also positioned in the same -# directory as the original .hg directory. The hgtip files are created in -# CreateHgtipFiles.gmk. -HGTIP_FILENAME := .hgtip + +# A file containing a way to uniquely identify the source code revision that +# the build was created from +SOURCE_REVISION_TRACKER := $(SUPPORT_OUTPUTDIR)/src-rev/source-revision-tracker + +# Locate all hg repositories included in the forest, as absolute paths FindAllReposAbs = \ $(strip $(sort $(dir $(filter-out $(SRC_ROOT)/build/%, $(wildcard \ - $(addprefix $(SRC_ROOT)/, \ - .hg */.hg */*/.hg */*/.hg */*/*/.hg \ - .hgtip */.hgtip */*/.hgtip */*/.hgtip */*/*/.hgtip \ - ) \ + $(addprefix $(SRC_ROOT)/, .hg */.hg */*/.hg */*/*/.hg) \ ))))) +# Locate all hg repositories included in the forest, as relative paths FindAllReposRel = \ $(strip $(subst $(SRC_ROOT)/,.,$(patsubst $(SRC_ROOT)/%/, %, $(FindAllReposAbs)))) -# Emit the repo:tip pairs to $@, but only if they changed since last time -define GetSourceTips - $(CD) $(SRC_ROOT) ; \ - for i in $(FindAllReposRel) IGNORE ; do \ - if [ "$${i}" = "IGNORE" ] ; then \ - continue; \ - elif [ -d $${i}/.hg -a "$(HG)" != "" ] ; then \ - $(PRINTF) " %s:%s" \ - "$${i}" `$(HG) tip --repository $${i} --template '{node|short}\n'` ; \ - elif [ -f $${i}/$(HGTIP_FILENAME) ] ; then \ - $(PRINTF) " %s:%s" \ - "$${i}" `$(CAT) $${i}/$(HGTIP_FILENAME)` ; \ - fi; \ - done > $@.tmp - $(PRINTF) "\n" >> $@.tmp - if [ ! -f $@ ] || [ "`$(CAT) $@`" != "`$(CAT) $@.tmp`" ]; then \ - $(MV) $@.tmp $@ ; \ - else \ - $(RM) $@.tmp ; \ - fi -endef - ################################################################################ define SetupLogging From f9f47ab86619dcac117074ddab3f746e85a127b9 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Mon, 28 Nov 2016 09:20:13 +0100 Subject: [PATCH 004/142] 8031567: Better model for storing source revision information Reviewed-by: erikj --- langtools/.hgignore | 1 - 1 file changed, 1 deletion(-) diff --git a/langtools/.hgignore b/langtools/.hgignore index 3e5642a05a5..d29603e7935 100644 --- a/langtools/.hgignore +++ b/langtools/.hgignore @@ -3,5 +3,4 @@ ^webrev ^.idea /nbproject/private/ -^.hgtip .DS_Store From a15f97efb9af090ba57216b138dec40cb1ee3de2 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Mon, 28 Nov 2016 09:20:13 +0100 Subject: [PATCH 005/142] 8031567: Better model for storing source revision information Reviewed-by: erikj --- jaxp/.hgignore | 1 - 1 file changed, 1 deletion(-) diff --git a/jaxp/.hgignore b/jaxp/.hgignore index 195f7dbfed1..1c1d4fc1a3f 100644 --- a/jaxp/.hgignore +++ b/jaxp/.hgignore @@ -4,4 +4,3 @@ ^drop_included/ ^webrev /nbproject/private/ -^.hgtip From 7723d4d6d2ba7824a7f2a02d75282e2ee3b75308 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Mon, 28 Nov 2016 09:20:13 +0100 Subject: [PATCH 006/142] 8031567: Better model for storing source revision information Reviewed-by: erikj --- corba/.hgignore | 1 - 1 file changed, 1 deletion(-) diff --git a/corba/.hgignore b/corba/.hgignore index 5e6b22f24ee..d782b284ae1 100644 --- a/corba/.hgignore +++ b/corba/.hgignore @@ -2,5 +2,4 @@ ^dist/ ^webrev /nbproject/private/ -^.hgtip .DS_Store From c32103fc284a93479dcb84223a0a407abe68afc8 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Mon, 28 Nov 2016 09:20:13 +0100 Subject: [PATCH 007/142] 8031567: Better model for storing source revision information Reviewed-by: erikj --- jaxws/.hgignore | 1 - 1 file changed, 1 deletion(-) diff --git a/jaxws/.hgignore b/jaxws/.hgignore index 94668d195b7..00a3c015497 100644 --- a/jaxws/.hgignore +++ b/jaxws/.hgignore @@ -4,5 +4,4 @@ ^drop_included/ ^webrev /nbproject/private/ -^.hgtip .DS_Store From db254a6acc29b01fe4513a21f3b52235fa1b873a Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Mon, 28 Nov 2016 09:20:13 +0100 Subject: [PATCH 008/142] 8031567: Better model for storing source revision information Reviewed-by: erikj --- hotspot/.hgignore | 1 - 1 file changed, 1 deletion(-) diff --git a/hotspot/.hgignore b/hotspot/.hgignore index f7628dd32dc..d3a43d0999e 100644 --- a/hotspot/.hgignore +++ b/hotspot/.hgignore @@ -8,7 +8,6 @@ ^src/share/tools/IdealGraphVisualizer/dist/ ^src/share/tools/IdealGraphVisualizer/nbplatform/ .igv.log -^.hgtip .DS_Store ^\.mx.jvmci/env ^\.mx.jvmci/.*\.pyc From ae84c4233fee1974eb5754fbf4cc33d18657e4c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Mon, 28 Nov 2016 09:57:40 +0100 Subject: [PATCH 009/142] 8161579: Array-like AbstractJSObject-based instance not treated as array by native array functions Reviewed-by: jlaskey, attila --- .../nashorn/internal/objects/NativeArray.java | 16 +++-- nashorn/test/script/basic/JDK-8161579.js | 60 +++++++++++++++++++ 2 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8161579.js diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java index ac7a7d58ae9..d311c85a014 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java @@ -822,13 +822,12 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin private static void concatToList(final ArrayList list, final Object obj) { final boolean isScriptArray = isArray(obj); final boolean isScriptObject = isScriptArray || obj instanceof ScriptObject; - if (isScriptArray || obj instanceof Iterable || (obj != null && obj.getClass().isArray())) { + if (isScriptArray || obj instanceof Iterable || obj instanceof JSObject || (obj != null && obj.getClass().isArray())) { final Iterator iter = arrayLikeIterator(obj, true); if (iter.hasNext()) { for (int i = 0; iter.hasNext(); ++i) { final Object value = iter.next(); - final boolean lacksIndex = obj != null && !((ScriptObject)obj).has(i); - if (value == ScriptRuntime.UNDEFINED && isScriptObject && lacksIndex) { + if (value == ScriptRuntime.UNDEFINED && isScriptObject && !((ScriptObject)obj).has(i)) { // TODO: eventually rewrite arrayLikeIterator to use a three-state enum for handling // UNDEFINED instead of an "includeUndefined" boolean with states SKIP, INCLUDE, // RETURN_EMPTY. Until then, this is how we'll make sure that empty elements don't make it @@ -1828,15 +1827,14 @@ public final class NativeArray extends ScriptObject implements OptimisticBuiltin } final Object arg = args[2]; - //args[2] continuousarray or non arraydata, let past non array datas + // The generic version uses its own logic and ArrayLikeIterator to decide if an object should + // be iterated over or added as single element. To avoid duplication of code and err on the safe side + // we only use the specialized version if arg is either a continuous array or a JS primitive. if (arg instanceof NativeArray) { - final ContinuousArrayData argData = getContinuousArrayData(arg); - if (argData == null) { - return false; - } + return (getContinuousArrayData(arg) != null); } - return true; + return JSType.isPrimitive(arg); } } diff --git a/nashorn/test/script/basic/JDK-8161579.js b/nashorn/test/script/basic/JDK-8161579.js new file mode 100644 index 00000000000..cc52c178d78 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8161579.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8161579: Array-like AbstractJSObject-based instance not treated as array by native array functions + * + * @test + * @run + */ + + +var AbstractJSObject = Java.type("jdk.nashorn.api.scripting.AbstractJSObject"); +var JavaStringArray = Java.type("java.lang.String[]"); +var JavaArrayList = Java.type("java.util.ArrayList"); + +var arrayLikeJSObject = new AbstractJSObject() { + hasMember: function(name) { return name == "length"; }, + getMember: function(name) { return name == "length" ? 3 : null; }, + hasSlot: function(slot) { return slot >= 0 && slot <= 2; }, + getSlot: function(slot) { return "abc"[slot]; }, + isArray: function() { return true; } +} + +var javaStringArray = new JavaStringArray(3); +javaStringArray[0] = "x"; +javaStringArray[1] = "y"; +javaStringArray[2] = "z"; + +var javaArrayList = new JavaArrayList(); +javaArrayList.add("i"); +javaArrayList.add("j"); +javaArrayList.add("k"); + +Assert.assertEquals([1, 2, 3].concat(arrayLikeJSObject).join(), "1,2,3,a,b,c"); +Assert.assertEquals([1, 2, 3].concat(javaStringArray).join(), "1,2,3,x,y,z"); +Assert.assertEquals([1, 2, 3].concat(javaArrayList).join(), "1,2,3,i,j,k"); +Assert.assertEquals([1, 2, 3].concat("foo").join(), "1,2,3,foo"); +Assert.assertEquals([1, 2, 3].concat(4).join(), "1,2,3,4"); +Assert.assertEquals([1, 2, 3].concat(false).join(), "1,2,3,false"); + From bac0ea684259dddebff6bddada757e9b5fa5b88f Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Mon, 28 Nov 2016 10:13:18 +0100 Subject: [PATCH 010/142] 8170385: JDK-8031567 broke source bundles Reviewed-by: erikj --- make/SourceRevision.gmk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/make/SourceRevision.gmk b/make/SourceRevision.gmk index bcc5dd6aa57..987fdfc3110 100644 --- a/make/SourceRevision.gmk +++ b/make/SourceRevision.gmk @@ -65,8 +65,8 @@ ifneq ($(and $(HG), $(wildcard $(TOPDIR)/.hg)), ) $1_FILENAME := $$(call MakeFilenameFromRepo, $1) $$(SUPPORT_OUTPUTDIR)/src-rev/$$($1_FILENAME): FRC - $(call MakeDir $$(@D)) - $(ECHO) $$(strip $1):`$(HG) id -i --repository $$($1_REPO_PATH)` > $$@ + $$(call MakeDir, $$(@D)) + $$(ECHO) $$(strip $1):`$$(HG) id -i --repository $$($1_REPO_PATH)` > $$@ REPO_REVISIONS += $$(SUPPORT_OUTPUTDIR)/src-rev/$$($1_FILENAME) endef @@ -81,7 +81,7 @@ ifneq ($(and $(HG), $(wildcard $(TOPDIR)/.hg)), ) # Param 1: The output file define CreateSourceRevisionFile $1: $$(REPO_REVISIONS) - $(call MakeDir $$(@D)) + $$(call MakeDir, $$(@D)) $$(ECHO) `$$(CAT) $$(REPO_REVISIONS)` > $$@.tmp if [ ! -f $$@ ] || [ "`$$(CAT) $$@`" != "`$$(CAT) $$@.tmp`" ]; then \ $$(MV) $$@.tmp $$@ ; \ From ffc4d62cccfe970a1305dedf19f461a62ed8fb72 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Mon, 28 Nov 2016 15:19:08 +0100 Subject: [PATCH 011/142] 8170392: JDK-8031567 broke builds from source bundles Reviewed-by: sla --- make/Images.gmk | 3 ++- make/SourceRevision.gmk | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/make/Images.gmk b/make/Images.gmk index bff0f5762a8..1ee70716b81 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -100,7 +100,8 @@ SOURCE_REVISION = $(shell \ $(CAT) $(SOURCE_REVISION_TRACKER) ; \ fi) -$(BASE_RELEASE_FILE): $(INFO_FILE_VARDEPS) $(SOURCE_REVISION_TRACKER) +# The SOURCE_REVISION_TRACKER file may not exist. Only depend on it if it does. +$(BASE_RELEASE_FILE): $(INFO_FILE_VARDEPS) $(wildcard $(SOURCE_REVISION_TRACKER)) $(info-file) ################################################################################ diff --git a/make/SourceRevision.gmk b/make/SourceRevision.gmk index 987fdfc3110..cdd77d74692 100644 --- a/make/SourceRevision.gmk +++ b/make/SourceRevision.gmk @@ -119,8 +119,7 @@ else exit 2 create-source-revision-tracker: - $(call LogWarn, Error: No mercurial configuration present and no .src-rev) - exit 2 + $(call LogWarn, Warning: No mercurial configuration present and no .src-rev) endif endif From b16751e52bee2b3c5c02f05d37fc53b13be08ac5 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Mon, 28 Nov 2016 21:13:52 +0530 Subject: [PATCH 012/142] 8170402: Compilation warning with NashornException Reviewed-by: hannesw, jlaskey --- .../classes/jdk/nashorn/api/scripting/NashornException.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/NashornException.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/NashornException.java index b082076e593..b8db1b7326d 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/NashornException.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/NashornException.java @@ -244,7 +244,7 @@ public abstract class NashornException extends RuntimeException { * @param global the global * @return initialized exception */ - protected NashornException initEcmaError(final ScriptObject global) { + NashornException initEcmaError(final ScriptObject global) { if (ecmaError != null) { return this; // initialized already! } From d8c7cf7073a96c47e7cab98fce525fa1f4d17d24 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Mon, 28 Nov 2016 11:36:15 -0800 Subject: [PATCH 013/142] 8169816: Move src.zip and jrt-fs.jar under the lib directory Reviewed-by: alanb, erikj --- make/Images.gmk | 14 ++------------ make/JrtfsJar.gmk | 2 +- make/Main.gmk | 13 ++++++------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/make/Images.gmk b/make/Images.gmk index 1ee70716b81..a20b930c249 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -354,11 +354,11 @@ JDK_TARGETS += $(JDK_DOC_TARGETS) ################################################################################ # src.zip -$(JDK_IMAGE_DIR)/src.zip: $(SUPPORT_OUTPUTDIR)/src.zip +$(JDK_IMAGE_DIR)/lib/src.zip: $(SUPPORT_OUTPUTDIR)/src.zip $(call LogInfo, Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)) $(install-file) -JDK_TARGETS += $(JDK_IMAGE_DIR)/src.zip +JDK_TARGETS += $(JDK_IMAGE_DIR)/lib/src.zip ################################################################################ # /demo dir @@ -400,16 +400,6 @@ $(eval $(call SetupCopyFiles, COPY_SAMPLES, \ JDK_TARGETS += $(COPY_SAMPLES) -################################################################################ -# jrt-fs.jar - -$(eval $(call SetupCopyFiles,COPY_JRTFS_JAR, \ - SRC := $(SUPPORT_OUTPUTDIR), \ - DEST := $(JDK_IMAGE_DIR), \ - FILES := $(SUPPORT_OUTPUTDIR)/jrt-fs.jar)) - -JDK_TARGETS += $(COPY_JRTFS_JAR) - ################################################################################ # Code coverage data files diff --git a/make/JrtfsJar.gmk b/make/JrtfsJar.gmk index 36ba0beba2b..a95049030ea 100644 --- a/make/JrtfsJar.gmk +++ b/make/JrtfsJar.gmk @@ -65,7 +65,7 @@ $(eval $(call SetupCopyFiles, COPY_JIMAGE_SERVICE_PROVIDER, \ $(eval $(call SetupJarArchive,BUILD_JRTFS_JAR, \ DEPENDENCIES := $(BUILD_JRTFS) $(COPY_JIMAGE_SERVICE_PROVIDER), \ SRCS := $(SUPPORT_OUTPUTDIR)/jrtfs_classes, \ - JAR := $(SUPPORT_OUTPUTDIR)/jrt-fs.jar, \ + JAR := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jrt-fs.jar, \ MANIFEST := $(SUPPORT_OUTPUTDIR)/java-main-manifest.mf, \ )) diff --git a/make/Main.gmk b/make/Main.gmk index d5d0802d70f..1add025480c 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -603,12 +603,12 @@ else jdk.jdeps-gendata: java rmic - # Declare dependencies between jmod targets. Only java.base jmod needs access - # to the other jmods to be built. + # Declare dependencies between jmod targets. + # java.base jmod needs jrt-fs.jar and access to the other jmods to be built. # When creating a BUILDJDK, we don't need to add hashes to java.base, thus # we don't need to depend on all other jmods ifneq ($(CREATING_BUILDJDK), true) - java.base-jmod: $(filter-out java.base-jmod \ + java.base-jmod: jrtfs-jar $(filter-out java.base-jmod \ $(addsuffix -jmod, $(call FindAllUpgradeableModules)), $(JMOD_TARGETS)) endif @@ -679,11 +679,10 @@ else java.base-jmod jdk-image jre-image: generate-link-opt-data endif - jdk-image: jmods zip-source create-source-revision-tracker demos samples \ - jrtfs-jar - jre-image: jmods create-source-revision-tracker jrtfs-jar + jdk-image: jmods zip-source create-source-revision-tracker demos samples + jre-image: jmods create-source-revision-tracker - profiles: jmods zip-source create-source-revision-tracker jrtfs-jar + profiles: jmods zip-source create-source-revision-tracker mac-bundles-jdk: jdk-image jre-image From 29904587f16e324b9e1a1763785e80fc412cc678 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Mon, 28 Nov 2016 18:04:52 -0800 Subject: [PATCH 014/142] 8170424: back out src.zip change from JDK-8170424 Reviewed-by: prr --- make/Images.gmk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/make/Images.gmk b/make/Images.gmk index a20b930c249..47fcd8f3323 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -354,11 +354,11 @@ JDK_TARGETS += $(JDK_DOC_TARGETS) ################################################################################ # src.zip -$(JDK_IMAGE_DIR)/lib/src.zip: $(SUPPORT_OUTPUTDIR)/src.zip +$(JDK_IMAGE_DIR)/src.zip: $(SUPPORT_OUTPUTDIR)/src.zip $(call LogInfo, Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)) $(install-file) -JDK_TARGETS += $(JDK_IMAGE_DIR)/lib/src.zip +JDK_TARGETS += $(JDK_IMAGE_DIR)/src.zip ################################################################################ # /demo dir From 3af52f25f3275f132dfef376497e004139778998 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Wed, 30 Nov 2016 19:28:45 +0530 Subject: [PATCH 015/142] 8160359: Improve jlink logging for cases when a plugin throws exception Reviewed-by: jlaskey, redestad --- make/Images.gmk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/make/Images.gmk b/make/Images.gmk index 47fcd8f3323..86303f8f7f7 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -125,7 +125,8 @@ JLINK_ORDER_RESOURCES += \ /jdk.localedata/** \ # -JLINK_TOOL := $(JLINK) --module-path $(IMAGES_OUTPUTDIR)/jmods \ +JLINK_TOOL := $(JLINK) -J-Djlink.debug=true \ + --module-path $(IMAGES_OUTPUTDIR)/jmods \ --endian $(OPENJDK_BUILD_CPU_ENDIAN) \ --release-info $(BASE_RELEASE_FILE) \ --order-resources=$(call CommaList, $(JLINK_ORDER_RESOURCES)) \ From 18af38e9271220076edef0c35d01e86c399e14aa Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Thu, 1 Dec 2016 08:56:28 +0000 Subject: [PATCH 016/142] 8169069: Module system implementation refresh (11/2016) Co-authored-by: Mandy Chung Co-authored-by: Erik Joelsson Co-authored-by: Jonathan Gibbons Reviewed-by: alanb, mchung --- common/autoconf/generated-configure.sh | 8 ++- common/autoconf/source-dirs.m4 | 6 ++ common/conf/jib-profiles.js | 2 +- make/GensrcModuleInfo.gmk | 80 +++++--------------------- make/Javadoc.gmk | 2 +- make/common/Modules.gmk | 7 ++- test/lib/sun/hotspot/WhiteBox.java | 2 - 7 files changed, 35 insertions(+), 72 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 238387046d6..cea02c099b8 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -5093,7 +5093,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1479120453 +DATE_WHEN_GENERATED=1479992729 ############################################################################### # @@ -31196,6 +31196,12 @@ $as_echo "$as_me: The path of IMPORT_MODULES_TOPDIR, which resolves as \"$path\" if test -d "$IMPORT_MODULES_TOPDIR/modules_src"; then IMPORT_MODULES_SRC="$IMPORT_MODULES_TOPDIR/modules_src" fi + # Workaround for using different imported module-info.java in Jake due to a + # change in format. Remove once new format is standard in JDK 9 and javafx + # delivers just that. + if test -d "$IMPORT_MODULES_TOPDIR/modules_src_jake"; then + IMPORT_MODULES_SRC="$IMPORT_MODULES_TOPDIR/modules_src_jake $IMPORT_MODULES_SRC" + fi if test -d "$IMPORT_MODULES_TOPDIR/make"; then IMPORT_MODULES_MAKE="$IMPORT_MODULES_TOPDIR/make" fi diff --git a/common/autoconf/source-dirs.m4 b/common/autoconf/source-dirs.m4 index 940707e81a0..81137cf95ff 100644 --- a/common/autoconf/source-dirs.m4 +++ b/common/autoconf/source-dirs.m4 @@ -126,6 +126,12 @@ AC_DEFUN_ONCE([SRCDIRS_SETUP_IMPORT_MODULES], if test -d "$IMPORT_MODULES_TOPDIR/modules_src"; then IMPORT_MODULES_SRC="$IMPORT_MODULES_TOPDIR/modules_src" fi + # Workaround for using different imported module-info.java in Jake due to a + # change in format. Remove once new format is standard in JDK 9 and javafx + # delivers just that. + if test -d "$IMPORT_MODULES_TOPDIR/modules_src_jake"; then + IMPORT_MODULES_SRC="$IMPORT_MODULES_TOPDIR/modules_src_jake $IMPORT_MODULES_SRC" + fi if test -d "$IMPORT_MODULES_TOPDIR/make"; then IMPORT_MODULES_MAKE="$IMPORT_MODULES_TOPDIR/make" fi diff --git a/common/conf/jib-profiles.js b/common/conf/jib-profiles.js index fa3c5749f8c..a40c8b05eef 100644 --- a/common/conf/jib-profiles.js +++ b/common/conf/jib-profiles.js @@ -427,7 +427,7 @@ var getJibProfilesDependencies = function (input, common) { jtreg: { server: "javare", revision: "4.2", - build_number: "b03", + build_number: "b04", checksum_file: "MD5_VALUES", file: "jtreg_bin-4.2.zip", environment_name: "JT_HOME", diff --git a/make/GensrcModuleInfo.gmk b/make/GensrcModuleInfo.gmk index cd0c3af9f00..25ade7f131e 100644 --- a/make/GensrcModuleInfo.gmk +++ b/make/GensrcModuleInfo.gmk @@ -60,8 +60,8 @@ TOOL_GENMODULEINFOSOURCE = $(JAVA_SMALL) \ ################################################################################ -# Name of data file. Keep module-info.java.ext until javafx has changed. -MOD_FILENAME := module-info.java.extra module-info.java.ext +# Name of modification file. +MOD_FILENAME := module-info.java.extra # Construct all possible src directories for the module. MODULE_CLASSES_DIRS := $(call FindModuleSrcDirs, $(MODULE)) @@ -74,74 +74,24 @@ ifneq ($(MOD_FILES), ) # Only make this call if modification files are found for this module ALL_MODULES := $(call FindAllModules) - # Read the contents of all the files into a variable. Replace space with / to - # let space represent new lines in the variable as $(shell) normalizes all - # whitespace. - $(foreach f, $(MOD_FILES), \ - $(eval MOD_FILE_CONTENTS += $(shell $(GREP) -v -e ".\*" -e "//" $f | $(TR) ' ' '/'))) - - # Separate the modifications into qualified exports and the rest - MODS_QUALIFIED_EXPORTS := $(call containing, /to/, $(MOD_FILE_CONTENTS)) - MODS_REST := $(filter-out $(MODS_QUALIFIED_EXPORTS), $(MOD_FILE_CONTENTS)) - - # Filter the contents for modules that are actually being built - ALL_MODULES_FILTER := $(addprefix %/, $(addsuffix ;, $(ALL_MODULES))) - MODIFICATIONS := $(filter $(ALL_MODULES_FILTER), $(MODS_QUALIFIED_EXPORTS)) \ - $(MODS_REST) - - # Returns non empty if the package exists in the current module - # Param 1 - Name of package with dots - PackageExists = \ - $(strip $(wildcard $(addsuffix $(subst .,/,/$(strip $1)), \ - $(MODULE_CLASSES_DIRS) \ - $(addsuffix /$(MODULE), $(IMPORT_MODULES_CLASSES)) \ - $(JDK_OUTPUTDIR)/modules/$(MODULE) \ - ))) - - # Convert the modification lines into arguments for the modification tool. - # Filter out modifications for non existing to-modules. - $(foreach line, $(MODIFICATIONS), \ - $(eval split_line := $(subst /,$(SPACE),$(line))) \ - $(eval command := $(word 1, $(split_line))) \ - $(if $(filter $(command), exports), \ - $(eval package := $(patsubst %;,%,$(word 2, $(split_line)))) \ - $(if $(call PackageExists, $(package)), \ - $(eval to_module := $(patsubst %;,%,$(word 4, $(split_line)))) \ - $(if $(to_module), \ - $(eval ARGS += -$(command) $(package)/$(to_module)) \ - , \ - $(eval ARGS += -$(command) $(package)) \ - ) \ - ) \ - , \ - $(if $(filter $(command), provides), \ - $(eval provider := $(patsubst %;,%,$(word 2, $(split_line)))) \ - $(eval class := $(patsubst %;,%,$(word 4, $(split_line)))) \ - $(eval ARGS += -$(command) $(provider)/$(class)) \ - , \ - $(error A module-info.extra in $(MODULE) contains invalid command $(command)) \ - ) \ - ) \ - ) - - ifneq ($(ARGS), ) - $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java: \ - $(firstword $(call FindAllModuleInfos, $(MODULE))) \ - $(BUILD_TOOLS_JDK) \ - $(call DependOnVariable, ARGS) + $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java: \ + $(firstword $(call FindAllModuleInfos, $(MODULE))) \ + $(BUILD_TOOLS_JDK) \ + $(MOD_FILES) \ + $(call DependOnVariable, ALL_MODULES) $(MKDIR) -p $(@D) $(RM) $@ $@.tmp - $(TOOL_GENMODULEINFOSOURCE) $(ARGS) -o $@.tmp $< + $(TOOL_GENMODULEINFOSOURCE) -o $@.tmp \ + --source-file $< \ + --modules $(call CommaList, $(ALL_MODULES)) \ + $(MOD_FILES) $(MV) $@.tmp $@ - TARGETS += $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java - endif + TARGETS += $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java -endif - -# If no modifications are found for this module, remove any module-info.java -# created by a previous build since that is no longer valid. -ifeq ($(MODIFICATIONS), ) +else + # If no modifications are found for this module, remove any module-info.java + # created by a previous build since that is no longer valid. ifneq ($(wildcard $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java), ) $(shell $(RM) $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/module-info.java) endif diff --git a/make/Javadoc.gmk b/make/Javadoc.gmk index 98bf06f2e28..bb491ecf109 100644 --- a/make/Javadoc.gmk +++ b/make/Javadoc.gmk @@ -33,7 +33,7 @@ include MakeBase.gmk # Allow custom to overwrite. JAVADOC_SOURCE_DIRS = \ $(SUPPORT_OUTPUTDIR)/gensrc/* \ - $(if $(IMPORT_MODULES_SRC), $(IMPORT_MODULES_SRC)/*) \ + $(addsuffix /*, $(IMPORT_MODULES_SRC)) \ $(JDK_TOPDIR)/src/*/$(OPENJDK_TARGET_OS)/classes \ $(JDK_TOPDIR)/src/*/$(OPENJDK_TARGET_OS_TYPE)/classes \ $(JDK_TOPDIR)/src/*/share/classes \ diff --git a/make/common/Modules.gmk b/make/common/Modules.gmk index bb1d05979dd..eeb82b0f118 100644 --- a/make/common/Modules.gmk +++ b/make/common/Modules.gmk @@ -171,12 +171,15 @@ SRC_SUBDIRS += share/classes # Find all module-info.java files for the current build target platform and # configuration. +# TODO: The $(firstword call is part of a workaround for using different +# imported module-info.java in Jake due to a change in format. Remove once +# new format is standard in JDK 9 and javafx delivers just that. # Param 1 - Module to find for, set to * for finding all FindAllModuleInfos = \ $(wildcard \ $(foreach sub, $(SRC_SUBDIRS), \ $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \ - $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC))) + $(patsubst %,%/$(strip $1)/module-info.java, $(firstword $(IMPORT_MODULES_SRC)))) # Find module-info.java files in the specific source dir # Param 1 - Src dir to find module-info.java files in @@ -244,7 +247,7 @@ $(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \ BEGIN { if (MODULE != "java.base") printf(" java.base"); } \ /requires/ { sub(/;/, ""); \ sub(/requires/, ""); \ - sub(/public/, ""); \ + sub(/transitive/, ""); \ sub(/\/\/.*/, ""); \ sub(/\/\*.*\*\//, ""); \ gsub(/^ +\*.*/, ""); \ diff --git a/test/lib/sun/hotspot/WhiteBox.java b/test/lib/sun/hotspot/WhiteBox.java index 9d3c38750b5..c01657f020e 100644 --- a/test/lib/sun/hotspot/WhiteBox.java +++ b/test/lib/sun/hotspot/WhiteBox.java @@ -453,8 +453,6 @@ public class WhiteBox { Object[] packages); public native void AddModuleExports(Object from_module, String pkg, Object to_module); public native void AddReadsModule(Object from_module, Object source_module); - public native boolean CanReadModule(Object asking_module, Object source_module); - public native boolean IsExportedToModule(Object from_module, String pkg, Object to_module); public native void AddModulePackage(Object module, String pkg); public native void AddModuleExportsToAllUnnamed(Object module, String pkg); public native void AddModuleExportsToAll(Object module, String pkg); From 32babf060327b26a3b68a020580d3f9b40821003 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Thu, 1 Dec 2016 10:43:59 +0100 Subject: [PATCH 017/142] 8170576: Silence error message in compare.sh when selecting images Reviewed-by: erikj --- common/bin/compare.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/bin/compare.sh b/common/bin/compare.sh index ba60485ea53..de909e0154c 100644 --- a/common/bin/compare.sh +++ b/common/bin/compare.sh @@ -1295,8 +1295,8 @@ if [ "$SKIP_DEFAULT" != "true" ]; then OTHER_JDK="$OTHER/images/jdk" OTHER_JRE="$OTHER/images/jre" echo "Selecting jdk images for compare" - elif [ -d "$(ls -d $THIS/licensee-src/build/*/images/jdk)" ] \ - && [ -d "$(ls -d $OTHER/licensee-src/build/*/images/jdk)" ] + elif [ -d "$(ls -d $THIS/licensee-src/build/*/images/jdk 2> /dev/null)" ] \ + && [ -d "$(ls -d $OTHER/licensee-src/build/*/images/jdk 2> /dev/null)" ] then echo "Selecting licensee images for compare" # Simply override the THIS and OTHER dir with the build dir from From c369b807302852609b224ab8ca541a0da5ef6397 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Thu, 1 Dec 2016 14:40:06 +0100 Subject: [PATCH 018/142] 8170528: Race condition with release file creation Reviewed-by: dholmes, ihse, tbell --- make/Images.gmk | 39 -------------------- make/Main.gmk | 15 +++++--- make/ReleaseFile.gmk | 86 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 44 deletions(-) create mode 100644 make/ReleaseFile.gmk diff --git a/make/Images.gmk b/make/Images.gmk index 86303f8f7f7..befae87987a 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -64,48 +64,9 @@ JRE_COMPACT2_MODULES_LIST := $(call CommaList, $(JRE_COMPACT2_MODULES)) JRE_COMPACT3_MODULES_LIST := $(call CommaList, $(JRE_COMPACT3_MODULES)) ################################################################################ -# Release file BASE_RELEASE_FILE := $(JDK_OUTPUTDIR)/release -# Common way to emit a line into the release or info file -define info-file-item # name value - $(PRINTF) '%s="%s"\n' $1 $2 >> $@ -endef - -# Param 1 - The file containing the MODULES list -define create-info-file - $(if $(JDK_ARCH_ABI_PROP_NAME), \ - $(call info-file-item, "SUN_ARCH_ABI", "$(JDK_ARCH_ABI_PROP_NAME)")) - $(call info-file-item, "SOURCE", "$(strip $(SOURCE_REVISION))") -endef - -# Param 1 - The file containing the MODULES list -define prepare-info-file - $(ECHO) $(LOG_INFO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@) - $(MKDIR) -p $(@D) - $(RM) $@ -endef - -define info-file - $(call prepare-info-file) - $(call create-info-file) -endef - -# Create a variable dependency file common for all release info files. -INFO_FILE_VARDEPS := $(call DependOnVariable, create-info-file) - -SOURCE_REVISION = $(shell \ - if [ -f $(SOURCE_REVISION_TRACKER) ] ; then \ - $(CAT) $(SOURCE_REVISION_TRACKER) ; \ - fi) - -# The SOURCE_REVISION_TRACKER file may not exist. Only depend on it if it does. -$(BASE_RELEASE_FILE): $(INFO_FILE_VARDEPS) $(wildcard $(SOURCE_REVISION_TRACKER)) - $(info-file) - -################################################################################ - JMODS := $(wildcard $(IMAGES_OUTPUTDIR)/jmods/*.jmod) # Use this file inside the image as target for make rule diff --git a/make/Main.gmk b/make/Main.gmk index 1add025480c..e264d91d6ad 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -324,13 +324,16 @@ profiles: mac-bundles-jdk: +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f MacBundles.gmk) +release-file: + +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ReleaseFile.gmk) + exploded-image-optimize: +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ExplodedImageOptimize.gmk) ALL_TARGETS += store-source-revision create-source-revision-tracker bootcycle-images zip-security \ zip-source jrtfs-jar jdk-image jre-image \ symbols-image profiles mac-bundles-jdk \ - exploded-image-optimize + release-file exploded-image-optimize ################################################################################ # Docs targets @@ -679,10 +682,12 @@ else java.base-jmod jdk-image jre-image: generate-link-opt-data endif - jdk-image: jmods zip-source create-source-revision-tracker demos samples - jre-image: jmods create-source-revision-tracker + release-file: create-source-revision-tracker - profiles: jmods zip-source create-source-revision-tracker + jdk-image: jmods zip-source demos samples release-file + jre-image: jmods release-file + + profiles: jmods release-file mac-bundles-jdk: jdk-image jre-image @@ -789,7 +794,7 @@ samples: samples-jdk # The "exploded image" is a locally runnable JDK in $(BUILD_OUTPUT)/jdk. exploded-image-base: $(ALL_MODULES) -exploded-image: exploded-image-base +exploded-image: exploded-image-base release-file # When cross compiling, no need to optimize the exploded image since it won't # be runnable on the host platform anyway. ifneq ($(COMPILE_TYPE), cross) diff --git a/make/ReleaseFile.gmk b/make/ReleaseFile.gmk new file mode 100644 index 00000000000..d68d9e47901 --- /dev/null +++ b/make/ReleaseFile.gmk @@ -0,0 +1,86 @@ +# +# Copyright (c) 2016, 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. +# + +default: all + +include $(SPEC) +include MakeBase.gmk + +################################################################################ +# This makefile generates the "release" file into the exploded image. Jlink is +# then responsible for using this as the base for release files in each linked +# image. +# +################################################################################ + +BASE_RELEASE_FILE := $(JDK_OUTPUTDIR)/release + +# Common way to emit a line into the release or info file +define info-file-item # name value + $(PRINTF) '%s="%s"\n' $1 $2 >> $@ +endef + +# Param 1 - The file containing the MODULES list +define create-info-file + $(if $(JDK_ARCH_ABI_PROP_NAME), \ + $(call info-file-item, "SUN_ARCH_ABI", "$(JDK_ARCH_ABI_PROP_NAME)")) + $(call info-file-item, "SOURCE", "$(strip $(SOURCE_REVISION))") +endef + +# Param 1 - The file containing the MODULES list +define prepare-info-file + $(call LogInfo, Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)) + $(call MakeDir, $(@D)) + $(RM) $@ +endef + +define info-file + $(call prepare-info-file) + $(call create-info-file) +endef + +# Create a variable dependency file common for all release info files. +INFO_FILE_VARDEPS := $(call DependOnVariable, create-info-file) + +SOURCE_REVISION = $(shell \ + if [ -f $(SOURCE_REVISION_TRACKER) ] ; then \ + $(CAT) $(SOURCE_REVISION_TRACKER) ; \ + fi) + +# The SOURCE_REVISION_TRACKER file may not exist. Only depend on it if it does. +$(BASE_RELEASE_FILE): $(INFO_FILE_VARDEPS) $(wildcard $(SOURCE_REVISION_TRACKER)) + $(info-file) + +TARGETS += $(BASE_RELEASE_FILE) + +################################################################################ + +$(eval $(call IncludeCustomExtension, , ReleaseFile.gmk)) + +################################################################################ + +all: $(TARGETS) + +.PHONY: all default From c38acad81f2a849a04c309b6d22513b7acb5eb10 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Thu, 1 Dec 2016 15:08:43 +0100 Subject: [PATCH 019/142] 8168924: Add jdk.unsupported to the compact profile builds Reviewed-by: alanb, chegar, mchung --- make/Images.gmk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/make/Images.gmk b/make/Images.gmk index befae87987a..fa3d3ba1db7 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -48,7 +48,8 @@ JRE_MODULES += $(filter $(ALL_MODULES), $(BOOT_MODULES) \ JDK_MODULES += $(ALL_MODULES) # Compact builds have additional modules -COMPACT1_EXTRA_MODULES := jdk.localedata jdk.crypto.pkcs11 jdk.crypto.ec +COMPACT1_EXTRA_MODULES := jdk.localedata jdk.crypto.pkcs11 jdk.crypto.ec \ + jdk.unsupported COMPACT2_EXTRA_MODULES := jdk.xml.dom jdk.httpserver COMPACT3_EXTRA_MODULES := java.smartcardio jdk.management \ jdk.naming.dns jdk.naming.rmi jdk.sctp jdk.security.auth From 73f6f8e873ccdfa09d7f58e540df0bd08e039e2d Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Thu, 1 Dec 2016 15:12:23 +0100 Subject: [PATCH 020/142] 8164304: JDK should build with Oracle Developer Studio Reviewed-by: tbell, ihse --- common/autoconf/generated-configure.sh | 18 +++++++++++++----- common/autoconf/toolchain.m4 | 4 +++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 5181bb585b3..5611e60ab04 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -5093,7 +5093,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1480584361 +DATE_WHEN_GENERATED=1480601517 ############################################################################### # @@ -33584,9 +33584,11 @@ $as_echo "$as_me: Please use --enable-ccache instead of providing a wrapped comp if test "x$TOOLCHAIN_TYPE" = xsolstudio; then # cc -V output typically looks like # cc: Sun C 5.12 Linux_i386 2011/11/16 + # or + # cc: Studio 12.5 Sun C 5.14 SunOS_sparc 2016/05/31 COMPILER_VERSION_OUTPUT=`$COMPILER -V 2>&1` # Check that this is likely to be the Solaris Studio cc. - $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null + $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "^.* Sun $COMPILER_NAME" > /dev/null if test $? -ne 0; then ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1` { $as_echo "$as_me:${as_lineno-$LINENO}: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler." >&5 @@ -34881,9 +34883,11 @@ $as_echo "$as_me: Please use --enable-ccache instead of providing a wrapped comp if test "x$TOOLCHAIN_TYPE" = xsolstudio; then # cc -V output typically looks like # cc: Sun C 5.12 Linux_i386 2011/11/16 + # or + # cc: Studio 12.5 Sun C 5.14 SunOS_sparc 2016/05/31 COMPILER_VERSION_OUTPUT=`$COMPILER -V 2>&1` # Check that this is likely to be the Solaris Studio cc. - $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null + $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "^.* Sun $COMPILER_NAME" > /dev/null if test $? -ne 0; then ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1` { $as_echo "$as_me:${as_lineno-$LINENO}: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler." >&5 @@ -46962,9 +46966,11 @@ $as_echo "$as_me: Rewriting BUILD_STRIP to \"$new_complete\"" >&6;} if test "x$TOOLCHAIN_TYPE" = xsolstudio; then # cc -V output typically looks like # cc: Sun C 5.12 Linux_i386 2011/11/16 + # or + # cc: Studio 12.5 Sun C 5.14 SunOS_sparc 2016/05/31 COMPILER_VERSION_OUTPUT=`$COMPILER -V 2>&1` # Check that this is likely to be the Solaris Studio cc. - $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null + $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "^.* Sun $COMPILER_NAME" > /dev/null if test $? -ne 0; then ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1` { $as_echo "$as_me:${as_lineno-$LINENO}: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler." >&5 @@ -47082,9 +47088,11 @@ $as_echo "$as_me: Using $TOOLCHAIN_TYPE $COMPILER_NAME compiler version $COMPILE if test "x$TOOLCHAIN_TYPE" = xsolstudio; then # cc -V output typically looks like # cc: Sun C 5.12 Linux_i386 2011/11/16 + # or + # cc: Studio 12.5 Sun C 5.14 SunOS_sparc 2016/05/31 COMPILER_VERSION_OUTPUT=`$COMPILER -V 2>&1` # Check that this is likely to be the Solaris Studio cc. - $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null + $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "^.* Sun $COMPILER_NAME" > /dev/null if test $? -ne 0; then ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1` { $as_echo "$as_me:${as_lineno-$LINENO}: The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler." >&5 diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4 index db3d39e2655..c0c35b9f12c 100644 --- a/common/autoconf/toolchain.m4 +++ b/common/autoconf/toolchain.m4 @@ -333,9 +333,11 @@ AC_DEFUN([TOOLCHAIN_EXTRACT_COMPILER_VERSION], if test "x$TOOLCHAIN_TYPE" = xsolstudio; then # cc -V output typically looks like # cc: Sun C 5.12 Linux_i386 2011/11/16 + # or + # cc: Studio 12.5 Sun C 5.14 SunOS_sparc 2016/05/31 COMPILER_VERSION_OUTPUT=`$COMPILER -V 2>&1` # Check that this is likely to be the Solaris Studio cc. - $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null + $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "^.* Sun $COMPILER_NAME" > /dev/null if test $? -ne 0; then ALT_VERSION_OUTPUT=`$COMPILER --version 2>&1` AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required $TOOLCHAIN_TYPE compiler.]) From 5722a3a6d08d041524a379df427e8ba6e78eab25 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 1 Dec 2016 21:01:51 +0000 Subject: [PATCH 021/142] Added tag jdk-9+147 for changeset 06c697759688 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 58e9fe724f4..a1da5758a42 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -389,3 +389,4 @@ f64afae7f1a5608e438585bbf0bc23785e69cba0 jdk-9+141 8d337fd6333e28c48aa87880144b840aad82baaf jdk-9+144 ff98aa9ec9fae991e426ce5926fc9036d25f5562 jdk-9+145 a22e2671d88f6b22a4aa82e3966986542ed2a381 jdk-9+146 +5f6920274c48eb00d31afee6c034826a754c13d9 jdk-9+147 From b89aaf9eb7e73432759b804debb66fd1193f8337 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Fri, 2 Dec 2016 12:33:53 +0100 Subject: [PATCH 022/142] 8170651: Remove legacy hotspot compiler setup Reviewed-by: erikj --- common/autoconf/configure.ac | 1 - common/autoconf/generated-configure.sh | 73 +------------------------- common/autoconf/toolchain.m4 | 32 +---------- 3 files changed, 2 insertions(+), 104 deletions(-) diff --git a/common/autoconf/configure.ac b/common/autoconf/configure.ac index bb5491ba0b4..4879d05622b 100644 --- a/common/autoconf/configure.ac +++ b/common/autoconf/configure.ac @@ -182,7 +182,6 @@ TOOLCHAIN_POST_DETECTION # Finally do some processing after the detection phase TOOLCHAIN_SETUP_BUILD_COMPILERS -TOOLCHAIN_SETUP_LEGACY TOOLCHAIN_MISC_CHECKS # Setup the JTReg Regression Test Harness. diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 5611e60ab04..62577f8d704 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -791,11 +791,6 @@ JTREGEXE HOTSPOT_TOOLCHAIN_TYPE USING_BROKEN_SUSE_LD PACKAGE_PATH -USE_CLANG -HOTSPOT_LD -HOTSPOT_CXX -HOTSPOT_RC -HOTSPOT_MT BUILD_AS BUILD_LDCXX BUILD_LD @@ -4982,10 +4977,6 @@ TOOLCHAIN_MINIMUM_VERSION_xlc="" # for this, we can only do this after these have been setup. -# Setup legacy variables that are still needed as alternative ways to refer to -# parts of the toolchain. - - # Do some additional checks on the detected tools. @@ -5093,7 +5084,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1480601517 +DATE_WHEN_GENERATED=1480671645 ############################################################################### # @@ -47273,68 +47264,6 @@ $as_echo "$as_me: WARNING: C compiler version number has a part larger than 9999 - if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then - # For hotspot, we need these in Windows mixed path, - # so rewrite them all. Need added .exe suffix. - HOTSPOT_CXX="$CXX.exe" - HOTSPOT_LD="$LD.exe" - HOTSPOT_MT="$MT.exe" - HOTSPOT_RC="$RC.exe" - - unix_path="$HOTSPOT_CXX" - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then - windows_path=`$CYGPATH -m "$unix_path"` - HOTSPOT_CXX="$windows_path" - elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then - windows_path=`cmd //c echo $unix_path` - HOTSPOT_CXX="$windows_path" - fi - - - unix_path="$HOTSPOT_LD" - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then - windows_path=`$CYGPATH -m "$unix_path"` - HOTSPOT_LD="$windows_path" - elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then - windows_path=`cmd //c echo $unix_path` - HOTSPOT_LD="$windows_path" - fi - - - unix_path="$HOTSPOT_MT" - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then - windows_path=`$CYGPATH -m "$unix_path"` - HOTSPOT_MT="$windows_path" - elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then - windows_path=`cmd //c echo $unix_path` - HOTSPOT_MT="$windows_path" - fi - - - unix_path="$HOTSPOT_RC" - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then - windows_path=`$CYGPATH -m "$unix_path"` - HOTSPOT_RC="$windows_path" - elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then - windows_path=`cmd //c echo $unix_path` - HOTSPOT_RC="$windows_path" - fi - - - - else - HOTSPOT_CXX="$CXX" - HOTSPOT_LD="$LD" - fi - - - - if test "x$TOOLCHAIN_TYPE" = xclang; then - USE_CLANG=true - fi - - - # The package path is used only on macosx? diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4 index c0c35b9f12c..670d0931fc7 100644 --- a/common/autoconf/toolchain.m4 +++ b/common/autoconf/toolchain.m4 @@ -829,7 +829,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_SETUP_BUILD_COMPILERS], BUILD_SYSROOT_CFLAGS="$SYSROOT_CFLAGS" BUILD_SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS" BUILD_AR="$AR" - + TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS([], [OPENJDK_BUILD_]) fi @@ -844,36 +844,6 @@ AC_DEFUN_ONCE([TOOLCHAIN_SETUP_BUILD_COMPILERS], AC_SUBST(BUILD_AR) ]) -# Setup legacy variables that are still needed as alternative ways to refer to -# parts of the toolchain. -AC_DEFUN_ONCE([TOOLCHAIN_SETUP_LEGACY], -[ - if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then - # For hotspot, we need these in Windows mixed path, - # so rewrite them all. Need added .exe suffix. - HOTSPOT_CXX="$CXX.exe" - HOTSPOT_LD="$LD.exe" - HOTSPOT_MT="$MT.exe" - HOTSPOT_RC="$RC.exe" - BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_CXX) - BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_LD) - BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_MT) - BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_RC) - AC_SUBST(HOTSPOT_MT) - AC_SUBST(HOTSPOT_RC) - else - HOTSPOT_CXX="$CXX" - HOTSPOT_LD="$LD" - fi - AC_SUBST(HOTSPOT_CXX) - AC_SUBST(HOTSPOT_LD) - - if test "x$TOOLCHAIN_TYPE" = xclang; then - USE_CLANG=true - fi - AC_SUBST(USE_CLANG) -]) - # Do some additional checks on the detected tools. AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS], [ From 1b86d8d6e053769c1b7065190db44b53214a20dd Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Fri, 2 Dec 2016 14:19:32 +0100 Subject: [PATCH 023/142] 8170666: Test for microsoft compiler minimum version Reviewed-by: erikj --- common/autoconf/generated-configure.sh | 58 +++++++++++++------------- common/autoconf/toolchain.m4 | 14 +++---- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 62577f8d704..8c658a14afd 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -4906,7 +4906,7 @@ TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++" # Minimum supported versions, empty means unspecified TOOLCHAIN_MINIMUM_VERSION_clang="3.2" TOOLCHAIN_MINIMUM_VERSION_gcc="4.3" -TOOLCHAIN_MINIMUM_VERSION_microsoft="" +TOOLCHAIN_MINIMUM_VERSION_microsoft="16.00.30319.01" # VS2010 TOOLCHAIN_MINIMUM_VERSION_solstudio="5.13" TOOLCHAIN_MINIMUM_VERSION_xlc="" @@ -5084,7 +5084,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1480671645 +DATE_WHEN_GENERATED=1480684711 ############################################################################### # @@ -35262,9 +35262,9 @@ $as_echo "$as_me: WARNING: This typically indicates a broken setup, and is not s fi # We only check CC_VERSION_NUMBER since we assume CXX_VERSION_NUMBER is equal. - if [[ "[$]CC_VERSION_NUMBER" =~ (.*\.){3} ]] ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: C compiler version number has more than three parts (X.Y.Z): $CC_VERSION_NUMBER. Comparisons might be wrong." >&5 -$as_echo "$as_me: WARNING: C compiler version number has more than three parts (X.Y.Z): $CC_VERSION_NUMBER. Comparisons might be wrong." >&2;} + if [[ "[$]CC_VERSION_NUMBER" =~ (.*\.){4} ]] ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: C compiler version number has more than four parts (W.X.Y.Z): $CC_VERSION_NUMBER. Comparisons might be wrong." >&5 +$as_echo "$as_me: WARNING: C compiler version number has more than four parts (W.X.Y.Z): $CC_VERSION_NUMBER. Comparisons might be wrong." >&2;} fi if [[ "[$]CC_VERSION_NUMBER" =~ [0-9]{6} ]] ; then @@ -35272,7 +35272,7 @@ $as_echo "$as_me: WARNING: C compiler version number has more than three parts ( $as_echo "$as_me: WARNING: C compiler version number has a part larger than 99999: $CC_VERSION_NUMBER. Comparisons might be wrong." >&2;} fi - COMPARABLE_ACTUAL_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", $1, $2, $3) }' <<< "$CC_VERSION_NUMBER"` + COMPARABLE_ACTUAL_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", $1, $2, $3, $4) }' <<< "$CC_VERSION_NUMBER"` if test "x$TOOLCHAIN_MINIMUM_VERSION" != x; then @@ -35330,8 +35330,8 @@ $as_echo "$as_me: WARNING: C compiler version number has a part larger than 9999 # Need to assign to a variable since m4 is blocked from modifying parts in []. REFERENCE_VERSION=$TOOLCHAIN_MINIMUM_VERSION - if [[ "$REFERENCE_VERSION" =~ (.*\.){3} ]] ; then - as_fn_error $? "Internal error: Cannot compare to $TOOLCHAIN_MINIMUM_VERSION, only three parts (X.Y.Z) is supported" "$LINENO" 5 + if [[ "$REFERENCE_VERSION" =~ (.*\.){4} ]] ; then + as_fn_error $? "Internal error: Cannot compare to $TOOLCHAIN_MINIMUM_VERSION, only four parts (W.X.Y.Z) is supported" "$LINENO" 5 fi if [[ "$REFERENCE_VERSION" =~ [0-9]{6} ]] ; then @@ -35339,7 +35339,7 @@ $as_echo "$as_me: WARNING: C compiler version number has a part larger than 9999 fi # Version comparison method inspired by http://stackoverflow.com/a/24067243 - COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", $1, $2, $3) }' <<< "$REFERENCE_VERSION"` + COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", $1, $2, $3, $4) }' <<< "$REFERENCE_VERSION"` if test $COMPARABLE_ACTUAL_VERSION -ge $COMPARABLE_REFERENCE_VERSION ; then : @@ -47203,9 +47203,9 @@ $as_echo "$as_me: WARNING: This typically indicates a broken setup, and is not s fi # We only check CC_VERSION_NUMBER since we assume CXX_VERSION_NUMBER is equal. - if [[ "[$]BUILD_CC_VERSION_NUMBER" =~ (.*\.){3} ]] ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: C compiler version number has more than three parts (X.Y.Z): $BUILD_CC_VERSION_NUMBER. Comparisons might be wrong." >&5 -$as_echo "$as_me: WARNING: C compiler version number has more than three parts (X.Y.Z): $BUILD_CC_VERSION_NUMBER. Comparisons might be wrong." >&2;} + if [[ "[$]BUILD_CC_VERSION_NUMBER" =~ (.*\.){4} ]] ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: C compiler version number has more than four parts (W.X.Y.Z): $BUILD_CC_VERSION_NUMBER. Comparisons might be wrong." >&5 +$as_echo "$as_me: WARNING: C compiler version number has more than four parts (W.X.Y.Z): $BUILD_CC_VERSION_NUMBER. Comparisons might be wrong." >&2;} fi if [[ "[$]BUILD_CC_VERSION_NUMBER" =~ [0-9]{6} ]] ; then @@ -47213,7 +47213,7 @@ $as_echo "$as_me: WARNING: C compiler version number has more than three parts ( $as_echo "$as_me: WARNING: C compiler version number has a part larger than 99999: $BUILD_CC_VERSION_NUMBER. Comparisons might be wrong." >&2;} fi - OPENJDK_BUILD_COMPARABLE_ACTUAL_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", $1, $2, $3) }' <<< "$BUILD_CC_VERSION_NUMBER"` + OPENJDK_BUILD_COMPARABLE_ACTUAL_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", $1, $2, $3, $4) }' <<< "$BUILD_CC_VERSION_NUMBER"` else # If we are not cross compiling, use the normal target compilers for @@ -47239,9 +47239,9 @@ $as_echo "$as_me: WARNING: This typically indicates a broken setup, and is not s fi # We only check CC_VERSION_NUMBER since we assume CXX_VERSION_NUMBER is equal. - if [[ "[$]CC_VERSION_NUMBER" =~ (.*\.){3} ]] ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: C compiler version number has more than three parts (X.Y.Z): $CC_VERSION_NUMBER. Comparisons might be wrong." >&5 -$as_echo "$as_me: WARNING: C compiler version number has more than three parts (X.Y.Z): $CC_VERSION_NUMBER. Comparisons might be wrong." >&2;} + if [[ "[$]CC_VERSION_NUMBER" =~ (.*\.){4} ]] ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: C compiler version number has more than four parts (W.X.Y.Z): $CC_VERSION_NUMBER. Comparisons might be wrong." >&5 +$as_echo "$as_me: WARNING: C compiler version number has more than four parts (W.X.Y.Z): $CC_VERSION_NUMBER. Comparisons might be wrong." >&2;} fi if [[ "[$]CC_VERSION_NUMBER" =~ [0-9]{6} ]] ; then @@ -47249,7 +47249,7 @@ $as_echo "$as_me: WARNING: C compiler version number has more than three parts ( $as_echo "$as_me: WARNING: C compiler version number has a part larger than 99999: $CC_VERSION_NUMBER. Comparisons might be wrong." >&2;} fi - OPENJDK_BUILD_COMPARABLE_ACTUAL_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", $1, $2, $3) }' <<< "$CC_VERSION_NUMBER"` + OPENJDK_BUILD_COMPARABLE_ACTUAL_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", $1, $2, $3, $4) }' <<< "$CC_VERSION_NUMBER"` fi @@ -49857,8 +49857,8 @@ $as_echo "$supports" >&6; } # Need to assign to a variable since m4 is blocked from modifying parts in []. REFERENCE_VERSION=6 - if [[ "$REFERENCE_VERSION" =~ (.*\.){3} ]] ; then - as_fn_error $? "Internal error: Cannot compare to 6, only three parts (X.Y.Z) is supported" "$LINENO" 5 + if [[ "$REFERENCE_VERSION" =~ (.*\.){4} ]] ; then + as_fn_error $? "Internal error: Cannot compare to 6, only four parts (W.X.Y.Z) is supported" "$LINENO" 5 fi if [[ "$REFERENCE_VERSION" =~ [0-9]{6} ]] ; then @@ -49866,7 +49866,7 @@ $as_echo "$supports" >&6; } fi # Version comparison method inspired by http://stackoverflow.com/a/24067243 - COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", $1, $2, $3) }' <<< "$REFERENCE_VERSION"` + COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", $1, $2, $3, $4) }' <<< "$REFERENCE_VERSION"` if test $COMPARABLE_ACTUAL_VERSION -ge $COMPARABLE_REFERENCE_VERSION ; then : @@ -50157,8 +50157,8 @@ $as_echo "$as_me: GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLA # Need to assign to a variable since m4 is blocked from modifying parts in []. REFERENCE_VERSION=4.8 - if [[ "$REFERENCE_VERSION" =~ (.*\.){3} ]] ; then - as_fn_error $? "Internal error: Cannot compare to 4.8, only three parts (X.Y.Z) is supported" "$LINENO" 5 + if [[ "$REFERENCE_VERSION" =~ (.*\.){4} ]] ; then + as_fn_error $? "Internal error: Cannot compare to 4.8, only four parts (W.X.Y.Z) is supported" "$LINENO" 5 fi if [[ "$REFERENCE_VERSION" =~ [0-9]{6} ]] ; then @@ -50166,7 +50166,7 @@ $as_echo "$as_me: GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLA fi # Version comparison method inspired by http://stackoverflow.com/a/24067243 - COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", $1, $2, $3) }' <<< "$REFERENCE_VERSION"` + COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", $1, $2, $3, $4) }' <<< "$REFERENCE_VERSION"` if test $COMPARABLE_ACTUAL_VERSION -ge $COMPARABLE_REFERENCE_VERSION ; then : @@ -50680,8 +50680,8 @@ $as_echo "$supports" >&6; } # Need to assign to a variable since m4 is blocked from modifying parts in []. REFERENCE_VERSION=6 - if [[ "$REFERENCE_VERSION" =~ (.*\.){3} ]] ; then - as_fn_error $? "Internal error: Cannot compare to 6, only three parts (X.Y.Z) is supported" "$LINENO" 5 + if [[ "$REFERENCE_VERSION" =~ (.*\.){4} ]] ; then + as_fn_error $? "Internal error: Cannot compare to 6, only four parts (W.X.Y.Z) is supported" "$LINENO" 5 fi if [[ "$REFERENCE_VERSION" =~ [0-9]{6} ]] ; then @@ -50689,7 +50689,7 @@ $as_echo "$supports" >&6; } fi # Version comparison method inspired by http://stackoverflow.com/a/24067243 - COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", $1, $2, $3) }' <<< "$REFERENCE_VERSION"` + COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", $1, $2, $3, $4) }' <<< "$REFERENCE_VERSION"` if test $OPENJDK_BUILD_COMPARABLE_ACTUAL_VERSION -ge $COMPARABLE_REFERENCE_VERSION ; then : @@ -50980,8 +50980,8 @@ $as_echo "$as_me: GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLA # Need to assign to a variable since m4 is blocked from modifying parts in []. REFERENCE_VERSION=4.8 - if [[ "$REFERENCE_VERSION" =~ (.*\.){3} ]] ; then - as_fn_error $? "Internal error: Cannot compare to 4.8, only three parts (X.Y.Z) is supported" "$LINENO" 5 + if [[ "$REFERENCE_VERSION" =~ (.*\.){4} ]] ; then + as_fn_error $? "Internal error: Cannot compare to 4.8, only four parts (W.X.Y.Z) is supported" "$LINENO" 5 fi if [[ "$REFERENCE_VERSION" =~ [0-9]{6} ]] ; then @@ -50989,7 +50989,7 @@ $as_echo "$as_me: GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLA fi # Version comparison method inspired by http://stackoverflow.com/a/24067243 - COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", $1, $2, $3) }' <<< "$REFERENCE_VERSION"` + COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", $1, $2, $3, $4) }' <<< "$REFERENCE_VERSION"` if test $OPENJDK_BUILD_COMPARABLE_ACTUAL_VERSION -ge $COMPARABLE_REFERENCE_VERSION ; then : diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4 index 670d0931fc7..16b0df04b4f 100644 --- a/common/autoconf/toolchain.m4 +++ b/common/autoconf/toolchain.m4 @@ -53,7 +53,7 @@ TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++" # Minimum supported versions, empty means unspecified TOOLCHAIN_MINIMUM_VERSION_clang="3.2" TOOLCHAIN_MINIMUM_VERSION_gcc="4.3" -TOOLCHAIN_MINIMUM_VERSION_microsoft="" +TOOLCHAIN_MINIMUM_VERSION_microsoft="16.00.30319.01" # VS2010 TOOLCHAIN_MINIMUM_VERSION_solstudio="5.13" TOOLCHAIN_MINIMUM_VERSION_xlc="" @@ -69,15 +69,15 @@ AC_DEFUN([TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS], fi # We only check CC_VERSION_NUMBER since we assume CXX_VERSION_NUMBER is equal. - if [ [[ "[$]$1CC_VERSION_NUMBER" =~ (.*\.){3} ]] ]; then - AC_MSG_WARN([C compiler version number has more than three parts (X.Y.Z): [$]$1CC_VERSION_NUMBER. Comparisons might be wrong.]) + if [ [[ "[$]$1CC_VERSION_NUMBER" =~ (.*\.){4} ]] ]; then + AC_MSG_WARN([C compiler version number has more than four parts (W.X.Y.Z): [$]$1CC_VERSION_NUMBER. Comparisons might be wrong.]) fi if [ [[ "[$]$1CC_VERSION_NUMBER" =~ [0-9]{6} ]] ]; then AC_MSG_WARN([C compiler version number has a part larger than 99999: [$]$1CC_VERSION_NUMBER. Comparisons might be wrong.]) fi - $2COMPARABLE_ACTUAL_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", [$]1, [$]2, [$]3) }' <<< "[$]$1CC_VERSION_NUMBER"` + $2COMPARABLE_ACTUAL_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "[$]$1CC_VERSION_NUMBER"` ]) # Check if the configured compiler (C and C++) is of a specific version or @@ -94,8 +94,8 @@ BASIC_DEFUN_NAMED([TOOLCHAIN_CHECK_COMPILER_VERSION], # Need to assign to a variable since m4 is blocked from modifying parts in []. REFERENCE_VERSION=ARG_VERSION - if [ [[ "$REFERENCE_VERSION" =~ (.*\.){3} ]] ]; then - AC_MSG_ERROR([Internal error: Cannot compare to ARG_VERSION, only three parts (X.Y.Z) is supported]) + if [ [[ "$REFERENCE_VERSION" =~ (.*\.){4} ]] ]; then + AC_MSG_ERROR([Internal error: Cannot compare to ARG_VERSION, only four parts (W.X.Y.Z) is supported]) fi if [ [[ "$REFERENCE_VERSION" =~ [0-9]{6} ]] ]; then @@ -103,7 +103,7 @@ BASIC_DEFUN_NAMED([TOOLCHAIN_CHECK_COMPILER_VERSION], fi # Version comparison method inspired by http://stackoverflow.com/a/24067243 - COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d\n", [$]1, [$]2, [$]3) }' <<< "$REFERENCE_VERSION"` + COMPARABLE_REFERENCE_VERSION=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$REFERENCE_VERSION"` if test [$]ARG_PREFIX[COMPARABLE_ACTUAL_VERSION] -ge $COMPARABLE_REFERENCE_VERSION ; then : From 801a14a0e776d455ce0ad1e59cb71cf8ce296b13 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Fri, 2 Dec 2016 15:57:02 +0100 Subject: [PATCH 024/142] 8076577: Do not allow ccache prior to 3.2 on macosx Reviewed-by: erikj --- common/autoconf/build-performance.m4 | 7 +++++++ common/autoconf/generated-configure.sh | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/common/autoconf/build-performance.m4 b/common/autoconf/build-performance.m4 index 863875065a6..fd77fe8c2b0 100644 --- a/common/autoconf/build-performance.m4 +++ b/common/autoconf/build-performance.m4 @@ -217,6 +217,13 @@ AC_DEFUN([BPERF_SETUP_CCACHE], AC_DEFUN([BPERF_SETUP_CCACHE_USAGE], [ if test "x$CCACHE" != x; then + if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then + HAS_BAD_CCACHE=[`$ECHO $CCACHE_VERSION | \ + $GREP -e '^1\.' -e '^2\.' -e '^3\.0\.' -e '^3\.1\.'`] + if test "x$HAS_BAD_CCACHE" != "x"; then + AC_MSG_ERROR([On macosx, ccache 3.2 or later is required, found $CCACHE_VERSION]) + fi + fi if test "x$USE_PRECOMPILED_HEADER" = "x1"; then HAS_BAD_CCACHE=[`$ECHO $CCACHE_VERSION | \ $GREP -e '^1.*' -e '^2.*' -e '^3\.0.*' -e '^3\.1\.[0123]$'`] diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 8c658a14afd..021872bb1f4 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -5084,7 +5084,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1480684711 +DATE_WHEN_GENERATED=1480690601 ############################################################################### # @@ -65468,6 +65468,13 @@ $as_echo "$as_me: WARNING: --with-ccache-dir has no meaning when ccache is not e if test "x$CCACHE" != x; then if test "x$CCACHE" != x; then + if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then + HAS_BAD_CCACHE=`$ECHO $CCACHE_VERSION | \ + $GREP -e '^1\.' -e '^2\.' -e '^3\.0\.' -e '^3\.1\.'` + if test "x$HAS_BAD_CCACHE" != "x"; then + as_fn_error $? "On macosx, ccache 3.2 or later is required, found $CCACHE_VERSION" "$LINENO" 5 + fi + fi if test "x$USE_PRECOMPILED_HEADER" = "x1"; then HAS_BAD_CCACHE=`$ECHO $CCACHE_VERSION | \ $GREP -e '^1.*' -e '^2.*' -e '^3\.0.*' -e '^3\.1\.[0123]$'` From f9cea3e766bb59f148ad36314bb455141e92343f Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Fri, 2 Dec 2016 16:15:41 +0100 Subject: [PATCH 025/142] 8038957: DEBUG_BINARIES can be removed Reviewed-by: erikj, tbell --- common/autoconf/buildjdk-spec.gmk.in | 68 +------------------------- common/autoconf/generated-configure.sh | 26 +--------- common/autoconf/jdk-options.m4 | 22 --------- 3 files changed, 2 insertions(+), 114 deletions(-) diff --git a/common/autoconf/buildjdk-spec.gmk.in b/common/autoconf/buildjdk-spec.gmk.in index dba07605a22..8eafa0a119a 100644 --- a/common/autoconf/buildjdk-spec.gmk.in +++ b/common/autoconf/buildjdk-spec.gmk.in @@ -86,73 +86,7 @@ DISABLE_WARNING_PREFIX := @BUILD_CC_DISABLE_WARNING_PREFIX@ # Save speed and disk space by not enabling debug symbols for the buildjdk ENABLE_DEBUG_SYMBOLS := false -#################################################### -# -# Legacy Hotspot support - -# Legacy setting: OPT or DBG -VARIANT := OPT -# Legacy setting: true or false -FASTDEBUG := false -# Legacy setting: debugging the class files? -DEBUG_CLASSFILES := false - -# Some users still set EXTRA_*FLAGS on the make command line. Must -# make sure to override that when building buildjdk. -override EXTRA_CFLAGS := -override EXTRA_CXXFLAGS := -override EXTRA_LDFLAGS := - -# The HOSTCC/HOSTCXX is Hotspot terminology for the BUILD_CC/BUILD_CXX, i.e. the -# compiler that produces code that can be run on the build platform. -HOSTCC := $(BUILD_CC) -HOSTCXX := $(BUILD_CXX) - -# Old name for OPENJDK_TARGET_OS (aix,bsd,hpux,linux,macosx,solaris,windows etc) -PLATFORM := $(OPENJDK_BUILD_OS) -# 32 or 64 bit -ARCH_DATA_MODEL := $(OPENJDK_BUILD_CPU_BITS) - -ALT_BOOTDIR := $(BOOT_JDK) -# Yet another name for arch used for an extra subdir below the jvm lib. -# Uses i386 and amd64, instead of x86 and x86_64. -LIBARCH := @OPENJDK_BUILD_CPU_LEGACY_LIB@ -# Set the cpu architecture. Some users still set ARCH on the make command line. Must -# make sure to override that when building buildjdk. -override ARCH := $(OPENJDK_BUILD_CPU_ARCH) -# Legacy setting for building for a 64 bit machine. -# If yes then this expands to _LP64 := 1 -ifeq ($(OPENJDK_BUILD_CPU_BITS), 64) - _LP64 := 1 -endif - -ALT_OUTPUTDIR := $(HOTSPOT_OUTPUTDIR) -ALT_EXPORT_PATH := $(HOTSPOT_DIST) - -JVM_INTERPRETER := @JVM_INTERPRETER@ -ifeq ($(JVM_INTERPRETER), cpp) - CC_INTERP=true -endif - -HOTSPOT_MAKE_ARGS := product docs export_product - # Control wether Hotspot builds gtest tests BUILD_GTEST := false -USE_PRECOMPILED_HEADER := @USE_PRECOMPILED_HEADER@ - -# Hotspot expects the variable FULL_DEBUG_SYMBOLS=1/0 to control debug symbols -# creation. -FULL_DEBUG_SYMBOLS := 0 -ZIP_DEBUGINFO_FILES := 0 -# Disable stripping -STRIP_POLICY := none - -JVM_VARIANTS := server -JVM_VARIANT_SERVER := true -JVM_VARIANT_CLIENT := false -JVM_VARIANT_MINIMAL1 := false -JVM_VARIANT_KERNEL := false -JVM_VARIANT_ZERO := false -JVM_VARIANT_ZEROSHARK := false -JVM_VARIANT_CORE := false +JVM_VARIANTS := server \ No newline at end of file diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 021872bb1f4..df6246fb168 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -700,8 +700,6 @@ JVM_FEATURES_client JVM_FEATURES_server INCLUDE_DTRACE GCOV_ENABLED -STRIP_POLICY -DEBUG_BINARIES ZIP_EXTERNAL_DEBUG_SYMBOLS COPY_DEBUG_SYMBOLS COMPILE_WITH_DEBUG_SYMBOLS @@ -5084,7 +5082,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1480690601 +DATE_WHEN_GENERATED=1480691704 ############################################################################### # @@ -52526,28 +52524,14 @@ $as_echo "$NATIVE_DEBUG_SYMBOLS" >&6; } COMPILE_WITH_DEBUG_SYMBOLS=true COPY_DEBUG_SYMBOLS=true ZIP_EXTERNAL_DEBUG_SYMBOLS=true - - # Hotspot legacy support, not relevant with COPY_DEBUG_SYMBOLS=true - DEBUG_BINARIES=false - STRIP_POLICY=min_strip - elif test "x$NATIVE_DEBUG_SYMBOLS" = xnone; then COMPILE_WITH_DEBUG_SYMBOLS=false COPY_DEBUG_SYMBOLS=false ZIP_EXTERNAL_DEBUG_SYMBOLS=false - - DEBUG_BINARIES=false - STRIP_POLICY=no_strip elif test "x$NATIVE_DEBUG_SYMBOLS" = xinternal; then COMPILE_WITH_DEBUG_SYMBOLS=true COPY_DEBUG_SYMBOLS=false ZIP_EXTERNAL_DEBUG_SYMBOLS=false - - # Hotspot legacy support, will turn on -g when COPY_DEBUG_SYMBOLS=false - DEBUG_BINARIES=true - STRIP_POLICY=no_strip - STRIP="" - elif test "x$NATIVE_DEBUG_SYMBOLS" = xexternal; then if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then @@ -52561,10 +52545,6 @@ $as_echo "$NATIVE_DEBUG_SYMBOLS" >&6; } COMPILE_WITH_DEBUG_SYMBOLS=true COPY_DEBUG_SYMBOLS=true ZIP_EXTERNAL_DEBUG_SYMBOLS=false - - # Hotspot legacy support, not relevant with COPY_DEBUG_SYMBOLS=true - DEBUG_BINARIES=false - STRIP_POLICY=min_strip else as_fn_error $? "Allowed native debug symbols are: none, internal, external, zipped" "$LINENO" 5 fi @@ -52613,10 +52593,6 @@ $as_echo "$as_me: WARNING: Please use --with-native-debug-symbols=zipped ." >&2; - # Legacy values - - - # Check whether --enable-native-coverage was given. if test "${enable_native_coverage+set}" = set; then : diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 index 8becdf3669c..06bd77d445b 100644 --- a/common/autoconf/jdk-options.m4 +++ b/common/autoconf/jdk-options.m4 @@ -265,28 +265,14 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS], COMPILE_WITH_DEBUG_SYMBOLS=true COPY_DEBUG_SYMBOLS=true ZIP_EXTERNAL_DEBUG_SYMBOLS=true - - # Hotspot legacy support, not relevant with COPY_DEBUG_SYMBOLS=true - DEBUG_BINARIES=false - STRIP_POLICY=min_strip - elif test "x$NATIVE_DEBUG_SYMBOLS" = xnone; then COMPILE_WITH_DEBUG_SYMBOLS=false COPY_DEBUG_SYMBOLS=false ZIP_EXTERNAL_DEBUG_SYMBOLS=false - - DEBUG_BINARIES=false - STRIP_POLICY=no_strip elif test "x$NATIVE_DEBUG_SYMBOLS" = xinternal; then COMPILE_WITH_DEBUG_SYMBOLS=true COPY_DEBUG_SYMBOLS=false ZIP_EXTERNAL_DEBUG_SYMBOLS=false - - # Hotspot legacy support, will turn on -g when COPY_DEBUG_SYMBOLS=false - DEBUG_BINARIES=true - STRIP_POLICY=no_strip - STRIP="" - elif test "x$NATIVE_DEBUG_SYMBOLS" = xexternal; then if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then @@ -300,10 +286,6 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS], COMPILE_WITH_DEBUG_SYMBOLS=true COPY_DEBUG_SYMBOLS=true ZIP_EXTERNAL_DEBUG_SYMBOLS=false - - # Hotspot legacy support, not relevant with COPY_DEBUG_SYMBOLS=true - DEBUG_BINARIES=false - STRIP_POLICY=min_strip else AC_MSG_ERROR([Allowed native debug symbols are: none, internal, external, zipped]) fi @@ -321,10 +303,6 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS], AC_SUBST(COMPILE_WITH_DEBUG_SYMBOLS) AC_SUBST(COPY_DEBUG_SYMBOLS) AC_SUBST(ZIP_EXTERNAL_DEBUG_SYMBOLS) - - # Legacy values - AC_SUBST(DEBUG_BINARIES) - AC_SUBST(STRIP_POLICY) ]) ################################################################################ From 62570cd493ccefd452b535dab77ec096001a48ed Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Fri, 2 Dec 2016 16:17:52 +0100 Subject: [PATCH 026/142] 8039103: "explicitly" is misspelled as "explicitely" in configure scripts Reviewed-by: erikj, tbell --- common/autoconf/boot-jdk.m4 | 8 ++-- common/autoconf/flags.m4 | 2 +- common/autoconf/generated-configure.sh | 66 +++++++++++++------------- common/autoconf/jdk-version.m4 | 2 +- common/autoconf/lib-x11.m4 | 2 +- common/autoconf/platform.m4 | 4 +- common/autoconf/toolchain_windows.m4 | 4 +- make/Init.gmk | 4 +- 8 files changed, 46 insertions(+), 46 deletions(-) diff --git a/common/autoconf/boot-jdk.m4 b/common/autoconf/boot-jdk.m4 index ab2bd9a87d7..f75f3adfa2a 100644 --- a/common/autoconf/boot-jdk.m4 +++ b/common/autoconf/boot-jdk.m4 @@ -98,7 +98,7 @@ AC_DEFUN([BOOTJDK_DO_CHECK], fi ]) -# Test: Is bootjdk explicitely set by command line arguments? +# Test: Is bootjdk explicitly set by command line arguments? AC_DEFUN([BOOTJDK_CHECK_ARGUMENTS], [ if test "x$with_boot_jdk" != x; then @@ -238,7 +238,7 @@ AC_DEFUN([BOOTJDK_CHECK_TOOL_IN_BOOTJDK], $1=$BOOT_JDK/bin/$2 if test ! -x [$]$1; then AC_MSG_RESULT(not found) - AC_MSG_NOTICE([Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk]) + AC_MSG_NOTICE([Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk]) AC_MSG_ERROR([Could not find $2 in the Boot JDK]) fi AC_MSG_RESULT(ok) @@ -262,7 +262,7 @@ AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK], # we detected something (if so, the path to the jdk is in BOOT_JDK). But we # must check if this is indeed valid; otherwise we'll continue looking. - # Test: Is bootjdk explicitely set by command line arguments? + # Test: Is bootjdk explicitly set by command line arguments? BOOTJDK_DO_CHECK([BOOTJDK_CHECK_ARGUMENTS]) if test "x$with_boot_jdk" != x && test "x$BOOT_JDK_FOUND" = xno; then # Having specified an argument which is incorrect will produce an instant failure; @@ -286,7 +286,7 @@ AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK], if test "x$BOOT_JDK_FOUND" = xno; then HELP_MSG_MISSING_DEPENDENCY([openjdk]) AC_MSG_NOTICE([Could not find a valid Boot JDK. $HELP_MSG]) - AC_MSG_NOTICE([This might be fixed by explicitely setting --with-boot-jdk]) + AC_MSG_NOTICE([This might be fixed by explicitly setting --with-boot-jdk]) AC_MSG_ERROR([Cannot continue]) fi diff --git a/common/autoconf/flags.m4 b/common/autoconf/flags.m4 index ba1e8dbc4b1..767f6bed510 100644 --- a/common/autoconf/flags.m4 +++ b/common/autoconf/flags.m4 @@ -1378,7 +1378,7 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC], AC_MSG_CHECKING([if native warnings are errors]) if test "x$enable_warnings_as_errors" = "xyes"; then - AC_MSG_RESULT([yes (explicitely set)]) + AC_MSG_RESULT([yes (explicitly set)]) WARNINGS_AS_ERRORS=true elif test "x$enable_warnings_as_errors" = "xno"; then AC_MSG_RESULT([no]) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index df6246fb168..a4c3524c654 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -3844,7 +3844,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # $1 A command line (typically autoconf macro) to execute -# Test: Is bootjdk explicitely set by command line arguments? +# Test: Is bootjdk explicitly set by command line arguments? # Test: Is $JAVA_HOME set? @@ -5082,7 +5082,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1480691704 +DATE_WHEN_GENERATED=1480691844 ############################################################################### # @@ -15512,7 +15512,7 @@ test -n "$target_alias" && ;; esac - # ..and setup our own variables. (Do this explicitely to facilitate searching) + # ..and setup our own variables. (Do this explicitly to facilitate searching) OPENJDK_BUILD_OS="$VAR_OS" if test "x$VAR_OS_TYPE" != x; then OPENJDK_BUILD_OS_TYPE="$VAR_OS_TYPE" @@ -15651,7 +15651,7 @@ $as_echo "$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU" >&6; } ;; esac - # ... and setup our own variables. (Do this explicitely to facilitate searching) + # ... and setup our own variables. (Do this explicitly to facilitate searching) OPENJDK_TARGET_OS="$VAR_OS" if test "x$VAR_OS_TYPE" != x; then OPENJDK_TARGET_OS_TYPE="$VAR_OS_TYPE" @@ -24389,7 +24389,7 @@ fi as_fn_error $? "Version string contains + but both 'BUILD' and 'OPT' are missing" "$LINENO" 5 fi # Stop the version part process from setting default values. - # We still allow them to explicitely override though. + # We still allow them to explicitly override though. NO_DEFAULT_VERSION_PARTS=true else as_fn_error $? "--with-version-string fails to parse as a valid version string: $with_version_string" "$LINENO" 5 @@ -24758,7 +24758,7 @@ fi # we detected something (if so, the path to the jdk is in BOOT_JDK). But we # must check if this is indeed valid; otherwise we'll continue looking. - # Test: Is bootjdk explicitely set by command line arguments? + # Test: Is bootjdk explicitly set by command line arguments? if test "x$BOOT_JDK_FOUND" = xno; then # Now execute the test @@ -29876,8 +29876,8 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find a valid Boot JDK. $HELP_MSG" >&5 $as_echo "$as_me: Could not find a valid Boot JDK. $HELP_MSG" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: This might be fixed by explicitely setting --with-boot-jdk" >&5 -$as_echo "$as_me: This might be fixed by explicitely setting --with-boot-jdk" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be fixed by explicitly setting --with-boot-jdk" >&5 +$as_echo "$as_me: This might be fixed by explicitly setting --with-boot-jdk" >&6;} as_fn_error $? "Cannot continue" "$LINENO" 5 fi @@ -29899,8 +29899,8 @@ $as_echo_n "checking for java in Boot JDK... " >&6; } if test ! -x $JAVA; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 -$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&5 +$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&6;} as_fn_error $? "Could not find java in the Boot JDK" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 @@ -29927,8 +29927,8 @@ $as_echo_n "checking for java in Boot JDK... " >&6; } if test ! -x $JAVA; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 -$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&5 +$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&6;} as_fn_error $? "Could not find java in the Boot JDK" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 @@ -30037,8 +30037,8 @@ $as_echo_n "checking for javac in Boot JDK... " >&6; } if test ! -x $JAVAC; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 -$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&5 +$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&6;} as_fn_error $? "Could not find javac in the Boot JDK" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 @@ -30065,8 +30065,8 @@ $as_echo_n "checking for javac in Boot JDK... " >&6; } if test ! -x $JAVAC; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 -$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&5 +$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&6;} as_fn_error $? "Could not find javac in the Boot JDK" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 @@ -30175,8 +30175,8 @@ $as_echo_n "checking for javah in Boot JDK... " >&6; } if test ! -x $JAVAH; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 -$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&5 +$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&6;} as_fn_error $? "Could not find javah in the Boot JDK" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 @@ -30203,8 +30203,8 @@ $as_echo_n "checking for javah in Boot JDK... " >&6; } if test ! -x $JAVAH; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 -$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&5 +$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&6;} as_fn_error $? "Could not find javah in the Boot JDK" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 @@ -30313,8 +30313,8 @@ $as_echo_n "checking for jar in Boot JDK... " >&6; } if test ! -x $JAR; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 -$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&5 +$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&6;} as_fn_error $? "Could not find jar in the Boot JDK" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 @@ -30341,8 +30341,8 @@ $as_echo_n "checking for jar in Boot JDK... " >&6; } if test ! -x $JAR; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 -$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&5 +$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&6;} as_fn_error $? "Could not find jar in the Boot JDK" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 @@ -30451,8 +30451,8 @@ $as_echo_n "checking for jarsigner in Boot JDK... " >&6; } if test ! -x $JARSIGNER; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 -$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&5 +$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&6;} as_fn_error $? "Could not find jarsigner in the Boot JDK" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 @@ -30479,8 +30479,8 @@ $as_echo_n "checking for jarsigner in Boot JDK... " >&6; } if test ! -x $JARSIGNER; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 -$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&5 +$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk" >&6;} as_fn_error $? "Could not find jarsigner in the Boot JDK" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 @@ -51858,8 +51858,8 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if native warnings are errors" >&5 $as_echo_n "checking if native warnings are errors... " >&6; } if test "x$enable_warnings_as_errors" = "xyes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (explicitely set)" >&5 -$as_echo "yes (explicitely set)" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (explicitly set)" >&5 +$as_echo "yes (explicitly set)" >&6; } WARNINGS_AS_ERRORS=true elif test "x$enable_warnings_as_errors" = "xno"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 @@ -53114,7 +53114,7 @@ fi if test "x$with_msvcr_dll" != x; then - # If given explicitely by user, do not probe. If not present, fail directly. + # If given explicitly by user, do not probe. If not present, fail directly. DLL_NAME="$MSVCR_NAME" POSSIBLE_MSVC_DLL="$with_msvcr_dll" @@ -54463,7 +54463,7 @@ fi if test "x$MSVCP_NAME" != "x"; then if test "x$with_msvcp_dll" != x; then - # If given explicitely by user, do not probe. If not present, fail directly. + # If given explicitly by user, do not probe. If not present, fail directly. DLL_NAME="$MSVCP_NAME" POSSIBLE_MSVC_DLL="$with_msvcp_dll" @@ -55822,7 +55822,7 @@ $as_echo "$as_me: WARNING: X11 is not used, so --with-x is ignored" >&2;} if test "x${with_x}" != x && test "x${with_x}" != xyes; then # The user has specified a X11 base directory. Use it for includes and - # libraries, unless explicitely overridden. + # libraries, unless explicitly overridden. if test "x$x_includes" = xNONE; then x_includes="${with_x}/include" fi diff --git a/common/autoconf/jdk-version.m4 b/common/autoconf/jdk-version.m4 index 4846c12647c..65df55e5690 100644 --- a/common/autoconf/jdk-version.m4 +++ b/common/autoconf/jdk-version.m4 @@ -110,7 +110,7 @@ AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS], AC_MSG_ERROR([Version string contains + but both 'BUILD' and 'OPT' are missing]) fi # Stop the version part process from setting default values. - # We still allow them to explicitely override though. + # We still allow them to explicitly override though. NO_DEFAULT_VERSION_PARTS=true else AC_MSG_ERROR([--with-version-string fails to parse as a valid version string: $with_version_string]) diff --git a/common/autoconf/lib-x11.m4 b/common/autoconf/lib-x11.m4 index 0614299e849..d4b878d8c54 100644 --- a/common/autoconf/lib-x11.m4 +++ b/common/autoconf/lib-x11.m4 @@ -42,7 +42,7 @@ AC_DEFUN_ONCE([LIB_SETUP_X11], if test "x${with_x}" != x && test "x${with_x}" != xyes; then # The user has specified a X11 base directory. Use it for includes and - # libraries, unless explicitely overridden. + # libraries, unless explicitly overridden. if test "x$x_includes" = xNONE; then x_includes="${with_x}/include" fi diff --git a/common/autoconf/platform.m4 b/common/autoconf/platform.m4 index e7ffe4a2fa5..392a23ad4cd 100644 --- a/common/autoconf/platform.m4 +++ b/common/autoconf/platform.m4 @@ -162,7 +162,7 @@ AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD], # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables. PLATFORM_EXTRACT_VARS_FROM_OS($build_os) PLATFORM_EXTRACT_VARS_FROM_CPU($build_cpu) - # ..and setup our own variables. (Do this explicitely to facilitate searching) + # ..and setup our own variables. (Do this explicitly to facilitate searching) OPENJDK_BUILD_OS="$VAR_OS" if test "x$VAR_OS_TYPE" != x; then OPENJDK_BUILD_OS_TYPE="$VAR_OS_TYPE" @@ -192,7 +192,7 @@ AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD], # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables. PLATFORM_EXTRACT_VARS_FROM_OS($host_os) PLATFORM_EXTRACT_VARS_FROM_CPU($host_cpu) - # ... and setup our own variables. (Do this explicitely to facilitate searching) + # ... and setup our own variables. (Do this explicitly to facilitate searching) OPENJDK_TARGET_OS="$VAR_OS" if test "x$VAR_OS_TYPE" != x; then OPENJDK_TARGET_OS_TYPE="$VAR_OS_TYPE" diff --git a/common/autoconf/toolchain_windows.m4 b/common/autoconf/toolchain_windows.m4 index 4a40fa63a91..f2304df0fe9 100644 --- a/common/autoconf/toolchain_windows.m4 +++ b/common/autoconf/toolchain_windows.m4 @@ -566,7 +566,7 @@ AC_DEFUN([TOOLCHAIN_SETUP_VS_RUNTIME_DLLS], [path to microsoft C runtime dll (msvcr*.dll) (Windows only) @<:@probed@:>@])]) if test "x$with_msvcr_dll" != x; then - # If given explicitely by user, do not probe. If not present, fail directly. + # If given explicitly by user, do not probe. If not present, fail directly. TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCR_NAME, [$with_msvcr_dll], [--with-msvcr-dll]) if test "x$MSVC_DLL" = x; then AC_MSG_ERROR([Could not find a proper $MSVCR_NAME as specified by --with-msvcr-dll]) @@ -589,7 +589,7 @@ AC_DEFUN([TOOLCHAIN_SETUP_VS_RUNTIME_DLLS], if test "x$MSVCP_NAME" != "x"; then if test "x$with_msvcp_dll" != x; then - # If given explicitely by user, do not probe. If not present, fail directly. + # If given explicitly by user, do not probe. If not present, fail directly. TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCP_NAME, [$with_msvcp_dll], [--with-msvcp-dll]) if test "x$MSVC_DLL" = x; then AC_MSG_ERROR([Could not find a proper $MSVCP_NAME as specified by --with-msvcp-dll]) diff --git a/make/Init.gmk b/make/Init.gmk index 2e391a4e199..15d25b4136d 100644 --- a/make/Init.gmk +++ b/make/Init.gmk @@ -157,7 +157,7 @@ ifeq ($(HAS_SPEC),) # Do not let make delete spec files even if aborted while doing a reconfigure .PRECIOUS: $(SPECS) - # Unless reconfigure is explicitely called, let all main targets depend on + # Unless reconfigure is explicitly called, let all main targets depend on # the spec files to be up to date. ifeq ($(findstring reconfigure, $(INIT_TARGETS)), ) $(MAIN_TARGETS): $(SPECS) @@ -278,7 +278,7 @@ else # HAS_SPEC=true # MAKEOVERRIDES is automatically set and propagated by Make to sub-Make calls. # We need to clear it of the init-specific variables. The user-specified - # variables are explicitely propagated using $(USER_MAKE_VARS). + # variables are explicitly propagated using $(USER_MAKE_VARS). main: MAKEOVERRIDES := main: $(INIT_TARGETS) From 99684f14fead725baa6ba809114d2ea59204f1fa Mon Sep 17 00:00:00 2001 From: Gustavo Romero Date: Mon, 28 Nov 2016 11:13:20 -0500 Subject: [PATCH 027/142] 8170153: PPC64/s390x/aarch64: Poor StrictMath performance due to non-optimized compilation Reviewed-by: mdoerr, erikj, simonis, aph --- make/common/NativeCompilation.gmk | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk index 36e0381facc..3a9cf477e23 100644 --- a/make/common/NativeCompilation.gmk +++ b/make/common/NativeCompilation.gmk @@ -568,17 +568,21 @@ define SetupNativeCompilationBody # Sort to remove dupliates and provide a reproducable order on the input files to the linker. $1_ALL_OBJS := $$(sort $$($1_EXPECTED_OBJS) $$($1_EXTRA_OBJECT_FILES)) - # Pickup extra OPENJDK_TARGET_OS_TYPE and/or OPENJDK_TARGET_OS dependent variables for CFLAGS. - $1_EXTRA_CFLAGS:=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_CFLAGS_$(OPENJDK_TARGET_OS)) + # Pickup extra OPENJDK_TARGET_OS_TYPE, OPENJDK_TARGET_OS, and/or OPENJDK_TARGET_OS plus + # OPENJDK_TARGET_CPU pair dependent variables for CFLAGS. + $1_EXTRA_CFLAGS:=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_CFLAGS_$(OPENJDK_TARGET_OS)) \ + $$($1_CFLAGS_$(OPENJDK_TARGET_OS)_$(OPENJDK_TARGET_CPU)) ifneq ($(DEBUG_LEVEL),release) # Pickup extra debug dependent variables for CFLAGS $1_EXTRA_CFLAGS+=$$($1_CFLAGS_debug) $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)_debug) $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_debug) + $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_$(OPENJDK_TARGET_CPU)_debug) else $1_EXTRA_CFLAGS+=$$($1_CFLAGS_release) $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)_release) $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_release) + $1_EXTRA_CFLAGS+=$$($1_CFLAGS_$(OPENJDK_TARGET_OS)_$(OPENJDK_TARGET_CPU)_release) endif # Pickup extra OPENJDK_TARGET_OS_TYPE and/or OPENJDK_TARGET_OS dependent variables for CXXFLAGS. From 9a866344345291942bf3f6fb27c809cc9009fed7 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Mon, 28 Nov 2016 11:36:43 -0800 Subject: [PATCH 028/142] 8169816: Move src.zip and jrt-fs.jar under the lib directory Reviewed-by: alanb, erikj, jjg --- .../share/classes/com/sun/tools/javac/file/Locations.java | 3 ++- .../share/classes/jdk/jshell/SourceCodeAnalysisImpl.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java index 6e2ece49b23..dc1de457dd9 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java @@ -1396,7 +1396,8 @@ public class Locations { } private void update(Path p) { - if (!isCurrentPlatform(p) && !Files.exists(p.resolve("jrt-fs.jar")) && !Files.exists(systemJavaHome.resolve("modules"))) + if (!isCurrentPlatform(p) && !Files.exists(p.resolve("lib").resolve("jrt-fs.jar")) && + !Files.exists(systemJavaHome.resolve("modules"))) throw new IllegalArgumentException(p.toString()); systemJavaHome = p; modules = null; diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java index 7254f2030d0..53a1ee991d1 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java @@ -1273,7 +1273,7 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis { } List result = new ArrayList<>(); Path home = Paths.get(System.getProperty("java.home")); - Path srcZip = home.resolve("src.zip"); + Path srcZip = home.resolve("lib").resolve("src.zip"); if (!Files.isReadable(srcZip)) srcZip = home.getParent().resolve("src.zip"); if (Files.isReadable(srcZip)) { From d67262a13fd4257291d62c4469cb4a06b844ca52 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Mon, 28 Nov 2016 18:05:09 -0800 Subject: [PATCH 029/142] 8170424: back out src.zip change from JDK-8170424 Reviewed-by: prr --- .../share/classes/jdk/jshell/SourceCodeAnalysisImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java index 53a1ee991d1..7254f2030d0 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java @@ -1273,7 +1273,7 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis { } List result = new ArrayList<>(); Path home = Paths.get(System.getProperty("java.home")); - Path srcZip = home.resolve("lib").resolve("src.zip"); + Path srcZip = home.resolve("src.zip"); if (!Files.isReadable(srcZip)) srcZip = home.getParent().resolve("src.zip"); if (Files.isReadable(srcZip)) { From 40f3d9e0f761cfe7fba588a019aecbf0ec9caf12 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 29 Nov 2016 11:51:01 +0100 Subject: [PATCH 030/142] 8166737: default langtools make test settings result in no ouput Reviewed-by: tbell --- langtools/test/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langtools/test/Makefile b/langtools/test/Makefile index 47e9c2b08b0..c464f9f7ac2 100644 --- a/langtools/test/Makefile +++ b/langtools/test/Makefile @@ -211,7 +211,7 @@ ifdef JCK_TIMEOUT_FACTOR endif # Default verbosity setting for jtreg -JTREG_VERBOSE ?= fail,error,nopass +JTREG_VERBOSE ?= fail,error,time # Default verbosity setting for jck JCK_VERBOSE ?= non-pass From 98430b9e559ce90247c672239877e0a7dde932c3 Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Tue, 29 Nov 2016 13:19:23 +0000 Subject: [PATCH 031/142] 8169778: Add new public methods to get new instances of the JAXP factories builtin system-default implementations A new public static method is added to each of the JAXP factories. The new method will create and return a new instance of the system-default builtin implementation, without going through the lookup process. Reviewed-by: rriggs, joehw, lancea, alanb --- .../javax/xml/datatype/DatatypeFactory.java | 15 +++ .../xml/parsers/DocumentBuilderFactory.java | 17 ++- .../javax/xml/parsers/SAXParserFactory.java | 17 ++- .../javax/xml/stream/XMLEventFactory.java | 17 ++- .../javax/xml/stream/XMLInputFactory.java | 17 ++- .../javax/xml/stream/XMLOutputFactory.java | 17 ++- .../xml/transform/TransformerFactory.java | 18 ++- .../javax/xml/validation/SchemaFactory.java | 22 +++- .../classes/javax/xml/xpath/XPathFactory.java | 28 ++++- .../ptests/FactoryNewInstanceTest.java | 23 +++- .../ptests/DocumentBuilderFactoryTest.java | 28 ++++- .../xml/parsers/ptests/SAXParserFactTest.java | 21 ++++ .../XMLEventFactoryNewInstanceTest.java | 33 +++++- .../XMLInputFactoryNewInstanceTest.java | 33 +++++- .../XMLOutputFactoryNewInstanceTest.java | 107 ++++++++++++++++++ .../ptests/TransformerFactoryTest.java | 27 ++++- .../validation/ptests/SchemaFactoryTest.java | 29 ++++- .../xml/xpath/ptests/XPathFactoryTest.java | 34 +++++- 18 files changed, 477 insertions(+), 26 deletions(-) create mode 100644 jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLOutputFactoryNewInstanceTest.java diff --git a/jaxp/src/java.xml/share/classes/javax/xml/datatype/DatatypeFactory.java b/jaxp/src/java.xml/share/classes/javax/xml/datatype/DatatypeFactory.java index 001b682e42b..a53f93df2ee 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/datatype/DatatypeFactory.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/datatype/DatatypeFactory.java @@ -30,6 +30,7 @@ import java.math.BigInteger; import java.util.GregorianCalendar; import java.util.regex.Matcher; import java.util.regex.Pattern; +import com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl; /** * Factory that creates new {@code javax.xml.datatype} {@code Object}s that map XML to/from Java {@code Object}s. @@ -135,6 +136,20 @@ public abstract class DatatypeFactory { protected DatatypeFactory() { } + /** + * Creates a new instance of the {@code DatatypeFactory} {@linkplain + * #DATATYPEFACTORY_IMPLEMENTATION_CLASS builtin system-default + * implementation}. + * + * @return A new instance of the {@code DatatypeFactory} builtin + * system-default implementation. + * + * @since 9 + */ + public static DatatypeFactory newDefaultInstance() { + return new DatatypeFactoryImpl(); + } + /** * Obtain a new instance of a {@code DatatypeFactory}. * diff --git a/jaxp/src/java.xml/share/classes/javax/xml/parsers/DocumentBuilderFactory.java b/jaxp/src/java.xml/share/classes/javax/xml/parsers/DocumentBuilderFactory.java index 71fed6c2c15..f04eccfbd20 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/parsers/DocumentBuilderFactory.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/parsers/DocumentBuilderFactory.java @@ -25,6 +25,7 @@ package javax.xml.parsers; +import com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl; import javax.xml.validation.Schema; /** @@ -53,6 +54,19 @@ public abstract class DocumentBuilderFactory { protected DocumentBuilderFactory () { } + /** + * Creates a new instance of the {@code DocumentBuilderFactory} builtin + * system-default implementation. + * + * @return A new instance of the {@code DocumentBuilderFactory} builtin + * system-default implementation. + * + * @since 9 + */ + public static DocumentBuilderFactory newDefaultInstance() { + return new DocumentBuilderFactoryImpl(); + } + /** * Obtain a new instance of a * {@code DocumentBuilderFactory}. This static method creates @@ -93,7 +107,8 @@ public abstract class DocumentBuilderFactory { * *
  • *

    - * Otherwise, the system-default implementation is returned. + * Otherwise, the {@linkplain #newDefaultInstance() system-default} + * implementation is returned. *

  • * * diff --git a/jaxp/src/java.xml/share/classes/javax/xml/parsers/SAXParserFactory.java b/jaxp/src/java.xml/share/classes/javax/xml/parsers/SAXParserFactory.java index 1732047ee5e..08deb5123d9 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/parsers/SAXParserFactory.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/parsers/SAXParserFactory.java @@ -25,6 +25,7 @@ package javax.xml.parsers; +import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl; import javax.xml.validation.Schema; import org.xml.sax.SAXException; import org.xml.sax.SAXNotRecognizedException; @@ -58,6 +59,19 @@ public abstract class SAXParserFactory { } + /** + * Creates a new instance of the {@code SAXParserFactory} builtin + * system-default implementation. + * + * @return A new instance of the {@code SAXParserFactory} builtin + * system-default implementation. + * + * @since 9 + */ + public static SAXParserFactory newDefaultInstance() { + return new SAXParserFactoryImpl(); + } + /** * Obtain a new instance of a {@code SAXParserFactory}. This * static method creates a new factory instance @@ -97,7 +111,8 @@ public abstract class SAXParserFactory { * *
  • *

    - * Otherwise the system-default implementation is returned. + * Otherwise, the {@linkplain #newDefaultInstance() system-default} + * implementation is returned. *

  • * * diff --git a/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLEventFactory.java b/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLEventFactory.java index 1ec4d382711..37e5f7a8772 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLEventFactory.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLEventFactory.java @@ -27,6 +27,7 @@ */ package javax.xml.stream; +import com.sun.xml.internal.stream.events.XMLEventFactoryImpl; import java.util.Iterator; import javax.xml.namespace.NamespaceContext; import javax.xml.namespace.QName; @@ -53,6 +54,19 @@ public abstract class XMLEventFactory { static final String DEFAULIMPL = "com.sun.xml.internal.stream.events.XMLEventFactoryImpl"; + /** + * Creates a new instance of the {@code XMLEventFactory} builtin + * system-default implementation. + * + * @return A new instance of the {@code XMLEventFactory} builtin + * system-default implementation. + * + * @since 9 + */ + public static XMLEventFactory newDefaultFactory() { + return new XMLEventFactoryImpl(); + } + /** * Creates a new instance of the factory in exactly the same manner as the * {@link #newFactory()} method. @@ -108,7 +122,8 @@ public abstract class XMLEventFactory { * *
  • *

    - * Otherwise, the system-default implementation is returned. + * Otherwise, the {@linkplain #newDefaultFactory() system-default} + * implementation is returned. *

  • * *

    diff --git a/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLInputFactory.java b/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLInputFactory.java index 191a6df6f19..cb936ac6fde 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLInputFactory.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLInputFactory.java @@ -28,6 +28,7 @@ package javax.xml.stream; +import com.sun.xml.internal.stream.XMLInputFactoryImpl; import javax.xml.stream.util.XMLEventAllocator; import javax.xml.transform.Source; @@ -143,6 +144,19 @@ public abstract class XMLInputFactory { protected XMLInputFactory(){} + /** + * Creates a new instance of the {@code XMLInputFactory} builtin + * system-default implementation. + * + * @return A new instance of the {@code XMLInputFactory} builtin + * system-default implementation. + * + * @since 9 + */ + public static XMLInputFactory newDefaultFactory() { + return new XMLInputFactoryImpl(); + } + /** * Creates a new instance of the factory in exactly the same manner as the * {@link #newFactory()} method. @@ -195,7 +209,8 @@ public abstract class XMLInputFactory { * ClassLoader#getSystemClassLoader() system class loader} will be used. * *

  • - *

    Otherwise, the system-default implementation is returned. + *

    Otherwise, the {@linkplain #newDefaultFactory() system-default} + * implementation is returned. *

  • * *

    diff --git a/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLOutputFactory.java b/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLOutputFactory.java index caa230594db..939cb67f34a 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLOutputFactory.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/stream/XMLOutputFactory.java @@ -28,6 +28,7 @@ package javax.xml.stream; +import com.sun.xml.internal.stream.XMLOutputFactoryImpl; import javax.xml.transform.Result; /** @@ -120,6 +121,19 @@ public abstract class XMLOutputFactory { protected XMLOutputFactory(){} + /** + * Creates a new instance of the {@code XMLOutputFactory} builtin + * system-default implementation. + * + * @return A new instance of the {@code XMLOutputFactory} builtin + * system-default implementation. + * + * @since 9 + */ + public static XMLOutputFactory newDefaultFactory() { + return new XMLOutputFactoryImpl(); + } + /** * Creates a new instance of the factory in exactly the same manner as the * {@link #newFactory()} method. @@ -175,7 +189,8 @@ public abstract class XMLOutputFactory { * *

  • *

    - * Otherwise, the system-default implementation is returned. + * Otherwise, the {@linkplain #newDefaultFactory() system-default} + * implementation is returned. *

  • * *

    diff --git a/jaxp/src/java.xml/share/classes/javax/xml/transform/TransformerFactory.java b/jaxp/src/java.xml/share/classes/javax/xml/transform/TransformerFactory.java index b0957826a0b..44774e44087 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/transform/TransformerFactory.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/transform/TransformerFactory.java @@ -25,6 +25,8 @@ package javax.xml.transform; +import com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl; + /** *

    A TransformerFactory instance can be used to create * {@link javax.xml.transform.Transformer} and @@ -50,6 +52,19 @@ public abstract class TransformerFactory { + /** + * Creates a new instance of the {@code TransformerFactory} builtin + * system-default implementation. + * + * @return A new instance of the {@code TransformerFactory} builtin + * system-default implementation. + * + * @since 9 + */ + public static TransformerFactory newDefaultInstance() { + return TransformerFactoryImpl.newTransformerFactoryNoServiceLoader(); + } + /** * Obtain a new instance of a {@code TransformerFactory}. * This static method creates a new factory instance. @@ -89,7 +104,8 @@ public abstract class TransformerFactory { * *

  • *

    - * Otherwise, the system-default implementation is returned. + * Otherwise, the {@linkplain #newDefaultInstance() system-default} + * implementation is returned. *

  • * * diff --git a/jaxp/src/java.xml/share/classes/javax/xml/validation/SchemaFactory.java b/jaxp/src/java.xml/share/classes/javax/xml/validation/SchemaFactory.java index 8152b675c7e..2bcc73e1be1 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/validation/SchemaFactory.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/validation/SchemaFactory.java @@ -25,6 +25,7 @@ package javax.xml.validation; +import com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory; import java.io.File; import java.net.URL; import javax.xml.transform.Source; @@ -123,6 +124,24 @@ public abstract class SchemaFactory { protected SchemaFactory() { } + /** + * Creates a new instance of the {@code SchemaFactory} builtin + * system-default implementation. + * + * @implSpec The {@code SchemaFactory} builtin + * system-default implementation is only required to support the + * W3C XML Schema 1.0, + * but may support additional schema languages. + * + * @return A new instance of the {@code SchemaFactory} builtin + * system-default implementation. + * + * @since 9 + */ + public static SchemaFactory newDefaultInstance() { + return XMLSchemaFactory.newXMLSchemaFactoryNoServiceLoader(); + } + /** * Lookup an implementation of the {@code SchemaFactory} that supports the specified * schema language and return it. @@ -179,7 +198,8 @@ public abstract class SchemaFactory { *
  • *

    * Platform default {@code SchemaFactory} is located - * in a implementation specific way. There must be a platform default + * in an implementation specific way. There must be a + * {@linkplain #newDefaultInstance() platform default} * {@code SchemaFactory} for W3C XML Schema. *

  • * diff --git a/jaxp/src/java.xml/share/classes/javax/xml/xpath/XPathFactory.java b/jaxp/src/java.xml/share/classes/javax/xml/xpath/XPathFactory.java index 220e6eaba0f..a5b0a4755da 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/xpath/XPathFactory.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/xpath/XPathFactory.java @@ -25,6 +25,8 @@ package javax.xml.xpath; +import com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl; + /** *

    An {@code XPathFactory} instance can be used to create * {@link javax.xml.xpath.XPath} objects.

    @@ -73,6 +75,25 @@ public abstract class XPathFactory { protected XPathFactory() { } + /** + * Creates a new instance of the {@code XPathFactory} builtin + * system-default implementation. + * + * @implSpec The {@code XPathFactory} builtin + * system-default implementation is only required to support the + * {@link #DEFAULT_OBJECT_MODEL_URI default object model}, the + * {@linkplain org.w3c.dom W3C DOM}, but may support additional + * object models. + * + * @return A new instance of the {@code XPathFactory} builtin + * system-default implementation. + * + * @since 9 + */ + public static XPathFactory newDefaultInstance() { + return XPathFactoryImpl.newXPathFactoryNoServiceLoader(); + } + /** *

    Get a new {@code XPathFactory} instance using the default object model, * {@link #DEFAULT_OBJECT_MODEL_URI}, @@ -153,8 +174,11 @@ public abstract class XPathFactory { * *

  • *

    - * Platform default {@code XPathFactory} is located in a platform specific way. - * There must be a platform default XPathFactory for the W3C DOM, i.e. {@link #DEFAULT_OBJECT_MODEL_URI}. + * Platform default {@code XPathFactory} is located in a platform + * specific way. + * There must be a {@linkplain #newDefaultInstance() platform default} + * {@code XPathFactory} for the W3C DOM, i.e. + * {@link #DEFAULT_OBJECT_MODEL_URI}. *

  • * *

    If everything fails, an {@code XPathFactoryConfigurationException} will be thrown. diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/FactoryNewInstanceTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/FactoryNewInstanceTest.java index 26aada36bcf..f00259f613b 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/FactoryNewInstanceTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/FactoryNewInstanceTest.java @@ -24,6 +24,9 @@ package javax.xml.datatype.ptests; import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNotSame; +import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertEquals; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; @@ -37,6 +40,7 @@ import org.testng.annotations.Test; /* * @test + * @bug 8169778 * @library /javax/xml/jaxp/libs * @run testng/othervm -DrunSecMngr=true javax.xml.datatype.ptests.FactoryNewInstanceTest * @run testng/othervm javax.xml.datatype.ptests.FactoryNewInstanceTest @@ -45,13 +49,30 @@ import org.testng.annotations.Test; @Listeners({jaxp.library.BasePolicy.class}) public class FactoryNewInstanceTest { - private static final String DATATYPE_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl"; + private static final String DEFAULT_IMPL_CLASS = + "com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl"; + private static final String DATATYPE_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS; @DataProvider(name = "parameters") public Object[][] getValidateParameters() { return new Object[][] { { DATATYPE_FACTORY_CLASSNAME, null }, { DATATYPE_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; } + /** + * Test if newDefaultInstance() method returns an instance + * of the expected factory. + * @throws Exception If any errors occur. + */ + @Test + public void testDefaultInstance() throws Exception { + DatatypeFactory dtf1 = DatatypeFactory.newDefaultInstance(); + DatatypeFactory dtf2 = DatatypeFactory.newInstance(); + assertNotSame(dtf1, dtf2, "same instance returned:"); + assertSame(dtf1.getClass(), dtf2.getClass(), + "unexpected class mismatch for newDefaultInstance():"); + assertEquals(dtf1.getClass().getName(), DEFAULT_IMPL_CLASS); + } + /* * test for DatatypeFactory.newInstance(java.lang.String factoryClassName, * java.lang.ClassLoader classLoader) factoryClassName points to correct diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java index bc5cc4c9fcc..c4d1aff87ff 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java @@ -34,6 +34,8 @@ import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertNotSame; import java.io.BufferedReader; import java.io.Closeable; @@ -66,7 +68,7 @@ import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; /** - * @bug 8080907 + * @bug 8080907 8169778 * This checks the methods of DocumentBuilderFactoryImpl. */ /* @@ -77,10 +79,17 @@ import org.xml.sax.helpers.DefaultHandler; */ @Listeners({jaxp.library.FilePolicy.class}) public class DocumentBuilderFactoryTest { + + /** + * DocumentBuilderFactory builtin system-default implementation class name. + */ + private static final String DEFAULT_IMPL_CLASS = + "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"; + /** * DocumentBuilderFactory implementation class name. */ - private static final String DOCUMENT_BUILDER_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"; + private static final String DOCUMENT_BUILDER_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS; /** * Provide valid DocumentBuilderFactory instantiation parameters. @@ -92,6 +101,21 @@ public class DocumentBuilderFactoryTest { return new Object[][] { { DOCUMENT_BUILDER_FACTORY_CLASSNAME, null }, { DOCUMENT_BUILDER_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; } + /** + * Test if newDefaultInstance() method returns an instance + * of the expected factory. + * @throws Exception If any errors occur. + */ + @Test + public void testDefaultInstance() throws Exception { + DocumentBuilderFactory dbf1 = DocumentBuilderFactory.newDefaultInstance(); + DocumentBuilderFactory dbf2 = DocumentBuilderFactory.newInstance(); + assertNotSame(dbf1, dbf2, "same instance returned:"); + assertSame(dbf1.getClass(), dbf2.getClass(), + "unexpected class mismatch for newDefaultInstance():"); + assertEquals(dbf1.getClass().getName(), DEFAULT_IMPL_CLASS); + } + /** * Test for DocumentBuilderFactory.newInstance(java.lang.String * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserFactTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserFactTest.java index c294abe51fb..2effec0126f 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserFactTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXParserFactTest.java @@ -24,6 +24,9 @@ package javax.xml.parsers.ptests; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.assertNotSame; +import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertEquals; import javax.xml.parsers.SAXParserFactory; @@ -35,6 +38,7 @@ import org.testng.annotations.Test; */ /* * @test + * @bug 8169778 * @library /javax/xml/jaxp/libs * @run testng/othervm -DrunSecMngr=true javax.xml.parsers.ptests.SAXParserFactTest * @run testng/othervm javax.xml.parsers.ptests.SAXParserFactTest @@ -48,6 +52,23 @@ public class SAXParserFactTest { private static final String VALIDATION = "http://xml.org/sax/features/validation"; private static final String EXTERNAL_G_ENTITIES = "http://xml.org/sax/features/external-general-entities"; private static final String EXTERNAL_P_ENTITIES = "http://xml.org/sax/features/external-parameter-entities"; + private static final String DEFAULT_IMPL_CLASS = + "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"; + + /** + * Test if newDefaultInstance() method returns an instance + * of the expected factory. + * @throws Exception If any errors occur. + */ + @Test + public void testDefaultInstance() throws Exception { + SAXParserFactory spf1 = SAXParserFactory.newDefaultInstance(); + SAXParserFactory spf2 = SAXParserFactory.newInstance(); + assertNotSame(spf1, spf2, "same instance returned:"); + assertSame(spf1.getClass(), spf2.getClass(), + "unexpected class mismatch for newDefaultInstance():"); + assertEquals(spf1.getClass().getName(), DEFAULT_IMPL_CLASS); + } /** * Test if newSAXParser() method returns SAXParser. diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLEventFactoryNewInstanceTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLEventFactoryNewInstanceTest.java index b272cd10cac..645a26e82ee 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLEventFactoryNewInstanceTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLEventFactoryNewInstanceTest.java @@ -27,6 +27,9 @@ import static jaxp.library.JAXPTestUtilities.setSystemProperty; import static jaxp.library.JAXPTestUtilities.clearSystemProperty; import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNotSame; +import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertEquals; import javax.xml.stream.XMLEventFactory; @@ -38,6 +41,7 @@ import org.testng.annotations.Test; /* * @test + * @bug 8169778 * @library /javax/xml/jaxp/libs * @run testng/othervm -DrunSecMngr=true javax.xml.stream.ptests.XMLEventFactoryNewInstanceTest * @run testng/othervm javax.xml.stream.ptests.XMLEventFactoryNewInstanceTest @@ -46,12 +50,31 @@ import org.testng.annotations.Test; @Listeners({jaxp.library.BasePolicy.class}) public class XMLEventFactoryNewInstanceTest { - private static final String XMLEVENT_FACTORY_CLASSNAME = "com.sun.xml.internal.stream.events.XMLEventFactoryImpl"; - private static final String XMLEVENT_FACRORY_ID = "javax.xml.stream.XMLEventFactory"; + private static final String DEFAULT_IMPL_CLASS = + "com.sun.xml.internal.stream.events.XMLEventFactoryImpl"; + private static final String XMLEVENT_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS; + private static final String XMLEVENT_FACTORY_ID = "javax.xml.stream.XMLEventFactory"; @DataProvider(name = "parameters") public Object[][] getValidateParameters() { - return new Object[][] { { XMLEVENT_FACRORY_ID, null }, { XMLEVENT_FACRORY_ID, this.getClass().getClassLoader() } }; + return new Object[][] { + { XMLEVENT_FACTORY_ID, null }, + { XMLEVENT_FACTORY_ID, this.getClass().getClassLoader() } }; + } + + /** + * Test if newDefaultFactory() method returns an instance + * of the expected factory. + * @throws Exception If any errors occur. + */ + @Test + public void testDefaultInstance() throws Exception { + XMLEventFactory ef1 = XMLEventFactory.newDefaultFactory(); + XMLEventFactory ef2 = XMLEventFactory.newFactory(); + assertNotSame(ef1, ef2, "same instance returned:"); + assertSame(ef1.getClass(), ef2.getClass(), + "unexpected class mismatch for newDefaultFactory():"); + assertEquals(ef1.getClass().getName(), DEFAULT_IMPL_CLASS); } /* @@ -62,12 +85,12 @@ public class XMLEventFactoryNewInstanceTest { */ @Test(dataProvider = "parameters") public void testNewFactory(String factoryId, ClassLoader classLoader) { - setSystemProperty(XMLEVENT_FACRORY_ID, XMLEVENT_FACTORY_CLASSNAME); + setSystemProperty(XMLEVENT_FACTORY_ID, XMLEVENT_FACTORY_CLASSNAME); try { XMLEventFactory xef = XMLEventFactory.newFactory(factoryId, classLoader); assertNotNull(xef); } finally { - clearSystemProperty(XMLEVENT_FACRORY_ID); + clearSystemProperty(XMLEVENT_FACTORY_ID); } } diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLInputFactoryNewInstanceTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLInputFactoryNewInstanceTest.java index 9b77ac4b1af..e747396ff9e 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLInputFactoryNewInstanceTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLInputFactoryNewInstanceTest.java @@ -27,6 +27,9 @@ import static jaxp.library.JAXPTestUtilities.setSystemProperty; import static jaxp.library.JAXPTestUtilities.clearSystemProperty; import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNotSame; +import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertEquals; import javax.xml.stream.XMLInputFactory; @@ -38,6 +41,7 @@ import org.testng.annotations.Test; /* * @test + * @bug 8169778 * @library /javax/xml/jaxp/libs * @run testng/othervm -DrunSecMngr=true javax.xml.stream.ptests.XMLInputFactoryNewInstanceTest * @run testng/othervm javax.xml.stream.ptests.XMLInputFactoryNewInstanceTest @@ -46,12 +50,31 @@ import org.testng.annotations.Test; @Listeners({jaxp.library.BasePolicy.class}) public class XMLInputFactoryNewInstanceTest { - private static final String XMLINPUT_FACTORY_CLASSNAME = "com.sun.xml.internal.stream.XMLInputFactoryImpl"; - private static final String XMLINPUT_FACRORY_ID = "javax.xml.stream.XMLInputFactory"; + private static final String DEFAULT_IMPL_CLASS = + "com.sun.xml.internal.stream.XMLInputFactoryImpl"; + private static final String XMLINPUT_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS; + private static final String XMLINPUT_FACTORY_ID = "javax.xml.stream.XMLInputFactory"; @DataProvider(name = "parameters") public Object[][] getValidateParameters() { - return new Object[][] { { XMLINPUT_FACRORY_ID, null }, { XMLINPUT_FACRORY_ID, this.getClass().getClassLoader() } }; + return new Object[][] { + { XMLINPUT_FACTORY_ID, null }, + { XMLINPUT_FACTORY_ID, this.getClass().getClassLoader() } }; + } + + /** + * Test if newDefaultFactory() method returns an instance + * of the expected factory. + * @throws Exception If any errors occur. + */ + @Test + public void testDefaultInstance() throws Exception { + XMLInputFactory if1 = XMLInputFactory.newDefaultFactory(); + XMLInputFactory if2 = XMLInputFactory.newFactory(); + assertNotSame(if1, if2, "same instance returned:"); + assertSame(if1.getClass(), if2.getClass(), + "unexpected class mismatch for newDefaultFactory():"); + assertEquals(if1.getClass().getName(), DEFAULT_IMPL_CLASS); } /* @@ -62,12 +85,12 @@ public class XMLInputFactoryNewInstanceTest { */ @Test(dataProvider = "parameters") public void testNewFactory(String factoryId, ClassLoader classLoader) { - setSystemProperty(XMLINPUT_FACRORY_ID, XMLINPUT_FACTORY_CLASSNAME); + setSystemProperty(XMLINPUT_FACTORY_ID, XMLINPUT_FACTORY_CLASSNAME); try { XMLInputFactory xif = XMLInputFactory.newFactory(factoryId, classLoader); assertNotNull(xif); } finally { - clearSystemProperty(XMLINPUT_FACRORY_ID); + clearSystemProperty(XMLINPUT_FACTORY_ID); } } diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLOutputFactoryNewInstanceTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLOutputFactoryNewInstanceTest.java new file mode 100644 index 00000000000..e901977e968 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLOutputFactoryNewInstanceTest.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.xml.stream.ptests; + +import static jaxp.library.JAXPTestUtilities.setSystemProperty; +import static jaxp.library.JAXPTestUtilities.clearSystemProperty; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNotSame; +import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertEquals; + +import javax.xml.stream.XMLOutputFactory; + +import jaxp.library.JAXPDataProvider; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; + +/* + * @test + * @bug 8169778 + * @library /javax/xml/jaxp/libs + * @run testng/othervm -DrunSecMngr=true javax.xml.stream.ptests.XMLOutputFactoryNewInstanceTest + * @run testng/othervm javax.xml.stream.ptests.XMLOutputFactoryNewInstanceTest + * @summary Tests for XMLOutputFactory.newFactory(factoryId , classLoader) + */ +@Listeners({jaxp.library.BasePolicy.class}) +public class XMLOutputFactoryNewInstanceTest { + + private static final String DEFAULT_IMPL_CLASS = + "com.sun.xml.internal.stream.XMLOutputFactoryImpl"; + private static final String XMLOUTPUT_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS; + private static final String XMLOUTPUT_FACTORY_ID = "javax.xml.stream.XMLOutputFactory"; + + @DataProvider(name = "parameters") + public Object[][] getValidateParameters() { + return new Object[][] { + { XMLOUTPUT_FACTORY_ID, null }, + { XMLOUTPUT_FACTORY_ID, this.getClass().getClassLoader() } }; + } + + /** + * Test if newDefaultFactory() method returns an instance + * of the expected factory. + * @throws Exception If any errors occur. + */ + @Test + public void testDefaultInstance() throws Exception { + XMLOutputFactory of1 = XMLOutputFactory.newDefaultFactory(); + XMLOutputFactory of2 = XMLOutputFactory.newFactory(); + assertNotSame(of1, of2, "same instance returned:"); + assertSame(of1.getClass(), of2.getClass(), + "unexpected class mismatch for newDefaultFactory():"); + assertEquals(of1.getClass().getName(), DEFAULT_IMPL_CLASS); + } + + /* + * test for XMLOutputFactory.newFactory(java.lang.String factoryId, + * java.lang.ClassLoader classLoader) factoryClassName points to correct + * implementation of javax.xml.stream.XMLOutputFactory , should return + * newInstance of XMLOutputFactory + */ + @Test(dataProvider = "parameters") + public void testNewFactory(String factoryId, ClassLoader classLoader) { + setSystemProperty(XMLOUTPUT_FACTORY_ID, XMLOUTPUT_FACTORY_CLASSNAME); + try { + XMLOutputFactory xif = XMLOutputFactory.newFactory(factoryId, classLoader); + assertNotNull(xif); + } finally { + clearSystemProperty(XMLOUTPUT_FACTORY_ID); + } + } + + /* + * test for XMLOutputFactory.newFactory(java.lang.String factoryClassName, + * java.lang.ClassLoader classLoader) factoryClassName is null , should + * throw NullPointerException + */ + @Test(expectedExceptions = NullPointerException.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class) + public void testNewFactoryNeg(String factoryId, ClassLoader classLoader) { + XMLOutputFactory.newFactory(factoryId, classLoader); + } + +} diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java index 5f1fbb29500..ec5d2d4f387 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java @@ -28,6 +28,9 @@ import static jaxp.library.JAXPTestUtilities.USER_DIR; import static jaxp.library.JAXPTestUtilities.compareWithGold; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.assertNotSame; +import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertEquals; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -55,16 +58,23 @@ import org.w3c.dom.Document; */ /* * @test + * @bug 8169778 * @library /javax/xml/jaxp/libs * @run testng/othervm -DrunSecMngr=true javax.xml.transform.ptests.TransformerFactoryTest * @run testng/othervm javax.xml.transform.ptests.TransformerFactoryTest */ @Listeners({jaxp.library.FilePolicy.class}) public class TransformerFactoryTest { + /** + * TransformerFactory builtin system-default implementation class name. + */ + private static final String DEFAULT_IMPL_CLASS = + "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"; + /** * TransformerFactory implementation class name. */ - private static final String TRANSFORMER_FACTORY_CLASSNAME = "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"; + private static final String TRANSFORMER_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS; /** * Provide valid TransformerFactory instantiation parameters. @@ -76,6 +86,21 @@ public class TransformerFactoryTest { return new Object[][] { { TRANSFORMER_FACTORY_CLASSNAME, null }, { TRANSFORMER_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; } + /** + * Test if newDefaultInstance() method returns an instance + * of the expected factory. + * @throws Exception If any errors occur. + */ + @Test + public void testDefaultInstance() throws Exception { + TransformerFactory tf1 = TransformerFactory.newDefaultInstance(); + TransformerFactory tf2 = TransformerFactory.newInstance(); + assertNotSame(tf1, tf2, "same instance returned:"); + assertSame(tf1.getClass(), tf2.getClass(), + "unexpected class mismatch for newDefaultInstance():"); + assertEquals(tf1.getClass().getName(), DEFAULT_IMPL_CLASS); + } + /** * Test for TransformerFactory.newInstance(java.lang.String * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java index c3a12612a05..920723c4a56 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java @@ -28,6 +28,9 @@ import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertSame; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotSame; +import static org.testng.Assert.assertEquals; import java.io.ByteArrayInputStream; import java.io.File; @@ -66,7 +69,7 @@ import org.xml.sax.SAXParseException; /* * @test - * @bug 8080907 + * @bug 8080907 8169778 * @library /javax/xml/jaxp/libs * @run testng/othervm -DrunSecMngr=true javax.xml.validation.ptests.SchemaFactoryTest * @run testng/othervm javax.xml.validation.ptests.SchemaFactoryTest @@ -102,6 +105,25 @@ public class SchemaFactoryTest { { W3C_XML_SCHEMA_NS_URI, SCHEMA_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; } + /** + * Test if newDefaultInstance() method returns an instance + * of the expected factory. + * @throws Exception If any errors occur. + */ + @Test + public void testDefaultInstance() throws Exception { + SchemaFactory sf1 = SchemaFactory.newDefaultInstance(); + SchemaFactory sf2 = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI); + assertNotSame(sf1, sf2, "same instance returned:"); + assertSame(sf1.getClass(), sf2.getClass(), + "unexpected class mismatch for newDefaultInstance():"); + assertEquals(sf1.getClass().getName(), DEFAULT_IMPL_CLASS); + assertTrue(sf1.isSchemaLanguageSupported(W3C_XML_SCHEMA_NS_URI), + "isSchemaLanguageSupported(W3C_XML_SCHEMA_NS_URI):"); + assertFalse(sf1.isSchemaLanguageSupported(UNRECOGNIZED_NAME), + "isSchemaLanguageSupported(UNRECOGNIZED_NAME):"); + } + /* * test for SchemaFactory.newInstance(java.lang.String schemaLanguage, * java.lang.String factoryClassName, java.lang.ClassLoader classLoader) @@ -394,7 +416,10 @@ public class SchemaFactoryTest { private static final String UNRECOGNIZED_NAME = "http://xml.org/sax/features/namespace-prefixes"; - private static final String SCHEMA_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory"; + private static final String DEFAULT_IMPL_CLASS = + "com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory"; + + private static final String SCHEMA_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS; private SchemaFactory sf; private XMLInputFactory ifac; diff --git a/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java b/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java index 8a9c51aa284..b0e778204d2 100644 --- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java @@ -24,7 +24,13 @@ package javax.xml.xpath.ptests; import static javax.xml.xpath.XPathConstants.DOM_OBJECT_MODEL; +import static javax.xml.xpath.XPathFactory.DEFAULT_OBJECT_MODEL_URI; import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNotSame; +import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.assertFalse; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathFactory; @@ -41,6 +47,7 @@ import org.testng.annotations.Test; */ /* * @test + * @bug 8169778 * @library /javax/xml/jaxp/libs * @run testng/othervm -DrunSecMngr=true javax.xml.xpath.ptests.XPathFactoryTest * @run testng/othervm javax.xml.xpath.ptests.XPathFactoryTest @@ -57,10 +64,16 @@ public class XPathFactoryTest { */ private static final String INVALID_URL = "http://java.sun.com/jaxp/xpath/dom1"; + /** + * XPathFactory builtin system-default implementation class name. + */ + private static final String DEFAULT_IMPL_CLASS = + "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl"; + /** * XPathFactory implementation class name. */ - private static final String XPATH_FACTORY_CLASSNAME = "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl"; + private static final String XPATH_FACTORY_CLASSNAME = DEFAULT_IMPL_CLASS; /** @@ -73,6 +86,25 @@ public class XPathFactoryTest { return new Object[][] { { VALID_URL, XPATH_FACTORY_CLASSNAME, null }, { VALID_URL, XPATH_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; } + /** + * Test if newDefaultInstance() method returns an instance + * of the expected factory. + * @throws Exception If any errors occur. + */ + @Test + public void testDefaultInstance() throws Exception { + XPathFactory xpf1 = XPathFactory.newDefaultInstance(); + XPathFactory xpf2 = XPathFactory.newInstance(DEFAULT_OBJECT_MODEL_URI); + assertNotSame(xpf1, xpf2, "same instance returned:"); + assertSame(xpf1.getClass(), xpf2.getClass(), + "unexpected class mismatch for newDefaultInstance():"); + assertEquals(xpf1.getClass().getName(), DEFAULT_IMPL_CLASS); + assertTrue(xpf1.isObjectModelSupported(DEFAULT_OBJECT_MODEL_URI), + "isObjectModelSupported(DEFAULT_OBJECT_MODEL_URI):"); + assertFalse(xpf1.isObjectModelSupported(INVALID_URL), + "isObjectModelSupported(INVALID_URL):"); + } + /** * Test for XPathFactory.newInstance(java.lang.String uri, java.lang.String * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName From 36779a0df3e2c7942dda40d502d8bd3848e1364e Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Mon, 5 Dec 2016 13:00:32 -0800 Subject: [PATCH 032/142] 8170733: HashMap.HashIterator.remove method does not use cached value for the hash code Reviewed-by: martin, dl, shade --- jdk/src/java.base/share/classes/java/util/HashMap.java | 3 +-- jdk/src/java.base/share/classes/java/util/LinkedHashMap.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/HashMap.java b/jdk/src/java.base/share/classes/java/util/HashMap.java index fd4d9b11c2d..5cc36296aa8 100644 --- a/jdk/src/java.base/share/classes/java/util/HashMap.java +++ b/jdk/src/java.base/share/classes/java/util/HashMap.java @@ -1502,8 +1502,7 @@ public class HashMap extends AbstractMap if (modCount != expectedModCount) throw new ConcurrentModificationException(); current = null; - K key = p.key; - removeNode(hash(key), key, null, false, false); + removeNode(p.hash, p.key, null, false, false); expectedModCount = modCount; } } diff --git a/jdk/src/java.base/share/classes/java/util/LinkedHashMap.java b/jdk/src/java.base/share/classes/java/util/LinkedHashMap.java index 0253cd51bfd..bd21f5bf6d4 100644 --- a/jdk/src/java.base/share/classes/java/util/LinkedHashMap.java +++ b/jdk/src/java.base/share/classes/java/util/LinkedHashMap.java @@ -731,8 +731,7 @@ public class LinkedHashMap if (modCount != expectedModCount) throw new ConcurrentModificationException(); current = null; - K key = p.key; - removeNode(hash(key), key, null, false, false); + removeNode(p.hash, p.key, null, false, false); expectedModCount = modCount; } } From e281099d2fb4123971a25834a1f063445e104c19 Mon Sep 17 00:00:00 2001 From: Valerie Peng Date: Mon, 5 Dec 2016 23:23:27 +0000 Subject: [PATCH 033/142] 8170245: [TEST_BUG] Cipher tests fail when running with unlimited policy Updated the failed cipher tests to work under unlimited policy Reviewed-by: xuelei --- .../Cipher/AES/TestAESCiphers/Dynamic.java | 21 +++----- .../Cipher/Blowfish/TestCipherBlowfish.java | 4 +- .../PBE/PBESameBuffer/AESPBEWrapper.java | 39 ++++++++------- .../PBE/PBESameBuffer/PBECipherWrapper.java | 48 +++++++++++-------- .../PBE/TestCipherKeyWrapperPBEKey.java | 17 ++++--- .../provider/Cipher/PBE/TestCipherPBE.java | 13 +++-- .../crypto/provider/Cipher/TestCipher.java | 40 +++++++++------- 7 files changed, 98 insertions(+), 84 deletions(-) diff --git a/jdk/test/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/Dynamic.java b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/Dynamic.java index 3aa6d29e8fe..91d7426b7f1 100644 --- a/jdk/test/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/Dynamic.java +++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/Dynamic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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 @@ -150,19 +150,8 @@ public class Dynamic { int offset = ci.update(plainText, 0, plainText.length, cipherText, 0); ci.doFinal(cipherText, offset); + ci.init(Cipher.DECRYPT_MODE, key, ci.getParameters()); - if (!mo.equalsIgnoreCase("ECB")) { - iv = ci.getIV(); - aps = new IvParameterSpec(iv); - } else { - aps = null; - } - - if (!mo.equalsIgnoreCase("GCM")) { - ci.init(Cipher.DECRYPT_MODE, key, aps); - } else { - ci.init(Cipher.DECRYPT_MODE, key, ci.getParameters()); - } byte[] recoveredText = new byte[ci.getOutputSize(cipherText.length)]; int len = ci.doFinal(cipherText, 0, cipherText.length, recoveredText); @@ -174,12 +163,14 @@ public class Dynamic { result = Arrays.equals(plainText, tmp); } catch (NoSuchAlgorithmException nsaEx) { - nsaEx.printStackTrace(); // CFB7 and OFB150 are negative test,SunJCE not support this // algorithm result = mo.equalsIgnoreCase("CFB7") || mo.equalsIgnoreCase("OFB150"); - + if (!result) { + // only report unexpected exception + nsaEx.printStackTrace(); + } } return result; } diff --git a/jdk/test/com/sun/crypto/provider/Cipher/Blowfish/TestCipherBlowfish.java b/jdk/test/com/sun/crypto/provider/Cipher/Blowfish/TestCipherBlowfish.java index 7006abc3646..1fae3a073d5 100644 --- a/jdk/test/com/sun/crypto/provider/Cipher/Blowfish/TestCipherBlowfish.java +++ b/jdk/test/com/sun/crypto/provider/Cipher/Blowfish/TestCipherBlowfish.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -42,7 +42,7 @@ public class TestCipherBlowfish extends TestCipher { "OFB", "OFB8", "OFB16", "OFB24", "OFB32", "OFB40", "OFB48", "OFB56", "OFB64"}, new String[]{"NoPaDDing", "PKCS5Padding"}, - true); + 32, 448); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/AESPBEWrapper.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/AESPBEWrapper.java index 16dd69ad32f..b166fc19de4 100644 --- a/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/AESPBEWrapper.java +++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/AESPBEWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ import java.io.PrintStream; import java.security.AlgorithmParameters; import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; import java.security.Provider; import javax.crypto.Cipher; import javax.crypto.SecretKeyFactory; @@ -69,6 +70,15 @@ public class AESPBEWrapper extends PBEWrapper { */ @Override public boolean execute(int edMode, byte[] inputText, int offset, int len) { + boolean isUnlimited; + try { + isUnlimited = + (Cipher.getMaxAllowedKeyLength(this.algo) == Integer.MAX_VALUE); + } catch (NoSuchAlgorithmException nsae) { + out.println("Got unexpected exception for " + this.algo); + nsae.printStackTrace(out); + return false; + } try { // init Cipher if (Cipher.ENCRYPT_MODE == edMode) { @@ -78,6 +88,11 @@ public class AESPBEWrapper extends PBEWrapper { ci.init(Cipher.DECRYPT_MODE, this.key, pbeParams); } + if (this.algo.endsWith("AES_256") && !isUnlimited) { + out.print("Expected exception not thrown for " + this.algo); + return false; + } + // First, generate the cipherText at an allocated buffer byte[] outputText = ci.doFinal(inputText, offset, len); @@ -86,29 +101,19 @@ public class AESPBEWrapper extends PBEWrapper { int off = ci.update(inputText, offset, len, inputText, myoff); ci.doFinal(inputText, myoff + off); - if (this.algo.endsWith("AES_256")) { - out.print("Expected exception uncaught, " - + "keyStrength > 128 within " + this.algo); - - return false; - } - // Compare to see whether the two results are the same or not return equalsBlock(inputText, myoff, outputText, 0, outputText.length); } catch (Exception ex) { if ((ex instanceof InvalidKeyException) - && this.algo.endsWith("AES_256")) { - out.println("Expected InvalidKeyException exception: " - + ex.getMessage()); - + && this.algo.endsWith("AES_256") && !isUnlimited) { + out.println("Expected InvalidKeyException thrown"); return true; + } else { + out.println("Got unexpected exception for " + algo); + ex.printStackTrace(out); + return false; } - - out.println("Catch unexpected exception within " + algo); - ex.printStackTrace(out); - - return false; } } } diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBECipherWrapper.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBECipherWrapper.java index e4a8509ca34..6a61ca0bcdf 100644 --- a/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBECipherWrapper.java +++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBECipherWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ import java.security.spec.AlgorithmParameterSpec; import java.util.StringTokenizer; import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; import java.security.Provider; import java.io.PrintStream; @@ -64,9 +65,25 @@ public class PBECipherWrapper extends PBEWrapper { StringTokenizer st = new StringTokenizer(algo, "/"); String baseAlgo = st.nextToken().toUpperCase(); + boolean isUnlimited; + try { + isUnlimited = + (Cipher.getMaxAllowedKeyLength(this.algo) == Integer.MAX_VALUE); + } catch (NoSuchAlgorithmException nsae) { + out.println("Got unexpected exception for " + this.algo); + nsae.printStackTrace(out); + return false; + } + // Perform encryption or decryption depends on the specified edMode try { ci.init(edMode, key, aps); + if ((baseAlgo.endsWith("TRIPLEDES") + || baseAlgo.endsWith("AES_256")) && !isUnlimited) { + out.print("Expected InvalidKeyException not thrown: " + + this.algo); + return false; + } // First, generate the cipherText at an allocated buffer byte[] outputText = ci.doFinal(inputText, offset, len); @@ -78,33 +95,24 @@ public class PBECipherWrapper extends PBEWrapper { ci.doFinal(inputText, myoff + off); - if (baseAlgo.endsWith("TRIPLEDES") - || baseAlgo.endsWith("AES_256")) { - out.print("Expected exception uncaught," - + "keyStrength > 128 within " + this.algo); - - return false; - } - // Compare to see whether the two results are the same or not boolean result = equalsBlock(inputText, myoff, outputText, 0, outputText.length); return result; } catch (Exception ex) { - if ((ex instanceof InvalidKeyException) - && (baseAlgo.endsWith("TRIPLEDES") - || baseAlgo.endsWith("AES_256"))) { - out.println("Expected InvalidKeyException exception: " - + ex.getMessage()); - + if ((ex instanceof InvalidKeyException) && + (baseAlgo.endsWith("TRIPLEDES") + || baseAlgo.endsWith("AES_256")) && + !isUnlimited) { + out.println("Expected InvalidKeyException thrown for " + + algo); return true; + } else { + out.println("Got unexpected exception for " + algo); + ex.printStackTrace(out); + return false; } - - out.println("Catch unexpected exception within " + algo); - ex.printStackTrace(out); - - return false; } } } diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherKeyWrapperPBEKey.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherKeyWrapperPBEKey.java index dd767ba1fed..437b8ff26d5 100644 --- a/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherKeyWrapperPBEKey.java +++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherKeyWrapperPBEKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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 @@ -120,6 +120,9 @@ public class TestCipherKeyWrapperPBEKey { = new StringTokenizer(algo, "/").nextToken().toUpperCase(); boolean isAES = baseAlgo.contains("AES"); + boolean isUnlimited = + (Cipher.getMaxAllowedKeyLength(algo) == Integer.MAX_VALUE); + try { // Initialization new Random().nextBytes(salt); @@ -129,7 +132,6 @@ public class TestCipherKeyWrapperPBEKey { SecretKey key = skf.generateSecret(new PBEKeySpec( "Secret Key".toCharArray())); Cipher ci = Cipher.getInstance(algo); - if (isAES) { ci.init(Cipher.WRAP_MODE, key); pbeParams = ci.getParameters(); @@ -146,10 +148,10 @@ public class TestCipherKeyWrapperPBEKey { Key unwrappedKey = ci.unwrap(keyWrapper, algo, Cipher.SECRET_KEY); - if (baseAlgo.endsWith("TRIPLEDES") - || baseAlgo.endsWith("AES_256")) { + if ((baseAlgo.endsWith("TRIPLEDES") + || baseAlgo.endsWith("AES_256")) && !isUnlimited) { out.print( - "InvalidKeyException not thrown when keyStrength > 128"); + "Expected InvalidKeyException not thrown"); return false; } @@ -158,8 +160,9 @@ public class TestCipherKeyWrapperPBEKey { } catch (InvalidKeyException ex) { if ((baseAlgo.endsWith("TRIPLEDES") - || baseAlgo.endsWith("AES_256"))) { - out.println("Expected InvalidKeyException, keyStrength > 128"); + || baseAlgo.endsWith("AES_256")) && !isUnlimited) { + out.print( + "Expected InvalidKeyException thrown"); return true; } else { throw ex; diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherPBE.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherPBE.java index f30498932c8..97a52c9125a 100644 --- a/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherPBE.java +++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherPBE.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ -79,6 +79,9 @@ public class TestCipherPBE { out.println("=> Testing: " + algorithm); + boolean isUnlimited = + (Cipher.getMaxAllowedKeyLength(algorithm) == Integer.MAX_VALUE); + try { // Initialization AlgorithmParameterSpec algoParamSpec @@ -98,9 +101,9 @@ public class TestCipherPBE { ci.init(Cipher.DECRYPT_MODE, secretKey, algoParamSpec); byte[] recoveredText = ci.doFinal(cipherText); - if (algorithm.contains("TripleDES")) { + if (algorithm.contains("TripleDES") && !isUnlimited) { throw new RuntimeException( - "Expected InvalidKeyException exception uncaugh"); + "Expected InvalidKeyException not thrown"); } // Comparison @@ -110,8 +113,8 @@ public class TestCipherPBE { } out.println("Test Passed."); } catch (InvalidKeyException ex) { - if (algorithm.contains("TripleDES")) { - out.println("Expected InvalidKeyException raised"); + if (algorithm.contains("TripleDES") && !isUnlimited) { + out.println("Expected InvalidKeyException thrown"); } else { throw new RuntimeException(ex); } diff --git a/jdk/test/com/sun/crypto/provider/Cipher/TestCipher.java b/jdk/test/com/sun/crypto/provider/Cipher/TestCipher.java index 9cb25c739bc..b5e50c842a0 100644 --- a/jdk/test/com/sun/crypto/provider/Cipher/TestCipher.java +++ b/jdk/test/com/sun/crypto/provider/Cipher/TestCipher.java @@ -49,14 +49,13 @@ public abstract class TestCipher { private final String[] MODES; private final String[] PADDINGS; - /* Used to test cipher with different key strengths - Key size tested is increment of KEYCUTTER from MINIMUM_KEY_SIZE to - maximum allowed keysize. - DES/DESede/Blowfish work with currently selected key sizes. + /* Used to test variable-key-length ciphers: + Key size tested is increment of KEYCUTTER from minKeySize + to min(maxKeySize, Cipher.getMaxAllowedKeyLength(algo)). */ - private final int variousKeySize; private final int KEYCUTTER = 8; - private final int MINIMUM_KEY_SIZE = 32; + private final int minKeySize; + private final int maxKeySize; // Used to assert that Encryption/Decryption works with same buffer // TEXT_LEN is multiple of blocks in order to work against ciphers w/ NoPadding @@ -68,23 +67,28 @@ public abstract class TestCipher { private final byte[] IV; private final byte[] INPUT_TEXT; + // for variable-key-length ciphers TestCipher(String algo, String[] modes, String[] paddings, - boolean keyStrength) throws NoSuchAlgorithmException { + int minKeySize, int maxKeySize) throws NoSuchAlgorithmException { ALGORITHM = algo; MODES = modes; PADDINGS = paddings; - this.variousKeySize - = keyStrength ? Cipher.getMaxAllowedKeyLength(ALGORITHM) : 0; - + this.minKeySize = minKeySize; + int maxAllowedKeySize = Cipher.getMaxAllowedKeyLength(ALGORITHM); + if (maxKeySize > maxAllowedKeySize) { + maxKeySize = maxAllowedKeySize; + } + this.maxKeySize = maxKeySize; IV = generateBytes(8); INPUT_TEXT = generateBytes(TEXT_LEN + PAD_BYTES + ENC_OFFSET); } + // for fixed-key-length ciphers TestCipher(String algo, String[] modes, String[] paddings) { ALGORITHM = algo; MODES = modes; PADDINGS = paddings; - variousKeySize = 0; + this.minKeySize = this.maxKeySize = 0; IV = generateBytes(8); INPUT_TEXT = generateBytes(TEXT_LEN + PAD_BYTES + ENC_OFFSET); @@ -98,8 +102,8 @@ public abstract class TestCipher { return bytes; } - private boolean isKeyStrenthSupported() { - return (variousKeySize != 0); + private boolean isMultipleKeyLengthSupported() { + return (maxKeySize != minKeySize); } public void runAll() throws InvalidKeyException, @@ -110,11 +114,11 @@ public abstract class TestCipher { for (String mode : MODES) { for (String padding : PADDINGS) { - if (!isKeyStrenthSupported()) { - runTest(mode, padding, 0); + if (!isMultipleKeyLengthSupported()) { + runTest(mode, padding, minKeySize); } else { - int keySize = variousKeySize; - while (keySize >= MINIMUM_KEY_SIZE) { + int keySize = maxKeySize; + while (keySize >= minKeySize) { out.println("With Key Strength: " + keySize); runTest(mode, padding, keySize); keySize -= KEYCUTTER; @@ -139,6 +143,7 @@ public abstract class TestCipher { if (keySize != 0) { kg.init(keySize); } + SecretKey key = kg.generateKey(); SecretKeySpec skeySpec = new SecretKeySpec(key.getEncoded(), ALGORITHM); @@ -150,7 +155,6 @@ public abstract class TestCipher { } // Encryption - byte[] plainText = INPUT_TEXT.clone(); // Generate cipher and save to separate buffer From e61006c1cbce9461a55e8da26f8ebb6d61005574 Mon Sep 17 00:00:00 2001 From: Hamlin Li Date: Mon, 5 Dec 2016 16:16:05 -0800 Subject: [PATCH 034/142] 8170669: com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java fails after JDK-8153916 Reviewed-by: rriggs --- jdk/test/ProblemList.txt | 2 +- .../rmi/registry/RegistryContext/ContextWithNullProperties.java | 2 +- .../sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 247de4ee6ee..441ef67d48e 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -310,7 +310,7 @@ demo/jvmti/compiledMethodLoad/CompiledMethodLoadTest.java 8151899 generic- # jdk_other com/sun/jndi/ldap/DeadSSLLdapTimeoutTest.java 8169942 linux-i586,macosx-all,windows-x64 -com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java 8170669 generic-all + javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java 8169737 linux-all javax/xml/ws/clientjar/TestWsImport.java 8170370 generic-all diff --git a/jdk/test/com/sun/jndi/rmi/registry/RegistryContext/ContextWithNullProperties.java b/jdk/test/com/sun/jndi/rmi/registry/RegistryContext/ContextWithNullProperties.java index 2004d96f2f9..f75eb88d1b0 100644 --- a/jdk/test/com/sun/jndi/rmi/registry/RegistryContext/ContextWithNullProperties.java +++ b/jdk/test/com/sun/jndi/rmi/registry/RegistryContext/ContextWithNullProperties.java @@ -30,7 +30,7 @@ * @library ../../../../../../java/rmi/testlibrary * @build TestLibrary * @compile --add-modules jdk.naming.rmi ContextWithNullProperties.java - * @run main ContextWithNullProperties + * @run main/othervm ContextWithNullProperties */ import com.sun.jndi.rmi.registry.RegistryContext; diff --git a/jdk/test/com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java b/jdk/test/com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java index 5ca80d3397f..8bcf6600983 100644 --- a/jdk/test/com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java +++ b/jdk/test/com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java @@ -31,7 +31,7 @@ * jdk.naming.rmi * @library ../../../../../../java/rmi/testlibrary * @build TestLibrary - * @run main UnbindIdempotent + * @run main/othervm UnbindIdempotent */ import java.rmi.registry.Registry; From 615fbfe49cc7d74bd930a0f400b74474827a8642 Mon Sep 17 00:00:00 2001 From: Hamlin Li Date: Mon, 5 Dec 2016 16:27:50 -0800 Subject: [PATCH 035/142] 8170644: java/rmi/registry/interfaceHash/InterfaceHash.java failed intermittently with "Port already in use" Reviewed-by: dfuchs --- .../rmi/registry/interfaceHash/InterfaceHash.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/jdk/test/java/rmi/registry/interfaceHash/InterfaceHash.java b/jdk/test/java/rmi/registry/interfaceHash/InterfaceHash.java index b324666e650..82a95548c4b 100644 --- a/jdk/test/java/rmi/registry/interfaceHash/InterfaceHash.java +++ b/jdk/test/java/rmi/registry/interfaceHash/InterfaceHash.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, 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 @@ -42,7 +42,6 @@ * java.rmi/sun.rmi.transport.tcp * @build TestLibrary ReferenceRegistryStub * @run main/othervm InterfaceHash - * @key intermittent */ import java.lang.reflect.Constructor; @@ -63,7 +62,6 @@ import sun.rmi.transport.tcp.TCPEndpoint; public class InterfaceHash { - private static final int PORT = TestLibrary.getUnusedRandomPort(); private static final String NAME = "WMM"; public static void main(String[] args) throws Exception { @@ -73,12 +71,13 @@ public class InterfaceHash { "\n=== verifying that J2SE registry's skeleton uses" + "\ncorrect interface hash and operation numbers:"); - Registry testImpl = LocateRegistry.createRegistry(PORT); - System.err.println("created test registry on port " + PORT); + Registry testImpl = TestLibrary.createRegistryOnEphemeralPort(); + int regPort = TestLibrary.getRegistryPort(testImpl); + System.err.println("created test registry on port " + regPort); RemoteRef ref = new UnicastRef( new LiveRef(new ObjID(ObjID.REGISTRY_ID), - new TCPEndpoint("", PORT), false)); + new TCPEndpoint("", regPort), false)); Registry referenceStub = new ReferenceRegistryStub(ref); System.err.println("created reference registry stub: " + referenceStub); @@ -144,7 +143,7 @@ public class InterfaceHash { } FakeRemoteRef f = new FakeRemoteRef(); - Registry testRegistry = LocateRegistry.getRegistry(PORT); + Registry testRegistry = LocateRegistry.getRegistry(regPort); System.err.println("created original test registry stub: " + testRegistry); From fdb9c95f6b3379eb7f435720fea8744c981772d5 Mon Sep 17 00:00:00 2001 From: Bradford Wetmore Date: Mon, 5 Dec 2016 17:04:02 -0800 Subject: [PATCH 036/142] 8170157: Enable unlimited cryptographic policy by default in OracleJDK 8169335: Add a crypto policy fallback in case Security Property 'crypto.policy' does not exist Reviewed-by: erikj, ihse, weijun, xuelei, coffeys --- jdk/make/gensrc/GensrcMisc.gmk | 16 +++ ...ecurity.java => JceSecurity.java.template} | 50 +++++++- .../share/conf/security/java.security | 47 ++++--- .../share/conf/security/policy/README.txt | 9 +- .../CryptoPolicyFallback.java | 119 ++++++++++++++++++ .../CryptoPermissions/TestUnlimited.java | 82 +++++++++--- 6 files changed, 280 insertions(+), 43 deletions(-) rename jdk/src/java.base/share/classes/javax/crypto/{JceSecurity.java => JceSecurity.java.template} (88%) create mode 100644 jdk/test/javax/crypto/CryptoPermissions/CryptoPolicyFallback.java diff --git a/jdk/make/gensrc/GensrcMisc.gmk b/jdk/make/gensrc/GensrcMisc.gmk index 475b8f1d033..6b5dcf9e6b6 100644 --- a/jdk/make/gensrc/GensrcMisc.gmk +++ b/jdk/make/gensrc/GensrcMisc.gmk @@ -108,3 +108,19 @@ ifeq ($(OPENJDK_TARGET_OS), solaris) endif ################################################################################ +# Create the javax/crypto/JceSecurity.class, using the build default. +# +ifeq ($(UNLIMITED_CRYPTO), true) + JCE_DEFAULT_POLICY = unlimited +else + JCE_DEFAULT_POLICY = limited +endif + +$(eval $(call SetupTextFileProcessing, BUILD_JCESECURITY_JAVA, \ + SOURCE_FILES := $(JDK_TOPDIR)/src/java.base/share/classes/javax/crypto/JceSecurity.java.template, \ + OUTPUT_FILE := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/javax/crypto/JceSecurity.java, \ + REPLACEMENTS := \ + @@JCE_DEFAULT_POLICY@@ => $(JCE_DEFAULT_POLICY), \ +)) + +GENSRC_JAVA_BASE += $(BUILD_JCESECURITY_JAVA) diff --git a/jdk/src/java.base/share/classes/javax/crypto/JceSecurity.java b/jdk/src/java.base/share/classes/javax/crypto/JceSecurity.java.template similarity index 88% rename from jdk/src/java.base/share/classes/javax/crypto/JceSecurity.java rename to jdk/src/java.base/share/classes/javax/crypto/JceSecurity.java.template index cc32f835696..2705b4c7eb2 100644 --- a/jdk/src/java.base/share/classes/javax/crypto/JceSecurity.java +++ b/jdk/src/java.base/share/classes/javax/crypto/JceSecurity.java.template @@ -23,10 +23,33 @@ * questions. */ +/* + * README README README README README README README README README + * + * This file is the template for generating the JceSecurity.java source + * file. + * + * In the current jdk builds, this file is first preprocessed to replace + * @@JCE_DEFAULT_POLICY@ [sic] with "limited" or "unlimited" which is + * determined by the $(UNLIMTED_CRYPTO) make variable. This variable is + * set by top-level configure script, using either + * --disable-unlimited-crypto or --enable-unlimited-crypto [default]. + * + * Since this file is a generated source, incremental changes to + * this file require regenerating the source. Compilation options: + * + * (fewer dependencies/"faster" ones first) + * + * 1. make JDK_FILTER=javax/crypto java.base-gensrc-only java.base-java-only + * 2. make java.base-gensrc-only java.base-java-only + * 3. make java.base-gensrc-only java.base-only + * 4. make java.base-only + * 5. make + */ + package javax.crypto; import java.util.*; -import java.util.jar.*; import java.io.*; import java.net.URL; import java.nio.file.*; @@ -36,6 +59,7 @@ import java.security.Provider.Service; import sun.security.jca.*; import sun.security.jca.GetInstance.Instance; +import sun.security.util.Debug; /** * This class instantiates implementations of JCE engine classes from @@ -47,6 +71,9 @@ import sun.security.jca.GetInstance.Instance; */ final class JceSecurity { + + + private static final Debug debug = Debug.getInstance("jca"); static final SecureRandom RANDOM = new SecureRandom(); @@ -251,10 +278,27 @@ final class JceSecurity { // directory entry, no pseudo-directories (".", "..", leading/trailing // path separators). normalize()/getParent() will help later. String cryptoPolicyProperty = Security.getProperty("crypto.policy"); + + /* + * In case no property is present, rather than fail catastrophically, + * we at least try for a "sane" value, which is what we were + * built with. We first preprocess this file to plug in that + * value, then compile the result gensrc. + * + * Log the warning first. + */ + if (cryptoPolicyProperty == null) { + cryptoPolicyProperty = "@@JCE_DEFAULT_POLICY@@"; + if (debug != null) { + debug.println( + "Security Property 'crypto.policy' not found: " + + "using '" + cryptoPolicyProperty + "' as fallback"); + } + } + Path cpPath = Paths.get(cryptoPolicyProperty); - if ((cryptoPolicyProperty == null) || - (cpPath.getNameCount() != 1) || + if ((cpPath.getNameCount() != 1) || (cpPath.compareTo(cpPath.getFileName()) != 0)) { throw new SecurityException( "Invalid policy directory name format: " + diff --git a/jdk/src/java.base/share/conf/security/java.security b/jdk/src/java.base/share/conf/security/java.security index a521dde7ebb..fe45e0ba06c 100644 --- a/jdk/src/java.base/share/conf/security/java.security +++ b/jdk/src/java.base/share/conf/security/java.security @@ -849,35 +849,35 @@ jdk.tls.legacyAlgorithms= \ # FFFFFFFF FFFFFFFF, 2} # Cryptographic Jurisdiction Policy defaults -# +# # Due to the import control restrictions of some countries, the default # JCE policy files allow for strong but "limited" cryptographic key # lengths to be used. If your country's cryptographic regulations allow, # the "unlimited" strength policy files can be used instead, which contain # no restrictions on cryptographic strengths. -# +# # If your country has restrictions that don't fit either "limited" or # "unlimited", an appropriate set of policy files should be created and # configured before using this distribution. The jurisdiction policy file # configuration must reflect the cryptographic restrictions appropriate # for your country. -# +# # YOU ARE ADVISED TO CONSULT YOUR EXPORT/IMPORT CONTROL COUNSEL OR ATTORNEY # TO DETERMINE THE EXACT REQUIREMENTS. -# +# # The policy files are flat text files organized into subdirectories of # /conf/security/policy. Each directory contains a complete # set of policy files. # # The "crypto.policy" Security property controls the directory selection, # and thus the effective cryptographic policy. -# -# The default set of directories is: -# -# limited | unlimited -# +# +# The default set of directories is: +# +# limited | unlimited +# # however other directories can be created and configured. -# +# # Within a directory, the effective policy is the combined minimum # permissions of the grant statements in the file(s) with the filename # pattern "default_*.policy". At least one grant is required. For @@ -891,11 +891,15 @@ jdk.tls.legacyAlgorithms= \ # "exempt_*.policy". Exemption grants are optional. # # limited = grants exemption permissions, by which the -# effective policy can be circumvented. +# effective policy can be circumvented. # e.g. KeyRecovery/Escrow/Weakening. -# +# # Please see the JCA documentation for additional information on these # files and formats. +# +# Note: This property is currently used by the JDK Reference implementation. +# It is not guaranteed to be examined and used by other implementations. +# crypto.policy=crypto.policydir-tbd # @@ -951,7 +955,8 @@ jdk.xml.dsig.secureValidationPolicy=\ # # If a pattern includes a "=", it sets a limit. # If a limit appears more than once the last value is used. -# Limits are checked before classes regardless of the order in the sequence of patterns. +# Limits are checked before classes regardless of the order in the +# sequence of patterns. # If any of the limits are exceeded, the filter status is REJECTED. # # maxdepth=value - the maximum depth of a graph @@ -961,20 +966,24 @@ jdk.xml.dsig.secureValidationPolicy=\ # # Other patterns, from left to right, match the class or package name as # returned from Class.getName. -# If the class is an array type, the class or package to be matched is the element type. +# If the class is an array type, the class or package to be matched is the +# element type. # Arrays of any number of dimensions are treated the same as the element type. # For example, a pattern of "!example.Foo", rejects creation of any instance or # array of example.Foo. # -# If the pattern starts with "!", the status is REJECTED if the remaining pattern -# is matched; otherwise the status is ALLOWED if the pattern matches. -# If the pattern contains "/", the non-empty prefix up to the "/" is the module name; +# If the pattern starts with "!", the status is REJECTED if the remaining +# pattern is matched; otherwise the status is ALLOWED if the pattern matches. +# If the pattern contains "/", the non-empty prefix up to the "/" is the +# module name; # if the module name matches the module name of the class then # the remaining pattern is matched with the class name. # If there is no "/", the module name is not compared. -# If the pattern ends with ".**" it matches any class in the package and all subpackages. +# If the pattern ends with ".**" it matches any class in the package and all +# subpackages. # If the pattern ends with ".*" it matches any class in the package. -# If the pattern ends with "*", it matches any class with the pattern as a prefix. +# If the pattern ends with "*", it matches any class with the pattern as a +# prefix. # If the pattern is equal to the class name, it matches. # Otherwise, the status is UNDECIDED. # diff --git a/jdk/src/java.base/share/conf/security/policy/README.txt b/jdk/src/java.base/share/conf/security/policy/README.txt index 84e33c972b7..3e0e2294a80 100644 --- a/jdk/src/java.base/share/conf/security/policy/README.txt +++ b/jdk/src/java.base/share/conf/security/policy/README.txt @@ -10,11 +10,10 @@ The JCE architecture allows flexible cryptographic strength to be configured via the jurisdiction policy files contained within these directories. -Due to import control restrictions of some countries, the default -JCE policy files bundled in this Java Runtime Environment allow -for strong but "limited" cryptographic strengths. For convenience, -this build also contains the "unlimited strength" policy files which -contain no restrictions on cryptographic strengths, but they must be +The default JCE policy files bundled in this Java Runtime Environment +allow for "unlimited" cryptographic strengths. For convenience, +this build also contains the historic "limited" strength policy files +which contain restrictions on cryptographic strengths, but they must be specifically activated by updating the "crypto.policy" Security property (e.g. /conf/security/java.security) to point to the appropriate directory. diff --git a/jdk/test/javax/crypto/CryptoPermissions/CryptoPolicyFallback.java b/jdk/test/javax/crypto/CryptoPermissions/CryptoPolicyFallback.java new file mode 100644 index 00000000000..8ccdd0cb39e --- /dev/null +++ b/jdk/test/javax/crypto/CryptoPermissions/CryptoPolicyFallback.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2016, 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. + */ + +/** + * @test + * @bug 8169335 + * @summary Add a crypto policy fallback in case Security Property + * 'crypto.policy' does not exist. + * @run main/othervm CryptoPolicyFallback + */ +import java.io.*; +import java.nio.file.*; +import java.util.stream.*; +import javax.crypto.*; + +/* + * Take the current java.security file, strip out the 'crypto.policy' entry, + * write to a new file in the current directory, then use that file as the + * replacement java.security file. This test will fail if the crypto.policy + * entry doesn't match the compiled in value. + */ +public class CryptoPolicyFallback { + + private static final String FILENAME = "java.security"; + + public static void main(String[] args) throws Exception { + + String javaHome = System.getProperty("java.home"); + + Path path = Paths.get(javaHome, "conf", "security", FILENAME); + + /* + * Get the default value. + */ + String defaultPolicy; + try (Stream lines = Files.lines(path)) { + /* + * If the input java.security file is malformed + * (missing crypto.policy, attribute/no value, etc), throw + * exception. split() might throw AIOOB which + * is ok behavior. + */ + defaultPolicy = lines.filter(x -> x.startsWith("crypto.policy=")) + .findFirst().orElseThrow( + () -> new Exception("Missing crypto.policy")) + .split("=")[1].trim(); + } + + /* + * We know there is at least one crypto.policy entry, strip + * all of them out of the java.security file. + */ + try (PrintWriter out = new PrintWriter(FILENAME); + Stream lines = Files.lines(path)) { + lines.filter(x -> !x.trim().startsWith("crypto.policy=")) + .forEach(out::println); + } + + /* + * "-Djava.security.properties==file" does a complete replacement + * of the system java.security file. i.e. value must be "=file" + */ + System.setProperty("java.security.properties", "=" + FILENAME); + + /* + * Find out expected value. + */ + int expected; + switch (defaultPolicy) { + case "limited": + expected = 128; + break; + case "unlimited": + expected = Integer.MAX_VALUE; + break; + default: + throw new Exception( + "Unexpected Default Policy Value: " + defaultPolicy); + } + + /* + * Do the actual check. If the JCE Framework can't initialize + * an Exception is normally thrown here. + */ + int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES"); + + System.out.println("Default Policy: " + defaultPolicy + + "\nExpected max AES key length: " + expected + + ", received : " + maxKeyLen); + + if (expected != maxKeyLen) { + throw new Exception("Wrong Key Length size!"); + } + + System.out.println("PASSED!"); + } +} diff --git a/jdk/test/javax/crypto/CryptoPermissions/TestUnlimited.java b/jdk/test/javax/crypto/CryptoPermissions/TestUnlimited.java index e6a8f7f37cc..a367021148e 100644 --- a/jdk/test/javax/crypto/CryptoPermissions/TestUnlimited.java +++ b/jdk/test/javax/crypto/CryptoPermissions/TestUnlimited.java @@ -27,10 +27,11 @@ * @test * @bug 8061842 * @summary Package jurisdiction policy files as something other than JAR + * @run main/othervm TestUnlimited use_default default * @run main/othervm TestUnlimited "" exception - * @run main/othervm TestUnlimited limited fail - * @run main/othervm TestUnlimited unlimited pass - * @run main/othervm TestUnlimited unlimited/ pass + * @run main/othervm TestUnlimited limited limited + * @run main/othervm TestUnlimited unlimited unlimited + * @run main/othervm TestUnlimited unlimited/ unlimited * @run main/othervm TestUnlimited NosuchDir exception * @run main/othervm TestUnlimited . exception * @run main/othervm TestUnlimited /tmp/unlimited exception @@ -40,9 +41,38 @@ */ import javax.crypto.*; import java.security.Security; +import java.nio.file.*; +import java.util.stream.*; public class TestUnlimited { + private enum Result { + UNLIMITED, + LIMITED, + EXCEPTION, + UNKNOWN + }; + + /* + * Grab the default policy entry from java.security. + * + * If the input java.security file is malformed + * (missing crypto.policy, attribute/no value, etc), throw + * exception. split() might throw AIOOB which + * is ok behavior. + */ + private static String getDefaultPolicy() throws Exception { + String javaHome = System.getProperty("java.home"); + Path path = Paths.get(javaHome, "conf", "security", "java.security"); + + try (Stream lines = Files.lines(path)) { + return lines.filter(x -> x.startsWith("crypto.policy=")) + .findFirst().orElseThrow( + () -> new Exception("Missing crypto.policy")) + .split("=")[1].trim(); + } + } + public static void main(String[] args) throws Exception { /* * Override the Security property to allow for unlimited policy. @@ -53,16 +83,37 @@ public class TestUnlimited { throw new Exception("Two args required"); } - boolean expected = args[1].equals("pass"); - boolean exception = args[1].equals("exception"); - boolean result = false; + String testStr = args[0]; + String expectedStr = args[1]; + if (testStr.equals("use_default")) { + expectedStr = getDefaultPolicy(); + } - System.out.println("Testing: " + args[0]); + Result expected = Result.UNKNOWN; // avoid NPE warnings + Result result; - if (args[0].equals("\"\"")) { + switch (expectedStr) { + case "unlimited": + expected = Result.UNLIMITED; + break; + case "limited": + expected = Result.LIMITED; + break; + case "exception": + expected = Result.EXCEPTION; + break; + default: + throw new Exception("Unexpected argument"); + } + + System.out.println("Testing: " + testStr); + if (testStr.equals("\"\"")) { Security.setProperty("crypto.policy", ""); } else { - Security.setProperty("crypto.policy", args[0]); + // skip default case. + if (!testStr.equals("use_default")) { + Security.setProperty("crypto.policy", testStr); + } } /* @@ -74,21 +125,20 @@ public class TestUnlimited { System.out.println("max AES key len:" + maxKeyLen); if (maxKeyLen > 128) { System.out.println("Unlimited policy is active"); - result = true; + result = Result.UNLIMITED; } else { System.out.println("Unlimited policy is NOT active"); - result = false; + result = Result.LIMITED; } } catch (Throwable e) { - if (!exception) { - throw new Exception(); - } + //ExceptionInInitializerError's + result = Result.EXCEPTION; } System.out.println( "Expected:\t" + expected + "\nResult:\t\t" + result); - if (expected != result) { - throw new Exception(); + if (!expected.equals(result)) { + throw new Exception("Didn't match"); } System.out.println("DONE!"); From 88352efab6219969a9f287098579cb5d30082a71 Mon Sep 17 00:00:00 2001 From: John Jiang Date: Mon, 5 Dec 2016 19:06:55 -0800 Subject: [PATCH 037/142] 8170523: Some PKCS11 test cases are ignored with security manager Get OS distro before enabling security manager Reviewed-by: mullan --- jdk/test/sun/security/pkcs11/PKCS11Test.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jdk/test/sun/security/pkcs11/PKCS11Test.java b/jdk/test/sun/security/pkcs11/PKCS11Test.java index 1724fd300d9..7b23e808e77 100644 --- a/jdk/test/sun/security/pkcs11/PKCS11Test.java +++ b/jdk/test/sun/security/pkcs11/PKCS11Test.java @@ -642,6 +642,8 @@ public abstract class PKCS11Test { static final boolean badNSSVersion = getNSSVersion() >= 3.11 && getNSSVersion() < 3.12; + private static final String distro = distro(); + static final boolean badSolarisSparc = System.getProperty("os.name").equals("SunOS") && System.getProperty("os.arch").equals("sparcv9") && @@ -735,13 +737,17 @@ public abstract class PKCS11Test { * Get the identifier for the operating system distribution */ static String getDistro() { + return distro; + } + + private static String distro() { try (BufferedReader in = new BufferedReader(new InputStreamReader( Runtime.getRuntime().exec("uname -v").getInputStream()))) { return in.readLine(); } catch (Exception e) { - return ""; + throw new RuntimeException("Failed to determine distro.", e); } } From 109b86908aba3d23d87329be2ae19552cf196624 Mon Sep 17 00:00:00 2001 From: Li Jiang Date: Tue, 29 Nov 2016 21:58:29 -0800 Subject: [PATCH 038/142] 8037111: space before percent is inconsistent between sv and sv_SE 8081643: wrong number format for Serbian locale with Latin script Reviewed-by: naoto --- .../sun/text/resources/ext/FormatData_sr_Latn.java | 4 ++-- .../classes/sun/text/resources/ext/FormatData_sv.java | 9 ++++++++- jdk/test/sun/text/resources/LocaleData | 6 ++++++ jdk/test/sun/text/resources/LocaleDataTest.java | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_sr_Latn.java b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_sr_Latn.java index 6c6a8d9e5dc..13b979cb6e8 100644 --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_sr_Latn.java +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_sr_Latn.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -167,8 +167,8 @@ public class FormatData_sr_Latn extends ParallelListResourceBundle { }, { "NumberElements", new String[] { - ".", ",", + ".", ";", "%", "0", diff --git a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_sv.java b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_sv.java index f22ca8ccb9a..29e63d9a458 100644 --- a/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_sv.java +++ b/jdk/src/jdk.localedata/share/classes/sun/text/resources/ext/FormatData_sv.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -270,6 +270,13 @@ public class FormatData_sv extends ParallelListResourceBundle { "e", } }, + { "NumberPatterns", + new String[] { + "#,##0.###;-#,##0.###", // decimal pattern + "\u00a4 #,##0.00;-\u00a4 #,##0.00", // currency pattern + "#,##0 %" // percent pattern + } + }, { "NumberElements", new String[] { ",", // decimal separator diff --git a/jdk/test/sun/text/resources/LocaleData b/jdk/test/sun/text/resources/LocaleData index a4bae5a9c21..630bea7a753 100644 --- a/jdk/test/sun/text/resources/LocaleData +++ b/jdk/test/sun/text/resources/LocaleData @@ -8293,3 +8293,9 @@ CurrencyNames//pen=Peruvian Sol # bug #8145952 CurrencyNames//byn=Belarusian Ruble CurrencyNames/be_BY/BYN=\u0420\u0443\u0431 + +# bug #8037111 +FormatData/sv/NumberPatterns/2=#,##0 % +# bug #8081643 +FormatData/sr-Latin/NumberElements/0=, +FormatData/sr-Latin/NumberElements/1=. diff --git a/jdk/test/sun/text/resources/LocaleDataTest.java b/jdk/test/sun/text/resources/LocaleDataTest.java index c8631e63875..acfcb12d4f1 100644 --- a/jdk/test/sun/text/resources/LocaleDataTest.java +++ b/jdk/test/sun/text/resources/LocaleDataTest.java @@ -37,7 +37,7 @@ * 7003124 7085757 7028073 7171028 7189611 8000983 7195759 8004489 8006509 * 7114053 7074882 7040556 8008577 8013836 8021121 6192407 6931564 8027695 * 8017142 8037343 8055222 8042126 8074791 8075173 8080774 8129361 8134916 - * 8145136 8145952 8164784 + * 8145136 8145952 8164784 8037111 8081643 * @summary Verify locale data * @modules java.base/sun.util.resources * @modules jdk.localedata From 53224e0782c64d8d56e297580e03b61d714d6f93 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Tue, 6 Dec 2016 14:44:12 -0800 Subject: [PATCH 039/142] 8170828: test/java/util/zip/ZipFile/TestZipFile needs @modules to work with Method.setAccessible() Reviewed-by: martin, rriggs --- jdk/test/java/util/zip/ZipFile/TestZipFile.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/test/java/util/zip/ZipFile/TestZipFile.java b/jdk/test/java/util/zip/ZipFile/TestZipFile.java index 25b87ff1242..d20a7367fde 100644 --- a/jdk/test/java/util/zip/ZipFile/TestZipFile.java +++ b/jdk/test/java/util/zip/ZipFile/TestZipFile.java @@ -24,6 +24,7 @@ /* * @test * @bug 8142508 8146431 + * @modules java.base/java.util.zip:open * @summary Tests various ZipFile apis * @run main/manual TestZipFile */ From 9877170d02bdae715bcb9e213770cfa266ffc157 Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Tue, 6 Dec 2016 17:26:43 -0800 Subject: [PATCH 040/142] 8166446: SingletonIterator.forEachRemaining doesn't advance before calling action Reviewed-by: martin --- .../share/classes/java/util/Collections.java | 4 +-- .../util/Collections/SingletonIterator.java | 29 ++++++++++++++----- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/Collections.java b/jdk/src/java.base/share/classes/java/util/Collections.java index 9f6ab76a723..7119fff3e89 100644 --- a/jdk/src/java.base/share/classes/java/util/Collections.java +++ b/jdk/src/java.base/share/classes/java/util/Collections.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, 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 @@ -4699,8 +4699,8 @@ public class Collections { public void forEachRemaining(Consumer action) { Objects.requireNonNull(action); if (hasNext) { - action.accept(e); hasNext = false; + action.accept(e); } } }; diff --git a/jdk/test/java/util/Collections/SingletonIterator.java b/jdk/test/java/util/Collections/SingletonIterator.java index 966cce07414..0f7dfd17252 100644 --- a/jdk/test/java/util/Collections/SingletonIterator.java +++ b/jdk/test/java/util/Collections/SingletonIterator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* * @test + * @bug 8024500 8166446 * @run testng SingletonIterator */ @@ -38,6 +39,15 @@ import static org.testng.Assert.fail; @Test(groups = "unit") public class SingletonIterator { + static void assertIteratorExhausted(Iterator it) { + assertFalse(it.hasNext()); + try { + it.next(); + fail("should have thrown NoSuchElementException"); + } catch (NoSuchElementException success) { } + it.forEachRemaining(e -> { throw new AssertionError("action called incorrectly"); }); + } + public void testForEachRemaining() { Iterator it = Collections.singleton("TheOne").iterator(); AtomicInteger cnt = new AtomicInteger(0); @@ -48,13 +58,18 @@ public class SingletonIterator { }); assertEquals(cnt.get(), 1); - assertFalse(it.hasNext()); + assertIteratorExhausted(it); + } + + static class SingletonException extends RuntimeException { } + + public void testThrowFromForEachRemaining() { + Iterator it = Collections.singleton("TheOne").iterator(); try { - String str = it.next(); - fail("Should throw NoSuchElementException at end"); - } catch (NoSuchElementException ex) { - // ignore; - } + it.forEachRemaining(s -> { throw new SingletonException(); }); + } catch (SingletonException ignore) { } + + assertIteratorExhausted(it); } } From 1dad4ab65f9dd95d0c3631ff54212675ca24fb0c Mon Sep 17 00:00:00 2001 From: Hamlin Li Date: Tue, 6 Dec 2016 17:53:22 -0800 Subject: [PATCH 041/142] 8170704: java/rmi/activation/Activatable/* tests fails intermittently with "output improperly annotated" Reviewed-by: dfuchs, rriggs --- .../checkAnnotations/CheckAnnotations.java | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/jdk/test/java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java b/jdk/test/java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java index a5a69a5c88c..4776f90c3be 100644 --- a/jdk/test/java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java +++ b/jdk/test/java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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 @@ -49,6 +49,7 @@ import java.util.StringTokenizer; public class CheckAnnotations extends Activatable implements MyRMI, Runnable { + private static final double TIME_FACTOR = TestLibrary.getTimeoutFactor(); private static Object dummy = new Object(); private static MyRMI myRMI = null; @@ -111,9 +112,7 @@ public class CheckAnnotations for (int i = 0; i < 3; i++) { // object activated in annotation check via method call - if(!checkAnnotations(i-1)) { - TestLibrary.bomb("Test failed: output improperly annotated."); - } + checkAnnotations(i-1); /* * Clean up object too. @@ -143,24 +142,27 @@ public class CheckAnnotations * check to make sure that the output from a spawned vm is * formatted/annotated properly. */ - public static boolean checkAnnotations(int iteration) + public static void checkAnnotations(int iteration) throws IOException { try { - Thread.sleep(5000); + Thread.sleep((long)(5000 * TIME_FACTOR)); } catch(Exception e) { System.err.println(e.getMessage()); } + final String FAIL_MSG = "Test failed: output improperly annotated."; + final String OUT = "outABC"; + final String ERR = "errXYZ"; /** * cause the spawned vm to generate output that will * be checked for proper annotation. printOut is * actually being called on an activated implementation. */ - myRMI.printOut("out" + iteration); - myRMI.printErr("err" + iteration); - myRMI.printOut("out" + iteration); - myRMI.printErr("err" + iteration); + myRMI.printOut(OUT + iteration); + myRMI.printErr(ERR + iteration); + myRMI.printOut(OUT + iteration); + myRMI.printErr(ERR + iteration); /* we have to wait for output to filter down * from children so we can read it before we @@ -174,7 +176,7 @@ public class CheckAnnotations // have to give output from rmid time to trickle down to // this process try { - Thread.sleep(4000); + Thread.sleep((long)(4000 * TIME_FACTOR)); } catch(InterruptedException e) { } @@ -222,27 +224,24 @@ public class CheckAnnotations if ((execErr == null)||(errTmp == null)|| (destErr == null)) { - return false; + TestLibrary.bomb(FAIL_MSG); } if ((execOut == null)||(outTmp == null)|| (destOut == null)) { - return false; + TestLibrary.bomb(FAIL_MSG); } // just make sure that last two strings are what we expect. - if (execOut.equals("ExecGroup-" + iteration) - && (new String(destOut.substring(0,4)).equals("out" + + if (!execOut.equals("ExecGroup-" + iteration) + || !(new String(destOut.substring(0,OUT.length()+1)).equals(OUT + iteration)) - && (execErr.equals("ExecGroup-"+iteration)) - && (new String(destErr.substring(0,4)).equals("err" + + || !(execErr.equals("ExecGroup-"+iteration)) + || !(new String(destErr.substring(0,ERR.length()+1)).equals(ERR + iteration)) ) { - return true; - } else { - return false; + TestLibrary.bomb(FAIL_MSG); } } - return true; } // implementation of MyRMI, make this object activatable. From ae8cf2835339d91b2f1dd79cc793da51a725ff2a Mon Sep 17 00:00:00 2001 From: Felix Yang Date: Tue, 6 Dec 2016 17:49:44 -0800 Subject: [PATCH 042/142] 8081390: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java may leave orphaned processes Reviewed-by: rriggs --- .../remote/mandatory/connection/RMIConnector_NPETest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jdk/test/javax/management/remote/mandatory/connection/RMIConnector_NPETest.java b/jdk/test/javax/management/remote/mandatory/connection/RMIConnector_NPETest.java index a2a1f9ca72c..732f8998184 100644 --- a/jdk/test/javax/management/remote/mandatory/connection/RMIConnector_NPETest.java +++ b/jdk/test/javax/management/remote/mandatory/connection/RMIConnector_NPETest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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,12 +43,12 @@ import javax.management.remote.rmi.*; public class RMIConnector_NPETest { public static void main(String argv[]) throws Exception { RMID rmid = RMID.createRMID(); - rmid.start(); - int rmidPort = rmid.getPort(); Exception failureCause = null; RMIConnector agent = null; try { + rmid.start(); + int rmidPort = rmid.getPort(); MBeanServer mbs = MBeanServerFactory.createMBeanServer(); RMIJRMPServerImpl rmiserver = new RMIJRMPServerImpl(rmidPort, null, null, null); rmiserver.setMBeanServer(mbs); @@ -75,3 +75,4 @@ public class RMIConnector_NPETest { } } + From 794ed77e3200e05d6138fb69a03f411d3c7a8b0e Mon Sep 17 00:00:00 2001 From: Rachna Goel Date: Wed, 7 Dec 2016 11:35:12 +0530 Subject: [PATCH 043/142] 8071929: Locale.getISOCountries() has inconsistent behaviour for "AN", "BU" and "CS" country codes Reviewed-by: naoto --- .../share/classes/java/util/Locale.java | 85 +++++++++- .../classes/java/util/LocaleISOData.java | 27 +++- jdk/test/java/util/Locale/Bug8071929.java | 149 ++++++++++++++++++ 3 files changed, 258 insertions(+), 3 deletions(-) create mode 100644 jdk/test/java/util/Locale/Bug8071929.java diff --git a/jdk/src/java.base/share/classes/java/util/Locale.java b/jdk/src/java.base/share/classes/java/util/Locale.java index faf2bb5ea42..d4fae4bb544 100644 --- a/jdk/src/java.base/share/classes/java/util/Locale.java +++ b/jdk/src/java.base/share/classes/java/util/Locale.java @@ -46,6 +46,7 @@ import java.io.ObjectOutputStream; import java.io.ObjectStreamField; import java.io.Serializable; import java.text.MessageFormat; +import java.util.concurrent.ConcurrentHashMap; import java.util.spi.LocaleNameProvider; import sun.security.action.GetPropertyAction; @@ -599,6 +600,68 @@ public final class Locale implements Cloneable, Serializable { */ static final long serialVersionUID = 9149081749638150636L; + /** + * Enum for specifying the type defined in ISO 3166. This enum is used to + * retrieve the two-letter ISO3166-1 alpha-2, three-letter ISO3166-1 + * alpha-3, four-letter ISO3166-3 country codes. + * + * @see #getISOCountries(Locale.IsoCountryCode) + * @since 9 + */ + public static enum IsoCountryCode { + /** + * PART1_ALPHA2 is used to represent the ISO3166-1 alpha-2 two letter + * country codes. + */ + PART1_ALPHA2 { + @Override + Set createCountryCodeSet() { + return Set.of(Locale.getISOCountries()); + } + }, + + /** + * + * PART1_ALPHA3 is used to represent the ISO3166-1 alpha-3 three letter + * country codes. + */ + PART1_ALPHA3 { + @Override + Set createCountryCodeSet() { + return LocaleISOData.computeISO3166_1Alpha3Countries(); + } + }, + + /** + * PART3 is used to represent the ISO3166-3 four letter country codes. + */ + PART3 { + @Override + Set createCountryCodeSet() { + return Set.of(LocaleISOData.ISO3166_3); + } + }; + + /** + * Concrete implementation of this method attempts to compute value + * for iso3166CodesMap for each IsoCountryCode type key. + */ + abstract Set createCountryCodeSet(); + + /** + * Map to hold country codes for each ISO3166 part. + */ + private static Map> iso3166CodesMap = new ConcurrentHashMap<>(); + + /** + * This method is called from Locale class to retrieve country code set + * for getISOCountries(type) + */ + static Set retrieveISOCountryCodes(IsoCountryCode type) { + return iso3166CodesMap.computeIfAbsent(type, IsoCountryCode::createCountryCodeSet); + } + } + /** * Display types for retrieving localized names from the name providers. */ @@ -996,12 +1059,18 @@ public final class Locale implements Cloneable, Serializable { /** * Returns a list of all 2-letter country codes defined in ISO 3166. * Can be used to create Locales. + * This method is equivalent to {@link #getISOCountries(Locale.IsoCountryCode type)} + * with {@code type} {@link IsoCountryCode#PART1_ALPHA2}. *

    * Note: The Locale class also supports other codes for * country (region), such as 3-letter numeric UN M.49 area codes. * Therefore, the list returned by this method does not contain ALL valid * codes that can be used to create Locales. - * + *

    + * Note that this method does not return obsolete 2-letter country codes. + * ISO3166-3 codes which designate country codes for those obsolete codes, + * can be retrieved from {@link #getISOCountries(Locale.IsoCountryCode type)} with + * {@code type} {@link IsoCountryCode#PART3}. * @return An array of ISO 3166 two-letter country codes. */ public static String[] getISOCountries() { @@ -1013,6 +1082,20 @@ public final class Locale implements Cloneable, Serializable { return result; } + /** + * Returns a {@code Set} of ISO3166 country codes for the specified type. + * + * @param type {@link Locale.IsoCountryCode} specified ISO code type. + * @see java.util.Locale.IsoCountryCode + * @throws NullPointerException if type is null + * @return a {@code Set} of ISO country codes for the specified type. + * @since 9 + */ + public static Set getISOCountries(IsoCountryCode type) { + Objects.requireNonNull(type); + return IsoCountryCode.retrieveISOCountryCodes(type); + } + /** * Returns a list of all 2-letter language codes defined in ISO 639. * Can be used to create Locales. diff --git a/jdk/src/java.base/share/classes/java/util/LocaleISOData.java b/jdk/src/java.base/share/classes/java/util/LocaleISOData.java index 266e79972c6..9dd9e83035f 100644 --- a/jdk/src/java.base/share/classes/java/util/LocaleISOData.java +++ b/jdk/src/java.base/share/classes/java/util/LocaleISOData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -231,7 +231,7 @@ class LocaleISOData { + "AI" + "AIA" // Anguilla + "AL" + "ALB" // Albania, People's Socialist Republic of + "AM" + "ARM" // Armenia - + "AN" + "ANT" // Netherlands Antilles +// + "AN" + "ANT" // Netherlands Antilles + "AO" + "AGO" // Angola, Republic of + "AQ" + "ATA" // Antarctica (the territory South of 60 deg S) + "AR" + "ARG" // Argentina, Argentine Republic @@ -477,6 +477,29 @@ class LocaleISOData { + "ZW" + "ZWE" // Zimbabwe ; + /** + * Array to hold country codes for ISO3166-3. + */ + static final String[] ISO3166_3 = { + "AIDJ", "ANHH", "BQAQ", "BUMM", "BYAA", "CSHH", "CSXX", "CTKI", "DDDE", + "DYBJ", "FQHH", "FXFR", "GEHH", "HVBF", "JTUM", "MIUM", "NHVU", "NQAQ", + "NTHH", "PCHH", "PUUM", "PZPA", "RHZW", "SKIN", "SUHH", "TPTL", "VDVN", + "WKUM", "YDYE", "YUCS", "ZRCD" + }; + + /** + * This method computes a set of ISO3166-1 alpha-3 country codes from + * existing isoCountryTable. + */ + static Set computeISO3166_1Alpha3Countries() { + int tableLength = isoCountryTable.length(); + String[] isoTable = new String[tableLength / 5]; + for (int i = 0, index = 0; index < tableLength; i++, index += 5) { + isoTable[i] = isoCountryTable.substring(index + 2, index + 5); + } + return Set.of(isoTable); + } + private LocaleISOData() { } } diff --git a/jdk/test/java/util/Locale/Bug8071929.java b/jdk/test/java/util/Locale/Bug8071929.java new file mode 100644 index 00000000000..19a316ac217 --- /dev/null +++ b/jdk/test/java/util/Locale/Bug8071929.java @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8071929 + * @summary Test obsolete ISO3166-1 alpha-2 country codes should not be retrieved. + * ISO3166-1 alpha-2, ISO3166-1 alpha-3, ISO3166-3 country codes + * from overloaded getISOCountries(Iso3166 type) are retrieved correctly. + */ +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Locale.IsoCountryCode; +import java.util.Set; +import java.util.stream.Collectors; + +public class Bug8071929 { + + private static final List ISO3166_1_ALPHA2_OBSOLETE_CODES = List.of("AN", "BU", "CS", + "NT", "SF", "TP", "YU", "ZR"); + + private static final Set ISO3166_3EXPECTED = Set.of( + "AIDJ", "ANHH", "BQAQ", "BUMM", "BYAA", "CSHH", "CSXX", "CTKI", "DDDE", + "DYBJ", "FQHH", "FXFR", "GEHH", "HVBF", "JTUM", "MIUM", "NHVU", "NQAQ", + "NTHH", "PCHH", "PUUM", "PZPA", "RHZW", "SKIN", "SUHH", "TPTL", "VDVN", + "WKUM", "YDYE", "YUCS", "ZRCD"); + + private static final Set ISO3166_1_ALPHA3_EXPECTED + = Set.of("ABW", "AFG", "AGO", "AIA", "ALA", "ALB", "AND", + "ARE", "ARG", "ARM", "ASM", "ATA", "ATF", "ATG", + "AUS", "AUT", "AZE", "BDI", "BEL", "BEN", "BES", "BFA", + "BGD", "BGR", "BHR", "BHS", "BIH", "BLM", "BLR", "BLZ", + "BMU", "BOL", "BRA", "BRB", "BRN", "BTN", "BVT", "BWA", "CAF", "CAN", + "CCK", "CHE", "CHL", "CHN", "CIV", "CMR", "COD", "COG", "COK", "COL", + "COM", "CPV", "CRI", "CUB", "CUW", "CXR", "CYM", "CYP", "CZE", "DEU", + "DJI", "DMA", "DNK", "DOM", "DZA", "ECU", "EGY", "ERI", "ESH", "ESP", + "EST", "ETH", "FIN", "FJI", "FLK", "FRA", "FRO", "FSM", "GAB", "GBR", + "GEO", "GGY", "GHA", "GIB", "GIN", "GLP", "GMB", "GNB", "GNQ", + "GRC", "GRD", "GRL", "GTM", "GUF", "GUM", "GUY", "HKG", "HMD", "HND", + "HRV", "HTI", "HUN", "IDN", "IMN", "IND", "IOT", "IRL", "IRN", "IRQ", + "ISL", "ISR", "ITA", "JAM", "JEY", "JOR", "JPN", "KAZ", "KEN", "KGZ", + "KHM", "KIR", "KNA", "KOR", "KWT", "LAO", "LBN", "LBR", "LBY", "LCA", + "LIE", "LKA", "LSO", "LTU", "LUX", "LVA", "MAC", "MAF", "MAR", "MCO", + "MDA", "MDG", "MDV", "MEX", "MHL", "MKD", "MLI", "MLT", "MMR", "MNE", + "MNG", "MNP", "MOZ", "MRT", "MSR", "MTQ", "MUS", "MWI", "MYS", "MYT", + "NAM", "NCL", "NER", "NFK", "NGA", "NIC", "NIU", "NLD", "NOR", "NPL", + "NRU", "NZL", "OMN", "PAK", "PAN", "PCN", "PER", "PHL", "PLW", "PNG", + "POL", "PRI", "PRK", "PRT", "PRY", "PSE", "PYF", "QAT", "REU", "ROU", + "RUS", "RWA", "SAU", "SDN", "SEN", "SGP", "SGS", "SHN", "SJM", "SLB", + "SLE", "SLV", "SMR", "SOM", "SPM", "SRB", "SSD", "STP", "SUR", "SVK", + "SVN", "SWE", "SWZ", "SXM", "SYC", "SYR", "TCA", "TCD", "TGO", "THA", + "TJK", "TKL", "TKM", "TLS", "TON", "TTO", "TUN", "TUR", "TUV", "TWN", + "TZA", "UGA", "UKR", "UMI", "URY", "USA", "UZB", "VAT", "VCT", "VEN", + "VGB", "VIR", "VNM", "VUT", "WLF", "WSM", "YEM", "ZAF", "ZMB", "ZWE"); + + /** + * This method checks that obsolete ISO3166-1 alpha-2 country codes are not + * retrieved in output of getISOCountries() method. + */ + private static void checkISO3166_1_Alpha2ObsoleteCodes() { + Set unexpectedCodes = ISO3166_1_ALPHA2_OBSOLETE_CODES.stream(). + filter(Set.of(Locale.getISOCountries())::contains).collect(Collectors.toSet()); + if (!unexpectedCodes.isEmpty()) { + throw new RuntimeException("Obsolete ISO3166-1 alpha2 two letter" + + " country Codes " + unexpectedCodes + " in output of getISOCountries() method"); + } + } + + /** + * This method checks that ISO3166-3 country codes which are PART3 of + * IsoCountryCode enum, are retrieved correctly. + */ + private static void checkISO3166_3Codes() { + Set iso3166_3Codes = Locale.getISOCountries(IsoCountryCode.PART3); + if (!iso3166_3Codes.equals(ISO3166_3EXPECTED)) { + reportDifference(iso3166_3Codes, ISO3166_3EXPECTED); + } + } + + /** + * This method checks that ISO3166-1 alpha-3 country codes which are + * PART1_ALPHA3 of IsoCountryCode enum, are retrieved correctly. + */ + private static void checkISO3166_1_Alpha3Codes() { + Set iso3166_1_Alpha3Codes = Locale.getISOCountries(IsoCountryCode.PART1_ALPHA3); + if (!iso3166_1_Alpha3Codes.equals(ISO3166_1_ALPHA3_EXPECTED)) { + reportDifference(iso3166_1_Alpha3Codes, ISO3166_1_ALPHA3_EXPECTED); + } + } + + /** + * This method checks that ISO3166-1 alpha-2 country codes, which are + * PART1_ALPHA2 of IsoCountryCode enum, are retrieved correctly. + */ + private static void checkISO3166_1_Alpha2Codes() { + Set iso3166_1_Alpha2Codes = Locale.getISOCountries(IsoCountryCode.PART1_ALPHA2); + Set ISO3166_1_ALPHA2_EXPECTED = Set.of(Locale.getISOCountries()); + if (!iso3166_1_Alpha2Codes.equals(ISO3166_1_ALPHA2_EXPECTED)) { + reportDifference(iso3166_1_Alpha2Codes, ISO3166_1_ALPHA2_EXPECTED); + } + } + + private static void reportDifference(Set retrievedCountrySet, Set expectedCountrySet) { + Set retrievedSet = new HashSet<>(retrievedCountrySet); + Set expectedSet = new HashSet<>(expectedCountrySet); + retrievedSet.removeAll(expectedCountrySet); + expectedSet.removeAll(retrievedCountrySet); + if ((retrievedSet.size() > 0) && (expectedSet.size() > 0)) { + throw new RuntimeException("Retrieved country codes set contains extra codes " + + retrievedSet + " and missing codes " + expectedSet); + } + if (retrievedSet.size() > 0) { + throw new RuntimeException("Retrieved country codes set contains extra codes " + + retrievedSet); + } + if (expectedSet.size() > 0) { + throw new RuntimeException("Retrieved country codes set is missing codes " + + expectedSet); + } + } + + public static void main(String[] args) { + checkISO3166_1_Alpha2ObsoleteCodes(); + checkISO3166_1_Alpha2Codes(); + checkISO3166_1_Alpha3Codes(); + checkISO3166_3Codes(); + } +} From 42c1512e0b46bc9875569e13c1fe9f8a8481b741 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Wed, 7 Dec 2016 09:48:31 +0100 Subject: [PATCH 044/142] 8170629: Remove code duplication in test makefiles Reviewed-by: erikj, dholmes --- jdk/test/Makefile | 341 +--------------------------------------------- 1 file changed, 5 insertions(+), 336 deletions(-) diff --git a/jdk/test/Makefile b/jdk/test/Makefile index d417600da79..ab801dedaa8 100644 --- a/jdk/test/Makefile +++ b/jdk/test/Makefile @@ -23,272 +23,20 @@ # questions. # -# -# Makefile to run various jdk tests -# +default: all -.DEFAULT : all +NATIVE_TEST_PATH := jdk/jtreg/native -# Empty these to get rid of some default rules -.SUFFIXES: -.SUFFIXES: .java -CO= -GET= +USE_FAILURE_HANDLER := true -# Utilities used -AWK = awk -CAT = cat -CD = cd -CHMOD = chmod -CP = cp -CUT = cut -DIRNAME = dirname -ECHO = echo -EGREP = egrep -EXPAND = expand -FIND = find -MKDIR = mkdir -PWD = pwd -SED = sed -SORT = sort -TEE = tee -UNAME = uname -UNIQ = uniq -WC = wc -ZIPEXE = zip +TREAT_EXIT_CODE_1_AS_0 := true -# Get OS name from uname (Cygwin inexplicably adds _NT-5.1) -UNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_) - -# Commands to run on paths to make mixed paths for java on windows -ifeq ($(UNAME_S), CYGWIN) - # Location of developer shared files - SLASH_JAVA = J: - GETMIXEDPATH = cygpath -m -else - # Location of developer shared files - SLASH_JAVA = /java - - GETMIXEDPATH=$(ECHO) -endif - -# Root of this test area (important to use full paths in some places) -TEST_ROOT := $(shell $(PWD)) - -# Root of all test results -ifdef TEST_OUTPUT_DIR - $(shell $(MKDIR) -p $(TEST_OUTPUT_DIR)/jtreg) - ABS_TEST_OUTPUT_DIR := \ - $(shell $(CD) $(TEST_OUTPUT_DIR)/jtreg && $(PWD)) -else - ifdef ALT_OUTPUTDIR - ABS_OUTPUTDIR = $(shell $(CD) $(ALT_OUTPUTDIR) && $(PWD)) - else - ABS_OUTPUTDIR = $(shell $(CD) $(TEST_ROOT)/.. && $(PWD)) - endif - - ABS_PLATFORM_BUILD_ROOT = $(ABS_OUTPUTDIR) - ABS_TEST_OUTPUT_DIR := $(ABS_PLATFORM_BUILD_ROOT)/testoutput/$(UNIQUE_DIR) -endif - -# Expect JPRT to set PRODUCT_HOME (the product or jdk in this case to test) -ifndef PRODUCT_HOME - # Try to use images/jdk if it exists - ABS_JDK_IMAGE = $(ABS_PLATFORM_BUILD_ROOT)/images/jdk - PRODUCT_HOME := \ - $(shell \ - if [ -d $(ABS_JDK_IMAGE) ] ; then \ - $(ECHO) "$(ABS_JDK_IMAGE)"; \ - else \ - $(ECHO) "$(ABS_PLATFORM_BUILD_ROOT)"; \ - fi) - PRODUCT_HOME := $(PRODUCT_HOME) -endif - -# Expect JPRT to set JPRT_PRODUCT_ARGS (e.g. -server etc.) -# Should be passed into 'java' only. -# Could include: -d64 -server -client OR any java option -ifdef JPRT_PRODUCT_ARGS - JAVA_ARGS = $(JPRT_PRODUCT_ARGS) -endif - -# Expect JPRT to set JPRT_PRODUCT_VM_ARGS (e.g. -Xcomp etc.) -# Should be passed into anything running the vm (java, javac, javadoc, ...). -ifdef JPRT_PRODUCT_VM_ARGS - JAVA_VM_ARGS = $(JPRT_PRODUCT_VM_ARGS) -endif - -# jtreg -nativepath

    -# -# Local make tests will be TEST_IMAGE_DIR and JPRT with jprt.use.reg.test.bundle=true -# should be JPRT_TESTNATIVE_PATH -ifdef TEST_IMAGE_DIR - TESTNATIVE_DIR = $(TEST_IMAGE_DIR) -else ifdef JPRT_TESTNATIVE_PATH - TESTNATIVE_DIR = $(JPRT_TESTNATIVE_PATH) -endif -ifdef TESTNATIVE_DIR - JTREG_NATIVE_PATH = -nativepath:$(shell $(GETMIXEDPATH) "$(TESTNATIVE_DIR)/jdk/jtreg/native") -endif - -# jtreg failure handler config -ifeq ($(FAILURE_HANDLER_DIR), ) - ifneq ($(TESTNATIVE_DIR), ) - FAILURE_HANDLER_DIR := $(TESTNATIVE_DIR)/failure_handler - endif -endif -ifneq ($(FAILURE_HANDLER_DIR), ) - FAILURE_HANDLER_DIR_MIXED := $(shell $(GETMIXEDPATH) "$(FAILURE_HANDLER_DIR)") - JTREG_FAILURE_HANDLER_OPTIONS := \ - -timeoutHandlerDir:$(FAILURE_HANDLER_DIR_MIXED)/jtregFailureHandler.jar \ - -observerDir:$(FAILURE_HANDLER_DIR_MIXED)/jtregFailureHandler.jar \ - -timeoutHandler:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler \ - -observer:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver \ - -timeoutHandlerTimeout:0 - ifeq ($(UNAME_S), CYGWIN) - JTREG_FAILURE_HANDLER_OPTIONS += -J-Djava.library.path="$(FAILURE_HANDLER_DIR_MIXED)" - endif -endif - -# Expect JPRT to set JPRT_ARCHIVE_BUNDLE (path to zip bundle for results) -ifdef JPRT_ARCHIVE_BUNDLE - ARCHIVE_BUNDLE = $(JPRT_ARCHIVE_BUNDLE) -else - ARCHIVE_BUNDLE = $(ABS_TEST_OUTPUT_DIR)/ARCHIVE_BUNDLE.zip -endif - -# How to create the test bundle (pass or fail, we want to create this) -# Follow command with ";$(BUNDLE_UP_AND_EXIT)", so it always gets executed. -ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)` \ - && $(CD) $(ABS_TEST_OUTPUT_DIR) \ - && $(CHMOD) -R a+r . \ - && $(ZIPEXE) -q -r $(ARCHIVE_BUNDLE) . ) - -# important results files -SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt") -STATS_TXT_NAME = Stats.txt -STATS_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/$(STATS_TXT_NAME)") -RUNLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/runlist.txt") -PASSLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/passlist.txt") -FAILLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/faillist.txt") -EXITCODE = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/exitcode.txt") - -TESTEXIT = \ - if [ ! -s $(EXITCODE) ] ; then \ - $(ECHO) "ERROR: EXITCODE file not filled in."; \ - $(ECHO) "1" > $(EXITCODE); \ - fi ; \ - testExitCode=`$(CAT) $(EXITCODE)`; \ - $(ECHO) "EXIT CODE: $${testExitCode}"; \ - exit $${testExitCode} - -BUNDLE_UP_AND_EXIT = \ -( \ - jtregExitCode=$$? && \ - _summary="$(SUMMARY_TXT)"; \ - if [ $${jtregExitCode} = 1 ] ; then \ - jtregExitCode=0; \ - fi; \ - $(RM) -f $(STATS_TXT) $(RUNLIST) $(PASSLIST) $(FAILLIST) $(EXITCODE); \ - $(ECHO) "$${jtregExitCode}" > $(EXITCODE); \ - if [ -r "$${_summary}" ] ; then \ - $(ECHO) "Summary: $(UNIQUE_DIR)" > $(STATS_TXT); \ - $(EXPAND) $${_summary} | $(EGREP) -v ' Not run\.' > $(RUNLIST); \ - $(EGREP) ' Passed\.' $(RUNLIST) \ - | $(EGREP) -v ' Error\.' \ - | $(EGREP) -v ' Failed\.' > $(PASSLIST); \ - ( $(EGREP) ' Failed\.' $(RUNLIST); \ - $(EGREP) ' Error\.' $(RUNLIST); \ - $(EGREP) -v ' Passed\.' $(RUNLIST) ) \ - | $(SORT) | $(UNIQ) > $(FAILLIST); \ - if [ $${jtregExitCode} != 0 -o -s $(FAILLIST) ] ; then \ - $(EXPAND) $(FAILLIST) \ - | $(CUT) -d' ' -f1 \ - | $(SED) -e 's@^@FAILED: @' >> $(STATS_TXT); \ - if [ $${jtregExitCode} = 0 ] ; then \ - jtregExitCode=1; \ - fi; \ - fi; \ - runc="`$(CAT) $(RUNLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ - passc="`$(CAT) $(PASSLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ - failc="`$(CAT) $(FAILLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ - exclc="FIXME CODETOOLS-7900176"; \ - $(ECHO) "TEST STATS: name=$(UNIQUE_DIR) run=$${runc} pass=$${passc} fail=$${failc}" \ - >> $(STATS_TXT); \ - else \ - $(ECHO) "Missing file: $${_summary}" >> $(STATS_TXT); \ - fi; \ - if [ -f $(STATS_TXT) ] ; then \ - $(CAT) $(STATS_TXT); \ - fi; \ - $(ZIP_UP_RESULTS) ; \ - $(TESTEXIT) \ -) - -################################################################ +include ../../test/TestCommon.gmk # Default make rule (runs default jdk tests) all: jdk_default @$(ECHO) "Testing completed successfully" -# Prep for output -# Change execute permissions on shared library files. -# Files in repositories should never have execute permissions, but -# there are some tests that have pre-built shared libraries, and these -# windows dll files must have execute permission. Adding execute -# permission may happen automatically on windows when using certain -# versions of mercurial but it cannot be guaranteed. And blindly -# adding execute permission might be seen as a mercurial 'change', so -# we avoid adding execute permission to repository files. But testing -# from a plain source tree needs the chmod a+rx. Applying the chmod to -# all shared libraries not just dll files. And with CYGWIN and sshd -# service, you may need CYGWIN=ntsec for this to work. -prep: - @$(MKDIR) -p $(ABS_TEST_OUTPUT_DIR) - @$(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)` - @if [ ! -d $(TEST_ROOT)/../.hg ] ; then \ - $(FIND) $(TEST_ROOT) \( -name \*.dll -o -name \*.DLL -o -name \*.so \) \ - -exec $(CHMOD) a+rx {} \; ; \ - fi - -# Cleanup -clean: - @$(RM) -r $(ABS_TEST_OUTPUT_DIR) - @$(RM) $(ARCHIVE_BUNDLE) - -################################################################ - -# jtreg tests - -# Expect JT_HOME to be set for jtreg tests. (home for jtreg) -ifndef JT_HOME - JT_HOME = $(SLASH_JAVA)/re/jtreg/4.2/promoted/latest/binaries/jtreg - ifdef JPRT_JTREG_HOME - JT_HOME = $(JPRT_JTREG_HOME) - endif -endif - -# Problematic tests to be excluded -PROBLEM_LISTS=$(call MixedDirs,$(wildcard ProblemList.txt closed/ProblemList.txt)) - -# Create exclude list for this platform and arch -ifdef NO_EXCLUDES - JTREG_EXCLUSIONS = -else - JTREG_EXCLUSIONS = $(PROBLEM_LISTS:%=-exclude:%) -endif - -# convert list of directories to dos paths -define MixedDirs -$(foreach i,$1,$(shell $(GETMIXEDPATH) "${i}")) -endef - -define SummaryInfo -$(ECHO) "########################################################" -$(CAT) $(?:%=$(ABS_TEST_OUTPUT_DIR)/%/$(STATS_TXT_NAME)) -$(ECHO) "########################################################" -endef - # ------------------------------------------------------------------ jdk_% core_% svc_%: @@ -296,82 +44,3 @@ jdk_% core_% svc_%: for each in $@; do \ $(MAKE) -j 1 TEST_SELECTION=":$$each" UNIQUE_DIR=$$each jtreg_tests; \ done - -# ------------------------------------------------------------------ - -# When called from JPRT the TESTDIRS variable is set to the jtreg tests to run -ifdef TESTDIRS - TEST_SELECTION = $(TESTDIRS) -endif - -ifdef CONCURRENCY - JTREG_BASIC_OPTIONS += -concurrency:$(CONCURRENCY) -endif -ifdef EXTRA_JTREG_OPTIONS - JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS) -endif - -# Default JTREG to run -JTREG = $(JT_HOME)/bin/jtreg -# run in agentvm mode -JTREG_BASIC_OPTIONS += -agentvm -# Only run automatic tests -JTREG_BASIC_OPTIONS += -a -# Always turn on assertions -JTREG_ASSERT_OPTION = -ea -esa -JTREG_BASIC_OPTIONS += $(JTREG_ASSERT_OPTION) -# jtreg verbosity setting -JTREG_VERBOSE ?= fail,error,time -JTREG_BASIC_OPTIONS += $(if $(JTREG_VERBOSE),-v:$(JTREG_VERBOSE)) -# Retain all files for failing tests -JTREG_BASIC_OPTIONS += -retain:fail,error -# Ignore tests are not run and completely silent about it -JTREG_IGNORE_OPTION = -ignore:quiet -JTREG_BASIC_OPTIONS += $(JTREG_IGNORE_OPTION) -# Multiple by 4 the timeout numbers -JTREG_TIMEOUT_OPTION = -timeoutFactor:4 -JTREG_BASIC_OPTIONS += $(JTREG_TIMEOUT_OPTION) -# Set the max memory for jtreg control vm -JTREG_MEMORY_OPTION = -J-Xmx512m -JTREG_BASIC_OPTIONS += $(JTREG_MEMORY_OPTION) -# Give tests access to JT_JAVA, see JDK-8141609 -JTREG_BASIC_OPTIONS += -e:JDK8_HOME=${JT_JAVA} -# Set other vm and test options -JTREG_TEST_OPTIONS = $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_VM_ARGS:%=-vmoption:%) -# Set the GC options for test vms -#JTREG_GC_OPTION = -vmoption:-XX:+UseSerialGC -#JTREG_TEST_OPTIONS += $(JTREG_GC_OPTION) -# Set the max memory for jtreg target test vms -JTREG_TESTVM_MEMORY_OPTION = -vmoption:-Xmx512m -JTREG_TEST_OPTIONS += $(JTREG_TESTVM_MEMORY_OPTION) - -# Make sure jtreg exists -$(JTREG): $(JT_HOME) - -# Run jtreg -jtreg_tests: prep $(PRODUCT_HOME) $(JTREG) - ( \ - ( JT_HOME=$(shell $(GETMIXEDPATH) "$(JT_HOME)"); \ - export JT_HOME; \ - $(shell $(GETMIXEDPATH) "$(JTREG)") \ - $(JTREG_BASIC_OPTIONS) \ - -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport") \ - -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTwork") \ - -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \ - $(JTREG_NATIVE_PATH) \ - $(JTREG_FAILURE_HANDLER_OPTIONS) \ - $(JTREG_EXCLUSIONS) \ - $(JTREG_TEST_OPTIONS) \ - $(TEST_SELECTION) \ - ) ; \ - $(BUNDLE_UP_AND_EXIT) \ - ) 2>&1 | $(TEE) $(ABS_TEST_OUTPUT_DIR)/output.txt ; $(TESTEXIT) - -PHONY_LIST += jtreg_tests - -################################################################ - -# Phony targets (e.g. these are not filenames) -.PHONY: all clean prep $(PHONY_LIST) - -################################################################ From 5c2b3026c267af862c8f41225248dbf9e8393c17 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 7 Dec 2016 09:32:32 +0000 Subject: [PATCH 045/142] 8169653: Restore ObjectInputStream::resolveClass call stack default search order Reviewed-by: dfuchs, mchung --- .../classes/java/io/ObjectInputStream.java | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java b/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java index f2c034ed148..eac811d9fe2 100644 --- a/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java +++ b/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java @@ -657,13 +657,11 @@ public class ObjectInputStream *
          *     Class.forName(desc.getName(), false, loader)
          * 
    - * where loader is determined as follows: if there is a - * method on the current thread's stack whose declaring class is not a - * - * platform class, then loader is - * the class loader of such class; otherwise, loader - * is the {@linkplain ClassLoader#getPlatformClassLoader() - * platform class loader}. If this call results in a + * where loader is the first class loader on the current + * thread's stack (starting from the currently executing method) that is + * neither the {@linkplain ClassLoader#getPlatformClassLoader() platform + * class loader} nor its ancestor; otherwise, loader is the + * platform class loader. If this call results in a * ClassNotFoundException and the name of the passed * ObjectStreamClass instance is the Java language keyword * for a primitive type or void, then the Class object @@ -721,13 +719,11 @@ public class ObjectInputStream *
          *     Class.forName(i, false, loader)
          * 
    - * where loader is determined as follows: if there is a - * method on the current thread's stack whose declaring class is not a - * - * platform class, then loader is - * the class loader of such class; otherwise, loader - * is the {@linkplain ClassLoader#getPlatformClassLoader() - * platform class loader}. + * where loader is the first class loader on the current + * thread's stack (starting from the currently executing method) that is + * neither the {@linkplain ClassLoader#getPlatformClassLoader() platform + * class loader} nor its ancestor; otherwise, loader is the + * platform class loader. * Unless any of the resolved interfaces are non-public, this same value * of loader is also the class loader passed to * Proxy.getProxyClass; if non-public interfaces are present, @@ -2370,16 +2366,10 @@ public class ObjectInputStream int ndoubles); /** - * Returns the first non-null and non-platform class loader - * (not counting class loaders of generated reflection implementation classes) - * up the execution stack, or null if only code from the bootstrap and - * platform class loader is on the stack. - * This method is also called via reflection by the following RMI-IIOP class: - * - * com.sun.corba.se.internal.util.JDKClassLoader - * - * This method should not be removed or its signature changed without - * corresponding modifications to the above class. + * Returns the first non-null and non-platform class loader (not counting + * class loaders of generated reflection implementation classes) up the + * execution stack, or the platform class loader if only code from the + * bootstrap and platform class loader is on the stack. */ private static ClassLoader latestUserDefinedLoader() { return jdk.internal.misc.VM.latestUserDefinedLoader(); From df8736b785eea30c5138ffe8b75201c48e46bcf2 Mon Sep 17 00:00:00 2001 From: Adam Petcher Date: Wed, 7 Dec 2016 10:55:13 -0500 Subject: [PATCH 046/142] 8158517: Minor optimizations to ISO10126PADDING Co-authored-by: Bernd Eckenfels Reviewed-by: mullan --- .../com/sun/crypto/provider/ISO10126Padding.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/jdk/src/java.base/share/classes/com/sun/crypto/provider/ISO10126Padding.java b/jdk/src/java.base/share/classes/com/sun/crypto/provider/ISO10126Padding.java index 7377fab0a9c..a7134238e14 100644 --- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/ISO10126Padding.java +++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/ISO10126Padding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -68,10 +68,10 @@ final class ISO10126Padding implements Padding { } byte paddingOctet = (byte) (len & 0xff); - byte[] padding = new byte[len]; + byte[] padding = new byte[len - 1]; SunJCE.getRandom().nextBytes(padding); - padding[len-1] = paddingOctet; - System.arraycopy(padding, 0, in, off, len); + System.arraycopy(padding, 0, in, off, len - 1); + in[off + len - 1] = paddingOctet; return; } @@ -101,7 +101,7 @@ final class ISO10126Padding implements Padding { return -1; } - int start = off + len - ((int)lastByte & 0x0ff); + int start = off + len - padValue; if (start < off) { return -1; } From d4becc9ff12abdfdde46bcc21a54154e13f98355 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Wed, 7 Dec 2016 08:54:56 -0800 Subject: [PATCH 047/142] 8170465: JNI exception pending in jni_util.c:190 8170466: JNI exception pending in jni_util.c:190 Reviewed-by: dholmes --- jdk/src/java.base/share/native/libjava/jni_util.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jdk/src/java.base/share/native/libjava/jni_util.c b/jdk/src/java.base/share/native/libjava/jni_util.c index 3ea11b0bbc6..25888cc4655 100644 --- a/jdk/src/java.base/share/native/libjava/jni_util.c +++ b/jdk/src/java.base/share/native/libjava/jni_util.c @@ -201,12 +201,14 @@ JNU_ThrowByNameWithMessageAndLastError jio_snprintf(str1, messageextlen, " (%s)", message); s2 = (*env)->NewStringUTF(env, str1); free(str1); + JNU_CHECK_EXCEPTION(env); if (s2 != NULL) { jstring s3 = JNU_CallMethodByName( env, NULL, s, "concat", "(Ljava/lang/String;)Ljava/lang/String;", s2).l; (*env)->DeleteLocalRef(env, s2); + JNU_CHECK_EXCEPTION(env); if (s3 != NULL) { (*env)->DeleteLocalRef(env, s); s = s3; From 502274b2c12341541dc4ce086b06d27d7bf0f551 Mon Sep 17 00:00:00 2001 From: Martin Buchholz Date: Wed, 30 Nov 2016 19:40:36 -0800 Subject: [PATCH 048/142] 8170560: Improve code samples in Collectors javadoc Reviewed-by: psandoz --- .../classes/java/util/stream/Collectors.java | 240 ++++++++++-------- 1 file changed, 134 insertions(+), 106 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/stream/Collectors.java b/jdk/src/java.base/share/classes/java/util/stream/Collectors.java index aaa8c465966..8a53a27589e 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/Collectors.java +++ b/jdk/src/java.base/share/classes/java/util/stream/Collectors.java @@ -65,36 +65,37 @@ import java.util.function.ToLongFunction; * common mutable reduction tasks: * *
    {@code
    - *     // Accumulate names into a List
    - *     List list = people.stream().map(Person::getName).collect(Collectors.toList());
    + * // Accumulate names into a List
    + * List list = people.stream()
    + *   .map(Person::getName)
    + *   .collect(Collectors.toList());
      *
    - *     // Accumulate names into a TreeSet
    - *     Set set = people.stream().map(Person::getName).collect(Collectors.toCollection(TreeSet::new));
    + * // Accumulate names into a TreeSet
    + * Set set = people.stream()
    + *   .map(Person::getName)
    + *   .collect(Collectors.toCollection(TreeSet::new));
      *
    - *     // Convert elements to strings and concatenate them, separated by commas
    - *     String joined = things.stream()
    - *                           .map(Object::toString)
    - *                           .collect(Collectors.joining(", "));
    + * // Convert elements to strings and concatenate them, separated by commas
    + * String joined = things.stream()
    + *   .map(Object::toString)
    + *   .collect(Collectors.joining(", "));
      *
    - *     // Compute sum of salaries of employee
    - *     int total = employees.stream()
    - *                          .collect(Collectors.summingInt(Employee::getSalary)));
    + * // Compute sum of salaries of employee
    + * int total = employees.stream()
    + *   .collect(Collectors.summingInt(Employee::getSalary));
      *
    - *     // Group employees by department
    - *     Map> byDept
    - *         = employees.stream()
    - *                    .collect(Collectors.groupingBy(Employee::getDepartment));
    + * // Group employees by department
    + * Map> byDept = employees.stream()
    + *   .collect(Collectors.groupingBy(Employee::getDepartment));
      *
    - *     // Compute sum of salaries by department
    - *     Map totalByDept
    - *         = employees.stream()
    - *                    .collect(Collectors.groupingBy(Employee::getDepartment,
    - *                                                   Collectors.summingInt(Employee::getSalary)));
    + * // Compute sum of salaries by department
    + * Map totalByDept = employees.stream()
    + *   .collect(Collectors.groupingBy(Employee::getDepartment,
    + *                                  Collectors.summingInt(Employee::getSalary)));
      *
    - *     // Partition students into passing and failing
    - *     Map> passingFailing =
    - *         students.stream()
    - *                 .collect(Collectors.partitioningBy(s -> s.getGrade() >= PASS_THRESHOLD));
    + * // Partition students into passing and failing
    + * Map> passingFailing = students.stream()
    + *   .collect(Collectors.partitioningBy(s -> s.getGrade() >= PASS_THRESHOLD));
      *
      * }
    * @@ -248,8 +249,8 @@ public final class Collectors { * * @param the type of the input elements * @param the type of the resulting {@code Collection} - * @param collectionFactory a {@code Supplier} which returns a new, empty - * {@code Collection} of the appropriate type + * @param collectionFactory a supplier providing a new empty {@code Collection} + * into which the results will be inserted * @return a {@code Collector} which collects all the input elements into a * {@code Collection}, in encounter order */ @@ -384,9 +385,11 @@ public final class Collectors { * {@code partitioningBy}. For example, given a stream of * {@code Person}, to accumulate the set of last names in each city: *
    {@code
    -     *     Map> lastNamesByCity
    -     *         = people.stream().collect(groupingBy(Person::getCity,
    -     *                                              mapping(Person::getLastName, toSet())));
    +     * Map> lastNamesByCity
    +     *   = people.stream().collect(
    +     *     groupingBy(Person::getCity,
    +     *                mapping(Person::getLastName,
    +     *                        toSet())));
          * }
    * * @param the type of the input elements @@ -424,9 +427,11 @@ public final class Collectors { * {@code partitioningBy}. For example, given a stream of * {@code Order}, to accumulate the set of line items for each customer: *
    {@code
    -     *     Map> itemsByCustomerName
    -     *         = orders.stream().collect(groupingBy(Order::getCustomerName,
    -     *                                              flatMapping(order -> order.getLineItems().stream(), toSet())));
    +     * Map> itemsByCustomerName
    +     *   = orders.stream().collect(
    +     *     groupingBy(Order::getCustomerName,
    +     *                flatMapping(order -> order.getLineItems().stream(),
    +     *                            toSet())));
          * }
    * * @param the type of the input elements @@ -468,9 +473,11 @@ public final class Collectors { * {@code Employee}, to accumulate the employees in each department that have a * salary above a certain threshold: *
    {@code
    -     *     Map> wellPaidEmployeesByDepartment
    -     *         = employees.stream().collect(groupingBy(Employee::getDepartment,
    -     *                                              filtering(e -> e.getSalary() > 2000, toSet())));
    +     * Map> wellPaidEmployeesByDepartment
    +     *   = employees.stream().collect(
    +     *     groupingBy(Employee::getDepartment,
    +     *                filtering(e -> e.getSalary() > 2000,
    +     *                          toSet())));
          * }
    * A filtering collector differs from a stream's {@code filter()} operation. * In this example, suppose there are no employees whose salary is above the @@ -491,7 +498,7 @@ public final class Collectors { */ public static Collector filtering(Predicate predicate, - Collector downstream) { + Collector downstream) { BiConsumer downstreamAccumulator = downstream.accumulator(); return new CollectorImpl<>(downstream.supplier(), (r, t) -> { @@ -508,8 +515,9 @@ public final class Collectors { * transformation. For example, one could adapt the {@link #toList()} * collector to always produce an immutable list with: *
    {@code
    -     *     List list
    -     *         = people.stream().collect(collectingAndThen(toList(), Collections::unmodifiableList));
    +     * List list = people.stream().collect(
    +     *   collectingAndThen(toList(),
    +     *                     Collections::unmodifiableList));
          * }
    * * @param the type of the input elements @@ -829,9 +837,11 @@ public final class Collectors { *

    For example, given a stream of {@code Person}, to calculate tallest * person in each city: *

    {@code
    -     *     Comparator byHeight = Comparator.comparing(Person::getHeight);
    -     *     Map> tallestByCity
    -     *         = people.stream().collect(groupingBy(Person::getCity, reducing(BinaryOperator.maxBy(byHeight))));
    +     * Comparator byHeight = Comparator.comparing(Person::getHeight);
    +     * Map> tallestByCity
    +     *   = people.stream().collect(
    +     *     groupingBy(Person::getCity,
    +     *                reducing(BinaryOperator.maxBy(byHeight))));
          * }
    * * @param element type for the input and output of the reduction @@ -882,10 +892,13 @@ public final class Collectors { *

    For example, given a stream of {@code Person}, to calculate the longest * last name of residents in each city: *

    {@code
    -     *     Comparator byLength = Comparator.comparing(String::length);
    -     *     Map longestLastNameByCity
    -     *         = people.stream().collect(groupingBy(Person::getCity,
    -     *                                              reducing("", Person::getLastName, BinaryOperator.maxBy(byLength))));
    +     * Comparator byLength = Comparator.comparing(String::length);
    +     * Map longestLastNameByCity
    +     *   = people.stream().collect(
    +     *     groupingBy(Person::getCity,
    +     *                reducing("",
    +     *                         Person::getLastName,
    +     *                         BinaryOperator.maxBy(byLength))));
          * }
    * * @param the type of the input elements @@ -969,9 +982,11 @@ public final class Collectors { * *

    For example, to compute the set of last names of people in each city: *

    {@code
    -     *     Map> namesByCity
    -     *         = people.stream().collect(groupingBy(Person::getCity,
    -     *                                              mapping(Person::getLastName, toSet())));
    +     * Map> namesByCity
    +     *   = people.stream().collect(
    +     *     groupingBy(Person::getCity,
    +     *                mapping(Person::getLastName,
    +     *                        toSet())));
          * }
    * * @implNote @@ -1016,9 +1031,12 @@ public final class Collectors { *

    For example, to compute the set of last names of people in each city, * where the city names are sorted: *

    {@code
    -     *     Map> namesByCity
    -     *         = people.stream().collect(groupingBy(Person::getCity, TreeMap::new,
    -     *                                              mapping(Person::getLastName, toSet())));
    +     * Map> namesByCity
    +     *   = people.stream().collect(
    +     *     groupingBy(Person::getCity,
    +     *                TreeMap::new,
    +     *                mapping(Person::getLastName,
    +     *                        toSet())));
          * }
    * * @implNote @@ -1036,8 +1054,8 @@ public final class Collectors { * @param the type of the resulting {@code Map} * @param classifier a classifier function mapping input elements to keys * @param downstream a {@code Collector} implementing the downstream reduction - * @param mapFactory a function which, when called, produces a new empty - * {@code Map} of the desired type + * @param mapFactory a supplier providing a new empty {@code Map} + * into which the results will be inserted * @return a {@code Collector} implementing the cascaded group-by operation * * @see #groupingBy(Function, Collector) @@ -1127,7 +1145,7 @@ public final class Collectors { *

    The classification function maps elements to some key type {@code K}. * The downstream collector operates on elements of type {@code T} and * produces a result of type {@code D}. The resulting collector produces a - * {@code Map}. + * {@code ConcurrentMap}. * *

    There are no guarantees on the type, mutability, or serializability * of the {@code ConcurrentMap} returned. @@ -1135,9 +1153,11 @@ public final class Collectors { *

    For example, to compute the set of last names of people in each city, * where the city names are sorted: *

    {@code
    -     *     ConcurrentMap> namesByCity
    -     *         = people.stream().collect(groupingByConcurrent(Person::getCity,
    -     *                                                        mapping(Person::getLastName, toSet())));
    +     * ConcurrentMap> namesByCity
    +     *   = people.stream().collect(
    +     *     groupingByConcurrent(Person::getCity,
    +     *                          mapping(Person::getLastName,
    +     *                                  toSet())));
          * }
    * * @param the type of the input elements @@ -1172,17 +1192,19 @@ public final class Collectors { *

    The classification function maps elements to some key type {@code K}. * The downstream collector operates on elements of type {@code T} and * produces a result of type {@code D}. The resulting collector produces a - * {@code Map}. + * {@code ConcurrentMap}. * *

    For example, to compute the set of last names of people in each city, * where the city names are sorted: *

    {@code
    -     *     ConcurrentMap> namesByCity
    -     *         = people.stream().collect(groupingBy(Person::getCity, ConcurrentSkipListMap::new,
    -     *                                              mapping(Person::getLastName, toSet())));
    +     * ConcurrentMap> namesByCity
    +     *   = people.stream().collect(
    +     *     groupingByConcurrent(Person::getCity,
    +     *                          ConcurrentSkipListMap::new,
    +     *                          mapping(Person::getLastName,
    +     *                                  toSet())));
          * }
    * - * * @param the type of the input elements * @param the type of the keys * @param the intermediate accumulation type of the downstream collector @@ -1190,8 +1212,8 @@ public final class Collectors { * @param the type of the resulting {@code ConcurrentMap} * @param classifier a classifier function mapping input elements to keys * @param downstream a {@code Collector} implementing the downstream reduction - * @param mapFactory a function which, when called, produces a new empty - * {@code ConcurrentMap} of the desired type + * @param mapFactory a supplier providing a new empty {@code ConcurrentMap} + * into which the results will be inserted * @return a concurrent, unordered {@code Collector} implementing the cascaded group-by operation * * @see #groupingByConcurrent(Function) @@ -1311,7 +1333,7 @@ public final class Collectors { * {@code Map} whose keys and values are the result of applying the provided * mapping functions to the input elements. * - *

    If the mapped keys contains duplicates (according to + *

    If the mapped keys contain duplicates (according to * {@link Object#equals(Object)}), an {@code IllegalStateException} is * thrown when the collection operation is performed. If the mapped keys * may have duplicates, use {@link #toMap(Function, Function, BinaryOperator)} @@ -1327,16 +1349,18 @@ public final class Collectors { * For example, the following produces a {@code Map} mapping * students to their grade point average: *

    {@code
    -     *     Map studentToGPA
    -     *         students.stream().collect(toMap(Function.identity(),
    -     *                                         student -> computeGPA(student)));
    +     * Map studentToGPA
    +     *   = students.stream().collect(
    +     *     toMap(Function.identity(),
    +     *           student -> computeGPA(student)));
          * }
    * And the following produces a {@code Map} mapping a unique identifier to * students: *
    {@code
    -     *     Map studentIdToStudent
    -     *         students.stream().collect(toMap(Student::getId,
    -     *                                         Function.identity());
    +     * Map studentIdToStudent
    +     *   = students.stream().collect(
    +     *     toMap(Student::getId,
    +     *           Function.identity()));
          * }
    * * @implNote @@ -1375,7 +1399,7 @@ public final class Collectors { * mapping functions to the input elements. * *

    If the mapped - * keys contains duplicates (according to {@link Object#equals(Object)}), + * keys contain duplicates (according to {@link Object#equals(Object)}), * the value mapping function is applied to each equal element, and the * results are merged using the provided merging function. * @@ -1389,13 +1413,14 @@ public final class Collectors { * more flexible merge policies. For example, if you have a stream * of {@code Person}, and you want to produce a "phone book" mapping name to * address, but it is possible that two persons have the same name, you can - * do as follows to gracefully deals with these collisions, and produce a + * do as follows to gracefully deal with these collisions, and produce a * {@code Map} mapping names to a concatenated list of addresses: *

    {@code
    -     *     Map phoneBook
    -     *         people.stream().collect(toMap(Person::getName,
    -     *                                       Person::getAddress,
    -     *                                       (s, a) -> s + ", " + a));
    +     * Map phoneBook
    +     *   = people.stream().collect(
    +     *     toMap(Person::getName,
    +     *           Person::getAddress,
    +     *           (s, a) -> s + ", " + a));
          * }
    * * @implNote @@ -1437,7 +1462,7 @@ public final class Collectors { * mapping functions to the input elements. * *

    If the mapped - * keys contains duplicates (according to {@link Object#equals(Object)}), + * keys contain duplicates (according to {@link Object#equals(Object)}), * the value mapping function is applied to each equal element, and the * results are merged using the provided merging function. The {@code Map} * is created by a provided supplier function. @@ -1459,8 +1484,8 @@ public final class Collectors { * @param mergeFunction a merge function, used to resolve collisions between * values associated with the same key, as supplied * to {@link Map#merge(Object, Object, BiFunction)} - * @param mapSupplier a function which returns a new, empty {@code Map} into - * which the results will be inserted + * @param mapFactory a supplier providing a new empty {@code Map} + * into which the results will be inserted * @return a {@code Collector} which collects elements into a {@code Map} * whose keys are the result of applying a key mapping function to the input * elements, and whose values are the result of applying a value mapping @@ -1473,13 +1498,13 @@ public final class Collectors { */ public static > Collector toMap(Function keyMapper, - Function valueMapper, - BinaryOperator mergeFunction, - Supplier mapSupplier) { + Function valueMapper, + BinaryOperator mergeFunction, + Supplier mapFactory) { BiConsumer accumulator = (map, element) -> map.merge(keyMapper.apply(element), valueMapper.apply(element), mergeFunction); - return new CollectorImpl<>(mapSupplier, accumulator, mapMerger(mergeFunction), CH_ID); + return new CollectorImpl<>(mapFactory, accumulator, mapMerger(mergeFunction), CH_ID); } /** @@ -1487,7 +1512,7 @@ public final class Collectors { * {@code ConcurrentMap} whose keys and values are the result of applying * the provided mapping functions to the input elements. * - *

    If the mapped keys contains duplicates (according to + *

    If the mapped keys contain duplicates (according to * {@link Object#equals(Object)}), an {@code IllegalStateException} is * thrown when the collection operation is performed. If the mapped keys * may have duplicates, use @@ -1500,19 +1525,21 @@ public final class Collectors { * It is common for either the key or the value to be the input elements. * In this case, the utility method * {@link java.util.function.Function#identity()} may be helpful. - * For example, the following produces a {@code Map} mapping + * For example, the following produces a {@code ConcurrentMap} mapping * students to their grade point average: *

    {@code
    -     *     Map studentToGPA
    -     *         students.stream().collect(toMap(Function.identity(),
    -     *                                         student -> computeGPA(student)));
    +     * ConcurrentMap studentToGPA
    +     *   = students.stream().collect(
    +     *     toConcurrentMap(Function.identity(),
    +     *                     student -> computeGPA(student)));
          * }
    - * And the following produces a {@code Map} mapping a unique identifier to - * students: + * And the following produces a {@code ConcurrentMap} mapping a + * unique identifier to students: *
    {@code
    -     *     Map studentIdToStudent
    -     *         students.stream().collect(toConcurrentMap(Student::getId,
    -     *                                                   Function.identity());
    +     * ConcurrentMap studentIdToStudent
    +     *   = students.stream().collect(
    +     *     toConcurrentMap(Student::getId,
    +     *                     Function.identity()));
          * }
    * *

    This is a {@link Collector.Characteristics#CONCURRENT concurrent} and @@ -1546,7 +1573,7 @@ public final class Collectors { * {@code ConcurrentMap} whose keys and values are the result of applying * the provided mapping functions to the input elements. * - *

    If the mapped keys contains duplicates (according to {@link Object#equals(Object)}), + *

    If the mapped keys contain duplicates (according to {@link Object#equals(Object)}), * the value mapping function is applied to each equal element, and the * results are merged using the provided merging function. * @@ -1560,13 +1587,14 @@ public final class Collectors { * more flexible merge policies. For example, if you have a stream * of {@code Person}, and you want to produce a "phone book" mapping name to * address, but it is possible that two persons have the same name, you can - * do as follows to gracefully deals with these collisions, and produce a - * {@code Map} mapping names to a concatenated list of addresses: + * do as follows to gracefully deal with these collisions, and produce a + * {@code ConcurrentMap} mapping names to a concatenated list of addresses: *

    {@code
    -     *     Map phoneBook
    -     *         people.stream().collect(toConcurrentMap(Person::getName,
    -     *                                                 Person::getAddress,
    -     *                                                 (s, a) -> s + ", " + a));
    +     * ConcurrentMap phoneBook
    +     *   = people.stream().collect(
    +     *     toConcurrentMap(Person::getName,
    +     *                     Person::getAddress,
    +     *                     (s, a) -> s + ", " + a));
          * }
    * *

    This is a {@link Collector.Characteristics#CONCURRENT concurrent} and @@ -1603,7 +1631,7 @@ public final class Collectors { * {@code ConcurrentMap} whose keys and values are the result of applying * the provided mapping functions to the input elements. * - *

    If the mapped keys contains duplicates (according to {@link Object#equals(Object)}), + *

    If the mapped keys contain duplicates (according to {@link Object#equals(Object)}), * the value mapping function is applied to each equal element, and the * results are merged using the provided merging function. The * {@code ConcurrentMap} is created by a provided supplier function. @@ -1620,8 +1648,8 @@ public final class Collectors { * @param mergeFunction a merge function, used to resolve collisions between * values associated with the same key, as supplied * to {@link Map#merge(Object, Object, BiFunction)} - * @param mapSupplier a function which returns a new, empty {@code Map} into - * which the results will be inserted + * @param mapFactory a supplier providing a new empty {@code ConcurrentMap} + * into which the results will be inserted * @return a concurrent, unordered {@code Collector} which collects elements into a * {@code ConcurrentMap} whose keys are the result of applying a key mapping * function to the input elements, and whose values are the result of @@ -1636,11 +1664,11 @@ public final class Collectors { Collector toConcurrentMap(Function keyMapper, Function valueMapper, BinaryOperator mergeFunction, - Supplier mapSupplier) { + Supplier mapFactory) { BiConsumer accumulator = (map, element) -> map.merge(keyMapper.apply(element), valueMapper.apply(element), mergeFunction); - return new CollectorImpl<>(mapSupplier, accumulator, mapMerger(mergeFunction), CH_CONCURRENT_ID); + return new CollectorImpl<>(mapFactory, accumulator, mapMerger(mergeFunction), CH_CONCURRENT_ID); } /** From d08eb8c2a9ac45a71e57b59f9934c78840f05817 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Wed, 7 Dec 2016 11:53:26 -0800 Subject: [PATCH 049/142] 8170831: ZipFile implementation no longer caches the last accessed entry/pos Reviewed-by: psandoz --- .../java.base/share/classes/java/util/zip/ZipFile.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java index ef26d1784cc..4a78e2eb277 100644 --- a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java +++ b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java @@ -331,7 +331,9 @@ class ZipFile implements ZipConstants, Closeable { ZipFileInputStream in = null; synchronized (this) { ensureOpen(); - if (!zc.isUTF8() && (entry.flag & EFS) != 0) { + if (Objects.equals(lastEntryName, entry.name)) { + pos = lastEntryPos; + } else if (!zc.isUTF8() && (entry.flag & EFS) != 0) { pos = zsrc.getEntryPos(zc.getBytesUTF8(entry.name), false); } else { pos = zsrc.getEntryPos(zc.getBytes(entry.name), false); @@ -526,6 +528,9 @@ class ZipFile implements ZipConstants, Closeable { Spliterator.IMMUTABLE | Spliterator.NONNULL), false); } + private String lastEntryName; + private int lastEntryPos; + /* Checks ensureOpen() before invoke this method */ private ZipEntry getZipEntry(String name, byte[] bname, int pos) { byte[] cen = zsrc.cen; @@ -563,6 +568,8 @@ class ZipFile implements ZipConstants, Closeable { e.comment = zc.toString(cen, start, clen); } } + lastEntryName = e.name; + lastEntryPos = pos; return e; } From 26bcf5dba0c3a22eed290df4768fcc434a1626d7 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Wed, 7 Dec 2016 12:47:19 -0800 Subject: [PATCH 050/142] 8170875: Problem list LocaleTest.java until JDK-8170840 is fixed Reviewed-by: rriggs, naoto --- jdk/test/ProblemList.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 441ef67d48e..7cc227da857 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -291,6 +291,8 @@ java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java 8062512 java/util/BitSet/BitSetStreamTest.java 8079538 generic-all +java/util/Locale/LocaleTest.java 8170840 generic-all + ############################################################################ # jdk_instrument From 1bcb7f93c06c2bf75f4a371bfbbc78a2a864b15b Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Wed, 7 Dec 2016 15:32:31 -0500 Subject: [PATCH 051/142] 8170291: Unpredictable results of j.i.ObjectInputFilter::createFilter Reviewed-by: dfuchs --- .../classes/java/io/ObjectInputFilter.java | 51 ++++++++++-------- .../classes/java/io/ObjectInputStream.java | 12 ++++- .../serialFilter/SerialFilterTest.java | 54 ++++++++++++++----- 3 files changed, 79 insertions(+), 38 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/io/ObjectInputFilter.java b/jdk/src/java.base/share/classes/java/io/ObjectInputFilter.java index e222f47c41a..a0e998c7b29 100644 --- a/jdk/src/java.base/share/classes/java/io/ObjectInputFilter.java +++ b/jdk/src/java.base/share/classes/java/io/ObjectInputFilter.java @@ -350,16 +350,24 @@ public interface ObjectInputFilter { * The first pattern that matches, working from left to right, determines * the {@link Status#ALLOWED Status.ALLOWED} * or {@link Status#REJECTED Status.REJECTED} result. - * If nothing matches, the result is {@link Status#UNDECIDED Status.UNDECIDED}. + * If the limits are not exceeded and no pattern matches the class, + * the result is {@link Status#UNDECIDED Status.UNDECIDED}. * * @param pattern the pattern string to parse; not null - * @return a filter to check a class being deserialized; may be null; + * @return a filter to check a class being deserialized; * {@code null} if no patterns - * @throws IllegalArgumentException - * if a limit is missing the name, or the long value - * is not a number or is negative, - * or the module name is missing if the pattern contains "/" - * or if the package is missing for ".*" and ".**" + * @throws IllegalArgumentException if the pattern string is illegal or + * malformed and cannot be parsed. + * In particular, if any of the following is true: + *

      + *
    • if a limit is missing the name or the name is not one of + * "maxdepth", "maxrefs", "maxbytes", or "maxarray" + *
    • if the value of the limit can not be parsed by + * {@link Long#parseLong Long.parseLong} or is negative + *
    • if the pattern contains "/" and the module name is missing + * or the remaining pattern is empty + *
    • if the package is missing for ".*" and ".**" + *
    */ public static ObjectInputFilter createFilter(String pattern) { Objects.requireNonNull(pattern, "pattern"); @@ -402,14 +410,19 @@ public interface ObjectInputFilter { * Returns an ObjectInputFilter from a string of patterns. * * @param pattern the pattern string to parse - * @return a filter to check a class being deserialized; not null + * @return a filter to check a class being deserialized; + * {@code null} if no patterns * @throws IllegalArgumentException if the parameter is malformed * if the pattern is missing the name, the long value * is not a number or is negative. */ static ObjectInputFilter createFilter(String pattern) { - Global filter = new Global(pattern); - return filter.isEmpty() ? null : filter; + try { + return new Global(pattern); + } catch (UnsupportedOperationException uoe) { + // no non-empty patterns + return null; + } } /** @@ -417,8 +430,10 @@ public interface ObjectInputFilter { * * @param pattern a pattern string of filters * @throws IllegalArgumentException if the pattern is malformed + * @throws UnsupportedOperationException if there are no non-empty patterns */ private Global(String pattern) { + boolean hasLimits = false; this.pattern = pattern; maxArrayLength = Long.MAX_VALUE; // Default values are unlimited @@ -436,6 +451,7 @@ public interface ObjectInputFilter { } if (parseLimit(p)) { // If the pattern contained a limit setting, i.e. type=value + hasLimits = true; continue; } boolean negate = p.charAt(0) == '!'; @@ -510,18 +526,9 @@ public interface ObjectInputFilter { filters.add(c -> moduleName.equals(c.getModule().getName()) ? patternFilter.apply(c) : Status.UNDECIDED); } } - } - - /** - * Returns if this filter has any checks. - * @return {@code true} if the filter has any checks, {@code false} otherwise - */ - private boolean isEmpty() { - return filters.isEmpty() && - maxArrayLength == Long.MAX_VALUE && - maxDepth == Long.MAX_VALUE && - maxReferences == Long.MAX_VALUE && - maxStreamBytes == Long.MAX_VALUE; + if (filters.isEmpty() && !hasLimits) { + throw new UnsupportedOperationException("no non-empty patterns"); + } } /** diff --git a/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java b/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java index eac811d9fe2..ed033d685e9 100644 --- a/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java +++ b/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java @@ -1164,6 +1164,13 @@ public class ObjectInputStream * for each class and reference in the stream. * The filter can check any or all of the class, the array length, the number * of references, the depth of the graph, and the size of the input stream. + * The depth is the number of nested {@linkplain #readObject readObject} + * calls starting with the reading of the root of the graph being deserialized + * and the current object being deserialized. + * The number of references is the cumulative number of objects and references + * to objects already read from the stream including the current object being read. + * The filter is invoked only when reading objects from the stream and for + * not primitives. *

    * If the filter returns {@link ObjectInputFilter.Status#REJECTED Status.REJECTED}, * {@code null} or throws a {@link RuntimeException}, @@ -1178,8 +1185,9 @@ public class ObjectInputStream * * @implSpec * The filter, when not {@code null}, is invoked during {@link #readObject readObject} - * and {@link #readUnshared readUnshared} for each object - * (regular or class) in the stream including the following: + * and {@link #readUnshared readUnshared} for each object (regular or class) in the stream. + * Strings are treated as primitives and do not invoke the filter. + * The filter is called for: *