From f183b74690743224d327d5bd4bee79dda1628aeb Mon Sep 17 00:00:00 2001 From: Jesper Wilhelmsson Date: Thu, 3 Jan 2019 02:22:30 +0100 Subject: [PATCH 01/22] Added tag jdk-12+26 for changeset de9fd809bb47 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 35959b6d547..99bd6945faf 100644 --- a/.hgtags +++ b/.hgtags @@ -528,3 +528,4 @@ f8fb0c86f2b3d24294d39c5685a628e1beb14ba7 jdk-12+21 eef755718cb24813031a842bbfc716a6cea18e9a jdk-12+23 7d4397b43fa305806160785a4c7210600d59581a jdk-12+24 7496df94b3b79f3da53925d2d137317715f11d97 jdk-12+25 +de9fd809bb475401aad188eab2264226788aad81 jdk-12+26 From 2f34c5ac6a3039274e12719f061dd67f84328c7a Mon Sep 17 00:00:00 2001 From: Srinivas Dama Date: Thu, 3 Jan 2019 11:21:11 +0530 Subject: [PATCH 02/22] 8208184: IllegalArgumentException while invoking code completion on netbeans IDE Set Log.useSource and fix the issue in Modules.java when broken module is encountered Co-authored-by: Jan Lahoda Reviewed-by: jjg --- .../com/sun/tools/javac/comp/Modules.java | 7 +- .../sun/tools/javac/main/JavaCompiler.java | 2 + .../tools/javac/modules/QueryBeforeEnter.java | 136 +++++++++++++++++- 3 files changed, 143 insertions(+), 2 deletions(-) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java index 95c211cc82a..34ad5f9627f 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java @@ -450,7 +450,12 @@ public class Modules extends JCTree.Visitor { String moduleOverride = singleModuleOverride(trees); switch (rootModules.size()) { case 0: - defaultModule = moduleFinder.findSingleModule(); + try { + defaultModule = moduleFinder.findSingleModule(); + } catch (CompletionFailure cf) { + chk.completionError(null, cf); + defaultModule = syms.unnamedModule; + } if (defaultModule == syms.unnamedModule) { if (moduleOverride != null) { checkNoAllModulePath(); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java index 381de6a0dd1..b6f41a4edc8 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java @@ -1761,6 +1761,7 @@ public class JavaCompiler { private Name parseAndGetName(JavaFileObject fo, Function tree2Name) { DiagnosticHandler dh = new DiscardDiagnosticHandler(log); + JavaFileObject prevSource = log.useSource(fo); try { JCTree.JCCompilationUnit t = parse(fo, fo.getCharContent(false)); return tree2Name.apply(t); @@ -1768,6 +1769,7 @@ public class JavaCompiler { return null; } finally { log.popDiagnosticHandler(dh); + log.useSource(prevSource); } } diff --git a/test/langtools/tools/javac/modules/QueryBeforeEnter.java b/test/langtools/tools/javac/modules/QueryBeforeEnter.java index b88f5fab07f..226c6aed8e3 100644 --- a/test/langtools/tools/javac/modules/QueryBeforeEnter.java +++ b/test/langtools/tools/javac/modules/QueryBeforeEnter.java @@ -23,6 +23,7 @@ /** * @test + * @bug 8208184 * @summary tests for module resolution * @library /tools/lib * @modules @@ -33,19 +34,33 @@ */ import java.io.File; +import java.io.IOException; import java.io.OutputStream; +import java.net.URI; +import java.net.URISyntaxException; import java.nio.file.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import java.util.Arrays; import java.util.Set; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedAnnotationTypes; -import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.SourceVersion; import javax.lang.model.element.TypeElement; +import javax.tools.FileObject; +import javax.tools.ForwardingJavaFileManager; import javax.tools.JavaCompiler; +import javax.tools.JavaFileManager; +import javax.tools.JavaFileObject; +import javax.tools.JavaFileObject.Kind; +import javax.tools.SimpleJavaFileObject; import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; import javax.tools.ToolProvider; // import com.sun.source.util.JavacTask; @@ -427,6 +442,125 @@ public class QueryBeforeEnter extends ModuleTestBase { } + @Test + public void testBrokenModule(Path base) throws Exception { + Map sourceFileName2Content = new HashMap<>(); + + sourceFileName2Content.put("module-info.java", "module test { requires unknown.; } "); + sourceFileName2Content.put("test/Test.java", "package test; public class Test {}"); + + Path out = base.resolve("out"); + + Files.createDirectories(out); + + JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler(); + try (StandardJavaFileManager fm = javaCompiler.getStandardFileManager(null, null, null)) { + com.sun.source.util.JavacTask task = + (com.sun.source.util.JavacTask) javaCompiler.getTask(null, + new TestMemoryFileManager(fm, sourceFileName2Content), + null, + Arrays.asList("-d", out.toString()), + null, + null); + task.getElements().getTypeElement("test.Test"); + } + } + + private static final class TestMemoryFileManager extends ForwardingJavaFileManager { + + private final Map sourceFileName2Content; + + public TestMemoryFileManager(JavaFileManager fileManager, Map sourceFileName2Content) { + super(fileManager); + this.sourceFileName2Content = sourceFileName2Content; + } + + @Override + public Iterable list(Location location, String packageName, Set kinds, boolean recurse) throws IOException { + if (location == StandardLocation.SOURCE_PATH) { + List result = new ArrayList<>(); + String dir = packageName.replace('.', '/') + "/"; + + for (Entry e : sourceFileName2Content.entrySet()) { + if (e.getKey().startsWith(dir) && + !e.getKey().substring(dir.length()).contains("/")) { + try { + result.add(new SourceFileObject(e.getKey(), e.getValue())); + } catch (URISyntaxException ex) { + throw new IOException(ex); + } + } + } + + return result; + } + return super.list(location, packageName, kinds, recurse); + } + + @Override + public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) throws IOException { + if (location == StandardLocation.SOURCE_PATH) { + String path = className.replace('.', '/') + ".java"; + String code = sourceFileName2Content.get(path); + + if (code == null) return null; + + try { + return new SourceFileObject(path, code); + } catch (URISyntaxException ex) { + throw new IOException(ex); + } + } + return super.getJavaFileForInput(location, className, kind); + } + + @Override + public boolean hasLocation(Location location) { + return super.hasLocation(location) || location == StandardLocation.SOURCE_PATH; + } + + @Override + public boolean contains(Location location, FileObject fo) throws IOException { + if (location == StandardLocation.SOURCE_PATH) { + return fo instanceof SourceFileObject; + } + return super.contains(location, fo); + } + + @Override + public String inferBinaryName(Location location, JavaFileObject file) { + if (location == StandardLocation.SOURCE_PATH) { + String path = ((SourceFileObject) file).path; + String fileName = path.substring(path.lastIndexOf('/')); + return fileName.substring(0, fileName.length() - ".java".length()); + } + return super.inferBinaryName(location, file); + } + + } + + private static final class SourceFileObject extends SimpleJavaFileObject { + private final String path; + private final String code; + + public SourceFileObject(String path, String code) throws URISyntaxException { + super(new URI("mem://" + path), Kind.SOURCE); + this.path = path; + this.code = code; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { + return code; + } + + @Override + public boolean isNameCompatible(String simpleName, Kind kind) { + return path.endsWith(simpleName + kind.extension); + } + + } + private static void assertNotNull(Object actual) { if (actual == null) { throw new AssertionError("unexpected null!"); From 326c6997a0a1a1fb0aa10645556f7ad9a6e98adc Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Thu, 13 Dec 2018 17:57:11 +0100 Subject: [PATCH 03/22] 8215044: C2 crash in loopTransform.cpp with assert(cl->trip_count() > 0) failed: peeling a fully unrolled loop Reviewed-by: thartmann, kvn --- src/hotspot/share/opto/loopTransform.cpp | 4 ++ .../loopopts/PeelingZeroTripCount.java | 56 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 test/hotspot/jtreg/compiler/loopopts/PeelingZeroTripCount.java diff --git a/src/hotspot/share/opto/loopTransform.cpp b/src/hotspot/share/opto/loopTransform.cpp index 209acbdffe0..001fe010ef4 100644 --- a/src/hotspot/share/opto/loopTransform.cpp +++ b/src/hotspot/share/opto/loopTransform.cpp @@ -354,6 +354,10 @@ bool IdealLoopTree::policy_peeling( PhaseIdealLoop *phase ) const { // check for vectorized loops, any peeling done was already applied if (_head->is_CountedLoop() && _head->as_CountedLoop()->do_unroll_only()) return false; + if (_head->is_CountedLoop() && _head->as_CountedLoop()->trip_count() == 1) { + return false; + } + while( test != _head ) { // Scan till run off top of loop if( test->is_If() ) { // Test? Node *ctrl = phase->get_ctrl(test->in(1)); diff --git a/test/hotspot/jtreg/compiler/loopopts/PeelingZeroTripCount.java b/test/hotspot/jtreg/compiler/loopopts/PeelingZeroTripCount.java new file mode 100644 index 00000000000..c6350c06751 --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/PeelingZeroTripCount.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018, Red Hat, Inc. 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 8215044 + * @summary C2 crash in loopTransform.cpp with assert(cl->trip_count() > 0) failed: peeling a fully unrolled loop + * + * @run main/othervm -XX:CompileOnly=PeelingZeroTripCount.test PeelingZeroTripCount + * + */ + +public class PeelingZeroTripCount { + + public static void main(String[] args) { + PeelingZeroTripCount issue = new PeelingZeroTripCount(); + for (int i = 0; i < 10000; i++) { + issue.test(new int[999]); + } + } + + public void test(int[] iaarg) { + int[] iarr = new int[777]; + for (int i = 4; i > 0; i--) { + for (int j = 0; j <= i - 1; j++) { + int istep = 2 * j - i + 1; + int iadj = 0; + if (istep < 0) { + iadj = iarr[0-istep] + iaarg[i-1]; + } else { + iadj = iarr[istep] + iaarg[i-1]; + } + } + } + } +} From 91e505187191f98607babc63a28d6a24d556bf50 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 31 Dec 2018 14:38:16 +0100 Subject: [PATCH 04/22] 8215975: [testbug] Adapt nsk tests to the PPC, S390 and AIX platforms Use LIBPATH on AIX, no shared memory connector on any Unix. Reviewed-by: gadams, simonis, sspitsyn --- .../AttachingConnector/attach/attach002.java | 4 +-- .../Allocate/alloc001/TestDescription.java | 4 ++- .../nsk/jvmti/Allocate/alloc001/alloc001.bash | 6 +++-- .../retransform003/TestDriver.java | 16 +++++++++--- .../SetNativeMethodPrefix002/TestDriver.java | 16 +++++++++--- .../nsk/share/jdi/ArgumentHandler.java | 26 ++++++++++++++++++- 6 files changed, 60 insertions(+), 12 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/AttachingConnector/attach/attach002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/AttachingConnector/attach/attach002.java index d4092f95bea..22720edadc1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/AttachingConnector/attach/attach002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/AttachingConnector/attach/attach002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2019, 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 @@ -203,6 +203,6 @@ public class attach002 extends Log { return connector; } } - throw new Error("No appropriate connector"); + throw new Error("No appropriate connector: " + connectorName); } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/TestDescription.java index 68e8bd881f5..c7bf3df62fb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/TestDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -21,6 +21,7 @@ * questions. */ +// Not run on AIX as it does not support ulimit -v. /* * @test @@ -40,6 +41,7 @@ * * @library /vmTestbase * /test/lib + * @requires os.family != "aix" * @run driver jdk.test.lib.FileInstaller . . * @build nsk.jvmti.Allocate.alloc001 * @run shell alloc001.sh diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.bash b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.bash index 6f59032bd56..83b2b09dd4c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.bash +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.bash @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2008, 2019, 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 @@ -41,7 +41,8 @@ aix | bsd | linux | solaris) max_ulimit=1048576 max_heap=256m else - max_ulimit=4194304 + # AIX requires a 32-bit value here. + max_ulimit=4194303 max_heap=512m fi @@ -74,6 +75,7 @@ esac export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$TESTNATIVEPATH export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TESTNATIVEPATH +export LIBPATH=$LIBPATH:$TESTNATIVEPATH export PATH=$PATH:$TESTNATIVEPATH echo $JAVA ${JAVA_OPTS} nsk.jvmti.Allocate.alloc001 diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform003/TestDriver.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform003/TestDriver.java index 38ff90a8423..f8dd655f0c3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform003/TestDriver.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform003/TestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -76,8 +76,18 @@ public class TestDriver { "-agentlib:retransform003-03=id=3 can_retransform_classes=1", nsk.jvmti.RetransformClasses.retransform003.class.getName() ); - String envName = Platform.isWindows() ? "PATH" : - (Platform.isOSX() ? "DYLD_LIBRARY_PATH" : "LD_LIBRARY_PATH"); + + String envName; + if (Platform.isWindows()) { + envName = "PATH"; + } else if (Platform.isOSX()) { + envName = "DYLD_LIBRARY_PATH"; + } else if (Platform.isAix()) { + envName = "LIBPATH"; + } else { + envName = "LD_LIBRARY_PATH"; + } + pb.environment() .merge(envName, ".", (x, y) -> y + File.pathSeparator + x); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/TestDriver.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/TestDriver.java index a3839375b92..ebc4b1d8baa 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/TestDriver.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/TestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, 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 @@ -66,8 +66,18 @@ public class TestDriver { "-agentlib:SetNativeMethodPrefix002-03=trace=all prefix=wc_", nsk.jvmti.SetNativeMethodPrefix.SetNativeMethodPrefix002.class.getName() ); - String envName = Platform.isWindows() ? "PATH" : - (Platform.isOSX() ? "DYLD_LIBRARY_PATH" : "LD_LIBRARY_PATH"); + + String envName; + if (Platform.isWindows()) { + envName = "PATH"; + } else if (Platform.isOSX()) { + envName = "DYLD_LIBRARY_PATH"; + } else if (Platform.isAix()) { + envName = "LIBPATH"; + } else { + envName = "LD_LIBRARY_PATH"; + } + pb.environment() .merge(envName, ".", (x, y) -> y + File.pathSeparator + x); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/ArgumentHandler.java b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/ArgumentHandler.java index fee4baf773e..ed43c1bf47f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/ArgumentHandler.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/ArgumentHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, 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 @@ -533,8 +533,12 @@ class CheckedFeatures { {"linux-sparcv9", "com.sun.jdi.SharedMemoryAttach"}, {"linux-aarch64", "com.sun.jdi.SharedMemoryAttach"}, {"linux-arm", "com.sun.jdi.SharedMemoryAttach"}, + {"linux-ppc64", "com.sun.jdi.SharedMemoryAttach"}, + {"linux-ppc64le", "com.sun.jdi.SharedMemoryAttach"}, + {"linux-s390x", "com.sun.jdi.SharedMemoryAttach"}, {"macosx-amd64", "com.sun.jdi.SharedMemoryAttach"}, {"mac-x64", "com.sun.jdi.SharedMemoryAttach"}, + {"aix-ppc64", "com.sun.jdi.SharedMemoryAttach"}, // listening connectors /* @@ -559,8 +563,12 @@ class CheckedFeatures { {"linux-sparcv9", "com.sun.jdi.SharedMemoryListen"}, {"linux-aarch64", "com.sun.jdi.SharedMemoryListen"}, {"linux-arm", "com.sun.jdi.SharedMemoryListen"}, + {"linux-ppc64", "com.sun.jdi.SharedMemoryListen"}, + {"linux-ppc64le", "com.sun.jdi.SharedMemoryListen"}, + {"linux-s390x", "com.sun.jdi.SharedMemoryListen"}, {"macosx-amd64", "com.sun.jdi.SharedMemoryListen"}, {"mac-x64", "com.sun.jdi.SharedMemoryListen"}, + {"aix-ppc64", "com.sun.jdi.SharedMemoryListen"}, // launching connectors /* @@ -615,6 +623,15 @@ class CheckedFeatures { {"linux-arm", "com.sun.jdi.CommandLineLaunch", "dt_shmem"}, {"linux-arm", "com.sun.jdi.RawCommandLineLaunch", "dt_shmem"}, + {"linux-ppc64", "com.sun.jdi.CommandLineLaunch", "dt_shmem"}, + {"linux-ppc64", "com.sun.jdi.RawCommandLineLaunch", "dt_shmem"}, + + {"linux-ppc64le", "com.sun.jdi.CommandLineLaunch", "dt_shmem"}, + {"linux-ppc64le", "com.sun.jdi.RawCommandLineLaunch", "dt_shmem"}, + + {"linux-s390x", "com.sun.jdi.CommandLineLaunch", "dt_shmem"}, + {"linux-s390x", "com.sun.jdi.RawCommandLineLaunch", "dt_shmem"}, + {"windows-i586", "com.sun.jdi.CommandLineLaunch", "dt_socket"}, {"windows-i586", "com.sun.jdi.RawCommandLineLaunch", "dt_socket"}, @@ -633,6 +650,9 @@ class CheckedFeatures { {"mac-x64", "com.sun.jdi.CommandLineLaunch", "dt_shmem"}, {"mac-x64", "com.sun.jdi.RawCommandLineLaunch", "dt_shmem"}, + {"aix-ppc64", "com.sun.jdi.CommandLineLaunch", "dt_shmem"}, + {"aix-ppc64", "com.sun.jdi.RawCommandLineLaunch", "dt_shmem"}, + // shared memory transport is implemented only on windows platform {"solaris-sparc", "dt_shmem"}, {"solaris-sparcv9", "dt_shmem"}, @@ -647,7 +667,11 @@ class CheckedFeatures { {"linux-sparcv9", "dt_shmem"}, {"linux-aarch64", "dt_shmem"}, {"linux-arm", "dt_shmem"}, + {"linux-ppc64", "dt_shmem"}, + {"linux-ppc64le", "dt_shmem"}, + {"linux-s390x", "dt_shmem"}, {"macosx-amd64", "dt_shmem"}, {"mac-x64", "dt_shmem"}, + {"aix-ppc64", "dt_shmem"}, }; } From 103c8dc6085469f96e19769755bae40dc7742f2e Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Fri, 14 Dec 2018 11:22:26 +0100 Subject: [PATCH 05/22] 8215265: C2: range check elimination may allow illegal out of bound access Reviewed-by: thartmann, kvn --- src/hotspot/share/opto/loopTransform.cpp | 20 +++- src/hotspot/share/opto/loopnode.hpp | 2 +- .../RangeCheckEliminationScaleNotOne.java | 100 ++++++++++++++++++ 3 files changed, 116 insertions(+), 6 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/rangechecks/RangeCheckEliminationScaleNotOne.java diff --git a/src/hotspot/share/opto/loopTransform.cpp b/src/hotspot/share/opto/loopTransform.cpp index 001fe010ef4..6bd26b740c7 100644 --- a/src/hotspot/share/opto/loopTransform.cpp +++ b/src/hotspot/share/opto/loopTransform.cpp @@ -2039,13 +2039,20 @@ void PhaseIdealLoop::mark_reductions(IdealLoopTree *loop) { //------------------------------adjust_limit----------------------------------- // Helper function for add_constraint(). -Node* PhaseIdealLoop::adjust_limit(int stride_con, Node * scale, Node *offset, Node *rc_limit, Node *loop_limit, Node *pre_ctrl) { +Node* PhaseIdealLoop::adjust_limit(int stride_con, Node * scale, Node *offset, Node *rc_limit, Node *loop_limit, Node *pre_ctrl, bool round_up) { // Compute "I :: (limit-offset)/scale" Node *con = new SubINode(rc_limit, offset); register_new_node(con, pre_ctrl); Node *X = new DivINode(0, con, scale); register_new_node(X, pre_ctrl); + // When the absolute value of scale is greater than one, the integer + // division may round limit down so add one to the limit. + if (round_up) { + X = new AddINode(X, _igvn.intcon(1)); + register_new_node(X, pre_ctrl); + } + // Adjust loop limit loop_limit = (stride_con > 0) ? (Node*)(new MinINode(loop_limit, X)) @@ -2086,7 +2093,7 @@ void PhaseIdealLoop::add_constraint( int stride_con, int scale_con, Node *offset // (upper_limit-offset) may overflow or underflow. // But it is fine since main loop will either have // less iterations or will be skipped in such case. - *main_limit = adjust_limit(stride_con, scale, offset, upper_limit, *main_limit, pre_ctrl); + *main_limit = adjust_limit(stride_con, scale, offset, upper_limit, *main_limit, pre_ctrl, false); // The underflow limit: low_limit <= scale*I+offset. // For pre-loop compute @@ -2121,7 +2128,8 @@ void PhaseIdealLoop::add_constraint( int stride_con, int scale_con, Node *offset // max(pre_limit, original_limit) is used in do_range_check(). } // Pass (-stride) to indicate pre_loop_cond = NOT(main_loop_cond); - *pre_limit = adjust_limit((-stride_con), scale, offset, low_limit, *pre_limit, pre_ctrl); + *pre_limit = adjust_limit((-stride_con), scale, offset, low_limit, *pre_limit, pre_ctrl, + scale_con > 1 && stride_con > 0); } else { // stride_con*scale_con < 0 // For negative stride*scale pre-loop checks for overflow and @@ -2147,7 +2155,8 @@ void PhaseIdealLoop::add_constraint( int stride_con, int scale_con, Node *offset Node *plus_one = new AddINode(offset, one); register_new_node( plus_one, pre_ctrl ); // Pass (-stride) to indicate pre_loop_cond = NOT(main_loop_cond); - *pre_limit = adjust_limit((-stride_con), scale, plus_one, upper_limit, *pre_limit, pre_ctrl); + *pre_limit = adjust_limit((-stride_con), scale, plus_one, upper_limit, *pre_limit, pre_ctrl, + scale_con < -1 && stride_con > 0); if (low_limit->get_int() == -max_jint) { // We need this guard when scale*main_limit+offset >= limit @@ -2181,7 +2190,8 @@ void PhaseIdealLoop::add_constraint( int stride_con, int scale_con, Node *offset // I > (low_limit-(offset+1))/scale // ) - *main_limit = adjust_limit(stride_con, scale, plus_one, low_limit, *main_limit, pre_ctrl); + *main_limit = adjust_limit(stride_con, scale, plus_one, low_limit, *main_limit, pre_ctrl, + false); } } diff --git a/src/hotspot/share/opto/loopnode.hpp b/src/hotspot/share/opto/loopnode.hpp index 064ced8f9e2..930a991f25d 100644 --- a/src/hotspot/share/opto/loopnode.hpp +++ b/src/hotspot/share/opto/loopnode.hpp @@ -1190,7 +1190,7 @@ public: // loop. Scale_con, offset and limit are all loop invariant. void add_constraint( int stride_con, int scale_con, Node *offset, Node *low_limit, Node *upper_limit, Node *pre_ctrl, Node **pre_limit, Node **main_limit ); // Helper function for add_constraint(). - Node* adjust_limit( int stride_con, Node * scale, Node *offset, Node *rc_limit, Node *loop_limit, Node *pre_ctrl ); + Node* adjust_limit(int stride_con, Node * scale, Node *offset, Node *rc_limit, Node *loop_limit, Node *pre_ctrl, bool round_up); // Partially peel loop up through last_peel node. bool partial_peel( IdealLoopTree *loop, Node_List &old_new ); diff --git a/test/hotspot/jtreg/compiler/rangechecks/RangeCheckEliminationScaleNotOne.java b/test/hotspot/jtreg/compiler/rangechecks/RangeCheckEliminationScaleNotOne.java new file mode 100644 index 00000000000..50b268a252e --- /dev/null +++ b/test/hotspot/jtreg/compiler/rangechecks/RangeCheckEliminationScaleNotOne.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2018, Red Hat, Inc. 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 8215265 + * @summary C2: range check elimination may allow illegal out of bound access + * + * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:-UseLoopPredicate RangeCheckEliminationScaleNotOne + * + */ + +import java.util.Arrays; + +public class RangeCheckEliminationScaleNotOne { + public static void main(String[] args) { + { + int[] array = new int[199]; + boolean[] flags = new boolean[100]; + Arrays.fill(flags, true); + flags[0] = false; + flags[1] = false; + for (int i = 0; i < 20_000; i++) { + test1(100, array, 0, flags); + } + boolean ex = false; + try { + test1(100, array, -5, flags); + } catch (ArrayIndexOutOfBoundsException aie) { + ex = true; + } + if (!ex) { + throw new RuntimeException("no AIOOB exception"); + } + } + + { + int[] array = new int[199]; + boolean[] flags = new boolean[100]; + Arrays.fill(flags, true); + flags[0] = false; + flags[1] = false; + for (int i = 0; i < 20_000; i++) { + test2(100, array, 198, flags); + } + boolean ex = false; + try { + test2(100, array, 203, flags); + } catch (ArrayIndexOutOfBoundsException aie) { + ex = true; + } + if (!ex) { + throw new RuntimeException("no AIOOB exception"); + } + } + } + + private static int test1(int stop, int[] array, int offset, boolean[] flags) { + if (array == null) {} + int res = 0; + for (int i = 0; i < stop; i++) { + if (flags[i]) { + res += array[2 * i + offset]; + } + } + return res; + } + + + private static int test2(int stop, int[] array, int offset, boolean[] flags) { + if (array == null) {} + int res = 0; + for (int i = 0; i < stop; i++) { + if (flags[i]) { + res += array[-2 * i + offset]; + } + } + return res; + } +} From a97d8a9a766b90f221cae18e344987303b00b2ed Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Thu, 3 Jan 2019 14:33:58 -0800 Subject: [PATCH 06/22] 8215947: JVM crash with -XX:+DumpSharedSpaces Disable JIT compilation if -XX:+DumpSharedSpaces is specified by the user Reviewed-by: lfoltan, jiangli --- src/hotspot/share/runtime/arguments.cpp | 4 ++++ .../jtreg/runtime/SharedArchiveFile/SharedArchiveFile.java | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 3941c473273..a2ff6b81fc8 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -3111,6 +3111,10 @@ jint Arguments::finalize_vm_init_args(bool patch_mod_javabase) { BytecodeVerificationRemote = true; log_info(cds)("All non-system classes will be verified (-Xverify:remote) during CDS dump time."); } + + // Compilation is already disabled if the user specifies -Xshare:dump. + // Disable compilation in case user specifies -XX:+DumpSharedSpaces instead of -Xshare:dump. + set_mode_flags(_int); } if (UseSharedSpaces && patch_mod_javabase) { no_shared_spaces("CDS is disabled when " JAVA_BASE_NAME " module is patched."); diff --git a/test/hotspot/jtreg/runtime/SharedArchiveFile/SharedArchiveFile.java b/test/hotspot/jtreg/runtime/SharedArchiveFile/SharedArchiveFile.java index 0e4ed4aceb0..0ad543bfab7 100644 --- a/test/hotspot/jtreg/runtime/SharedArchiveFile/SharedArchiveFile.java +++ b/test/hotspot/jtreg/runtime/SharedArchiveFile/SharedArchiveFile.java @@ -47,6 +47,13 @@ public class SharedArchiveFile { OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "SharedArchiveFile"); CDSTestUtils.checkDump(out); + // -XX:+DumpSharedSpaces should behave the same as -Xshare:dump + pb = ProcessTools.createJavaProcessBuilder(true, + "-XX:SharedArchiveFile=./SharedArchiveFile.jsa", + "-XX:+DumpSharedSpaces"); + out = CDSTestUtils.executeAndLog(pb, "SharedArchiveFile"); + CDSTestUtils.checkDump(out); + pb = ProcessTools.createJavaProcessBuilder(true, "-XX:SharedArchiveFile=./SharedArchiveFile.jsa", "-Xshare:on", "-version"); From e1071d80bd1532581b5314f6e5018319aadee7b6 Mon Sep 17 00:00:00 2001 From: Sandhya Viswanathan Date: Thu, 3 Jan 2019 14:55:13 -0800 Subject: [PATCH 07/22] 8215888: Register to register spill may use AVX 512 move instruction on unsupported platform Reviewed-by: vlivanov, thartmann --- src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp | 4 ++-- src/hotspot/cpu/x86/x86.ad | 24 ++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp index a95bf5daf44..7894552f67f 100644 --- a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp @@ -649,7 +649,7 @@ void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_cod case T_FLOAT: { if (dest->is_single_xmm()) { - if (LP64_ONLY(UseAVX < 2 &&) c->is_zero_float()) { + if (LP64_ONLY(UseAVX <= 2 &&) c->is_zero_float()) { __ xorps(dest->as_xmm_float_reg(), dest->as_xmm_float_reg()); } else { __ movflt(dest->as_xmm_float_reg(), @@ -671,7 +671,7 @@ void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_cod case T_DOUBLE: { if (dest->is_double_xmm()) { - if (LP64_ONLY(UseAVX < 2 &&) c->is_zero_double()) { + if (LP64_ONLY(UseAVX <= 2 &&) c->is_zero_double()) { __ xorpd(dest->as_xmm_double_reg(), dest->as_xmm_double_reg()); } else { __ movdbl(dest->as_xmm_double_reg(), diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad index 6e52124df10..0850bec9a45 100644 --- a/src/hotspot/cpu/x86/x86.ad +++ b/src/hotspot/cpu/x86/x86.ad @@ -2924,11 +2924,11 @@ instruct MoveVecX2Leg(legVecX dst, vecX src) %{ match(Set dst src); format %{ "movdqu $dst,$src\t! load vector (16 bytes)" %} ins_encode %{ - if (UseAVX < 2 || VM_Version::supports_avx512vl()) { - __ movdqu($dst$$XMMRegister, $src$$XMMRegister); - } else { + if (UseAVX > 2 && !VM_Version::supports_avx512vl()) { int vector_len = 2; __ evmovdquq($dst$$XMMRegister, $src$$XMMRegister, vector_len); + } else { + __ movdqu($dst$$XMMRegister, $src$$XMMRegister); } %} ins_pipe( fpu_reg_reg ); @@ -2939,11 +2939,11 @@ instruct MoveLeg2VecX(vecX dst, legVecX src) %{ match(Set dst src); format %{ "movdqu $dst,$src\t! load vector (16 bytes)" %} ins_encode %{ - if (UseAVX < 2 || VM_Version::supports_avx512vl()) { - __ movdqu($dst$$XMMRegister, $src$$XMMRegister); - } else { + if (UseAVX > 2 && !VM_Version::supports_avx512vl()) { int vector_len = 2; __ evmovdquq($dst$$XMMRegister, $src$$XMMRegister, vector_len); + } else { + __ movdqu($dst$$XMMRegister, $src$$XMMRegister); } %} ins_pipe( fpu_reg_reg ); @@ -2966,11 +2966,11 @@ instruct MoveVecY2Leg(legVecY dst, vecY src) %{ match(Set dst src); format %{ "vmovdqu $dst,$src\t! load vector (32 bytes)" %} ins_encode %{ - if (UseAVX < 2 || VM_Version::supports_avx512vl()) { - __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); - } else { + if (UseAVX > 2 && !VM_Version::supports_avx512vl()) { int vector_len = 2; __ evmovdquq($dst$$XMMRegister, $src$$XMMRegister, vector_len); + } else { + __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); } %} ins_pipe( fpu_reg_reg ); @@ -2981,11 +2981,11 @@ instruct MoveLeg2VecY(vecY dst, legVecY src) %{ match(Set dst src); format %{ "vmovdqu $dst,$src\t! load vector (32 bytes)" %} ins_encode %{ - if (UseAVX < 2 || VM_Version::supports_avx512vl()) { - __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); - } else { + if (UseAVX > 2 && !VM_Version::supports_avx512vl()) { int vector_len = 2; __ evmovdquq($dst$$XMMRegister, $src$$XMMRegister, vector_len); + } else { + __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); } %} ins_pipe( fpu_reg_reg ); From 19507d7ff7c9b0950a0109da930a7a1b9de1669f Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Fri, 4 Jan 2019 11:00:29 +0100 Subject: [PATCH 08/22] 8216021: RunTest.gmk might set concurrency level to 1 on Windows Reviewed-by: ctornqvi, tbell --- make/RunTestsPrebuilt.gmk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/make/RunTestsPrebuilt.gmk b/make/RunTestsPrebuilt.gmk index 9d7cba23e63..3ab849ad64e 100644 --- a/make/RunTestsPrebuilt.gmk +++ b/make/RunTestsPrebuilt.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2017, 2019, 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 @@ -237,7 +237,8 @@ else ifeq ($(OPENJDK_TARGET_OS), solaris) else ifeq ($(OPENJDK_TARGET_OS), windows) NUM_CORES := $(NUMBER_OF_PROCESSORS) MEMORY_SIZE := $(shell \ - $(EXPR) `wmic computersystem get totalphysicalmemory -value | $(GREP) = \ + $(EXPR) `wmic computersystem get totalphysicalmemory -value \ + | $(GREP) = | $(SED) 's/\\r//g' \ | $(CUT) -d "=" -f 2-` / 1024 / 1024 \ ) endif From db1518dae2f688fc0634bf3a3cf5de4649bbd8f6 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Fri, 4 Jan 2019 17:46:56 +0100 Subject: [PATCH 09/22] 8215962: Support ThreadPriorityPolicy mode 1 for non-root users on linux/bsd Reviewed-by: dcubed, dholmes --- src/hotspot/os/bsd/os_bsd.cpp | 14 +++++++------- src/hotspot/os/linux/os_linux.cpp | 13 ++++++------- src/hotspot/share/runtime/globals.hpp | 3 ++- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp index 5c59dcdd02f..fd007ae527e 100644 --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2019, 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 @@ -2256,7 +2256,8 @@ void os::naked_yield() { // not the entire user process, and user level threads are 1:1 mapped to kernel // threads. It has always been the case, but could change in the future. For // this reason, the code should not be used as default (ThreadPriorityPolicy=0). -// It is only used when ThreadPriorityPolicy=1 and requires root privilege. +// It is only used when ThreadPriorityPolicy=1 and may require system level permission +// (e.g., root privilege or CAP_SYS_NICE capability). #if !defined(__APPLE__) int os::java_to_os_priority[CriticalPriority + 1] = { @@ -2303,14 +2304,12 @@ int os::java_to_os_priority[CriticalPriority + 1] = { static int prio_init() { if (ThreadPriorityPolicy == 1) { - // Only root can raise thread priority. Don't allow ThreadPriorityPolicy=1 - // if effective uid is not root. Perhaps, a more elegant way of doing - // this is to test CAP_SYS_NICE capability, but that will require libcap.so if (geteuid() != 0) { if (!FLAG_IS_DEFAULT(ThreadPriorityPolicy)) { - warning("-XX:ThreadPriorityPolicy requires root privilege on Bsd"); + warning("-XX:ThreadPriorityPolicy=1 may require system level permission, " \ + "e.g., being the root user. If the necessary permission is not " \ + "possessed, changes to priority will be silently ignored."); } - ThreadPriorityPolicy = 0; } } if (UseCriticalJavaThreadPriority) { @@ -2327,6 +2326,7 @@ OSReturn os::set_native_priority(Thread* thread, int newpri) { return OS_OK; #elif defined(__FreeBSD__) int ret = pthread_setprio(thread->osthread()->pthread_id(), newpri); + return (ret == 0) ? OS_OK : OS_ERR; #elif defined(__APPLE__) || defined(__NetBSD__) struct sched_param sp; int policy; diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 079ed8943af..17a75bd458e 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2019, 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 @@ -4076,7 +4076,8 @@ void os::naked_yield() { // not the entire user process, and user level threads are 1:1 mapped to kernel // threads. It has always been the case, but could change in the future. For // this reason, the code should not be used as default (ThreadPriorityPolicy=0). -// It is only used when ThreadPriorityPolicy=1 and requires root privilege. +// It is only used when ThreadPriorityPolicy=1 and may require system level permission +// (e.g., root privilege or CAP_SYS_NICE capability). int os::java_to_os_priority[CriticalPriority + 1] = { 19, // 0 Entry should never be used @@ -4100,14 +4101,12 @@ int os::java_to_os_priority[CriticalPriority + 1] = { static int prio_init() { if (ThreadPriorityPolicy == 1) { - // Only root can raise thread priority. Don't allow ThreadPriorityPolicy=1 - // if effective uid is not root. Perhaps, a more elegant way of doing - // this is to test CAP_SYS_NICE capability, but that will require libcap.so if (geteuid() != 0) { if (!FLAG_IS_DEFAULT(ThreadPriorityPolicy)) { - warning("-XX:ThreadPriorityPolicy requires root privilege on Linux"); + warning("-XX:ThreadPriorityPolicy=1 may require system level permission, " \ + "e.g., being the root user. If the necessary permission is not " \ + "possessed, changes to priority will be silently ignored."); } - ThreadPriorityPolicy = 0; } } if (UseCriticalJavaThreadPriority) { diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index ede99612e3e..fe97ddac760 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -2049,7 +2049,8 @@ define_pd_global(uint64_t,MaxRAM, 1ULL*G); " to higher native thread priorities. This policy should be "\ " used with care, as sometimes it can cause performance "\ " degradation in the application and/or the entire system. On "\ - " Linux this policy requires root privilege.") \ + " Linux/BSD/macOS this policy requires root privilege or an "\ + " extended capability.") \ range(0, 1) \ \ product(bool, ThreadPriorityVerbose, false, \ From 912b13fdddb5aafe166a3ea58418852138bc2f90 Mon Sep 17 00:00:00 2001 From: Mikhailo Seledtsov Date: Fri, 4 Jan 2019 15:17:40 -0800 Subject: [PATCH 10/22] 8215583: Exclude runtime/handshake/HandshakeWalkSuspendExitTest.java Added test to problem list Reviewed-by: iignatyev --- test/hotspot/jtreg/ProblemList.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index 1b68703e0f0..a49c474b424 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -85,6 +85,7 @@ runtime/appcds/javaldr/GCSharedStringsDuringDump.java 8208778 macosx-x64 runtime/appcds/javaldr/GCDuringDump.java 8208778 macosx-x64 runtime/appcds/jigsaw/classpathtests/EmptyClassInBootClassPath.java 8213299 generic-all runtime/CompressedOops/UseCompressedOops.java 8079353 generic-all +runtime/handshake/HandshakeWalkSuspendExitTest.java 8214174 generic-all runtime/RedefineTests/RedefineRunningMethods.java 8208778 macosx-x64 runtime/SharedArchiveFile/SASymbolTableTest.java 8193639 solaris-all From 7487daf2118af8789fcde211699bbabbeda74883 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Mon, 7 Jan 2019 10:00:41 +0100 Subject: [PATCH 11/22] 8215400: Warn on usage of trampolines with gcc Reviewed-by: tbell, kbarrett --- make/autoconf/flags-cflags.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index 76101ccbe53..de3d946acfb 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -183,7 +183,8 @@ AC_DEFUN([FLAGS_SETUP_WARNINGS], # Additional warnings that are not activated by -Wall and -Wextra WARNINGS_ENABLE_ADDITIONAL="-Wpointer-arith -Wsign-compare \ - -Wunused-function -Wundef -Wunused-value -Wreturn-type" + -Wunused-function -Wundef -Wunused-value -Wreturn-type \ + -Wtrampolines" WARNINGS_ENABLE_ADDITIONAL_CXX="-Woverloaded-virtual -Wreorder" WARNINGS_ENABLE_ALL_CFLAGS="-Wall -Wextra -Wformat=2 $WARNINGS_ENABLE_ADDITIONAL" WARNINGS_ENABLE_ALL_CXXFLAGS="$WARNINGS_ENABLE_ALL_CFLAGS $WARNINGS_ENABLE_ADDITIONAL_CXX" From c6c604784a4c33c2f1ba22d0f5f1f503067c3d1e Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Mon, 7 Jan 2019 10:21:43 +0100 Subject: [PATCH 12/22] 8216197: Remove unused new_hash methods Reviewed-by: kbarrett, dholmes --- src/hotspot/share/oops/metadata.hpp | 5 +---- src/hotspot/share/oops/oop.cpp | 17 +---------------- src/hotspot/share/oops/oop.hpp | 5 +---- src/hotspot/share/oops/symbol.cpp | 9 +-------- src/hotspot/share/oops/symbol.hpp | 5 +---- 5 files changed, 5 insertions(+), 36 deletions(-) diff --git a/src/hotspot/share/oops/metadata.hpp b/src/hotspot/share/oops/metadata.hpp index c511b4a035a..8acdd88c9ae 100644 --- a/src/hotspot/share/oops/metadata.hpp +++ b/src/hotspot/share/oops/metadata.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2019, 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 @@ -39,9 +39,6 @@ class Metadata : public MetaspaceObj { int identity_hash() { return (int)(uintptr_t)this; } - // Rehashing support for tables containing pointers to this - unsigned int new_hash(juint seed) { ShouldNotReachHere(); return 0; } - virtual bool is_metadata() const volatile { return true; } virtual bool is_klass() const volatile { return false; } virtual bool is_method() const volatile { return false; } diff --git a/src/hotspot/share/oops/oop.cpp b/src/hotspot/share/oops/oop.cpp index eda422cb305..ab0a89dce2a 100644 --- a/src/hotspot/share/oops/oop.cpp +++ b/src/hotspot/share/oops/oop.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -97,21 +97,6 @@ intptr_t oopDesc::slow_identity_hash() { return ObjectSynchronizer::identity_hash_value_for(object); } -// When String table needs to rehash -unsigned int oopDesc::new_hash(juint seed) { - EXCEPTION_MARK; - ResourceMark rm; - int length; - jchar* chars = java_lang_String::as_unicode_string(this, length, THREAD); - if (chars != NULL) { - // Use alternate hashing algorithm on the string - return AltHashing::murmur3_32(seed, chars, length); - } else { - vm_exit_out_of_memory(length, OOM_MALLOC_ERROR, "unable to create Unicode strings for String table rehash"); - return 0; - } -} - // used only for asserts and guarantees bool oopDesc::is_oop(oop obj, bool ignore_mark_word) { if (!Universe::heap()->is_oop(obj)) { diff --git a/src/hotspot/share/oops/oop.hpp b/src/hotspot/share/oops/oop.hpp index f673c98b452..f8c996d9030 100644 --- a/src/hotspot/share/oops/oop.hpp +++ b/src/hotspot/share/oops/oop.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -308,9 +308,6 @@ class oopDesc { inline intptr_t identity_hash(); intptr_t slow_identity_hash(); - // Alternate hashing code if string table is rehashed - unsigned int new_hash(juint seed); - // marks are forwarded to stack when object is locked inline bool has_displaced_mark_raw() const; inline markOop displaced_mark_raw() const; diff --git a/src/hotspot/share/oops/symbol.cpp b/src/hotspot/share/oops/symbol.cpp index 800a652712c..94218c05475 100644 --- a/src/hotspot/share/oops/symbol.cpp +++ b/src/hotspot/share/oops/symbol.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -212,13 +212,6 @@ const char* Symbol::as_klass_external_name() const { return str; } -// Alternate hashing for unbalanced symbol tables. -unsigned int Symbol::new_hash(juint seed) { - ResourceMark rm; - // Use alternate hashing algorithm on this symbol. - return AltHashing::murmur3_32(seed, (const jbyte*)as_C_string(), utf8_length()); -} - // Increment refcount while checking for zero. If the Symbol's refcount becomes zero // a thread could be concurrently removing the Symbol. This is used during SymbolTable // lookup to avoid reviving a dead Symbol. diff --git a/src/hotspot/share/oops/symbol.hpp b/src/hotspot/share/oops/symbol.hpp index ac74c674af8..20b58bfc6a7 100644 --- a/src/hotspot/share/oops/symbol.hpp +++ b/src/hotspot/share/oops/symbol.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -164,9 +164,6 @@ class Symbol : public MetaspaceObj { ((addr_bits ^ (length() << 8) ^ (( _body[0] << 8) | _body[1])) << 16); } - // For symbol table alternate hashing - unsigned int new_hash(juint seed); - // Reference counting. See comments above this class for when to use. int refcount() const { return extract_refcount(_length_and_refcount); } bool try_increment_refcount(); From 16851a2846b02f5ccc493195920e88f57ef001f4 Mon Sep 17 00:00:00 2001 From: Jesper Wilhelmsson Date: Mon, 7 Jan 2019 13:04:32 +0100 Subject: [PATCH 13/22] 8216266: ProblemList PeelingZeroTripCount.java Reviewed-by: thartmann, roland --- test/hotspot/jtreg/ProblemList.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index a49c474b424..4fff8dc6453 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -61,6 +61,8 @@ compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java 8190680 generic-all compiler/runtime/Test8168712.java 8211769,8211771 generic-ppc64,generic-ppc64le,linux-s390x +compiler/loopopts/PeelingZeroTripCount.java 8216135 generic-all + ############################################################################# # :hotspot_gc From 0007eebae3e926425557d3bf729adeaa09494396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20=C3=96sterlund?= Date: Mon, 7 Jan 2019 12:22:31 +0100 Subject: [PATCH 14/22] 8215773: applications/kitchensink/Kitchensink.java crash with "assert(ZAddress::is_marked(addr)) failed: Should be marked" Reviewed-by: coleenp, pliden --- .../share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.cpp index 5e259992f78..ca2c04b29fc 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.cpp @@ -164,7 +164,7 @@ bool JfrSymbolId::is_unsafe_anonymous_klass(const Klass* k) { uintptr_t JfrSymbolId::unsafe_anonymous_klass_name_hash_code(const InstanceKlass* ik) { assert(ik != NULL, "invariant"); assert(ik->is_unsafe_anonymous(), "invariant"); - const oop mirror = ik->java_mirror(); + const oop mirror = ik->java_mirror_no_keepalive(); assert(mirror != NULL, "invariant"); return (uintptr_t)mirror->identity_hash(); } @@ -174,7 +174,7 @@ const char* JfrSymbolId::create_unsafe_anonymous_klass_symbol(const InstanceKlas assert(ik->is_unsafe_anonymous(), "invariant"); assert(0 == hashcode, "invariant"); char* anonymous_symbol = NULL; - const oop mirror = ik->java_mirror(); + const oop mirror = ik->java_mirror_no_keepalive(); assert(mirror != NULL, "invariant"); char hash_buf[40]; hashcode = unsafe_anonymous_klass_name_hash_code(ik); From 91a88da167f3b404a3d39c00af0e56aa77eb9983 Mon Sep 17 00:00:00 2001 From: Andrew Luo Date: Mon, 7 Jan 2019 04:56:59 -0800 Subject: [PATCH 15/22] 8216267: Fix hotspot-ide-project target on WSL Reviewed-by: erikj --- make/autoconf/spec.gmk.in | 3 ++- make/hotspot/ide/CreateVSProject.gmk | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in index 1f2cf97847c..b6d5a126d02 100644 --- a/make/autoconf/spec.gmk.in +++ b/make/autoconf/spec.gmk.in @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2019, 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 @@ -729,6 +729,7 @@ MT:=@FIXPATH@ @MT@ RC:=@FIXPATH@ @RC@ DUMPBIN:=@FIXPATH@ @DUMPBIN@ CYGPATH:=@CYGPATH@ +WSLPATH:=@WSLPATH@ LDD:=@LDD@ OTOOL:=@OTOOL@ READELF:=@READELF@ diff --git a/make/hotspot/ide/CreateVSProject.gmk b/make/hotspot/ide/CreateVSProject.gmk index 2040e3a1d37..55188b95c1f 100644 --- a/make/hotspot/ide/CreateVSProject.gmk +++ b/make/hotspot/ide/CreateVSProject.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2019, 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 @@ -46,8 +46,17 @@ ifeq ($(OPENJDK_TARGET_OS), windows) # Helper macro to convert a unix path to a Windows path, suitable for # inclusion in a command line. - FixPath = \ - $(strip $(subst \,\\,$(shell $(CYGPATH) -w $1))) + ifeq ($(OPENJDK_BUILD_OS_ENV), windows.cygwin) + FixPath = \ + $(strip $(subst \,\\,$(shell $(CYGPATH) -w $1))) + FixLinuxExecutable = \ + $(call FixPath, $1) + else ifeq ($(OPENJDK_BUILD_OS_ENV), windows.wsl) + FixPath = \ + $(strip $(subst \,\\,$(shell $(WSLPATH) -w $1))) + FixLinuxExecutable = \ + "%windir%\Sysnative\wsl.exe $1" + endif JVM_DEFINES_client := $(patsubst -D%,%, $(filter -D%, $(JVM_CFLAGS))) EXTRACTED_DEFINES_client := $(addprefix -define , $(JVM_DEFINES_client)) @@ -121,7 +130,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) -platformName x64 \ -buildBase $(call FixPath, $(IDE_OUTPUTDIR)/vs-output) \ -buildSpace $(call FixPath, $(IDE_OUTPUTDIR)) \ - -makeBinary $(call FixPath, $(MAKE)) \ + -makeBinary $(call FixLinuxExecutable, $(MAKE)) \ -makeOutput $(call FixPath, $(JDK_OUTPUTDIR)/bin/server) \ -absoluteInclude $(call FixPath, $(HOTSPOT_OUTPUTDIR)/variant-server/gensrc) \ -absoluteSrcInclude $(call FixPath, $(HOTSPOT_OUTPUTDIR)/variant-server/gensrc) \ From eefbe6709f3c10f9b081cf031ee906aaf66ba909 Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Mon, 7 Jan 2019 09:29:31 -0500 Subject: [PATCH 16/22] 8216134: (process) ProcessBuilder startPipeline does not hide piped streams Reviewed-by: lancea, bchristi, sgroeger --- .../classes/java/lang/ProcessImpl.java | 11 ++++++-- .../lang/ProcessBuilder/PipelineTest.java | 28 ++++++++++++------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/java.base/windows/classes/java/lang/ProcessImpl.java b/src/java.base/windows/classes/java/lang/ProcessImpl.java index b2208faf849..5bbaa853b19 100644 --- a/src/java.base/windows/classes/java/lang/ProcessImpl.java +++ b/src/java.base/windows/classes/java/lang/ProcessImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2019, 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 @@ -106,6 +106,7 @@ final class ProcessImpl extends Process { FileOutputStream f2 = null; try { + boolean forceNullOutputStream = false; long[] stdHandles; if (redirects == null) { stdHandles = new long[] { -1L, -1L, -1L }; @@ -129,6 +130,9 @@ final class ProcessImpl extends Process { stdHandles[1] = fdAccess.getHandle(FileDescriptor.out); } else if (redirects[1] instanceof ProcessBuilder.RedirectPipeImpl) { stdHandles[1] = fdAccess.getHandle(((ProcessBuilder.RedirectPipeImpl) redirects[1]).getFd()); + // Force getInputStream to return a null stream, + // the handle is directly assigned to the next process. + forceNullOutputStream = true; } else { f1 = newFileOutputStream(redirects[1].file(), redirects[1].append()); @@ -149,7 +153,7 @@ final class ProcessImpl extends Process { } Process p = new ProcessImpl(cmdarray, envblock, dir, - stdHandles, redirectErrorStream); + stdHandles, forceNullOutputStream, redirectErrorStream); if (redirects != null) { // Copy the handles's if they are to be redirected to another process if (stdHandles[0] >= 0 @@ -349,6 +353,7 @@ final class ProcessImpl extends Process { final String envblock, final String path, final long[] stdHandles, + boolean forceNullOutputStream, final boolean redirectErrorStream) throws IOException { @@ -437,7 +442,7 @@ final class ProcessImpl extends Process { new FileOutputStream(stdin_fd)); } - if (stdHandles[1] == -1L) + if (stdHandles[1] == -1L || forceNullOutputStream) stdout_stream = ProcessBuilder.NullInputStream.INSTANCE; else { FileDescriptor stdout_fd = new FileDescriptor(); diff --git a/test/jdk/java/lang/ProcessBuilder/PipelineTest.java b/test/jdk/java/lang/ProcessBuilder/PipelineTest.java index b2c1bd72ead..47878dc50ba 100644 --- a/test/jdk/java/lang/ProcessBuilder/PipelineTest.java +++ b/test/jdk/java/lang/ProcessBuilder/PipelineTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -34,6 +34,8 @@ import java.util.List; /* * @test PipelineTest + * @bug 8211844 + * @summary Tests for ProcessBuilder.startPipeline */ public class PipelineTest { @@ -170,7 +172,7 @@ public class PipelineTest { static void verify(String input, String expected, List builders) throws IOException { File infile = new File("test.in"); File outfile = new File("test.out"); - setFileContents(infile, expected); + setFileContents(infile, input); for (int i = 0; i < builders.size(); i++) { ProcessBuilder b = builders.get(i); if (i == 0) { @@ -184,8 +186,8 @@ public class PipelineTest { verifyProcesses(processes); waitForAll(processes); String result = fileContents(outfile); - System.out.printf(" in: %s%nout: %s%n", input, expected); - check(result.equals(expected), "result not as expected"); + check(result.equals(expected), + "result not as expected: " + result + ", expected: " + expected); } /** @@ -219,11 +221,14 @@ public class PipelineTest { static void verifyProcesses(List processes) { for (int i = 0; i < processes.size(); i++) { Process p = processes.get(i); + if (i != 0) { verifyNullStream(p.getOutputStream(), "getOutputStream"); } - if (i == processes.size() - 1) { + if (i <= processes.size() - 1) { verifyNullStream(p.getInputStream(), "getInputStream"); + } + if (i == processes.size() - 1) { verifyNullStream(p.getErrorStream(), "getErrorStream"); } } @@ -232,7 +237,7 @@ public class PipelineTest { static void verifyNullStream(OutputStream s, String msg) { try { s.write(0xff); - fail("Stream should have been a NullStream" + msg); + fail("Stream should have been a NullStream: " + msg); } catch (IOException ie) { // expected } @@ -241,7 +246,7 @@ public class PipelineTest { static void verifyNullStream(InputStream s, String msg) { try { int len = s.read(); - check(len == -1, "Stream should have been a NullStream" + msg); + check(len == -1, "Stream should have been a NullStream: " + msg); } catch (IOException ie) { // expected } @@ -271,9 +276,12 @@ public class PipelineTest { //--------------------- Infrastructure --------------------------- static volatile int passed = 0, failed = 0; static void pass() {passed++;} - static void fail() {failed++; Thread.dumpStack();} - static void fail(String msg) {System.err.println(msg); fail();} - static void unexpected(Throwable t) {failed++; t.printStackTrace();} + static void fail() {failed++; new Exception("Stack trace").printStackTrace(System.out);} + static void fail(String msg) { + System.out.println(msg); failed++; + new Exception("Stack trace: " + msg).printStackTrace(System.out); + } + static void unexpected(Throwable t) {failed++; t.printStackTrace(System.out);} static void check(boolean cond) {if (cond) pass(); else fail();} static void check(boolean cond, String m) {if (cond) pass(); else fail(m);} static void equal(Object x, Object y) { From 360f1421e8b67b8cf22beae91986ffec11a4a28b Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Mon, 7 Jan 2019 17:09:17 +0100 Subject: [PATCH 17/22] 8216275: Disable annotation processing lint warnings when building microbenchmarks Reviewed-by: erikj, ecaspole --- make/test/BuildMicrobenchmark.gmk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/make/test/BuildMicrobenchmark.gmk b/make/test/BuildMicrobenchmark.gmk index aeec1b0f9e4..cebf444cafe 100644 --- a/make/test/BuildMicrobenchmark.gmk +++ b/make/test/BuildMicrobenchmark.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2019, 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 @@ -78,7 +78,7 @@ $(eval $(call SetupJavaCompiler, MICROBENCHMARK_JAVA_COMPILER, \ # Build microbenchmark suite for the current JDK $(eval $(call SetupJavaCompilation, BUILD_JDK_MICROBENCHMARK, \ SETUP := MICROBENCHMARK_JAVA_COMPILER, \ - ADD_JAVAC_FLAGS := -cp $(MICROBENCHMARK_CLASSPATH) -Xlint -Werror, \ + ADD_JAVAC_FLAGS := -cp $(MICROBENCHMARK_CLASSPATH) -Xlint -Xlint:-processing -Werror, \ SRC := $(MICROBENCHMARK_SRC), \ BIN := $(MICROBENCHMARK_CLASSES), \ )) From fc741865bd2faa2432436f8e17ce3fdc04e545fe Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Mon, 7 Jan 2019 14:15:00 -0500 Subject: [PATCH 18/22] 8216205: Java API documentation formatting error in System.getEnv Reviewed-by: lancea, bchristi, alanb --- src/java.base/share/classes/java/lang/System.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/java.base/share/classes/java/lang/System.java b/src/java.base/share/classes/java/lang/System.java index 42b97d670fe..9c51536bed1 100644 --- a/src/java.base/share/classes/java/lang/System.java +++ b/src/java.base/share/classes/java/lang/System.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2019, 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 @@ -984,7 +984,7 @@ public final class System { *

If a security manager exists, its * {@link SecurityManager#checkPermission checkPermission} * method is called with a - * {@code {@link RuntimePermission}("getenv."+name)} + * {@link RuntimePermission RuntimePermission("getenv."+name)} * permission. This may result in a {@link SecurityException} * being thrown. If no exception is thrown the value of the * variable {@code name} is returned. @@ -1055,7 +1055,7 @@ public final class System { *

If a security manager exists, its * {@link SecurityManager#checkPermission checkPermission} * method is called with a - * {@code {@link RuntimePermission}("getenv.*")} permission. + * {@link RuntimePermission RuntimePermission("getenv.*")} permission. * This may result in a {@link SecurityException} being thrown. * *

When passing information to a Java subprocess, From 6a3c8e4c1041cbf885b8a86e6acfca33846f3abd Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Mon, 7 Jan 2019 15:20:23 -0500 Subject: [PATCH 19/22] 8215985: ZGC: Simplify reference processing in light of JDK-8175797 Only self-loop 'next' field for FinalReference deactivation. Reviewed-by: eosterlund, pliden --- .../share/gc/z/zReferenceProcessor.cpp | 41 ++++++++----------- .../share/gc/z/zReferenceProcessor.hpp | 5 +-- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/src/hotspot/share/gc/z/zReferenceProcessor.cpp b/src/hotspot/share/gc/z/zReferenceProcessor.cpp index 29ef2ea765b..d0c430de972 100644 --- a/src/hotspot/share/gc/z/zReferenceProcessor.cpp +++ b/src/hotspot/share/gc/z/zReferenceProcessor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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,9 +68,9 @@ void ZReferenceProcessor::update_soft_reference_clock() const { java_lang_ref_SoftReference::set_clock(now); } -bool ZReferenceProcessor::is_reference_inactive(oop obj) const { - // A non-null next field means the reference is inactive - return java_lang_ref_Reference::next(obj) != NULL; +bool ZReferenceProcessor::is_inactive_final_reference(oop obj, ReferenceType type) const { + // A non-null next field for a FinalReference means the reference is inactive. + return (type == REF_FINAL) && (java_lang_ref_Reference::next(obj) != NULL); } ReferenceType ZReferenceProcessor::reference_type(oop obj) const { @@ -167,11 +167,6 @@ bool ZReferenceProcessor::should_mark_referent(ReferenceType type) const { return type == REF_FINAL; } -bool ZReferenceProcessor::should_clear_referent(ReferenceType type) const { - // Referents that were not marked must be cleared - return !should_mark_referent(type); -} - void ZReferenceProcessor::keep_referent_alive(oop obj, ReferenceType type) const { volatile oop* const p = reference_referent_addr(obj); if (type == REF_PHANTOM) { @@ -192,8 +187,8 @@ bool ZReferenceProcessor::discover_reference(oop obj, ReferenceType type) { // Update statistics _encountered_count.get()[type]++; - if (is_reference_inactive(obj) || - is_referent_strongly_alive_or_null(obj, type) || + if (is_referent_strongly_alive_or_null(obj, type) || + is_inactive_final_reference(obj, type) || is_referent_softly_alive(obj, type)) { // Not discovered return false; @@ -242,23 +237,19 @@ oop* ZReferenceProcessor::keep(oop obj, ReferenceType type) { // Update statistics _enqueued_count.get()[type]++; - // Clear referent - if (should_clear_referent(type)) { + if (type != REF_FINAL) { + // Clear referent java_lang_ref_Reference::set_referent(obj, NULL); + } else { + // For a FinalReference, don't clear the referent, because it is + // needed for the finalize call. Instead, make the reference + // inactive by self-looping the 'next' field. FinalReference + // doesn't allow Reference.enqueue, so there's no race to worry + // about when setting 'next'. + assert(java_lang_ref_Reference::next(obj) == NULL, "enqueued FinalReference"); + java_lang_ref_Reference::set_next_raw(obj, obj); } - // Make reference inactive by self-looping the next field. We could be racing with a - // call to Reference.enqueue() from the application, which is why we are using a CAS - // to make sure we change the next field only if it is NULL. A failing CAS means the - // reference has already been enqueued. However, we don't check the result of the CAS, - // since we still have no option other than keeping the reference on the pending list. - // It's ok to have the reference both on the pending list and enqueued at the same - // time (the pending list is linked through the discovered field, while the reference - // queue is linked through the next field). When the ReferenceHandler thread later - // calls Reference.enqueue() we detect that it has already been enqueued and drop it. - oop* const next_addr = (oop*)java_lang_ref_Reference::next_addr_raw(obj); - Atomic::cmpxchg(obj, next_addr, oop(NULL)); - // Return next in list return (oop*)java_lang_ref_Reference::discovered_addr_raw(obj); } diff --git a/src/hotspot/share/gc/z/zReferenceProcessor.hpp b/src/hotspot/share/gc/z/zReferenceProcessor.hpp index de2e9f351d5..14041cc4061 100644 --- a/src/hotspot/share/gc/z/zReferenceProcessor.hpp +++ b/src/hotspot/share/gc/z/zReferenceProcessor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, 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 @@ -52,12 +52,11 @@ private: const char* reference_type_name(ReferenceType type) const; volatile oop* reference_referent_addr(oop obj) const; oop reference_referent(oop obj) const; - bool is_reference_inactive(oop obj) const; + bool is_inactive_final_reference(oop obj, ReferenceType type) const; bool is_referent_strongly_alive_or_null(oop obj, ReferenceType type) const; bool is_referent_softly_alive(oop obj, ReferenceType type) const; bool should_drop_reference(oop obj, ReferenceType type) const; bool should_mark_referent(ReferenceType type) const; - bool should_clear_referent(ReferenceType type) const; void keep_referent_alive(oop obj, ReferenceType type) const; void discover(oop obj, ReferenceType type); From abbabdbeb3a3a2d0129fc516725d851f1a7fb7cb Mon Sep 17 00:00:00 2001 From: Yasumasa Suenaga Date: Tue, 8 Jan 2019 10:35:06 +0900 Subject: [PATCH 20/22] 8216154: C4819 warnings at HotSpot sources on Windows Reviewed-by: kbarrett, tschatzl --- src/hotspot/share/code/codeHeapState.cpp | 4 ++-- src/hotspot/share/compiler/methodMatcher.cpp | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/code/codeHeapState.cpp b/src/hotspot/share/code/codeHeapState.cpp index 8d03c8afa0c..c21235ea10f 100644 --- a/src/hotspot/share/code/codeHeapState.cpp +++ b/src/hotspot/share/code/codeHeapState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -1976,7 +1976,7 @@ void CodeHeapState::print_age(outputStream* out, CodeHeap* heap) { ast->print_cr(" The age of a compiled method in the CodeHeap is not available as a\n" " time stamp. Instead, a relative age is deducted from the method's compilation ID.\n" " Age information is available for tier1 and tier2 methods only. There is no\n" - " age information for stubs and blobs, because they have no compilation ID assigned.\n" + " age information for stubs and blobs, because they have no compilation ID assigned.\n" " Information for the youngest method (highest ID) in the granule is printed.\n" " Refer to the legend to learn how method age is mapped to the displayed digit."); print_age_legend(ast); diff --git a/src/hotspot/share/compiler/methodMatcher.cpp b/src/hotspot/share/compiler/methodMatcher.cpp index ac78ce77da9..8cd2b922081 100644 --- a/src/hotspot/share/compiler/methodMatcher.cpp +++ b/src/hotspot/share/compiler/methodMatcher.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, 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 @@ -237,6 +237,12 @@ void skip_leading_spaces(char*& line, int* total_bytes_read ) { } } +#ifdef _MSC_VER +#pragma warning(push) +// warning C4189: The file contains a character that cannot be represented +// in the current code page +#pragma warning(disable : 4819) +#endif void MethodMatcher::parse_method_pattern(char*& line, const char*& error_msg, MethodMatcher* matcher) { MethodMatcher::Mode c_match; MethodMatcher::Mode m_match; @@ -306,6 +312,9 @@ void MethodMatcher::parse_method_pattern(char*& line, const char*& error_msg, Me error_msg = "Could not parse method pattern"; } } +#ifdef _MSC_VER +#pragma warning(pop) +#endif bool MethodMatcher::matches(const methodHandle& method) const { Symbol* class_name = method->method_holder()->name(); From b1a3c7d538bb37614c87d929dc90bc59ca34841e Mon Sep 17 00:00:00 2001 From: Dora Zhou Date: Mon, 7 Jan 2019 18:48:39 -0800 Subject: [PATCH 21/22] 8215913: [Test_bug]java/util/Locale/LocaleProvidersRun.java failed on de_DE and ja_JP locale Reviewed-by: naoto, rgoel, rriggs --- test/jdk/java/util/Locale/LocaleProviders.java | 18 +++++++++++------- .../java/util/Locale/LocaleProvidersRun.java | 6 +++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/test/jdk/java/util/Locale/LocaleProviders.java b/test/jdk/java/util/Locale/LocaleProviders.java index 230d11c320c..f256677b504 100644 --- a/test/jdk/java/util/Locale/LocaleProviders.java +++ b/test/jdk/java/util/Locale/LocaleProviders.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, 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 @@ -237,12 +237,16 @@ public class LocaleProviders { } static void bug8027289Test(String expectedCodePoint) { - char[] expectedSymbol = Character.toChars(Integer.valueOf(expectedCodePoint, 16)); - NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.CHINA); - char formatted = nf.format(7000).charAt(0); - System.out.println("returned: " + formatted + ", expected: " + expectedSymbol[0]); - if (formatted != expectedSymbol[0]) { - throw new RuntimeException("Unexpected Chinese currency symbol. returned: " + formatted + ", expected: " + expectedSymbol[0]); + if (System.getProperty("os.name").startsWith("Windows")) { + char[] expectedSymbol = Character.toChars(Integer.valueOf(expectedCodePoint, 16)); + NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.CHINA); + char formatted = nf.format(7000).charAt(0); + System.out.println("returned: " + formatted + ", expected: " + expectedSymbol[0]); + if (formatted != expectedSymbol[0]) { + throw new RuntimeException( + "Unexpected Chinese currency symbol. returned: " + + formatted + ", expected: " + expectedSymbol[0]); + } } } } diff --git a/test/jdk/java/util/Locale/LocaleProvidersRun.java b/test/jdk/java/util/Locale/LocaleProvidersRun.java index 6cb041847eb..958642c6dfe 100644 --- a/test/jdk/java/util/Locale/LocaleProvidersRun.java +++ b/test/jdk/java/util/Locale/LocaleProvidersRun.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @bug 6336885 7196799 7197573 7198834 8000245 8000615 8001440 8008577 * 8010666 8013086 8013233 8013903 8015960 8028771 8054482 8062006 - * 8150432 + * 8150432 8215913 * @summary tests for "java.locale.providers" system property * @library /test/lib * @build LocaleProviders @@ -143,7 +143,7 @@ public class LocaleProvidersRun { //testing 8027289 fix, if the platform format default is zh_CN // this assumes Windows' currency symbol for zh_CN is \u00A5, the yen // (yuan) sign. - if (!defLang.equals("en") && !defCtry.equals("CN")){ + if (defFmtLang.equals("zh") && defFmtCtry.equals("CN")) { testRun("JRE,HOST", "bug8027289Test", "FFE5", "", ""); testRun("COMPAT,HOST", "bug8027289Test", "FFE5", "", ""); testRun("HOST", "bug8027289Test", "00A5", "", ""); From 61c1c09d866bca8e86358ec0840ba02ce311a1c1 Mon Sep 17 00:00:00 2001 From: Priya Lakshmi Muthuswamy Date: Tue, 8 Jan 2019 11:16:32 +0530 Subject: [PATCH 22/22] 8214738: javadoc should honor styles in doc-files Reviewed-by: jjg --- .../com/sun/tools/doclint/HtmlTag.java | 2 + .../formats/html/DocFilesHandlerImpl.java | 132 ++++++++---------- .../formats/html/HtmlDocletWriter.java | 22 ++- .../doclets/formats/html/markup/Head.java | 5 +- .../doclet/testCopyFiles/TestCopyFiles.java | 25 +++- 5 files changed, 104 insertions(+), 82 deletions(-) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/doclint/HtmlTag.java b/src/jdk.compiler/share/classes/com/sun/tools/doclint/HtmlTag.java index 0dfe2a194ae..32bc9a3a1ea 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/doclint/HtmlTag.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/doclint/HtmlTag.java @@ -305,6 +305,8 @@ public enum HtmlTag { STRONG(BlockType.INLINE, EndKind.REQUIRED, EnumSet.of(Flag.EXPECT_CONTENT)), + STYLE(BlockType.OTHER, EndKind.REQUIRED), + SUB(BlockType.INLINE, EndKind.REQUIRED, EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)), diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java index 16f07e67229..b4280ad4252 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java @@ -31,6 +31,7 @@ import com.sun.source.doctree.DocTree; import com.sun.source.doctree.EndElementTree; import com.sun.source.doctree.StartElementTree; import com.sun.source.doctree.TextTree; +import com.sun.source.util.DocTreeFactory; import com.sun.source.util.SimpleDocTreeVisitor; import com.sun.tools.doclint.HtmlTag; import com.sun.tools.doclint.HtmlTag.Attr; @@ -43,6 +44,7 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; +import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; import jdk.javadoc.internal.doclets.toolkit.util.Utils; import javax.lang.model.element.Element; @@ -51,6 +53,7 @@ import javax.lang.model.element.PackageElement; import javax.tools.FileObject; import javax.tools.JavaFileManager.Location; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -140,13 +143,12 @@ public class DocFilesHandlerImpl implements DocFilesHandler { srcfile.getPath(), dstdir.getPath()); } else { if (Utils.toLowerCase(srcfile.getPath()).endsWith(".html")) { - if (handleHtmlFile(srcfile, dstDocPath)) { - continue; - } + handleHtmlFile(srcfile, dstDocPath); + } else { + configuration.messages.notice("doclet.Copying_File_0_To_Dir_1", + srcfile.getPath(), dstdir.getPath()); + destfile.copyFile(srcfile); } - configuration.messages.notice("doclet.Copying_File_0_To_Dir_1", - srcfile.getPath(), dstdir.getPath()); - destfile.copyFile(srcfile); } } else if (srcfile.isDirectory()) { if (configuration.copydocfilesubdirs @@ -158,19 +160,18 @@ public class DocFilesHandlerImpl implements DocFilesHandler { } } - private boolean handleHtmlFile(DocFile srcfile, DocPath dstPath) throws DocFileIOException { + private void handleHtmlFile(DocFile srcfile, DocPath dstPath) throws DocFileIOException { Utils utils = configuration.utils; FileObject fileObject = srcfile.getFileObject(); DocFileElement dfElement = new DocFileElement(element, fileObject); - if (shouldPassThrough(utils.getPreamble(dfElement))) { - return false; - } - DocPath dfilePath = dstPath.resolve(srcfile.getName()); HtmlDocletWriter docletWriter = new DocFileWriter(configuration, dfilePath, element); configuration.messages.notice("doclet.Generating_0", docletWriter.filename.getPath()); + List localTags = getLocalHeaderTags(utils.getPreamble(dfElement)); + Content localTagsContent = docletWriter.commentTagsToContent(null, dfElement, localTags, false); + String title = getWindowTitle(docletWriter, dfElement).trim(); HtmlTree htmlContent = docletWriter.getBody(true, title); docletWriter.addTop(htmlContent); @@ -193,70 +194,61 @@ public class DocFilesHandlerImpl implements DocFilesHandler { navBar.setUserFooter(docletWriter.getUserHeaderFooter(false)); htmlContent.addContent(navBar.getContent(false)); docletWriter.addBottom(htmlContent); - docletWriter.printHtmlDocument(Collections.emptyList(), false, htmlContent); - return true; + docletWriter.printHtmlDocument(Collections.emptyList(), false, localTagsContent, htmlContent); } - private boolean shouldPassThrough(List dtrees) { - SimpleDocTreeVisitor check = new SimpleDocTreeVisitor() { - @Override - public Boolean visitStartElement(StartElementTree node, Boolean p) { - if (Utils.toLowerCase(node.getName().toString()).equals((Attr.STYLE.getText()))) { - return true; - } - if (Utils.toLowerCase(node.getName().toString()).equals(HtmlTag.LINK.getText())) { - for (DocTree dt : node.getAttributes()) { - if (this.visit(dt, true)) - return true; - } - } - return false; - } - - @Override - public Boolean visitAttribute(AttributeTree node, Boolean p) { - if (p == null || p == false) { - return false; - } - if (Utils.toLowerCase(node.getName().toString()).equals("rel")) { - for (DocTree dt : node.getValue()) { - Boolean found = new SimpleDocTreeVisitor() { - - @Override - public Boolean visitText(TextTree node, ValueKind valueKind) { - switch (valueKind) { - case EMPTY: - return false; - default: - return Utils.toLowerCase(node.getBody()).equals("stylesheet"); - } - } - - @Override - protected Boolean defaultAction(DocTree node, ValueKind valueKind) { - return false; - } - - }.visit(dt, node.getValueKind()); - - if (found) - return true; - } - } - return false; - } - - @Override - protected Boolean defaultAction(DocTree node, Boolean p) { - return false; - } - }; + private List getLocalHeaderTags(List dtrees) { + List localTags = new ArrayList<>(); + DocTreeFactory docTreeFactory = configuration.docEnv.getDocTrees().getDocTreeFactory(); + boolean inHead = false; + boolean inTitle = false; + loop: for (DocTree dt : dtrees) { - if (check.visit(dt, false)) - return true; + switch (dt.getKind()) { + case START_ELEMENT: + StartElementTree startElem = (StartElementTree)dt; + switch (HtmlTag.get(startElem.getName())) { + case HEAD: + inHead = true; + break; + case META: + break; + case TITLE: + inTitle = true; + break; + default: + if (inHead) { + localTags.add(startElem); + localTags.add(docTreeFactory.newTextTree(DocletConstants.NL)); + } + } + break; + case END_ELEMENT: + EndElementTree endElem = (EndElementTree)dt; + switch (HtmlTag.get(endElem.getName())) { + case HEAD: + inHead = false; + break loop; + case TITLE: + inTitle = false; + break; + default: + if (inHead) { + localTags.add(endElem); + localTags.add(docTreeFactory.newTextTree(DocletConstants.NL)); + } + } + break; + case ENTITY: + case TEXT: + if (inHead && !inTitle) { + localTags.add(dt); + } + break; + } } - return false; + return localTags; } private String getWindowTitle(HtmlDocletWriter docletWriter, Element element) { diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java index 967f276b45c..e8f36e75837 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java @@ -427,7 +427,24 @@ public class HtmlDocletWriter { * @throws DocFileIOException if there is a problem writing the file */ public void printHtmlDocument(List metakeywords, boolean includeScript, - Content body) throws DocFileIOException { + Content body) throws DocFileIOException { + printHtmlDocument(metakeywords, includeScript, new ContentBuilder(), body); + } + + /** + * Generates the HTML document tree and prints it out. + * + * @param metakeywords Array of String keywords for META tag. Each element + * of the array is assigned to a separate META tag. + * Pass in null for no array + * @param includeScript true if printing windowtitle script + * false for files that appear in the left-hand frames + * @param extraContent any additional content to be included in the HEAD element + * @param body the body htmltree to be included in the document + * @throws DocFileIOException if there is a problem writing the file + */ + public void printHtmlDocument(List metakeywords, boolean includeScript, Content extraContent, + Content body) throws DocFileIOException { DocType htmlDocType = DocType.forVersion(configuration.htmlVersion); Content htmlComment = contents.newPage; Head head = new Head(path, configuration.htmlVersion, configuration.docletVersion) @@ -437,7 +454,8 @@ public class HtmlDocletWriter { .addKeywords(metakeywords) .setStylesheets(configuration.getMainStylesheet(), configuration.getAdditionalStylesheets()) .setUseModuleDirectories(configuration.useModuleDirectories) - .setIndex(configuration.createindex, mainBodyScript); + .setIndex(configuration.createindex, mainBodyScript) + .addContent(extraContent); Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), head.toContent(), body); HtmlDocument htmlDocument = new HtmlDocument(htmlDocType, htmlComment, htmlTree); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java index 525464a963e..3bd4ad4189b 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java @@ -254,10 +254,6 @@ public class Head { tree.addContent(HtmlTree.META("keywords", k)); } - for (Content c : extraContent) { - tree.addContent(c); - } - if (canonicalLink != null) { HtmlTree link = new HtmlTree(HtmlTag.LINK); link.addAttr(HtmlAttr.REL, "canonical"); @@ -267,6 +263,7 @@ public class Head { addStylesheets(tree); addScripts(tree); + extraContent.forEach(tree::addContent); return tree; } diff --git a/test/langtools/jdk/javadoc/doclet/testCopyFiles/TestCopyFiles.java b/test/langtools/jdk/javadoc/doclet/testCopyFiles/TestCopyFiles.java index 80909a50829..603021a532b 100644 --- a/test/langtools/jdk/javadoc/doclet/testCopyFiles/TestCopyFiles.java +++ b/test/langtools/jdk/javadoc/doclet/testCopyFiles/TestCopyFiles.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2019, 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,7 +23,7 @@ /* * @test - * @bug 8157349 8185985 8194953 + * @bug 8157349 8185985 8194953 8214738 * @summary test copy of doc-files, and its contents for HTML meta content. * @library ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -268,9 +268,22 @@ public class TestCopyFiles extends JavadocTester { "-sourcepath", testSrc("packages"), "p2"); checkExit(Exit.OK); - checkOutput("p2/doc-files/case1.html", true, "