# HG changeset patch # User mullan # Date 1476718364 0 # Node ID ce1843f66c0321be35cf81bd021095824c936730 # Parent 563c1d911dcba6e4f70cd41e1141334d20e30a7d# Parent 9aadd2163b568d76f8969ad2fb404a63733da359 Merge diff -r 563c1d911dcb -r ce1843f66c03 .hgtags --- a/.hgtags Mon Oct 17 15:31:50 2016 +0000 +++ b/.hgtags Mon Oct 17 15:32:44 2016 +0000 @@ -382,3 +382,4 @@ 9cb87c88ed851c0575b8ead753ea238ed5b544e9 jdk-9+137 d273dfe9a126d3bffe92072547fef2cd1361b0eb jdk-9+138 65477538bec32963dc41153d89c4417eb46c45fc jdk-9+139 +0875007901f7d364a08220b052f0c81003e9c8c5 jdk-9+140 diff -r 563c1d911dcb -r ce1843f66c03 .hgtags-top-repo --- a/.hgtags-top-repo Mon Oct 17 15:31:50 2016 +0000 +++ b/.hgtags-top-repo Mon Oct 17 15:32:44 2016 +0000 @@ -382,3 +382,4 @@ d7f519b004254b19e384131d9f0d0e40e31a0fd3 jdk-9+137 67c4388142bdf58aec8fefa4475faaa8a5d7380c jdk-9+138 7dcf453eacae79ee86a6bcc75fd0b546fc99b48a jdk-9+139 +a5815c6098a241d3a1df64d22b84b3524e4a77df jdk-9+140 diff -r 563c1d911dcb -r ce1843f66c03 common/autoconf/basics.m4 --- a/common/autoconf/basics.m4 Mon Oct 17 15:31:50 2016 +0000 +++ b/common/autoconf/basics.m4 Mon Oct 17 15:32:44 2016 +0000 @@ -428,9 +428,10 @@ # Call BASIC_SETUP_TOOL with AC_PATH_PROGS to locate the tool # $1: variable to set # $2: executable name (or list of names) to look for +# $3: [path] AC_DEFUN([BASIC_PATH_PROGS], [ - BASIC_SETUP_TOOL($1, [AC_PATH_PROGS($1, $2)]) + BASIC_SETUP_TOOL($1, [AC_PATH_PROGS($1, $2, , $3)]) ]) # Call BASIC_SETUP_TOOL with AC_CHECK_TOOLS to locate the tool @@ -444,9 +445,10 @@ # Like BASIC_PATH_PROGS but fails if no tool was found. # $1: variable to set # $2: executable name (or list of names) to look for +# $3: [path] AC_DEFUN([BASIC_REQUIRE_PROGS], [ - BASIC_PATH_PROGS($1, $2) + BASIC_PATH_PROGS($1, $2, , $3) BASIC_CHECK_NONEMPTY($1) ]) @@ -1065,7 +1067,9 @@ BASIC_PATH_PROGS(HG, hg) BASIC_PATH_PROGS(STAT, stat) BASIC_PATH_PROGS(TIME, time) - BASIC_PATH_PROGS(DTRACE, dtrace) + # Dtrace is usually found in /usr/sbin on Solaris, but that directory may not + # be in the user path. + BASIC_PATH_PROGS(DTRACE, dtrace, $PATH:/usr/sbin) BASIC_PATH_PROGS(PATCH, [gpatch patch]) # Check if it's GNU time IS_GNU_TIME=`$TIME --version 2>&1 | $GREP 'GNU time'` diff -r 563c1d911dcb -r ce1843f66c03 common/autoconf/basics_windows.m4 --- a/common/autoconf/basics_windows.m4 Mon Oct 17 15:31:50 2016 +0000 +++ b/common/autoconf/basics_windows.m4 Mon Oct 17 15:32:44 2016 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 diff -r 563c1d911dcb -r ce1843f66c03 common/autoconf/boot-jdk.m4 --- a/common/autoconf/boot-jdk.m4 Mon Oct 17 15:31:50 2016 +0000 +++ b/common/autoconf/boot-jdk.m4 Mon Oct 17 15:32:44 2016 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 diff -r 563c1d911dcb -r ce1843f66c03 common/autoconf/bootcycle-spec.gmk.in --- a/common/autoconf/bootcycle-spec.gmk.in Mon Oct 17 15:31:50 2016 +0000 +++ b/common/autoconf/bootcycle-spec.gmk.in Mon Oct 17 15:32:44 2016 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 diff -r 563c1d911dcb -r ce1843f66c03 common/autoconf/build-performance.m4 --- a/common/autoconf/build-performance.m4 Mon Oct 17 15:31:50 2016 +0000 +++ b/common/autoconf/build-performance.m4 Mon Oct 17 15:32:44 2016 +0000 @@ -168,7 +168,6 @@ [AS_HELP_STRING([--enable-ccache], [enable using ccache to speed up recompilations @<:@disabled@:>@])]) - CCACHE= CCACHE_STATUS= AC_MSG_CHECKING([is ccache enabled]) if test "x$enable_ccache" = xyes; then diff -r 563c1d911dcb -r ce1843f66c03 common/autoconf/buildjdk-spec.gmk.in --- a/common/autoconf/buildjdk-spec.gmk.in Mon Oct 17 15:31:50 2016 +0000 +++ b/common/autoconf/buildjdk-spec.gmk.in Mon Oct 17 15:32:44 2016 +0000 @@ -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 @@ -156,7 +156,3 @@ JVM_VARIANT_ZERO := false JVM_VARIANT_ZEROSHARK := false JVM_VARIANT_CORE := false - -# Sneak this in via the spec.gmk file, since we don't want to mess around too much with the Hotspot make files. -# This is needed to get the LOG setting to work properly. -include $(SRC_ROOT)/make/common/MakeBase.gmk diff -r 563c1d911dcb -r ce1843f66c03 common/autoconf/compare.sh.in --- a/common/autoconf/compare.sh.in Mon Oct 17 15:31:50 2016 +0000 +++ b/common/autoconf/compare.sh.in Mon Oct 17 15:32:44 2016 +0000 @@ -1,6 +1,6 @@ #!/bin/bash # -# 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 diff -r 563c1d911dcb -r ce1843f66c03 common/autoconf/generated-configure.sh --- a/common/autoconf/generated-configure.sh Mon Oct 17 15:31:50 2016 +0000 +++ b/common/autoconf/generated-configure.sh Mon Oct 17 15:32:44 2016 +0000 @@ -3657,6 +3657,7 @@ # Call BASIC_SETUP_TOOL with AC_PATH_PROGS to locate the tool # $1: variable to set # $2: executable name (or list of names) to look for +# $3: [path] # Call BASIC_SETUP_TOOL with AC_CHECK_TOOLS to locate the tool @@ -3667,6 +3668,7 @@ # Like BASIC_PATH_PROGS but fails if no tool was found. # $1: variable to set # $2: executable name (or list of names) to look for +# $3: [path] # Like BASIC_SETUP_TOOL but fails if no tool was found. @@ -3733,7 +3735,7 @@ # -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 @@ -3792,7 +3794,7 @@ # ... then the rest # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 @@ -4403,7 +4405,7 @@ # -# 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 @@ -4498,7 +4500,7 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 @@ -4818,7 +4820,7 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 @@ -5091,7 +5093,7 @@ #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1475218974 +DATE_WHEN_GENERATED=1476275292 ############################################################################### # @@ -22769,6 +22771,8 @@ fi + # Dtrace is usually found in /usr/sbin on Solaris, but that directory may not + # be in the user path. # Publish this variable in the help. @@ -22791,7 +22795,8 @@ ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH +as_dummy="$PATH:/usr/sbin" +for as_dir in $as_dummy do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. @@ -22849,7 +22854,8 @@ ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH +as_dummy="$PATH:/usr/sbin" +for as_dir in $as_dummy do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. @@ -65239,7 +65245,6 @@ fi - CCACHE= CCACHE_STATUS= { $as_echo "$as_me:${as_lineno-$LINENO}: checking is ccache enabled" >&5 $as_echo_n "checking is ccache enabled... " >&6; } diff -r 563c1d911dcb -r ce1843f66c03 common/autoconf/jdk-version.m4 --- a/common/autoconf/jdk-version.m4 Mon Oct 17 15:31:50 2016 +0000 +++ b/common/autoconf/jdk-version.m4 Mon Oct 17 15:32:44 2016 +0000 @@ -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 diff -r 563c1d911dcb -r ce1843f66c03 common/autoconf/lib-bundled.m4 --- a/common/autoconf/lib-bundled.m4 Mon Oct 17 15:31:50 2016 +0000 +++ b/common/autoconf/lib-bundled.m4 Mon Oct 17 15:32:44 2016 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 diff -r 563c1d911dcb -r ce1843f66c03 common/autoconf/source-dirs.m4 --- a/common/autoconf/source-dirs.m4 Mon Oct 17 15:31:50 2016 +0000 +++ b/common/autoconf/source-dirs.m4 Mon Oct 17 15:32:44 2016 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 diff -r 563c1d911dcb -r ce1843f66c03 common/autoconf/spec.gmk.in --- a/common/autoconf/spec.gmk.in Mon Oct 17 15:31:50 2016 +0000 +++ b/common/autoconf/spec.gmk.in Mon Oct 17 15:32:44 2016 +0000 @@ -175,7 +175,7 @@ VERSION_STRING := @VERSION_STRING@ # The short version string, without trailing zeroes and just PRE, if present. VERSION_SHORT := @VERSION_SHORT@ -# The Java specification version. It usually equals to the major version number. +# The Java specification version. It usually equals the major version number. VERSION_SPECIFICATION := @VERSION_MAJOR@ # A GA version is defined by the PRE string being empty. Rather than testing for # that, this variable defines it with true/false. @@ -244,9 +244,6 @@ # Only build headless support or not ENABLE_HEADLESS_ONLY := @ENABLE_HEADLESS_ONLY@ -# Legacy support -USE_NEW_HOTSPOT_BUILD:=@USE_NEW_HOTSPOT_BUILD@ - # JDK_OUTPUTDIR specifies where a working jvm is built. # You can run $(JDK_OUTPUTDIR)/bin/java # Though the layout of the contents of $(JDK_OUTPUTDIR) is not diff -r 563c1d911dcb -r ce1843f66c03 common/autoconf/version-numbers --- a/common/autoconf/version-numbers Mon Oct 17 15:31:50 2016 +0000 +++ b/common/autoconf/version-numbers Mon Oct 17 15:32:44 2016 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 diff -r 563c1d911dcb -r ce1843f66c03 common/bin/compare_exceptions.sh.incl --- a/common/bin/compare_exceptions.sh.incl Mon Oct 17 15:31:50 2016 +0000 +++ b/common/bin/compare_exceptions.sh.incl Mon Oct 17 15:32:44 2016 +0000 @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2012, 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 diff -r 563c1d911dcb -r ce1843f66c03 common/bin/hgforest.sh --- a/common/bin/hgforest.sh Mon Oct 17 15:31:50 2016 +0000 +++ b/common/bin/hgforest.sh Mon Oct 17 15:32:44 2016 +0000 @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 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 diff -r 563c1d911dcb -r ce1843f66c03 common/bin/jib.sh --- a/common/bin/jib.sh Mon Oct 17 15:31:50 2016 +0000 +++ b/common/bin/jib.sh Mon Oct 17 15:32:44 2016 +0000 @@ -1,6 +1,6 @@ #!/bin/bash # -# 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 diff -r 563c1d911dcb -r ce1843f66c03 common/conf/jib-profiles.js --- a/common/conf/jib-profiles.js Mon Oct 17 15:31:50 2016 +0000 +++ b/common/conf/jib-profiles.js Mon Oct 17 15:32:44 2016 +0000 @@ -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 @@ -287,7 +287,8 @@ target_os: "solaris", target_cpu: "x64", dependencies: concat(common.dependencies, "devkit", "cups"), - configure_args: concat(common.configure_args, "--with-zlib=system"), + configure_args: concat(common.configure_args, "--with-zlib=system", + "--enable-dtrace"), default_make_targets: common.default_make_targets }, @@ -295,7 +296,8 @@ target_os: "solaris", target_cpu: "sparcv9", dependencies: concat(common.dependencies, "devkit", "cups"), - configure_args: concat(common.configure_args, "--with-zlib=system"), + configure_args: concat(common.configure_args, "--with-zlib=system", + "--enable-dtrace"), default_make_targets: common.default_make_targets }, diff -r 563c1d911dcb -r ce1843f66c03 corba/.hgtags --- a/corba/.hgtags Mon Oct 17 15:31:50 2016 +0000 +++ b/corba/.hgtags Mon Oct 17 15:32:44 2016 +0000 @@ -382,3 +382,4 @@ 258cf18fa7fc59359b874f8743b7168dc48baf73 jdk-9+137 27bb44be32076861a0951bcefb07a1d92509a4b6 jdk-9+138 8c9da7fc5b07c606afd571c7012441b77dda83b2 jdk-9+139 +9f3fc931bc230f44f2a58d75f7f6360af98bb113 jdk-9+140 diff -r 563c1d911dcb -r ce1843f66c03 corba/make/gensrc/Gensrc-java.corba.gmk --- a/corba/make/gensrc/Gensrc-java.corba.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/corba/make/gensrc/Gensrc-java.corba.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 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 diff -r 563c1d911dcb -r ce1843f66c03 hotspot/.hgtags --- a/hotspot/.hgtags Mon Oct 17 15:31:50 2016 +0000 +++ b/hotspot/.hgtags Mon Oct 17 15:32:44 2016 +0000 @@ -542,3 +542,4 @@ dfcbf839e299e7e2bba1da69bdb347617ea4c7e8 jdk-9+137 fc0956308c7a586267c5dd35dff74f773aa9c3eb jdk-9+138 08492e67bf3226784dab3bf9ae967382ddbc1af5 jdk-9+139 +fec31089c2ef5a12dd64f401b0bf2e00f56ee0d0 jdk-9+140 diff -r 563c1d911dcb -r ce1843f66c03 hotspot/make/lib/CompileGtest.gmk --- a/hotspot/make/lib/CompileGtest.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/hotspot/make/lib/CompileGtest.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -69,7 +69,7 @@ CFLAGS := $(JVM_CFLAGS) -I$(GTEST_FRAMEWORK_SRC) \ -I$(GTEST_FRAMEWORK_SRC)/include \ $(addprefix -I,$(GTEST_TEST_SRC)), \ - CFLAGS_windows := /EHsc, \ + CFLAGS_windows := -EHsc, \ CFLAGS_solaris := -DGTEST_HAS_EXCEPTIONS=0 -library=stlport4, \ CFLAGS_macosx := -DGTEST_OS_MAC=1, \ CFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \ diff -r 563c1d911dcb -r ce1843f66c03 hotspot/src/share/vm/runtime/arguments.cpp --- a/hotspot/src/share/vm/runtime/arguments.cpp Mon Oct 17 15:31:50 2016 +0000 +++ b/hotspot/src/share/vm/runtime/arguments.cpp Mon Oct 17 15:32:44 2016 +0000 @@ -422,6 +422,8 @@ { "UseAltSigs", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, { "SegmentedHeapDumpThreshold", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, { "PrintOopAddress", JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) }, + { "PermSize", JDK_Version::undefined(), JDK_Version::jdk(8), JDK_Version::jdk(10) }, + { "MaxPermSize", JDK_Version::undefined(), JDK_Version::jdk(8), JDK_Version::jdk(10) }, #ifdef TEST_VERIFY_SPECIAL_JVM_FLAGS { "dep > obs", JDK_Version::jdk(9), JDK_Version::jdk(8), JDK_Version::undefined() }, diff -r 563c1d911dcb -r ce1843f66c03 hotspot/test/runtime/CommandLine/PermGenFlagsTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/test/runtime/CommandLine/PermGenFlagsTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -0,0 +1,51 @@ +/* + * 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 8167446 + * @summary Commandline options PermSize and MaxPermSize should be recognized but ignored. + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.management + * @run driver PermGenFlagsTest + */ + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public class PermGenFlagsTest { + public static void main(String[] args) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:PermSize=22k", + "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("Ignoring option PermSize; support was removed in 8.0"); + output.shouldHaveExitValue(0); + + pb = ProcessTools.createJavaProcessBuilder("-XX:MaxPermSize=22k", + "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Ignoring option MaxPermSize; support was removed in 8.0"); + output.shouldHaveExitValue(0); + } +} diff -r 563c1d911dcb -r ce1843f66c03 hotspot/test/runtime/modules/IgnoreModulePropertiesTest.java --- a/hotspot/test/runtime/modules/IgnoreModulePropertiesTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/hotspot/test/runtime/modules/IgnoreModulePropertiesTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -67,10 +67,11 @@ } public static void main(String[] args) throws Exception { - testOption("--add-modules", "java.sqlx", "jdk.module.addmods", "java.lang.module.ResolutionException"); + testOption("--add-modules", "java.sqlx", "jdk.module.addmods.0", "java.lang.module.ResolutionException"); testOption("--limit-modules", "java.sqlx", "jdk.module.limitmods", "java.lang.module.ResolutionException"); - testOption("--add-reads", "xyzz=yyzd", "jdk.module.addreads.0", "java.lang.RuntimeException"); - testOption("--add-exports", "java.base/xyzz=yyzd", "jdk.module.addexports.0", "java.lang.RuntimeException"); + testOption("--add-reads", "xyzz=yyzd", "jdk.module.addreads.0", "WARNING: Unknown module: xyzz"); + testOption("--add-exports", "java.base/xyzz=yyzd", "jdk.module.addexports.0", + "WARNING: package xyzz not in java.base"); testOption("--patch-module", "=d", "jdk.module.patch.0", "IllegalArgumentException"); } } diff -r 563c1d911dcb -r ce1843f66c03 jaxp/.hgtags --- a/jaxp/.hgtags Mon Oct 17 15:31:50 2016 +0000 +++ b/jaxp/.hgtags Mon Oct 17 15:32:44 2016 +0000 @@ -382,3 +382,4 @@ a8d5fe567ae72b4931040e59dd4478363f9004f5 jdk-9+137 69c3b12ba75b2e321dee731ac545e7fbff608451 jdk-9+138 8991d71c5316bde259e6a417c1199b008ca3cdf0 jdk-9+139 +8d100cb9b04819b5bd09f33c7fd5b8628d1a456f jdk-9+140 diff -r 563c1d911dcb -r ce1843f66c03 jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java Mon Oct 17 15:32:44 2016 +0000 @@ -1342,6 +1342,12 @@ } else { SyntaxTreeNode parent = _parentStack.peek(); + if (element.getClass().isAssignableFrom(Import.class) && + parent.notTypeOf(Import.class)) { + ErrorMsg err = new ErrorMsg(ErrorMsg.IMPORT_PRECEDE_OTHERS_ERR, + prefix+':'+localname); + throw new SAXException(err.toString()); + } parent.addElement(element); element.setParent(parent); } diff -r 563c1d911dcb -r ce1843f66c03 jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/SyntaxTreeNode.java Mon Oct 17 15:32:44 2016 +0000 @@ -524,6 +524,24 @@ } /** + * Checks whether any children of this node is not of the specified type. + * + * @param type the type to be checked against + * @return true if there is at least one child that is not of the specified + * type, false otherwise. + */ + public boolean notTypeOf(Class type) { + if (_contents.size() > 0) { + for (SyntaxTreeNode item : _contents) { + if (!item.getClass().isAssignableFrom(type)) { + return true; + } + } + } + return false; + } + + /** * Return true if the node represents a simple RTF. * * A node is a simple RTF if all children only produce Text value. diff -r 563c1d911dcb -r ce1843f66c03 jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java Mon Oct 17 15:32:44 2016 +0000 @@ -274,6 +274,14 @@ "Circular import/include. Stylesheet ''{0}'' already loaded."}, /* + * Note to translators: "xsl:import" and "xsl:include" are keywords that + * should not be translated. + */ + {ErrorMsg.IMPORT_PRECEDE_OTHERS_ERR, + "The xsl:import element children must precede all other element children of " + + "an xsl:stylesheet element, including any xsl:include element children."}, + + /* * Note to translators: A result-tree fragment is a portion of a * resulting XML document represented as a tree. "" is a * keyword and should not be translated. diff -r 563c1d911dcb -r ce1843f66c03 jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java Mon Oct 17 15:32:44 2016 +0000 @@ -70,6 +70,7 @@ public static final String STRAY_ATTRIBUTE_ERR = "STRAY_ATTRIBUTE_ERR"; public static final String ILLEGAL_ATTRIBUTE_ERR = "ILLEGAL_ATTRIBUTE_ERR"; public static final String CIRCULAR_INCLUDE_ERR = "CIRCULAR_INCLUDE_ERR"; + public static final String IMPORT_PRECEDE_OTHERS_ERR = "IMPORT_PRECEDE_OTHERS_ERR"; public static final String RESULT_TREE_SORT_ERR = "RESULT_TREE_SORT_ERR"; public static final String SYMBOLS_REDEF_ERR = "SYMBOLS_REDEF_ERR"; public static final String XSL_VERSION_ERR = "XSL_VERSION_ERR"; diff -r 563c1d911dcb -r ce1843f66c03 jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/StAXStream2SAX.java --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/StAXStream2SAX.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/StAXStream2SAX.java Mon Oct 17 15:32:44 2016 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, 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 @@ -305,9 +305,12 @@ if (prefix == null) { // true for default namespace prefix = ""; } - _sax.startPrefixMapping( - prefix, - staxStreamReader.getNamespaceURI(i)); + String uri = staxStreamReader.getNamespaceURI(i); + if (uri == null && prefix.isEmpty()) { // true for default namespace + uri = ""; + } + + _sax.startPrefixMapping(prefix, uri); } // fire startElement diff -r 563c1d911dcb -r ce1843f66c03 jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6341770.java --- a/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6341770.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/Bug6341770.java Mon Oct 17 15:32:44 2016 +0000 @@ -28,6 +28,7 @@ import java.io.File; import java.io.FileWriter; import java.io.PrintWriter; +import java.nio.file.Paths; import java.util.PropertyPermission; import javax.xml.parsers.SAXParserFactory; @@ -53,8 +54,14 @@ // naming a file "aux" would fail on windows. @Test public void testNonAsciiURI() { + if (!isNonAsciiSupported()) { + // @bug 8167478 + // if it doesn't support non-ascii, the following test is invalid even if test is passed. + System.out.println("Current environment doesn't support non-ascii, exit the test."); + return; + } try { - File dir = new File("sko\u0159ice"); + File dir = new File(ALPHA); dir.delete(); dir.mkdir(); File main = new File(dir, "main.xml"); @@ -82,4 +89,18 @@ } System.out.println("OK."); } + + private boolean isNonAsciiSupported() { + // Use Paths.get method to test if the path is valid in current environment + try { + Paths.get(ALPHA); + return true; + } catch (Exception e) { + return false; + } + } + + // Select alpha because it's a very common non-ascii character in different charsets. + // That this test can run in as many as possible environments if it's possible. + private static final String ALPHA = "\u03b1"; } diff -r 563c1d911dcb -r ce1843f66c03 jaxp/test/javax/xml/jaxp/unittest/transform/StAXSourceTest.java --- a/jaxp/test/javax/xml/jaxp/unittest/transform/StAXSourceTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/StAXSourceTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -30,7 +30,9 @@ import javax.xml.stream.XMLEventWriter; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; @@ -38,6 +40,7 @@ import javax.xml.transform.dom.DOMResult; import javax.xml.transform.stax.StAXResult; import javax.xml.transform.stax.StAXSource; +import javax.xml.transform.stream.StreamResult; import org.testng.Assert; import org.testng.annotations.Listeners; @@ -45,6 +48,7 @@ /* * @test + * @bug 8152530 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm -DrunSecMngr=true transform.StAXSourceTest * @run testng/othervm transform.StAXSourceTest @@ -52,6 +56,33 @@ */ @Listeners({jaxp.library.FilePolicy.class}) public class StAXSourceTest { + /** + * @bug 8152530 + * Verifies that StAXSource handles empty namespace properly. NPE was thrown + * before the fix. + * @throws Exception if the test fails + */ + @Test + public final void testStAXSourceWEmptyNS() throws Exception { + String xml = "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " "; + + XMLInputFactory xif = XMLInputFactory.newInstance(); + XMLStreamReader xsr = xif.createXMLStreamReader(new StringReader(xml)); + xsr.nextTag(); + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer t = tf.newTransformer(); + while (xsr.nextTag() == XMLStreamConstants.START_ELEMENT && xsr.getLocalName().equals("Entity")) { + StringWriter stringResult = new StringWriter(); + t.transform(new StAXSource(xsr), new StreamResult(stringResult)); + System.out.println("result: \n" + stringResult.toString()); + } + } @Test public final void testStAXSource() throws XMLStreamException { diff -r 563c1d911dcb -r ce1843f66c03 jaxp/test/javax/xml/jaxp/unittest/transform/StylesheetTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/StylesheetTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -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. + */ + +package transform; + +import java.io.StringReader; +import org.xml.sax.InputSource; + +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.TransformerConfigurationException; +import org.testng.annotations.Listeners; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8058152 + * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest + * @run testng/othervm -DrunSecMngr=true transform.StylesheetTest + * @run testng/othervm transform.StylesheetTest + * @summary this test contains test cases for verifying stylesheet + */ +@Listeners(jaxp.library.FilePolicy.class) +public class StylesheetTest { + + /** + * @bug 8058152 + * Verifies that an error is reported if the xsl:import element + * is not at the top of the stylesheet. + * @throws TransformerConfigurationException + */ + @Test(dataProvider = "invalidImport", expectedExceptions = TransformerConfigurationException.class) + public void testInvalidImport(String xsl) throws TransformerConfigurationException { + StringReader xsl1 = new StringReader(xsl); + TransformerFactory factory = TransformerFactory.newInstance(); + SAXSource xslSource = new SAXSource(new InputSource(xsl1)); + Transformer transformer = factory.newTransformer(xslSource); + } + + /** + * @bug 8058152 + * Verifies that valid xsl:import elements are accepted + * @throws TransformerConfigurationException + */ + @Test(dataProvider = "validImport") + public void testValidImport(String file) throws TransformerConfigurationException { + String xsl = getClass().getResource(file).getFile(); + TransformerFactory factory = TransformerFactory.newInstance(); + SAXSource xslSource = new SAXSource(new InputSource(xsl)); + Transformer transformer = factory.newTransformer(xslSource); + } + + /* + DataProvider: for testing with xsl:import placed incorrectly + Data: stylesheet + */ + @DataProvider(name = "invalidImport") + public Object[][] getInvalid() { + + return new Object[][]{ + // xsl:import after template and include elements + {"\n" + + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "\n" + + " \n" + + "

\n" + + " \n" + + "

\n" + + "
\n" + + " \n" + + " \n" + + "\n" + + "
"}, + + // xsl:import inside template + {"\n" + + "\n" + + "\n" + + " \n" + + " " + + " \n" + + " \n" + + " \n" + + " \n" + + "\n" + + ""}, + + // xsl:import after xsl:include + {"\n" + + "\n" + + " \n" + + " \n" + + "\n" + + " \n" + + "

\n" + + " \n" + + "

\n" + + "
\n" + + "\n" + + "
"} + }; + } + + /* + DataProvider: for testing with xsl:import placed correctly + Data: path to stylesheet + */ + @DataProvider(name = "validImport") + public Object[][] getValid() { + + return new Object[][]{ + // xsl:import at the top + {"XSLInclude_main.xsl"}, + + // two xsl:import elements at the top + {"XSLImport.xsl"} + }; + } +} diff -r 563c1d911dcb -r ce1843f66c03 jaxp/test/javax/xml/jaxp/unittest/transform/XSLImport.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/XSLImport.xsl Mon Oct 17 15:32:44 2016 +0000 @@ -0,0 +1,21 @@ + + + + + + + + + + + + + +

+ +

+
+ + + +
\ No newline at end of file diff -r 563c1d911dcb -r ce1843f66c03 jaxp/test/javax/xml/jaxp/unittest/transform/XSLInclude_footer.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/XSLInclude_footer.xsl Mon Oct 17 15:32:44 2016 +0000 @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff -r 563c1d911dcb -r ce1843f66c03 jaxp/test/javax/xml/jaxp/unittest/transform/XSLInclude_header.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/XSLInclude_header.xsl Mon Oct 17 15:32:44 2016 +0000 @@ -0,0 +1,8 @@ + + + + +

+
+ +
\ No newline at end of file diff -r 563c1d911dcb -r ce1843f66c03 jaxp/test/javax/xml/jaxp/unittest/transform/XSLInclude_main.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/transform/XSLInclude_main.xsl Mon Oct 17 15:32:44 2016 +0000 @@ -0,0 +1,20 @@ + + + + + + + + + + + + +

+ +

+
+ + + +
\ No newline at end of file diff -r 563c1d911dcb -r ce1843f66c03 jaxws/.hgtags --- a/jaxws/.hgtags Mon Oct 17 15:31:50 2016 +0000 +++ b/jaxws/.hgtags Mon Oct 17 15:32:44 2016 +0000 @@ -385,3 +385,4 @@ 297c16d401c534cb879809d2a746d21ca99d2954 jdk-9+137 7d3a8f52b124db26ba8425c2931b748dd9d2791b jdk-9+138 7a7aadf3c4500cc273c889aa1172d4fe3844bb6b jdk-9+139 +9004617323fe99cbe4fad48f373cb2ed4fc50aa6 jdk-9+140 diff -r 563c1d911dcb -r ce1843f66c03 jdk/.hgtags --- a/jdk/.hgtags Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/.hgtags Mon Oct 17 15:32:44 2016 +0000 @@ -382,3 +382,4 @@ e72df94364e3686e7d62059ce0d6b187b82da713 jdk-9+137 665096863382bf23ce891307cf2a7511e77c1c88 jdk-9+138 5518ac2f2ead5e594bd983f2047178136aafdfd0 jdk-9+139 +e93b7ea559759f036c9f69fd2ddaf47bb4e98385 jdk-9+140 diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java --- a/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java Mon Oct 17 15:32:44 2016 +0000 @@ -33,7 +33,6 @@ import java.security.AccessController; import java.security.Permission; import java.security.PrivilegedAction; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -333,7 +332,7 @@ * *

When locating modules then any exceptions or errors thrown by the * {@code find} or {@code findAll} methods of the underlying module finders - * will be propogated to the caller of the resulting module finder's + * will be propagated to the caller of the resulting module finder's * {@code find} or {@code findAll} methods.

* * @param finders @@ -342,8 +341,8 @@ * @return A {@code ModuleFinder} that composes a sequence of module finders */ static ModuleFinder compose(ModuleFinder... finders) { - final List finderList = Arrays.asList(finders); - finderList.forEach(Objects::requireNonNull); + // copy the list, also checking for nulls + final List finderList = List.of(finders); return new ModuleFinder() { private final Map nameToModule = new HashMap<>(); diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/net/CookieManager.java --- a/jdk/src/java.base/share/classes/java/net/CookieManager.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/net/CookieManager.java Mon Oct 17 15:32:44 2016 +0000 @@ -81,7 +81,7 @@ *
  • * Currently, only CookieStore.add(URI, HttpCookie) and CookieStore.get(URI) * are used by CookieManager. Others are for completeness and might be needed - * by a more sophisticated CookieStore implementation, e.g. a NetscapeCookieSotre. + * by a more sophisticated CookieStore implementation, e.g. a NetscapeCookieStore. *
  • * * @@ -201,10 +201,9 @@ throw new IllegalArgumentException("Argument is null"); } - Map> cookieMap = new java.util.HashMap<>(); // if there's no default CookieStore, no way for us to get any cookie if (cookieJar == null) - return Collections.unmodifiableMap(cookieMap); + return Map.of(); boolean secureLink = "https".equalsIgnoreCase(uri.getScheme()); List cookies = new java.util.ArrayList<>(); @@ -244,8 +243,7 @@ // apply sort rule (RFC 2965 sec. 3.3.4) List cookieHeader = sortByPath(cookies); - cookieMap.put("Cookie", cookieHeader); - return Collections.unmodifiableMap(cookieMap); + return Map.of("Cookie", cookieHeader); } public void diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/nio/file/FileTreeIterator.java --- a/jdk/src/java.base/share/classes/java/nio/file/FileTreeIterator.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/nio/file/FileTreeIterator.java Mon Oct 17 15:32:44 2016 +0000 @@ -31,11 +31,10 @@ import java.util.Arrays; import java.util.Iterator; import java.util.NoSuchElementException; -import java.util.Objects; import java.nio.file.FileTreeWalker.Event; /** - * An {@code Iterator to iterate over the nodes of a file tree. + * An {@code Iterator} to iterate over the nodes of a file tree. * *
    {@code
      *     try (FileTreeIterator iterator = new FileTreeIterator(start, maxDepth, options)) {
    @@ -62,7 +61,7 @@
          * @throws  SecurityException
          *          if the security manager denies access to the starting file
          * @throws  NullPointerException
    -     *          if {@code start} or {@code options} is {@ocde null} or
    +     *          if {@code start} or {@code options} is {@code null} or
          *          the options array contains a {@code null} element
          */
         FileTreeIterator(Path start, int maxDepth, FileVisitOption... options)
    diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/nio/file/FileTreeWalker.java
    --- a/jdk/src/java.base/share/classes/java/nio/file/FileTreeWalker.java	Mon Oct 17 15:31:50 2016 +0000
    +++ b/jdk/src/java.base/share/classes/java/nio/file/FileTreeWalker.java	Mon Oct 17 15:32:44 2016 +0000
    @@ -171,7 +171,7 @@
          *          if {@code options} contains an element that is not a
          *          {@code FileVisitOption}
          * @throws  NullPointerException
    -     *          if {@code options} is {@ocde null} or the options
    +     *          if {@code options} is {@code null} or the options
          *          array contains a {@code null} element
          */
         FileTreeWalker(Collection options, int maxDepth) {
    diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/security/KeyStoreSpi.java
    --- a/jdk/src/java.base/share/classes/java/security/KeyStoreSpi.java	Mon Oct 17 15:31:50 2016 +0000
    +++ b/jdk/src/java.base/share/classes/java/security/KeyStoreSpi.java	Mon Oct 17 15:32:44 2016 +0000
    @@ -479,6 +479,10 @@
                 } else if (engineIsKeyEntry(alias)) {
                     KeyStore.PasswordProtection pp =
                             (KeyStore.PasswordProtection)protParam;
    +                if (pp.getProtectionAlgorithm() != null) {
    +                    throw new KeyStoreException(
    +                        "unsupported password protection algorithm");
    +                }
                     char[] password = pp.getPassword();
     
                     Key key = engineGetKey(alias, password);
    @@ -524,6 +528,10 @@
             KeyStore.PasswordProtection pProtect = null;
             if (protParam != null) {
                 pProtect = (KeyStore.PasswordProtection)protParam;
    +            if (pProtect.getProtectionAlgorithm() != null) {
    +                throw new KeyStoreException(
    +                    "unsupported password protection algorithm");
    +            }
             }
     
             // set entry
    diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/security/Signature.java
    --- a/jdk/src/java.base/share/classes/java/security/Signature.java	Mon Oct 17 15:31:50 2016 +0000
    +++ b/jdk/src/java.base/share/classes/java/security/Signature.java	Mon Oct 17 15:32:44 2016 +0000
    @@ -37,7 +37,6 @@
     import java.security.Provider.Service;
     
     import javax.crypto.Cipher;
    -import javax.crypto.CipherSpi;
     import javax.crypto.IllegalBlockSizeException;
     import javax.crypto.BadPaddingException;
     import javax.crypto.NoSuchPaddingException;
    @@ -180,15 +179,12 @@
         private static final String RSA_CIPHER = "RSA/ECB/PKCS1Padding";
     
         // all the services we need to lookup for compatibility with Cipher
    -    private static final List rsaIds = Arrays.asList(
    -        new ServiceId[] {
    -            new ServiceId("Signature", "NONEwithRSA"),
    -            new ServiceId("Cipher", "RSA/ECB/PKCS1Padding"),
    -            new ServiceId("Cipher", "RSA/ECB"),
    -            new ServiceId("Cipher", "RSA//PKCS1Padding"),
    -            new ServiceId("Cipher", "RSA"),
    -        }
    -    );
    +    private static final List rsaIds = List.of(
    +        new ServiceId("Signature", "NONEwithRSA"),
    +        new ServiceId("Cipher", "RSA/ECB/PKCS1Padding"),
    +        new ServiceId("Cipher", "RSA/ECB"),
    +        new ServiceId("Cipher", "RSA//PKCS1Padding"),
    +        new ServiceId("Cipher", "RSA"));
     
         /**
          * Returns a Signature object that implements the specified signature
    diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/time/Duration.java
    --- a/jdk/src/java.base/share/classes/java/time/Duration.java	Mon Oct 17 15:31:50 2016 +0000
    +++ b/jdk/src/java.base/share/classes/java/time/Duration.java	Mon Oct 17 15:32:44 2016 +0000
    @@ -88,8 +88,6 @@
     import java.time.temporal.TemporalAmount;
     import java.time.temporal.TemporalUnit;
     import java.time.temporal.UnsupportedTemporalTypeException;
    -import java.util.Arrays;
    -import java.util.Collections;
     import java.util.List;
     import java.util.Objects;
     import java.util.regex.Matcher;
    @@ -578,8 +576,7 @@
          * the simple initialization in Duration.
          */
         private static class DurationUnits {
    -        static final List UNITS =
    -                Collections.unmodifiableList(Arrays.asList(SECONDS, NANOS));
    +        static final List UNITS = List.of(SECONDS, NANOS);
         }
     
         //-----------------------------------------------------------------------
    diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/time/Instant.java
    --- a/jdk/src/java.base/share/classes/java/time/Instant.java	Mon Oct 17 15:31:50 2016 +0000
    +++ b/jdk/src/java.base/share/classes/java/time/Instant.java	Mon Oct 17 15:32:44 2016 +0000
    @@ -610,7 +610,7 @@
          * 

    * The epoch second count is a simple incrementing count of seconds where * second 0 is 1970-01-01T00:00:00Z. - * The nanosecond part of the day is returned by {@code getNanosOfSecond}. + * The nanosecond part of the day is returned by {@link #getNano}. * * @return the seconds from the epoch of 1970-01-01T00:00:00Z */ @@ -623,7 +623,7 @@ * of the second. *

    * The nanosecond-of-second value measures the total number of nanoseconds from - * the second returned by {@code getEpochSecond}. + * the second returned by {@link #getEpochSecond}. * * @return the nanoseconds within the second, always positive, never exceeds 999,999,999 */ diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/time/Period.java --- a/jdk/src/java.base/share/classes/java/time/Period.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/time/Period.java Mon Oct 17 15:32:44 2016 +0000 @@ -83,8 +83,6 @@ import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalUnit; import java.time.temporal.UnsupportedTemporalTypeException; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.regex.Matcher; @@ -152,8 +150,7 @@ /** * The set of supported units. */ - private static final List SUPPORTED_UNITS = - Collections.unmodifiableList(Arrays.asList(YEARS, MONTHS, DAYS)); + private static final List SUPPORTED_UNITS = List.of(YEARS, MONTHS, DAYS); /** * The number of years. diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/time/ZoneId.java --- a/jdk/src/java.base/share/classes/java/time/ZoneId.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/time/ZoneId.java Mon Oct 17 15:32:44 2016 +0000 @@ -76,14 +76,14 @@ import java.time.zone.ZoneRules; import java.time.zone.ZoneRulesException; import java.time.zone.ZoneRulesProvider; -import java.util.Collections; -import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.TimeZone; +import static java.util.Map.entry; + /** * A time-zone ID, such as {@code Europe/Paris}. *

    @@ -220,39 +220,36 @@ * * The map is unmodifiable. */ - public static final Map SHORT_IDS; - static { - Map map = new HashMap<>(64); - map.put("ACT", "Australia/Darwin"); - map.put("AET", "Australia/Sydney"); - map.put("AGT", "America/Argentina/Buenos_Aires"); - map.put("ART", "Africa/Cairo"); - map.put("AST", "America/Anchorage"); - map.put("BET", "America/Sao_Paulo"); - map.put("BST", "Asia/Dhaka"); - map.put("CAT", "Africa/Harare"); - map.put("CNT", "America/St_Johns"); - map.put("CST", "America/Chicago"); - map.put("CTT", "Asia/Shanghai"); - map.put("EAT", "Africa/Addis_Ababa"); - map.put("ECT", "Europe/Paris"); - map.put("IET", "America/Indiana/Indianapolis"); - map.put("IST", "Asia/Kolkata"); - map.put("JST", "Asia/Tokyo"); - map.put("MIT", "Pacific/Apia"); - map.put("NET", "Asia/Yerevan"); - map.put("NST", "Pacific/Auckland"); - map.put("PLT", "Asia/Karachi"); - map.put("PNT", "America/Phoenix"); - map.put("PRT", "America/Puerto_Rico"); - map.put("PST", "America/Los_Angeles"); - map.put("SST", "Pacific/Guadalcanal"); - map.put("VST", "Asia/Ho_Chi_Minh"); - map.put("EST", "-05:00"); - map.put("MST", "-07:00"); - map.put("HST", "-10:00"); - SHORT_IDS = Collections.unmodifiableMap(map); - } + public static final Map SHORT_IDS = Map.ofEntries( + entry("ACT", "Australia/Darwin"), + entry("AET", "Australia/Sydney"), + entry("AGT", "America/Argentina/Buenos_Aires"), + entry("ART", "Africa/Cairo"), + entry("AST", "America/Anchorage"), + entry("BET", "America/Sao_Paulo"), + entry("BST", "Asia/Dhaka"), + entry("CAT", "Africa/Harare"), + entry("CNT", "America/St_Johns"), + entry("CST", "America/Chicago"), + entry("CTT", "Asia/Shanghai"), + entry("EAT", "Africa/Addis_Ababa"), + entry("ECT", "Europe/Paris"), + entry("IET", "America/Indiana/Indianapolis"), + entry("IST", "Asia/Kolkata"), + entry("JST", "Asia/Tokyo"), + entry("MIT", "Pacific/Apia"), + entry("NET", "Asia/Yerevan"), + entry("NST", "Pacific/Auckland"), + entry("PLT", "Asia/Karachi"), + entry("PNT", "America/Phoenix"), + entry("PRT", "America/Puerto_Rico"), + entry("PST", "America/Los_Angeles"), + entry("SST", "Pacific/Guadalcanal"), + entry("VST", "Asia/Ho_Chi_Minh"), + entry("EST", "-05:00"), + entry("MST", "-07:00"), + entry("HST", "-10:00") + ); /** * Serialization version. */ diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/time/chrono/ChronoPeriodImpl.java --- a/jdk/src/java.base/share/classes/java/time/chrono/ChronoPeriodImpl.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/time/chrono/ChronoPeriodImpl.java Mon Oct 17 15:32:44 2016 +0000 @@ -77,8 +77,6 @@ import java.time.temporal.TemporalUnit; import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Objects; @@ -105,8 +103,7 @@ /** * The set of supported units. */ - private static final List SUPPORTED_UNITS = - Collections.unmodifiableList(Arrays.asList(YEARS, MONTHS, DAYS)); + private static final List SUPPORTED_UNITS = List.of(YEARS, MONTHS, DAYS); /** * The chronology. diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java --- a/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java Mon Oct 17 15:32:44 2016 +0000 @@ -59,10 +59,7 @@ import static java.time.temporal.ChronoField.EPOCH_DAY; -import java.io.File; -import java.io.FileInputStream; import java.io.FilePermission; -import java.io.IOException; import java.io.InputStream; import java.io.InvalidObjectException; import java.io.ObjectInputStream; @@ -83,7 +80,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Properties; import sun.util.logging.PlatformLogger; @@ -512,7 +508,7 @@ @Override public List eras() { - return Arrays.asList(HijrahEra.values()); + return List.of(HijrahEra.values()); } //----------------------------------------------------------------------- diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/time/chrono/IsoChronology.java --- a/jdk/src/java.base/share/classes/java/time/chrono/IsoChronology.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/time/chrono/IsoChronology.java Mon Oct 17 15:32:44 2016 +0000 @@ -90,7 +90,6 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.ValueRange; -import java.util.Arrays; import java.util.List; import java.util.Locale; import java.util.Map; @@ -492,7 +491,7 @@ @Override public List eras() { - return Arrays.asList(IsoEra.values()); + return List.of(IsoEra.values()); } //----------------------------------------------------------------------- diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/time/chrono/JapaneseChronology.java --- a/jdk/src/java.base/share/classes/java/time/chrono/JapaneseChronology.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/time/chrono/JapaneseChronology.java Mon Oct 17 15:32:44 2016 +0000 @@ -81,7 +81,6 @@ import java.time.temporal.TemporalField; import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; -import java.util.Arrays; import java.util.Calendar; import java.util.List; import java.util.Locale; @@ -379,7 +378,7 @@ @Override public List eras() { - return Arrays.asList(JapaneseEra.values()); + return List.of(JapaneseEra.values()); } JapaneseEra getCurrentEra() { diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/time/chrono/MinguoChronology.java --- a/jdk/src/java.base/share/classes/java/time/chrono/MinguoChronology.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/time/chrono/MinguoChronology.java Mon Oct 17 15:32:44 2016 +0000 @@ -72,7 +72,6 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.ValueRange; -import java.util.Arrays; import java.util.List; import java.util.Locale; import java.util.Map; @@ -306,7 +305,7 @@ @Override public List eras() { - return Arrays.asList(MinguoEra.values()); + return List.of(MinguoEra.values()); } //----------------------------------------------------------------------- diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/time/chrono/ThaiBuddhistChronology.java --- a/jdk/src/java.base/share/classes/java/time/chrono/ThaiBuddhistChronology.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/time/chrono/ThaiBuddhistChronology.java Mon Oct 17 15:32:44 2016 +0000 @@ -342,7 +342,7 @@ @Override public List eras() { - return Arrays.asList(ThaiBuddhistEra.values()); + return List.of(ThaiBuddhistEra.values()); } //----------------------------------------------------------------------- diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java --- a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java Mon Oct 17 15:32:44 2016 +0000 @@ -1685,6 +1685,7 @@ public DateTimeFormatter withResolverFields(TemporalField... resolverFields) { Set fields = null; if (resolverFields != null) { + // Set.of cannot be used because it is hostile to nulls and duplicate elements fields = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(resolverFields))); } if (Objects.equals(this.resolverFields, fields)) { diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/time/zone/ZoneOffsetTransition.java --- a/jdk/src/java.base/share/classes/java/time/zone/ZoneOffsetTransition.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/time/zone/ZoneOffsetTransition.java Mon Oct 17 15:32:44 2016 +0000 @@ -387,9 +387,9 @@ */ List getValidOffsets() { if (isGap()) { - return Collections.emptyList(); + return List.of(); } - return Arrays.asList(getOffsetBefore(), getOffsetAfter()); + return List.of(getOffsetBefore(), getOffsetAfter()); } //----------------------------------------------------------------------- diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/time/zone/ZoneRules.java --- a/jdk/src/java.base/share/classes/java/time/zone/ZoneRules.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/time/zone/ZoneRules.java Mon Oct 17 15:32:44 2016 +0000 @@ -303,7 +303,6 @@ * Creates an instance of ZoneRules that has fixed zone rules. * * @param offset the offset this fixed zone rules is based on, not null - * @return the zone rules, not null * @see #isFixedOffset() */ private ZoneRules(ZoneOffset offset) { @@ -970,7 +969,7 @@ * @return an immutable list of transition rules, not null */ public List getTransitionRules() { - return Collections.unmodifiableList(Arrays.asList(lastRules)); + return List.of(lastRules); } /** diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/util/Date.java --- a/jdk/src/java.base/share/classes/java/util/Date.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/util/Date.java Mon Oct 17 15:32:44 2016 +0000 @@ -85,12 +85,12 @@ * further information is the U.S. Naval Observatory, particularly * the Directorate of Time at: *

    - *     http://tycho.usno.navy.mil
    + *     http://www.usno.navy.mil
      * 
    *

    * and their definitions of "Systems of Time" at: *

    - *     http://tycho.usno.navy.mil/systime.html
    + *     http://www.usno.navy.mil/USNO/time/master-clock/systems-of-time
      * 
    *

    * In all methods of class {@code Date} that accept or return diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/util/ResourceBundle.java --- a/jdk/src/java.base/share/classes/java/util/ResourceBundle.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/util/ResourceBundle.java Mon Oct 17 15:32:44 2016 +0000 @@ -2491,34 +2491,29 @@ /** * The default format List, which contains the strings * "java.class" and "java.properties", in - * this order. This List is {@linkplain - * Collections#unmodifiableList(List) unmodifiable}. + * this order. This List is unmodifiable. * * @see #getFormats(String) */ public static final List FORMAT_DEFAULT - = Collections.unmodifiableList(Arrays.asList("java.class", - "java.properties")); + = List.of("java.class", "java.properties"); /** * The class-only format List containing - * "java.class". This List is {@linkplain - * Collections#unmodifiableList(List) unmodifiable}. + * "java.class". This List is unmodifiable. * * @see #getFormats(String) */ - public static final List FORMAT_CLASS - = Collections.unmodifiableList(Arrays.asList("java.class")); + public static final List FORMAT_CLASS = List.of("java.class"); /** * The properties-only format List containing - * "java.properties". This List is - * {@linkplain Collections#unmodifiableList(List) unmodifiable}. + * "java.properties". This List is unmodifiable. * * @see #getFormats(String) */ public static final List FORMAT_PROPERTIES - = Collections.unmodifiableList(Arrays.asList("java.properties")); + = List.of("java.properties"); /** * The time-to-live constant for not caching loaded resource bundle diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/util/spi/ToolProvider.java --- a/jdk/src/java.base/share/classes/java/util/spi/ToolProvider.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/util/spi/ToolProvider.java Mon Oct 17 15:32:44 2016 +0000 @@ -56,8 +56,8 @@ /** * Returns the name of this tool provider. * - * @apiNote It is recommended that the name be the same as would be used on - * the command line: for example, "javac", "jar", "jlink". + * @apiNote It is recommended that the name be the same as would be + * used on the command line: for example, "javac", "jar", "jlink". * * @return the name of this tool provider */ @@ -67,12 +67,13 @@ * Runs an instance of the tool, returning zero for a successful run. * Any non-zero return value indicates a tool-specific error during the * execution. + * * Two streams should be provided, for "expected" output, and for any * error messages. If it is not necessary to distinguish the output, * the same stream may be used for both. * * @apiNote The interpretation of the arguments will be specific to - * each tool. + * each tool. * * @param out a stream to which "expected" output should be written * @@ -81,12 +82,13 @@ * @param args the command-line arguments for the tool * * @return the result of executing the tool. - * A return value of 0 means the tool did not encounter any errors; - * any other value indicates that at least one error occurred during - * execution. + * A return value of 0 means the tool did not encounter any errors; + * any other value indicates that at least one error occurred + * during execution. * * @throws NullPointerException if any of the arguments are {@code null}, - * or if there are any {@code null} values in the {@code args} array + * or if there are any {@code null} values in the {@code args} + * array */ int run(PrintWriter out, PrintWriter err, String... args); @@ -94,16 +96,17 @@ * Runs an instance of the tool, returning zero for a successful run. * Any non-zero return value indicates a tool-specific error during the * execution. + * * Two streams should be provided, for "expected" output, and for any * error messages. If it is not necessary to distinguish the output, * the same stream may be used for both. * * @apiNote The interpretation of the arguments will be specific to - * each tool. + * each tool. * * @implNote This implementation wraps the {@code out} and {@code err} - * streams within {@link PrintWriter}s, and then calls - * {@link run(PrintWriter, PrintWriter, String[])}. + * streams within {@link PrintWriter}s, and then calls + * {@link #run(PrintWriter, PrintWriter, String[])}. * * @param out a stream to which "expected" output should be written * @@ -112,12 +115,13 @@ * @param args the command-line arguments for the tool * * @return the result of executing the tool. - * A return value of 0 means the tool did not encounter any errors; - * any other value indicates that at least one error occurred during - * execution. + * A return value of 0 means the tool did not encounter any errors; + * any other value indicates that at least one error occurred + * during execution. * * @throws NullPointerException if any of the arguments are {@code null}, - * or if there are any {@code null} values in the {@code args} array + * or if there are any {@code null} values in the {@code args} + * array */ default int run(PrintStream out, PrintStream err, String... args) { Objects.requireNonNull(out); diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/java/util/stream/Collectors.java --- a/jdk/src/java.base/share/classes/java/util/stream/Collectors.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/java/util/stream/Collectors.java Mon Oct 17 15:32:44 2016 +0000 @@ -27,7 +27,6 @@ import java.util.AbstractMap; import java.util.AbstractSet; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; @@ -1720,12 +1719,12 @@ @Override public Set> entrySet() { - return new AbstractSet>() { + return new AbstractSet<>() { @Override public Iterator> iterator() { Map.Entry falseEntry = new SimpleImmutableEntry<>(false, forFalse); Map.Entry trueEntry = new SimpleImmutableEntry<>(true, forTrue); - return Arrays.asList(falseEntry, trueEntry).iterator(); + return List.of(falseEntry, trueEntry).iterator(); } @Override diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/classes/sun/nio/cs/HKSCS.java --- a/jdk/src/java.base/share/classes/sun/nio/cs/HKSCS.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/classes/sun/nio/cs/HKSCS.java Mon Oct 17 15:32:44 2016 +0000 @@ -432,6 +432,8 @@ continue; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); + if (c == UNMAPPABLE_DECODING) + continue; int hi = c >> 8; if (c2b[hi] == C2B_UNMAPPABLE) { c2b[hi] = new char[0x100]; diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/java.base/share/lib/security/default.policy --- a/jdk/src/java.base/share/lib/security/default.policy Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/java.base/share/lib/security/default.policy Mon Oct 17 15:32:44 2016 +0000 @@ -91,7 +91,6 @@ }; grant codeBase "jrt:/jdk.charsets" { - permission java.io.FilePermission "${java.home}/-", "read"; permission java.util.PropertyPermission "os.name", "read"; permission java.util.PropertyPermission "sun.nio.cs.map", "read"; permission java.lang.RuntimePermission "charsetProvider"; diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/jdk.jartool/share/classes/module-info.java --- a/jdk/src/jdk.jartool/share/classes/module-info.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/jdk.jartool/share/classes/module-info.java Mon Oct 17 15:32:44 2016 +0000 @@ -26,5 +26,7 @@ module jdk.jartool { exports com.sun.jarsigner; exports jdk.security.jarsigner; + + provides java.util.spi.ToolProvider with sun.tools.jar.JarToolProvider; } diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java Mon Oct 17 15:32:44 2016 +0000 @@ -27,6 +27,7 @@ import java.io.File; import java.io.PrintStream; +import java.io.PrintWriter; import java.lang.module.ModuleFinder; import java.lang.module.ModuleDescriptor.Version; import java.nio.file.Path; @@ -253,7 +254,8 @@ // process options for (; count < args.length; count++) { - if (args[count].charAt(0) != '-' || args[count].equals("-C")) + if (args[count].charAt(0) != '-' || args[count].equals("-C") + || args[count].equals("--release")) break; String name = args[count]; @@ -289,7 +291,7 @@ throw new BadArgs("error.unrecognized.option", name).showUsage(true); } - static void printHelp(PrintStream out) { + static void printHelp(PrintWriter out) { out.format("%s%n", Main.getMsg("main.help.preopt")); for (OptionType type : OptionType.values()) { boolean typeHeadingWritten = false; @@ -312,16 +314,16 @@ out.format("%n%s%n%n", Main.getMsg("main.help.postopt")); } - static void printCompatHelp(PrintStream out) { + static void printCompatHelp(PrintWriter out) { out.format("%s%n", Main.getMsg("usage.compat")); } - static void printUsageSummary(PrintStream out) { + static void printUsageSummary(PrintWriter out) { out.format("%s%n", Main.getMsg("main.usage.summary")); out.format("%s%n", Main.getMsg("main.usage.summary.try")); } - static void printVersion(PrintStream out) { + static void printVersion(PrintWriter out) { out.format("%s %s%n", "jar", System.getProperty("java.version")); } } diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/jdk.jartool/share/classes/sun/tools/jar/JarToolProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/JarToolProvider.java Mon Oct 17 15:32:44 2016 +0000 @@ -0,0 +1,40 @@ +/* + * 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. + */ + +package sun.tools.jar; + +import java.io.PrintWriter; +import java.util.spi.ToolProvider; + +public class JarToolProvider implements ToolProvider { + public String name() { + return "jar"; + } + + public int run(PrintWriter out, PrintWriter err, String... args) { + boolean ok = new Main(out, err, name()).run(args); + return ok ? 0 : 1; + } +} diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java --- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java Mon Oct 17 15:32:44 2016 +0000 @@ -76,7 +76,7 @@ public class Main { String program; - PrintStream out, err; + PrintWriter out, err; String fname, mname, ename; String zname = ""; String rootjar = null; @@ -189,9 +189,9 @@ USAGE_SUMMARY(GNUStyleOptions::printUsageSummary), VERSION(GNUStyleOptions::printVersion); - private Consumer printFunction; - Info(Consumer f) { this.printFunction = f; } - void print(PrintStream out) { printFunction.accept(out); } + private Consumer printFunction; + Info(Consumer f) { this.printFunction = f; } + void print(PrintWriter out) { printFunction.accept(out); } }; Info info; @@ -252,6 +252,12 @@ } public Main(PrintStream out, PrintStream err, String program) { + this.out = new PrintWriter(out, true); + this.err = new PrintWriter(err, true); + this.program = program; + } + + public Main(PrintWriter out, PrintWriter err, String program) { this.out = out; this.err = err; this.program = program; diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java Mon Oct 17 15:32:44 2016 +0000 @@ -153,7 +153,7 @@ = taskHelper.newOptionsHelper(JlinkTask.class, recognizedOptions); private PrintWriter log; - void setLog(PrintWriter out) { + void setLog(PrintWriter out, PrintWriter err) { log = out; taskHelper.setLog(log); } @@ -182,7 +182,8 @@ int run(String[] args) { if (log == null) { - setLog(new PrintWriter(System.out, true)); + setLog(new PrintWriter(System.out, true), + new PrintWriter(System.err, true)); } try { optionsHelper.handleOptions(this, args); diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Main.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Main.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Main.java Mon Oct 17 15:32:44 2016 +0000 @@ -26,6 +26,7 @@ package jdk.tools.jlink.internal; import java.io.*; +import java.util.spi.ToolProvider; public class Main { public static void main(String... args) throws Exception { @@ -34,17 +35,27 @@ System.exit(rc); } - /** * Entry point that does not call System.exit. * + * @param out output stream + * @param err error output stream * @param args command line arguments - * @param out output stream * @return an exit code. 0 means success, non-zero means an error occurred. */ - public static int run(String[] args, PrintWriter out) { + public static int run(PrintWriter out, PrintWriter err, String... args) { JlinkTask t = new JlinkTask(); - t.setLog(out); + t.setLog(out, err); return t.run(args); } + + public static class JlinkToolProvider implements ToolProvider { + public String name() { + return "jlink"; + } + + public int run(PrintWriter out, PrintWriter err, String... args) { + return Main.run(out, err, args); + } + } } diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java Mon Oct 17 15:32:44 2016 +0000 @@ -32,6 +32,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; +import java.io.PrintWriter; import java.io.UncheckedIOException; import java.lang.module.Configuration; import java.lang.module.ModuleReader; @@ -136,8 +137,8 @@ private static final String MODULE_INFO = "module-info.class"; private Options options; - private PrintStream out = System.out; - void setLog(PrintStream out) { + private PrintWriter out = new PrintWriter(System.out, true); + void setLog(PrintWriter out, PrintWriter err) { this.out = out; } diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/Main.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/Main.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/Main.java Mon Oct 17 15:32:44 2016 +0000 @@ -26,6 +26,7 @@ package jdk.tools.jmod; import java.io.*; +import java.util.spi.ToolProvider; public class Main { public static void main(String... args) throws Exception { @@ -37,13 +38,24 @@ /** * Entry point that does not call System.exit. * + * @param out output stream + * @param err error output stream * @param args command line arguments - * @param out output stream * @return an exit code. 0 means success, non-zero means an error occurred. */ - public static int run(String[] args, PrintStream out) { + public static int run(PrintWriter out, PrintWriter err, String... args) { JmodTask t = new JmodTask(); - t.setLog(out); + t.setLog(out, err); return t.run(args); } + + public static class JmodToolProvider implements ToolProvider { + public String name() { + return "jmod"; + } + + public int run(PrintWriter out, PrintWriter err, String... args) { + return Main.run(out, err, args); + } + } } diff -r 563c1d911dcb -r ce1843f66c03 jdk/src/jdk.jlink/share/classes/module-info.java --- a/jdk/src/jdk.jlink/share/classes/module-info.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/src/jdk.jlink/share/classes/module-info.java Mon Oct 17 15:32:44 2016 +0000 @@ -31,6 +31,9 @@ uses jdk.tools.jlink.plugin.Plugin; + provides java.util.spi.ToolProvider with jdk.tools.jmod.Main.JmodToolProvider; + provides java.util.spi.ToolProvider with jdk.tools.jlink.internal.Main.JlinkToolProvider; + provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.FileCopierPlugin; provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.StripDebugPlugin; provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.ExcludePlugin; diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/java/lang/module/ModuleReader/ModuleReaderTest.java --- a/jdk/test/java/lang/module/ModuleReader/ModuleReaderTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/java/lang/module/ModuleReader/ModuleReaderTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -25,8 +25,8 @@ * @test * @library /lib/testlibrary * @modules java.base/jdk.internal.module - * jdk.jlink/jdk.tools.jmod * jdk.compiler + * jdk.jlink * @build ModuleReaderTest CompilerUtils JarUtils * @run testng ModuleReaderTest * @summary Basic tests for java.lang.module.ModuleReader @@ -48,6 +48,7 @@ import java.nio.file.Paths; import java.util.Arrays; import java.util.Optional; +import java.util.spi.ToolProvider; import jdk.internal.module.ConfigurableModuleFinder; import jdk.internal.module.ConfigurableModuleFinder.Phase; @@ -196,8 +197,11 @@ String cp = MODS_DIR.resolve(TEST_MODULE).toString(); String jmod = dir.resolve("m.jmod").toString(); String[] args = { "create", "--class-path", cp, jmod }; - jdk.tools.jmod.JmodTask task = new jdk.tools.jmod.JmodTask(); - assertEquals(task.run(args), 0); + ToolProvider jmodTool = ToolProvider.findFirst("jmod") + .orElseThrow(() -> + new RuntimeException("jmod tool not found") + ); + assertEquals(jmodTool.run(System.out, System.out, args), 0); test(dir); } diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/java/security/KeyStore/TestKeyStoreBasic.java --- a/jdk/test/java/security/KeyStore/TestKeyStoreBasic.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/java/security/KeyStore/TestKeyStoreBasic.java Mon Oct 17 15:32:44 2016 +0000 @@ -40,7 +40,7 @@ /* * @test - * @bug 8048621 8133090 + * @bug 8048621 8133090 8167371 * @summary Test basic operations with keystores (jks, jceks, pkcs12) * @author Yu-Ching Valerie PENG */ @@ -116,6 +116,8 @@ }; private static final String ALIAS_HEAD = "test"; + private static final String CRYPTO_ALG = "PBEWithHmacSHA256AndAES_128"; + public static void main(String args[]) throws Exception { TestKeyStoreBasic jstest = new TestKeyStoreBasic(); jstest.run(); @@ -125,7 +127,7 @@ for (String provider : PROVIDERS) { try { runTest(provider); - System.out.println("Test with provider " + provider + "passed"); + System.out.println("Test with provider " + provider + " passed"); } catch (java.security.KeyStoreException e) { if (provider.equals("SunPKCS11-Solaris")) { System.out.println("KeyStoreException is expected: " @@ -236,6 +238,44 @@ // compare the creation date of the 2 key stores for all aliases compareCreationDate(ks, ks2, numEntries); + // check setEntry/getEntry with a password protection algorithm + if ("PKCS12".equalsIgnoreCase(ks.getType())) { + System.out.println( + "Skipping the setEntry/getEntry check for PKCS12 keystore..."); + return; + } + String alias = ALIAS_HEAD + ALIAS_HEAD; + KeyStore.PasswordProtection pw = + new KeyStore.PasswordProtection(PASSWD2, CRYPTO_ALG, null); + KeyStore.PrivateKeyEntry entry = + new KeyStore.PrivateKeyEntry(privateKey, new Certificate[]{ cert }); + checkSetEntry(ks, alias, pw, entry); + ks.setEntry(alias, entry, new KeyStore.PasswordProtection(PASSWD2)); + checkGetEntry(ks, alias, pw); + } + + // check setEntry with a password protection algorithm + private void checkSetEntry(KeyStore ks, String alias, + KeyStore.PasswordProtection pw, KeyStore.Entry entry) throws Exception { + try { + ks.setEntry(alias, entry, pw); + throw new Exception( + "ERROR: expected KeyStore.setEntry to throw an exception"); + } catch (KeyStoreException e) { + // ignore the expected exception + } + } + + // check getEntry with a password protection algorithm + private void checkGetEntry(KeyStore ks, String alias, + KeyStore.PasswordProtection pw) throws Exception { + try { + ks.getEntry(alias, pw); + throw new Exception( + "ERROR: expected KeyStore.getEntry to throw an exception"); + } catch (KeyStoreException e) { + // ignore the expected exception + } } // check key store type diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/jdk/internal/util/jar/TestVersionedStream.java --- a/jdk/test/jdk/internal/util/jar/TestVersionedStream.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/jdk/internal/util/jar/TestVersionedStream.java Mon Oct 17 15:32:44 2016 +0000 @@ -25,13 +25,14 @@ * @test * @bug 8163798 * @summary basic tests for multi-release jar versioned streams + * @library /lib/testlibrary * @modules jdk.jartool/sun.tools.jar java.base/jdk.internal.util.jar + * @build jdk.testlibrary.FileUtils * @run testng TestVersionedStream */ import org.testng.Assert; import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -40,29 +41,31 @@ import java.io.InputStream; import java.io.UncheckedIOException; import java.net.URI; -import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.zip.ZipFile; -public class TestVersionedStream { - private String userdir; +import jdk.testlibrary.FileUtils; - @BeforeClass - public void initialize() { - userdir = System.getProperty("user.dir", "."); +public class TestVersionedStream { + private final Path userdir; + private final Set unversionedEntryNames; + + public TestVersionedStream() throws IOException { + userdir = Paths.get(System.getProperty("user.dir", ".")); // These are not real class files even though they end with .class. // They are resource files so jar tool validation won't reject them. @@ -70,91 +73,103 @@ // could be in a concealed package if this was a modular multi-release // jar. createFiles( + "base/p/Bar.class", "base/p/Foo.class", "base/p/Main.class", "v9/p/Foo.class", "v10/p/Foo.class", "v10/q/Bar.class", + "v11/p/Bar.class", "v11/p/Foo.class" ); - jar("cf mmr.jar -C base . --release 9 -C v9 . --release 10 -C v10 . --release 11 -C v11 ."); + jar("cf mmr.jar -C base . --release 9 -C v9 . " + + "--release 10 -C v10 . --release 11 -C v11 ."); System.out.println("Contents of mmr.jar\n======="); - jar("tf mmr.jar"); + + try(JarFile jf = new JarFile("mmr.jar")) { + unversionedEntryNames = jf.stream() + .map(je -> je.getName()) + .peek(System.out::println) + .map(nm -> nm.startsWith("META-INF/versions/") + ? nm.replaceFirst("META-INF/versions/\\d+/", "") + : nm) + .collect(Collectors.toCollection(LinkedHashSet::new)); + } + System.out.println("======="); } @AfterClass public void close() throws IOException { - Path root = Paths.get(userdir); - Files.walkFileTree(root, new SimpleFileVisitor<>() { - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - Files.delete(file); - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { - if (!dir.equals(root)) { - Files.delete(dir); - } - return FileVisitResult.CONTINUE; - } - }); + Files.walk(userdir, 1) + .filter(p -> !p.equals(userdir)) + .forEach(p -> { + try { + if (Files.isDirectory(p)) { + FileUtils.deleteFileTreeWithRetry(p); + } else { + FileUtils.deleteFileIfExistsWithRetry(p); + } + } catch (IOException x) { + throw new UncheckedIOException(x); + } + }); } @DataProvider public Object[][] data() { - List p = List.of( - "META-INF/", - "META-INF/MANIFEST.MF", - "p/", - "p/Foo.class", - "p/Main.class" - ); - List q = List.of( - "META-INF/", - "META-INF/MANIFEST.MF", - "p/", - "p/Foo.class", - "p/Main.class", - "q/", - "q/Bar.class" - ); - Runtime.Version rt = JarFile.runtimeVersion(); return new Object[][] { - {Runtime.Version.parse("8"), p}, - {Runtime.Version.parse("9"), p}, - {Runtime.Version.parse("10"), q}, - {Runtime.Version.parse("11"), q}, - {JarFile.baseVersion(), p}, - {rt, rt.major() > 9 ? q : p} + {Runtime.Version.parse("8")}, + {Runtime.Version.parse("9")}, + {Runtime.Version.parse("10")}, + {Runtime.Version.parse("11")}, + {JarFile.baseVersion()}, + {JarFile.runtimeVersion()} }; } @Test(dataProvider="data") - public void test(Runtime.Version version, List names) throws Exception { + public void test(Runtime.Version version) throws Exception { try (JarFile jf = new JarFile(new File("mmr.jar"), false, ZipFile.OPEN_READ, version); - Stream jes = jdk.internal.util.jar.VersionedStream.stream(jf)) + Stream jes = jdk.internal.util.jar.VersionedStream.stream(jf)) { Assert.assertNotNull(jes); - List entries = jes.collect(Collectors.toList()); + // put versioned entries in list so we can reuse them + List versionedEntries = jes.collect(Collectors.toList()); + + Assert.assertTrue(versionedEntries.size() > 0); + + // also keep the names + List versionedNames = new ArrayList<>(versionedEntries.size()); + + // verify the correct order while building enames + Iterator allIt = unversionedEntryNames.iterator(); + Iterator verIt = versionedEntries.iterator(); + boolean match = false; - // verify the correct order - List enames = entries.stream() - .map(je -> je.getName()) - .collect(Collectors.toList()); - Assert.assertEquals(enames, names); + while (verIt.hasNext()) { + match = false; + if (!allIt.hasNext()) break; + String name = verIt.next().getName(); + versionedNames.add(name); + while (allIt.hasNext()) { + if (name.equals(allIt.next())) { + match = true; + break; + } + } + } + if (!match) { + Assert.fail("versioned entries not in same order as unversioned entries"); + } // verify the contents Map contents = new HashMap<>(); + contents.put("p/Bar.class", "base/p/Bar.class\n"); contents.put("p/Main.class", "base/p/Main.class\n"); - if (version.major() > 9) { - contents.put("q/Bar.class", "v10/q/Bar.class\n"); - } switch (version.major()) { case 8: contents.put("p/Foo.class", "base/p/Foo.class\n"); @@ -164,9 +179,12 @@ break; case 10: contents.put("p/Foo.class", "v10/p/Foo.class\n"); + contents.put("q/Bar.class", "v10/q/Bar.class\n"); break; case 11: + contents.put("p/Bar.class", "v11/p/Bar.class\n"); contents.put("p/Foo.class", "v11/p/Foo.class\n"); + contents.put("q/Bar.class", "v10/q/Bar.class\n"); break; default: Assert.fail("Test out of date, please add more cases"); @@ -174,9 +192,9 @@ contents.entrySet().stream().forEach(e -> { String name = e.getKey(); - int i = enames.indexOf(name); + int i = versionedNames.indexOf(name); Assert.assertTrue(i != -1, name + " not in enames"); - JarEntry je = entries.get(i); + JarEntry je = versionedEntries.get(i); try (InputStream is = jf.getInputStream(je)) { String s = new String(is.readAllBytes()); Assert.assertTrue(s.endsWith(e.getValue()), s); @@ -210,5 +228,4 @@ new sun.tools.jar.Main(System.out, System.err, "jar") .run(args.split(" +")); } - } diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/sun/nio/cs/TestHKSCS.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/sun/nio/cs/TestHKSCS.java Mon Oct 17 15:32:44 2016 +0000 @@ -0,0 +1,49 @@ +/* + * 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 8166258 + * @summary Some corner cases for hkscs charsets + * @modules jdk.charsets + * @run main TestHKSCS + */ + +import java.util.Arrays; + +public class TestHKSCS { + public static void main(String args[]) throws Exception { + String[] charsets = { "x-MS950-HKSCS-XP", + "x-MS950-HKSCS", + "Big5-HKSCS", + "x-Big5-HKSCS-2001" + }; + String s = "\ufffd\ud87f\udffd"; + byte[] bytes = new byte[] { 0x3f, 0x3f }; + for (String cs : charsets) { + if (!Arrays.equals(bytes, s.getBytes(cs))) { + throw new RuntimeException(cs + " failed to decode u+fffd"); + } + } + } +} diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/sun/security/pkcs11/PKCS11Test.java --- a/jdk/test/sun/security/pkcs11/PKCS11Test.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/sun/security/pkcs11/PKCS11Test.java Mon Oct 17 15:32:44 2016 +0000 @@ -299,11 +299,12 @@ + props.getProperty("os.arch") + "-" + props.getProperty("sun.arch.data.model"); String[] nssLibDirs = osMap.get(osid); if (nssLibDirs == null) { - System.out.println("Unsupported OS, skipping: " + osid); + System.out.println("Warning: unsupported OS: " + osid + + ", please initialize NSS librarys location firstly, skipping test"); return null; } if (nssLibDirs.length == 0) { - System.out.println("NSS not supported on this platform, skipping test"); + System.out.println("Warning: NSS not supported on this platform, skipping test"); return null; } String nssLibDir = null; @@ -315,6 +316,10 @@ break; } } + if (nssLibDir == null) { + System.out.println("Warning: can't find NSS librarys on this machine, skipping test"); + return null; + } return nssLibDir; } @@ -624,6 +629,11 @@ PKCS11_BASE + "/nss/lib/windows-amd64/".replace('/', SEP)}); osMap.put("MacOSX-x86_64-64", new String[]{ PKCS11_BASE + "/nss/lib/macosx-x86_64/"}); + osMap.put("Linux-arm-32", new String[]{ + "/usr/lib/arm-linux-gnueabi/nss/", + "/usr/lib/arm-linux-gnueabihf/nss/"}); + osMap.put("Linux-aarch64-64", new String[]{ + "/usr/lib/aarch64-linux-gnu/nss/"}); } private final static char[] hexDigits = "0123456789abcdef".toCharArray(); diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/sun/tools/jrunscript/jrunscript-DTest.sh --- a/jdk/test/sun/tools/jrunscript/jrunscript-DTest.sh Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/sun/tools/jrunscript/jrunscript-DTest.sh Mon Oct 17 15:32:44 2016 +0000 @@ -33,7 +33,7 @@ . ${TESTSRC-.}/common.sh setup -${JAVA} -cp ${TESTCLASSES} CheckEngine +${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine if [ $? -eq 2 ]; then echo "No js engine found and engine not required; test vacuously passes." exit 0 diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/sun/tools/jrunscript/jrunscript-argsTest.sh --- a/jdk/test/sun/tools/jrunscript/jrunscript-argsTest.sh Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/sun/tools/jrunscript/jrunscript-argsTest.sh Mon Oct 17 15:32:44 2016 +0000 @@ -33,7 +33,7 @@ . ${TESTSRC-.}/common.sh setup -${JAVA} -cp ${TESTCLASSES} CheckEngine +${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine if [ $? -eq 2 ]; then echo "No js engine found and engine not required; test vacuously passes." exit 0 diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/sun/tools/jrunscript/jrunscript-cpTest.sh --- a/jdk/test/sun/tools/jrunscript/jrunscript-cpTest.sh Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/sun/tools/jrunscript/jrunscript-cpTest.sh Mon Oct 17 15:32:44 2016 +0000 @@ -33,14 +33,14 @@ . ${TESTSRC-.}/common.sh setup -${JAVA} -cp ${TESTCLASSES} CheckEngine +${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine if [ $? -eq 2 ]; then echo "No js engine found and engine not required; test vacuously passes." exit 0 fi rm -f Hello.class -${JAVAC} ${TESTSRC}/Hello.java -d . +${JAVAC} ${TESTTOOLVMOPTS} ${TESTJAVACOPTS} ${TESTSRC}/Hello.java -d . # we check whether classpath setting for app classes # work with jrunscript. Script should be able to diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/sun/tools/jrunscript/jrunscript-eTest.sh --- a/jdk/test/sun/tools/jrunscript/jrunscript-eTest.sh Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/sun/tools/jrunscript/jrunscript-eTest.sh Mon Oct 17 15:32:44 2016 +0000 @@ -33,7 +33,7 @@ . ${TESTSRC-.}/common.sh setup -${JAVA} -cp ${TESTCLASSES} CheckEngine +${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine if [ $? -eq 2 ]; then echo "No js engine found and engine not required; test vacuously passes." exit 0 diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/sun/tools/jrunscript/jrunscript-fTest.sh --- a/jdk/test/sun/tools/jrunscript/jrunscript-fTest.sh Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/sun/tools/jrunscript/jrunscript-fTest.sh Mon Oct 17 15:32:44 2016 +0000 @@ -33,7 +33,7 @@ . ${TESTSRC-.}/common.sh setup -${JAVA} -cp ${TESTCLASSES} CheckEngine +${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine if [ $? -eq 2 ]; then echo "No js engine found and engine not required; test vacuously passes." exit 0 diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/sun/tools/jrunscript/jrunscriptTest.sh --- a/jdk/test/sun/tools/jrunscript/jrunscriptTest.sh Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/sun/tools/jrunscript/jrunscriptTest.sh Mon Oct 17 15:32:44 2016 +0000 @@ -33,7 +33,7 @@ . ${TESTSRC-.}/common.sh setup -${JAVA} -cp ${TESTCLASSES} CheckEngine +${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine if [ $? -eq 2 ]; then echo "No js engine found and engine not required; test vacuously passes." exit 0 diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/tools/jar/ChangeDir.java --- a/jdk/test/tools/jar/ChangeDir.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/tools/jar/ChangeDir.java Mon Oct 17 15:32:44 2016 +0000 @@ -24,7 +24,7 @@ /** * @test * @bug 4806786 8023113 - * @modules jdk.jartool/sun.tools.jar + * @modules jdk.jartool * @summary jar -C doesn't ignore multiple // in path */ @@ -32,10 +32,15 @@ import java.nio.file.*; import java.util.*; import java.util.jar.*; +import java.util.spi.ToolProvider; import java.util.stream.Stream; -import sun.tools.jar.Main; public class ChangeDir { + private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") + .orElseThrow(() -> + new RuntimeException("jar tool not found") + ); + private final static String jarName = "test.jar"; private final static String fileName = "hello.txt"; @@ -88,8 +93,9 @@ argList.add(topDir.toString() + sep + "a" + sep + sep + "b"); // Note double 'sep' is intentional argList.add(fileName); - Main jarTool = new Main(System.out, System.err, "jar"); - if (!jarTool.run(argList.toArray(new String[argList.size()]))) { + int rc = JAR_TOOL.run(System.out, System.err, + argList.toArray(new String[argList.size()])); + if (rc != 0) { fail("Could not create jar file."); } diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/tools/jar/InputFilesTest.java --- a/jdk/test/tools/jar/InputFilesTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/tools/jar/InputFilesTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -29,7 +29,7 @@ * duplicates that sometimes cause exceptions and other times do not, * demonstrating identical behavior to JDK 8 jar tool. * @library /lib/testlibrary - * @modules jdk.jartool/sun.tools.jar + * @modules jdk.jartool * @build jdk.testlibrary.FileUtils * @run testng InputFilesTest */ @@ -47,12 +47,18 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; +import java.util.spi.ToolProvider; import java.util.stream.Stream; import java.util.zip.ZipException; import jdk.testlibrary.FileUtils; public class InputFilesTest { + private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") + .orElseThrow(() -> + new RuntimeException("jar tool not found") + ); + private final String nl = System.lineSeparator(); private final ByteArrayOutputStream baos = new ByteArrayOutputStream(); private final PrintStream out = new PrintStream(baos); @@ -195,9 +201,9 @@ PrintStream err = new PrintStream(baes); PrintStream saveErr = System.err; System.setErr(err); - boolean ok = new sun.tools.jar.Main(out, err, "jar").run(cmdline.split(" +")); + int rc = JAR_TOOL.run(out, err, cmdline.split(" +")); System.setErr(saveErr); - if (!ok) { + if (rc != 0) { String s = baes.toString(); if (s.startsWith("java.util.zip.ZipException: duplicate entry: ")) { throw new ZipException(s); diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/tools/jar/JarBackSlash.java --- a/jdk/test/tools/jar/JarBackSlash.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/tools/jar/JarBackSlash.java Mon Oct 17 15:32:44 2016 +0000 @@ -28,7 +28,7 @@ /* * @test * @bug 7201156 - * @modules jdk.jartool/sun.tools.jar + * @modules jdk.jartool * @summary jar tool fails to convert file separation characters for list and extract * @author Sean Chou */ @@ -43,10 +43,13 @@ import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; - -import sun.tools.jar.Main; +import java.util.spi.ToolProvider; public class JarBackSlash { + private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") + .orElseThrow(() -> + new RuntimeException("jar tool not found") + ); // used construct an entry JarBackSlash/dir/file.txt private static String JARBACKSLASH = "JarBackSlash"; @@ -78,8 +81,8 @@ PipedInputStream pipedInput = new PipedInputStream(pipedOutput); PrintStream out = new PrintStream(pipedOutput); - Main jarTool = new Main(out, System.err, "jar"); - if (!jarTool.run(jarArgs)) { + int rc = JAR_TOOL.run(out, System.err, jarArgs); + if (rc != 0) { fail("Could not list jar file."); } @@ -101,8 +104,8 @@ PipedInputStream pipedInput = new PipedInputStream(pipedOutput); PrintStream out = new PrintStream(pipedOutput); - Main jarTool = new Main(out, System.err, "jar"); - if (!jarTool.run(jarArgs)) { + int rc = JAR_TOOL.run(out, System.err, jarArgs); + if (rc != 0) { fail("Could not list jar file."); } diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/tools/jar/JarEntryTime.java --- a/jdk/test/tools/jar/JarEntryTime.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/tools/jar/JarEntryTime.java Mon Oct 17 15:32:44 2016 +0000 @@ -24,7 +24,7 @@ /** * @test * @bug 4225317 6969651 - * @modules jdk.jartool/sun.tools.jar + * @modules jdk.jartool * @summary Check extracted files have date as per those in the .jar file */ @@ -33,9 +33,14 @@ import java.nio.file.attribute.FileTime; import java.util.Date; import java.util.TimeZone; -import sun.tools.jar.Main; +import java.util.spi.ToolProvider; public class JarEntryTime { + static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") + .orElseThrow(() -> + new RuntimeException("jar tool not found") + ); + // ZipEntry's mod date has 2 seconds precision: give extra time to // allow for e.g. rounding/truncation and networked/samba drives. @@ -114,10 +119,8 @@ check(fileInner.setLastModified(earlier)); // Make a jar file from that directory structure - Main jartool = new Main(System.out, System.err, "jar"); - check(jartool.run(new String[] { - "cf", - jarFile.getName(), dirOuter.getName() } )); + check(JAR_TOOL.run(System.out, System.err, + "cf", jarFile.getName(), dirOuter.getName()) == 0); check(jarFile.exists()); check(cleanup(dirInner)); @@ -142,7 +145,6 @@ final long start = testFile.lastModified(); // Extract and check the last modified values are the current times. - // See sun.tools.jar.Main extractJar(jarFile, true); try (PrintWriter pw = new PrintWriter(testFile)) { diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/tools/jar/ReleaseBeforeFiles.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/tools/jar/ReleaseBeforeFiles.java Mon Oct 17 15:32:44 2016 +0000 @@ -0,0 +1,165 @@ +/* + * 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 8167237 + * @summary test that both old style command line options and new gnu style + * command line options work with the --release option whether or + * not the --release option is preceded by a file name. + * @library /lib/testlibrary + * @modules jdk.jartool/sun.tools.jar + * @build jdk.testlibrary.FileUtils + * @run testng ReleaseBeforeFiles + */ + +import org.testng.Assert; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.stream.Stream; + +import jdk.testlibrary.FileUtils; + +public class ReleaseBeforeFiles { + private Runnable onCompletion; + + @BeforeMethod + public void reset() { + onCompletion = null; + } + + @AfterMethod + public void run() { + if (onCompletion != null) { + onCompletion.run(); + } + } + + @Test // passes before bug fix + public void test1() throws IOException { + mkdir("test1"); + touch("test1/testfile1"); + jar("cf test.jar --release 9 test1"); + jar("tf test.jar"); + rm("test.jar test1"); + } + + @Test // fails before bug fix + public void test2() throws IOException { + System.out.println("====="); + mkdir("test1"); + touch("test1/testfile1"); + onCompletion = () -> rm("test.jar test1"); + jar("--create --file=test.jar --release 9 test1"); + jar("tf test.jar"); + } + + @Test // passes before bug fix + public void test3() throws IOException { + System.out.println("====="); + mkdir("test1"); + touch("test1/testfile1"); + jar("-cf test.jar -C test1 ."); + jar("-uf test.jar --release 9 -C test1 ."); + jar("tf test.jar"); + rm("test.jar test1"); + } + + @Test // fails before bug fix + public void test4() throws IOException { + System.out.println("====="); + mkdir("test1"); + touch("test1/testfile1"); + onCompletion = () -> rm("test.jar test1"); + jar("--create --file=test.jar -C test1 ."); + jar("--update --file=test.jar --release 9 -C test1 ."); + jar("tf test.jar"); + } + + @Test // passes before bug fix since test2 precedes --release 9 + public void test5() throws IOException { + System.out.println("====="); + mkdir("test1 test2"); + touch("test1/testfile1 test2/testfile2"); + jar("--create --file=test.jar -C test1 ."); + jar("--update --file=test.jar test2 --release 9 -C test1 ."); + jar("tf test.jar"); + rm("test.jar test1 test2"); + } + + private Stream mkpath(String... args) { + return Arrays.stream(args).map(d -> Paths.get(".", d.split("/"))); + } + + private void mkdir(String cmdline) { + System.out.println("mkdir -p " + cmdline); + mkpath(cmdline.split(" +")).forEach(p -> { + try { + Files.createDirectories(p); + } catch (IOException x) { + throw new UncheckedIOException(x); + } + }); + } + + private void touch(String cmdline) { + System.out.println("touch " + cmdline); + mkpath(cmdline.split(" +")).forEach(p -> { + try { + Files.createFile(p); + } catch (IOException x) { + throw new UncheckedIOException(x); + } + }); + } + + private void rm(String cmdline) { + System.out.println("rm -rf " + cmdline); + mkpath(cmdline.split(" +")).forEach(p -> { + try { + if (Files.isDirectory(p)) { + FileUtils.deleteFileTreeWithRetry(p); + } else { + FileUtils.deleteFileIfExistsWithRetry(p); + } + } catch (IOException x) { + throw new UncheckedIOException(x); + } + }); + } + + private void jar(String cmdline) throws IOException { + System.out.println("jar " + cmdline); + boolean ok = new sun.tools.jar.Main(System.out, System.err, "jar") + .run(cmdline.split(" +")); + Assert.assertTrue(ok); + } +} diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/tools/jar/UpdateJar.java --- a/jdk/test/tools/jar/UpdateJar.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/tools/jar/UpdateJar.java Mon Oct 17 15:32:44 2016 +0000 @@ -24,7 +24,7 @@ /** * @test * @bug 7175845 - * @modules jdk.jartool/sun.tools.jar + * @modules jdk.jartool * @summary jar -uf should not change file permission */ @@ -32,9 +32,13 @@ import java.nio.file.*; import java.nio.file.attribute.*; import java.util.Set; -import sun.tools.jar.Main; +import java.util.spi.ToolProvider; public class UpdateJar { + private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") + .orElseThrow(() -> + new RuntimeException("jar tool not found") + ); private static void cleanup(String... fnames) throws Throwable { for (String fname : fnames) { @@ -55,12 +59,12 @@ fos1.write(0); } String[] jarArgs = new String[] {"cfM0", jar, e0}; - if (!new Main(System.out, System.err, "jar").run(jarArgs)) { + if (JAR_TOOL.run(System.out, System.err, jarArgs) != 0) { fail("Could not create jar file."); } Set pm = Files.getPosixFilePermissions(Paths.get(jar)); jarArgs = new String[] {"uf", jar, e1}; - if (!new Main(System.out, System.err, "jar").run(jarArgs)) { + if (JAR_TOOL.run(System.out, System.err, jarArgs) != 0) { fail("Could not create jar file."); } equal(pm, Files.getPosixFilePermissions(Paths.get(jar))); diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/tools/jar/UpdateManifest.java --- a/jdk/test/tools/jar/UpdateManifest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/tools/jar/UpdateManifest.java Mon Oct 17 15:32:44 2016 +0000 @@ -24,7 +24,7 @@ /** * @test * @bug 6434207 6442687 6984046 - * @modules jdk.jartool/sun.tools.jar + * @modules jdk.jartool * @summary Ensure that jar ufm actually updates the * existing jar file's manifest with contents of the * manifest file. @@ -32,14 +32,19 @@ import java.io.*; import java.util.logging.*; +import java.util.spi.ToolProvider; import java.util.zip.*; -import sun.tools.jar.Main; public class UpdateManifest { static PrintStream out = System.out; static PrintStream err = System.err; static boolean debug = true; + static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") + .orElseThrow(() -> + new RuntimeException("jar tool not found") + ); + static final Logger JAR_LOGGER = Logger.getLogger("java.util.jar"); public static void realMain(String[] args) throws Throwable { @@ -64,17 +69,14 @@ // Create a jar file, specifying a Main-Class final String jarFileName = "um-existence.jar"; new File(jarFileName).delete(); // remove pre-existing first! - Main jartool = new Main(out, err, "jar"); - boolean status = jartool.run( - new String[] { "cfe", jarFileName, "Hello", existence.getPath() }); - check(status); + int status = JAR_TOOL.run(out, err, "cfe", jarFileName, + "Hello", existence.getPath()); + check(status == 0); checkManifest(jarFileName, "Hello"); // Update that jar file by changing the Main-Class - jartool = new Main(out, err, "jar"); - status = jartool.run( - new String[] { "ufe", jarFileName, "Bye" }); - check(status); + status = JAR_TOOL.run(out, err, "ufe", jarFileName, "Bye"); + check(status == 0); checkManifest(jarFileName, "Bye"); } @@ -101,11 +103,9 @@ // Create a jar file final String jarFileName = "um-test.jar"; new File(jarFileName).delete(); // remove pre-existing first! - Main jartool = new Main(out, err, "jar"); - boolean status = jartool.run( - new String[] {"cfm", jarFileName, - manifestOrig.getPath(), hello.getPath() }); - check(status); + int status = JAR_TOOL.run(out, err, "cfm", jarFileName, + manifestOrig.getPath(), hello.getPath()); + check(status == 0); // Create a new manifest, to use in updating the jar file. File manifestUpdate = File.createTempFile("manifestUpdate", ".txt"); @@ -122,10 +122,9 @@ pw.close(); // Update jar file with manifest - jartool = new Main(out, err, "jar"); - status = jartool.run( - new String[] { "ufm", jarFileName, manifestUpdate.getPath() }); - check(status); + status = JAR_TOOL.run(out, err, "ufm", + jarFileName, manifestUpdate.getPath()); + check(status == 0); // Extract jar, and verify contents of manifest file File f = new File(jarFileName); diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/tools/jar/index/MetaInf.java --- a/jdk/test/tools/jar/index/MetaInf.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/tools/jar/index/MetaInf.java Mon Oct 17 15:32:44 2016 +0000 @@ -24,17 +24,21 @@ /* * @test * @bug 4408526 6854795 - * @modules jdk.jartool/sun.tools.jar + * @modules jdk.jartool * @summary Index the non-meta files in META-INF, such as META-INF/services. */ import java.io.*; import java.util.Arrays; import java.util.jar.*; -import sun.tools.jar.Main; +import java.util.spi.ToolProvider; import java.util.zip.ZipFile; public class MetaInf { + static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") + .orElseThrow(() -> + new RuntimeException("jar tool not found") + ); static String jarName = "a.jar"; static String INDEX = "META-INF/INDEX.LIST"; @@ -43,7 +47,7 @@ System.getProperty("test.src") + File.separatorChar + "jarcontents"; static void run(String ... args) { - if (! new Main(System.out, System.err, "jar").run(args)) + if (JAR_TOOL.run(System.out, System.err, args) != 0) throw new Error("jar failed: args=" + Arrays.toString(args)); } diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/tools/jlink/JLinkTest.java --- a/jdk/test/tools/jlink/JLinkTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/tools/jlink/JLinkTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -32,13 +32,13 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.spi.ToolProvider; import java.util.stream.Stream; import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.internal.PluginRepository; import tests.Helper; import tests.JImageGenerator; -import tests.JImageGenerator.InMemoryFile; /* * @test @@ -48,13 +48,17 @@ * @modules java.base/jdk.internal.jimage * jdk.jdeps/com.sun.tools.classfile * jdk.jlink/jdk.tools.jlink.internal - * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage * jdk.compiler * @build tests.* * @run main/othervm -Xmx1g JLinkTest */ public class JLinkTest { + static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink") + .orElseThrow(() -> + new RuntimeException("jlink tool not found") + ); + // number of built-in plugins from jdk.jlink module private static int getNumJlinkPlugins() { ModuleDescriptor desc = Plugin.class.getModule().getDescriptor(); @@ -180,7 +184,8 @@ { // Help StringWriter writer = new StringWriter(); - jdk.tools.jlink.internal.Main.run(new String[]{"--help"}, new PrintWriter(writer)); + PrintWriter pw = new PrintWriter(writer); + JLINK_TOOL.run(pw, pw, "--help"); String output = writer.toString(); if (output.split("\n").length < 10) { System.err.println(output); @@ -202,7 +207,9 @@ { // List plugins StringWriter writer = new StringWriter(); - jdk.tools.jlink.internal.Main.run(new String[]{"--list-plugins"}, new PrintWriter(writer)); + PrintWriter pw = new PrintWriter(writer); + + JLINK_TOOL.run(pw, pw, "--list-plugins"); String output = writer.toString(); long number = Stream.of(output.split("\\R")) .filter((s) -> s.matches("Plugin Name:.*")) diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/tools/jlink/basic/BasicTest.java --- a/jdk/test/tools/jlink/basic/BasicTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/tools/jlink/basic/BasicTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -27,8 +27,7 @@ * @author Andrei Eremeev * @library /lib/testlibrary * @modules java.base/jdk.internal.module - * jdk.jlink/jdk.tools.jlink.internal - * jdk.jlink/jdk.tools.jmod + * jdk.jlink * jdk.compiler * @build jdk.testlibrary.ProcessTools * jdk.testlibrary.OutputAnalyzer @@ -44,11 +43,21 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.spi.ToolProvider; import jdk.testlibrary.OutputAnalyzer; import jdk.testlibrary.ProcessTools; public class BasicTest { + static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod") + .orElseThrow(() -> + new RuntimeException("jmod tool not found") + ); + + static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink") + .orElseThrow(() -> + new RuntimeException("jlink tool not found") + ); private final Path jdkHome = Paths.get(System.getProperty("test.jdk")); private final Path jdkMods = jdkHome.resolve("jmods"); @@ -110,20 +119,22 @@ "--add-modules", modName, "--output", image.toString()); Collections.addAll(args, options); - int rc = jdk.tools.jlink.internal.Main.run(args.toArray(new String[args.size()]), new PrintWriter(System.out)); + + PrintWriter pw = new PrintWriter(System.out); + int rc = JLINK_TOOL.run(pw, pw, args.toArray(new String[args.size()])); if (rc != 0) { throw new AssertionError("Jlink failed: rc = " + rc); } } private void runJmod(String cp, String modName) { - int rc = jdk.tools.jmod.Main.run(new String[] { + int rc = JMOD_TOOL.run(System.out, System.out, new String[] { "create", "--class-path", cp, "--module-version", "1.0", "--main-class", "jdk.test.Test", jmods.resolve(modName + ".jmod").toString(), - }, System.out); + }); if (rc != 0) { throw new AssertionError("Jmod failed: rc = " + rc); } diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/tools/jmod/JmodNegativeTest.java --- a/jdk/test/tools/jmod/JmodNegativeTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/tools/jmod/JmodNegativeTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -24,8 +24,8 @@ /* * @test * @library /lib/testlibrary - * @modules jdk.jlink/jdk.tools.jmod - * jdk.compiler + * @modules jdk.compiler + * jdk.jlink * @build jdk.testlibrary.FileUtils CompilerUtils * @run testng JmodNegativeTest * @summary Negative tests for jmod @@ -39,6 +39,7 @@ import java.util.List; import java.util.function.Consumer; import java.util.function.Supplier; +import java.util.spi.ToolProvider; import java.util.zip.ZipOutputStream; import jdk.testlibrary.FileUtils; import org.testng.annotations.BeforeTest; @@ -51,6 +52,11 @@ public class JmodNegativeTest { + static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod") + .orElseThrow(() -> + new RuntimeException("jmod tool not found") + ); + static final String TEST_SRC = System.getProperty("test.src", "."); static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); static final Path EXPLODED_DIR = Paths.get("build"); @@ -515,7 +521,7 @@ ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); System.out.println("jmod " + Arrays.asList(args)); - int ec = jdk.tools.jmod.Main.run(args, ps); + int ec = JMOD_TOOL.run(ps, ps, args); return new JmodResult(ec, new String(baos.toByteArray(), UTF_8)); } diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/tools/jmod/JmodTest.java --- a/jdk/test/tools/jmod/JmodTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/tools/jmod/JmodTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -24,8 +24,8 @@ /* * @test * @library /lib/testlibrary - * @modules jdk.jlink/jdk.tools.jmod - * jdk.compiler + * @modules jdk.compiler + * jdk.jlink * @build jdk.testlibrary.FileUtils CompilerUtils * @run testng JmodTest * @summary Basic test for jmod @@ -38,6 +38,7 @@ import java.util.*; import java.util.function.Consumer; import java.util.regex.Pattern; +import java.util.spi.ToolProvider; import java.util.stream.Stream; import jdk.testlibrary.FileUtils; import org.testng.annotations.BeforeTest; @@ -51,6 +52,11 @@ public class JmodTest { + static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod") + .orElseThrow(() -> + new RuntimeException("jmod tool not found") + ); + static final String TEST_SRC = System.getProperty("test.src", "."); static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); static final Path EXPLODED_DIR = Paths.get("build"); @@ -479,7 +485,7 @@ ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); System.out.println("jmod " + Arrays.asList(args)); - int ec = jdk.tools.jmod.Main.run(args, ps); + int ec = JMOD_TOOL.run(ps, ps, args); return new JmodResult(ec, new String(baos.toByteArray(), UTF_8)); } diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/tools/jmod/hashes/HashesTest.java --- a/jdk/test/tools/jmod/hashes/HashesTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/tools/jmod/hashes/HashesTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -27,8 +27,7 @@ * @author Andrei Eremeev * @library /lib/testlibrary * @modules java.base/jdk.internal.module - * jdk.jlink/jdk.tools.jlink.internal - * jdk.jlink/jdk.tools.jmod + * jdk.jlink * jdk.compiler * @build CompilerUtils * @run testng HashesTest @@ -53,6 +52,7 @@ import java.util.List; import java.util.Optional; import java.util.Set; +import java.util.spi.ToolProvider; import java.util.stream.Collectors; import jdk.internal.module.ConfigurableModuleFinder; @@ -63,6 +63,10 @@ import static org.testng.Assert.*; public class HashesTest { + static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod") + .orElseThrow(() -> + new RuntimeException("jmod tool not found") + ); private final Path testSrc = Paths.get(System.getProperty("test.src")); private final Path modSrc = testSrc.resolve("src"); @@ -204,7 +208,7 @@ } private void runJmod(List args) { - int rc = jdk.tools.jmod.Main.run(args.toArray(new String[args.size()]), System.out); + int rc = JMOD_TOOL.run(System.out, System.out, args.toArray(new String[args.size()])); System.out.println("jmod options: " + args.stream().collect(Collectors.joining(" "))); if (rc != 0) { throw new AssertionError("Jmod failed: rc = " + rc); diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/tools/launcher/modules/basic/BasicTest.java --- a/jdk/test/tools/launcher/modules/basic/BasicTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/tools/launcher/modules/basic/BasicTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -24,9 +24,9 @@ /** * @test * @library /lib/testlibrary - * @modules jdk.jartool/sun.tools.jar - * jdk.jlink/jdk.tools.jmod - * jdk.compiler + * @modules jdk.compiler + * jdk.jartool + * jdk.jlink * @build BasicTest CompilerUtils jdk.testlibrary.* * @run testng BasicTest * @summary Basic test of starting an application as a module @@ -36,6 +36,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.spi.ToolProvider; import jdk.testlibrary.ProcessTools; @@ -46,6 +47,14 @@ @Test public class BasicTest { + private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") + .orElseThrow(() -> + new RuntimeException("jar tool not found") + ); + private static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod") + .orElseThrow(() -> + new RuntimeException("jmod tool not found") + ); private static final Path USER_DIR = Paths.get(System.getProperty("user.dir")); @@ -132,10 +141,8 @@ "--main-class=" + MAIN_CLASS, "-C", classes, "." }; - boolean success - = new sun.tools.jar.Main(System.out, System.out, "jar") - .run(args); - assertTrue(success); + int rc = JAR_TOOL.run(System.out, System.out, args); + assertTrue(rc == 0); // java --module-path mlib -module $TESTMODULE int exitValue = exec("--module-path", dir.toString(), @@ -164,8 +171,8 @@ "--main-class", MAIN_CLASS, jmod }; - jdk.tools.jmod.JmodTask task = new jdk.tools.jmod.JmodTask(); - assertEquals(task.run(args), 0); + + assertEquals(JMOD_TOOL.run(System.out, System.out, args), 0); // java --module-path mods --module $TESTMODULE int exitValue = exec("--module-path", dir.toString(), @@ -229,10 +236,8 @@ "--file=" + jar, "-C", classes, "." }; - boolean success - = new sun.tools.jar.Main(System.out, System.out, "jar") - .run(args); - assertTrue(success); + int rc = JAR_TOOL.run(System.out, System.out, args); + assertTrue(rc == 0); // java --module-path mods -m $TESTMODULE int exitValue = exec("--module-path", dir.toString(), "-m", TEST_MODULE); diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/tools/launcher/modules/dryrun/DryRunTest.java --- a/jdk/test/tools/launcher/modules/dryrun/DryRunTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/tools/launcher/modules/dryrun/DryRunTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -26,7 +26,7 @@ * @bug 8159596 * @library /lib/testlibrary * @modules jdk.compiler - * jdk.jartool/sun.tools.jar + * jdk.jartool * @build DryRunTest CompilerUtils jdk.testlibrary.ProcessTools * @run testng DryRunTest * @summary Test java --dry-run @@ -37,6 +37,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.spi.ToolProvider; import jdk.testlibrary.ProcessTools; @@ -78,8 +79,8 @@ Files.createDirectories(LIBS_DIR); // create JAR files with no module-info.class - assertTrue(jar(M_MODULE, "p/Lib.class")); - assertTrue(jar(TEST_MODULE, "jdk/test/Main.class")); + assertTrue(jar(M_MODULE, "p/Lib.class") == 0); + assertTrue(jar(TEST_MODULE, "jdk/test/Main.class") == 0); } /** @@ -197,7 +198,12 @@ assertTrue(exitValue != 0); } - private static boolean jar(String name, String entries) throws IOException { + private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") + .orElseThrow(() -> + new RuntimeException("jar tool not found") + ); + + private static int jar(String name, String entries) throws IOException { Path jar = LIBS_DIR.resolve(name + ".jar"); // jar --create ... @@ -207,8 +213,6 @@ "--file=" + jar, "-C", classes, entries }; - boolean success - = new sun.tools.jar.Main(System.out, System.out, "jar").run(args); - return success; + return JAR_TOOL.run(System.out, System.out, args); } } diff -r 563c1d911dcb -r ce1843f66c03 jdk/test/tools/lib/tests/JImageGenerator.java --- a/jdk/test/tools/lib/tests/JImageGenerator.java Mon Oct 17 15:31:50 2016 +0000 +++ b/jdk/test/tools/lib/tests/JImageGenerator.java Mon Oct 17 15:32:44 2016 +0000 @@ -338,6 +338,10 @@ } public static class JModTask { + static final java.util.spi.ToolProvider JMOD_TOOL = + java.util.spi.ToolProvider.findFirst("jmod").orElseThrow(() -> + new RuntimeException("jmod tool not found") + ); private final List classpath = new ArrayList<>(); private final List libs = new ArrayList<>(); @@ -477,7 +481,8 @@ String[] args = optionsJMod(cmd); System.err.println("jmod options: " + optionsPrettyPrint(args)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); - int exitCode = jdk.tools.jmod.Main.run(args, new PrintStream(baos)); + PrintStream ps = new PrintStream(baos); + int exitCode = JMOD_TOOL.run(ps, ps, args); String msg = new String(baos.toByteArray()); return new Result(exitCode, msg, output); } @@ -556,6 +561,10 @@ } public static class JLinkTask { + static final java.util.spi.ToolProvider JLINK_TOOL = + java.util.spi.ToolProvider.findFirst("jlink").orElseThrow(() -> + new RuntimeException("jlink tool not found") + ); private final List jars = new ArrayList<>(); private final List jmods = new ArrayList<>(); @@ -691,7 +700,8 @@ String[] args = optionsJLink(); System.err.println("jlink options: " + optionsPrettyPrint(args)); StringWriter writer = new StringWriter(); - int exitCode = jdk.tools.jlink.internal.Main.run(args, new PrintWriter(writer)); + PrintWriter pw = new PrintWriter(writer); + int exitCode = JLINK_TOOL.run(pw, pw, args); return new Result(exitCode, writer.toString(), output); } @@ -699,7 +709,8 @@ String[] args = optionsPostProcessJLink(); System.err.println("jlink options: " + optionsPrettyPrint(args)); StringWriter writer = new StringWriter(); - int exitCode = jdk.tools.jlink.internal.Main.run(args, new PrintWriter(writer)); + PrintWriter pw = new PrintWriter(writer); + int exitCode = JLINK_TOOL.run(pw, pw, args); return new Result(exitCode, writer.toString(), output); } } diff -r 563c1d911dcb -r ce1843f66c03 langtools/.hgtags --- a/langtools/.hgtags Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/.hgtags Mon Oct 17 15:32:44 2016 +0000 @@ -382,3 +382,4 @@ dd56c243c199a540c9f1fbff4855f0934b32a9d0 jdk-9+137 90dd93e668a521642382561c47abe96ee2e065b7 jdk-9+138 17a82cb0e4b480e97021691d39917f15e3f7b653 jdk-9+139 +6842e63d6c3971172214b411f29965852ca175d1 jdk-9+140 diff -r 563c1d911dcb -r ce1843f66c03 langtools/make/build.properties --- a/langtools/make/build.properties Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/make/build.properties Mon Oct 17 15:32:44 2016 +0000 @@ -24,11 +24,12 @@ # #javac configuration for "normal build" (these will be passed to the bootstrap compiler): -javac.opts = -XDignore.symbol.file=true -Xlint:all,-deprecation,-options -Werror -g:source,lines,vars +javac.opts = -XDignore.symbol.file=true -Xlint:all,-deprecation,-options,-exports -Werror -g:source,lines,vars javac.source = 9 javac.target = 9 #version used to compile build tools +javac.build.opts = -XDignore.symbol.file=true -Xlint:all,-deprecation,-options -Werror -g:source,lines,vars javac.build.source = 8 javac.build.target = 8 diff -r 563c1d911dcb -r ce1843f66c03 langtools/make/build.xml --- a/langtools/make/build.xml Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/make/build.xml Mon Oct 17 15:32:44 2016 +0000 @@ -275,7 +275,7 @@ classpath="${ant.core.lib}" bootclasspath="${langtools.jdk.home}/jre/lib/rt.jar" includeantruntime="false"> - + - + - + diff -r 563c1d911dcb -r ce1843f66c03 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java Mon Oct 17 15:32:44 2016 +0000 @@ -949,6 +949,7 @@ @Override @DefinedBy(Api.LANGUAGE_MODEL) public java.util.List getDirectives() { + complete(); completeUsesProvides(); return Collections.unmodifiableList(directives); } diff -r 563c1d911dcb -r ce1843f66c03 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java Mon Oct 17 15:32:44 2016 +0000 @@ -30,6 +30,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.WeakHashMap; import java.util.function.BiPredicate; @@ -468,89 +469,14 @@ * and return-type substitutable with each method in the original list. */ private FunctionDescriptor mergeDescriptors(TypeSymbol origin, List methodSyms) { - //pick argument types - simply take the signature that is a - //subsignature of all other signatures in the list (as per JLS 8.4.2) - List mostSpecific = List.nil(); - outer: for (Symbol msym1 : methodSyms) { - Type mt1 = memberType(origin.type, msym1); - for (Symbol msym2 : methodSyms) { - Type mt2 = memberType(origin.type, msym2); - if (!isSubSignature(mt1, mt2)) { - continue outer; - } - } - mostSpecific = mostSpecific.prepend(msym1); - } - if (mostSpecific.isEmpty()) { - return null; - } - - - //pick return types - this is done in two phases: (i) first, the most - //specific return type is chosen using strict subtyping; if this fails, - //a second attempt is made using return type substitutability (see JLS 8.4.5) - boolean phase2 = false; - Symbol bestSoFar = null; - while (bestSoFar == null) { - outer: for (Symbol msym1 : mostSpecific) { - Type mt1 = memberType(origin.type, msym1); - for (Symbol msym2 : methodSyms) { - Type mt2 = memberType(origin.type, msym2); - if (phase2 ? - !returnTypeSubstitutable(mt1, mt2) : - !isSubtypeInternal(mt1.getReturnType(), mt2.getReturnType())) { - continue outer; + return mergeAbstracts(methodSyms, origin.type, false) + .map(bestSoFar -> new FunctionDescriptor(bestSoFar.baseSymbol()) { + @Override + public Type getType(Type origin) { + Type mt = memberType(origin, getSymbol()); + return createMethodTypeWithThrown(mt, bestSoFar.type.getThrownTypes()); } - } - bestSoFar = msym1; - } - if (phase2) { - break; - } else { - phase2 = true; - } - } - if (bestSoFar == null) return null; - - //merge thrown types - form the intersection of all the thrown types in - //all the signatures in the list - List thrown = null; - Type mt1 = memberType(origin.type, bestSoFar); - boolean toErase = !mt1.hasTag(FORALL); - for (Symbol msym2 : methodSyms) { - Type mt2 = memberType(origin.type, msym2); - List thrown_mt2 = mt2.getThrownTypes(); - if (toErase) { - thrown_mt2 = erasure(thrown_mt2); - } else { - /* If bestSoFar is generic then all the methods are generic. - * The opposite is not true: a non generic method can override - * a generic method (raw override) so it's safe to cast mt1 and - * mt2 to ForAll. - */ - ForAll fa1 = (ForAll)mt1; - ForAll fa2 = (ForAll)mt2; - thrown_mt2 = subst(thrown_mt2, fa2.tvars, fa1.tvars); - } - thrown = (thrown == null) ? - thrown_mt2 : - chk.intersect(thrown_mt2, thrown); - } - - final List thrown1 = thrown; - return new FunctionDescriptor(bestSoFar) { - @Override - public Type getType(Type origin) { - Type mt = memberType(origin, getSymbol()); - return createMethodTypeWithThrown(mt, thrown1); - } - }; - } - - boolean isSubtypeInternal(Type s, Type t) { - return (s.isPrimitive() && t.isPrimitive()) ? - isSameType(t, s) : - isSubtype(s, t); + }).orElse(null); } FunctionDescriptorLookupError failure(String msg, Object... args) { @@ -2604,6 +2530,106 @@ return false; } + /** + * This enum defines the strategy for implementing most specific return type check + * during the most specific and functional interface checks. + */ + public enum MostSpecificReturnCheck { + /** + * Return r1 is more specific than r2 if {@code r1 <: r2}. Extra care required for (i) handling + * method type variables (if either method is generic) and (ii) subtyping should be replaced + * by type-equivalence for primitives. This is essentially an inlined version of + * {@link Types#resultSubtype(Type, Type, Warner)}, where the assignability check has been + * replaced with a strict subtyping check. + */ + BASIC() { + @Override + public boolean test(Type mt1, Type mt2, Types types) { + List tvars = mt1.getTypeArguments(); + List svars = mt2.getTypeArguments(); + Type t = mt1.getReturnType(); + Type s = types.subst(mt2.getReturnType(), svars, tvars); + return types.isSameType(t, s) || + !t.isPrimitive() && + !s.isPrimitive() && + types.isSubtype(t, s); + } + }, + /** + * Return r1 is more specific than r2 if r1 is return-type-substitutable for r2. + */ + RTS() { + @Override + public boolean test(Type mt1, Type mt2, Types types) { + return types.returnTypeSubstitutable(mt1, mt2); + } + }; + + public abstract boolean test(Type mt1, Type mt2, Types types); + } + + /** + * Merge multiple abstract methods. The preferred method is a method that is a subsignature + * of all the other signatures and whose return type is more specific {@see MostSpecificReturnCheck}. + * The resulting preferred method has a thrown clause that is the intersection of the merged + * methods' clauses. + */ + public Optional mergeAbstracts(List ambiguousInOrder, Type site, boolean sigCheck) { + //first check for preconditions + boolean shouldErase = false; + List erasedParams = ambiguousInOrder.head.erasure(this).getParameterTypes(); + for (Symbol s : ambiguousInOrder) { + if ((s.flags() & ABSTRACT) == 0 || + (sigCheck && !isSameTypes(erasedParams, s.erasure(this).getParameterTypes()))) { + return Optional.empty(); + } else if (s.type.hasTag(FORALL)) { + shouldErase = true; + } + } + //then merge abstracts + for (MostSpecificReturnCheck mostSpecificReturnCheck : MostSpecificReturnCheck.values()) { + outer: for (Symbol s : ambiguousInOrder) { + Type mt = memberType(site, s); + List allThrown = mt.getThrownTypes(); + for (Symbol s2 : ambiguousInOrder) { + if (s != s2) { + Type mt2 = memberType(site, s2); + if (!isSubSignature(mt, mt2) || + !mostSpecificReturnCheck.test(mt, mt2, this)) { + //ambiguity cannot be resolved + continue outer; + } else { + List thrownTypes2 = mt2.getThrownTypes(); + if (!mt.hasTag(FORALL) && shouldErase) { + thrownTypes2 = erasure(thrownTypes2); + } else if (mt.hasTag(FORALL)) { + //subsignature implies that if most specific is generic, then all other + //methods are too + Assert.check(mt2.hasTag(FORALL)); + // if both are generic methods, adjust thrown types ahead of intersection computation + thrownTypes2 = subst(thrownTypes2, mt2.getTypeArguments(), mt.getTypeArguments()); + } + allThrown = chk.intersect(allThrown, thrownTypes2); + } + } + } + return (allThrown == mt.getThrownTypes()) ? + Optional.of(s) : + Optional.of(new MethodSymbol( + s.flags(), + s.name, + createMethodTypeWithThrown(s.type, allThrown), + s.owner) { + @Override + public Symbol baseSymbol() { + return s; + } + }); + } + } + return Optional.empty(); + } + // class ImplementationCache { diff -r 563c1d911dcb -r ce1843f66c03 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Mon Oct 17 15:32:44 2016 +0000 @@ -1691,28 +1691,6 @@ } } //where - Type mostSpecificReturnType(Type mt1, Type mt2) { - Type rt1 = mt1.getReturnType(); - Type rt2 = mt2.getReturnType(); - - if (mt1.hasTag(FORALL) && mt2.hasTag(FORALL)) { - //if both are generic methods, adjust return type ahead of subtyping check - rt1 = types.subst(rt1, mt1.getTypeArguments(), mt2.getTypeArguments()); - } - //first use subtyping, then return type substitutability - if (types.isSubtype(rt1, rt2)) { - return mt1; - } else if (types.isSubtype(rt2, rt1)) { - return mt2; - } else if (types.returnTypeSubstitutable(mt1, mt2)) { - return mt1; - } else if (types.returnTypeSubstitutable(mt2, mt1)) { - return mt2; - } else { - return null; - } - } - //where Symbol ambiguityError(Symbol m1, Symbol m2) { if (((m1.flags() | m2.flags()) & CLASH) != 0) { return (m1.flags() & CLASH) == 0 ? m1 : m2; @@ -4112,43 +4090,7 @@ */ Symbol mergeAbstracts(Type site) { List ambiguousInOrder = ambiguousSyms.reverse(); - for (Symbol s : ambiguousInOrder) { - Type mt = types.memberType(site, s); - boolean found = true; - List allThrown = mt.getThrownTypes(); - for (Symbol s2 : ambiguousInOrder) { - Type mt2 = types.memberType(site, s2); - if ((s2.flags() & ABSTRACT) == 0 || - !types.overrideEquivalent(mt, mt2) || - !types.isSameTypes(s.erasure(types).getParameterTypes(), - s2.erasure(types).getParameterTypes())) { - //ambiguity cannot be resolved - return this; - } - Type mst = mostSpecificReturnType(mt, mt2); - if (mst == null || mst != mt) { - found = false; - break; - } - List thrownTypes2 = mt2.getThrownTypes(); - if (mt.hasTag(FORALL) && mt2.hasTag(FORALL)) { - // if both are generic methods, adjust thrown types ahead of intersection computation - thrownTypes2 = types.subst(thrownTypes2, mt2.getTypeArguments(), mt.getTypeArguments()); - } - allThrown = chk.intersect(allThrown, thrownTypes2); - } - if (found) { - //all ambiguous methods were abstract and one method had - //most specific return type then others - return (allThrown == mt.getThrownTypes()) ? - s : new MethodSymbol( - s.flags(), - s.name, - types.createMethodTypeWithThrown(s.type, allThrown), - s.owner); - } - } - return this; + return types.mergeAbstracts(ambiguousInOrder, site, true).orElse(this); } @Override diff -r 563c1d911dcb -r ce1843f66c03 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js Mon Oct 17 15:32:44 2016 +0000 @@ -30,6 +30,9 @@ var catTypes = "Types"; var catMembers = "Members"; var catSearchTags = "SearchTags"; +var highlight = "$&"; +var camelCaseRegexp = ""; +var secondaryMatcher = ""; function getName(name) { var anchor = ""; var ch = ''; @@ -65,27 +68,35 @@ } return anchor; } +function getHighlightedText(item) { + var ccMatcher = new RegExp(camelCaseRegexp); + var label = item.replace(ccMatcher, highlight); + if (label === item) { + label = item.replace(secondaryMatcher, highlight); + } + return label; +} var watermark = 'Search'; $(function() { $("#search").prop("disabled", false); $("#reset").prop("disabled", false); $("#search").val(watermark).addClass('watermark'); - $("#search").blur(function(){ + $("#search").blur(function() { if ($(this).val().length == 0) { $(this).val(watermark).addClass('watermark'); } }); - $("#search").keydown(function(){ - if ($(this).val() == watermark) { + $("#search").keydown(function() { + if ($(this).val() == watermark) { $(this).val('').removeClass('watermark'); } }); - $("#reset").click(function(){ - $("#search").val(''); - $("#search").focus(); + $("#reset").click(function() { + $("#search").val(''); + $("#search").focus(); }); $("#search").focus(); - $("#search")[0].setSelectionRange(0,0); + $("#search")[0].setSelectionRange(0, 0); }); $.widget("custom.catcomplete", $.ui.autocomplete, { _create: function() { @@ -112,22 +123,19 @@ }); }, _renderItem: function(ul, item) { - var result = this.element.val(); - var regexp = new RegExp($.ui.autocomplete.escapeRegex(result), "i"); - highlight = "$&"; var label = ""; if (item.category === catModules) { - label = item.l.replace(regexp, highlight); + label = getHighlightedText(item.l); } else if (item.category === catPackages) { label = (item.m) - ? (item.m + "/" + item.l).replace(regexp, highlight) - : item.l.replace(regexp, highlight); + ? getHighlightedText(item.m + "/" + item.l) + : getHighlightedText(item.l); } else if (item.category === catTypes) { - label += (item.p + "." + item.l).replace(regexp, highlight); + label = getHighlightedText(item.p + "." + item.l); } else if (item.category === catMembers) { - label += item.p + "." + (item.c + "." + item.l).replace(regexp, highlight); + label = getHighlightedText(item.p + "." + (item.c + "." + item.l)); } else if (item.category === catSearchTags) { - label = item.l.replace(regexp, highlight); + label = getHighlightedText(item.l); } else { label = item.l; } @@ -163,7 +171,9 @@ var tgresult = new Array(); var displayCount = 0; var exactMatcher = new RegExp("^" + $.ui.autocomplete.escapeRegex(request.term) + "$", "i"); - var secondaryMatcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i"); + camelCaseRegexp = ($.ui.autocomplete.escapeRegex(request.term)).split(/(?=[A-Z])/).join("([a-z0-9_$]*?)"); + var camelCaseMatcher = new RegExp("^" + camelCaseRegexp); + secondaryMatcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i"); if (moduleSearchIndex) { var mdleCount = 0; $.each(moduleSearchIndex, function(index, item) { @@ -171,6 +181,8 @@ if (exactMatcher.test(item.l)) { result.unshift(item); mdleCount++; + } else if (camelCaseMatcher.test(item.l)) { + result.unshift(item); } else if (secondaryMatcher.test(item.l)) { result.push(item); } @@ -188,6 +200,8 @@ if (exactMatcher.test(item.l)) { presult.unshift(item); pCount++; + } else if (camelCaseMatcher.test(pkg)) { + presult.unshift(item); } else if (secondaryMatcher.test(pkg)) { presult.push(item); } @@ -202,6 +216,8 @@ if (exactMatcher.test(item.l)) { tresult.unshift(item); tCount++; + } else if (camelCaseMatcher.test(item.l)) { + tresult.unshift(item); } else if (secondaryMatcher.test(item.p + "." + item.l)) { tresult.push(item); } @@ -216,6 +232,8 @@ if (exactMatcher.test(item.l)) { mresult.unshift(item); mCount++; + } else if (camelCaseMatcher.test(item.l)) { + mresult.unshift(item); } else if (secondaryMatcher.test(item.c + "." + item.l)) { mresult.push(item); } @@ -294,4 +312,4 @@ } } }); -}); +}); \ No newline at end of file diff -r 563c1d911dcb -r ce1843f66c03 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java Mon Oct 17 15:32:44 2016 +0000 @@ -384,14 +384,14 @@ .collect(toList())); } else { // TODO: kind of a hack... - // Create a throwaway compilation task with options "-release N" + // Create a throwaway compilation task with options "--release N" // which has the side effect of setting the file manager's // PLATFORM_CLASS_PATH to the right value. JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fm = compiler.getStandardFileManager(this, null, StandardCharsets.UTF_8); JavaCompiler.CompilationTask task = - compiler.getTask(null, fm, this, List.of("-release", release), null, null); + compiler.getTask(null, fm, this, List.of("--release", release), null, null); List paths = new ArrayList<>(); for (Path p : fm.getLocationAsPaths(StandardLocation.PLATFORM_CLASS_PATH)) { try (Stream str = Files.walk(p)) { diff -r 563c1d911dcb -r ce1843f66c03 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java Mon Oct 17 15:32:44 2016 +0000 @@ -680,20 +680,21 @@ private boolean genModuleInfo(JdepsConfiguration config) throws IOException { // check if any JAR file contains unnamed package for (String arg : inputArgs) { - Optional classInUnnamedPackage = - ClassFileReader.newInstance(Paths.get(arg)) - .entries().stream() - .filter(n -> n.endsWith(".class")) - .filter(cn -> toPackageName(cn).isEmpty()) - .findFirst(); + try (ClassFileReader reader = ClassFileReader.newInstance(Paths.get(arg))) { + Optional classInUnnamedPackage = + reader.entries().stream() + .filter(n -> n.endsWith(".class")) + .filter(cn -> toPackageName(cn).isEmpty()) + .findFirst(); - if (classInUnnamedPackage.isPresent()) { - if (classInUnnamedPackage.get().equals("module-info.class")) { - reportError("err.genmoduleinfo.not.jarfile", arg); - } else { - reportError("err.genmoduleinfo.unnamed.package", arg); + if (classInUnnamedPackage.isPresent()) { + if (classInUnnamedPackage.get().equals("module-info.class")) { + reportError("err.genmoduleinfo.not.jarfile", arg); + } else { + reportError("err.genmoduleinfo.unnamed.package", arg); + } + return false; } - return false; } } diff -r 563c1d911dcb -r ce1843f66c03 langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Mon Oct 17 15:32:44 2016 +0000 @@ -73,7 +73,6 @@ import jdk.jshell.JShell; import jdk.jshell.JShell.Subscription; import jdk.jshell.MethodSnippet; -import jdk.jshell.PersistentSnippet; import jdk.jshell.Snippet; import jdk.jshell.Snippet.Status; import jdk.jshell.SnippetEvent; @@ -1137,10 +1136,9 @@ return state.snippets(); } - Stream dropableSnippets() { + Stream dropableSnippets() { return state.snippets() - .filter(sn -> state.status(sn).isActive() && sn instanceof PersistentSnippet) - .map(sn -> (PersistentSnippet) sn); + .filter(sn -> state.status(sn).isActive()); } Stream allVarSnippets() { @@ -1761,13 +1759,13 @@ errormsg("jshell.err.drop.arg"); return false; } - Stream stream = argsToSnippets(this::dropableSnippets, args); + Stream stream = argsToSnippets(this::dropableSnippets, args); if (stream == null) { // Snippet not found. Error already printed fluffmsg("jshell.msg.see.classes.etc"); return false; } - List snippets = stream.collect(toList()); + List snippets = stream.collect(toList()); if (snippets.size() > args.size()) { // One of the args references more thean one snippet errormsg("jshell.err.drop.ambiguous"); diff -r 563c1d911dcb -r ce1843f66c03 langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/StopDetectingInputStream.java Mon Oct 17 15:32:44 2016 +0000 @@ -77,9 +77,7 @@ } catch (IOException ex) { errorHandler.accept(ex); } finally { - synchronized (StopDetectingInputStream.this) { - state = StopDetectingInputStream.State.CLOSED; - } + shutdown(); } } }; @@ -140,8 +138,10 @@ } public synchronized void setState(State state) { - this.state = state; - notifyAll(); + if (this.state != State.CLOSED) { + this.state = state; + notifyAll(); + } } private synchronized State waitInputNeeded() { diff -r 563c1d911dcb -r ce1843f66c03 langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties Mon Oct 17 15:32:44 2016 +0000 @@ -743,7 +743,7 @@ /set format verbose result '{name} ==> {value}{post}' added,modified,replaced-ok-primary \n\ \n\ /set format verbose display '{result}{pre}created scratch variable {name} : {type}{post}' expression-added,modified,replaced-primary \n\ -/set format verbose display '{result}{pre}value of {name} : {type}{post}' varvalue-primary \n\ +/set format verbose display '{result}{pre}value of {name} : {type}{post}' varvalue-added,modified,replaced-primary \n\ /set format verbose display '{result}{pre}assigned to {name} : {type}{post}' assignment-primary \n\ /set format verbose display '{result}{pre}{action} variable {name} : {type}{resolve}{post}' varinit,vardecl \n\ /set format verbose display '{pre}{action} variable {name}{resolve}{post}' vardecl,varinit-notdefined \n\ diff -r 563c1d911dcb -r ce1843f66c03 langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java Mon Oct 17 15:32:44 2016 +0000 @@ -521,10 +521,13 @@ List drop(Snippet si) { Unit c = new Unit(state, si); - - Set ins = c.dependents().collect(toSet()); - Set outs = compileAndLoad(ins); - + Set outs; + if (si instanceof PersistentSnippet) { + Set ins = c.dependents().collect(toSet()); + outs = compileAndLoad(ins); + } else { + outs = Collections.emptySet(); + } return events(c, outs, null, null); } diff -r 563c1d911dcb -r ce1843f66c03 langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java Mon Oct 17 15:32:44 2016 +0000 @@ -58,7 +58,7 @@ * API. A {@code JShell} instance holds the evolving compilation and * execution state. The state is changed with the instance methods * {@link jdk.jshell.JShell#eval(java.lang.String) eval(String)}, - * {@link jdk.jshell.JShell#drop(jdk.jshell.PersistentSnippet) drop(PersistentSnippet)} and + * {@link jdk.jshell.JShell#drop(jdk.jshell.Snippet) drop(Snippet)} and * {@link jdk.jshell.JShell#addToClasspath(java.lang.String) addToClasspath(String)}. * The majority of methods query the state. * A {@code JShell} instance also allows registering for events with @@ -428,7 +428,12 @@ } /** - * Remove a declaration from the state. + * Remove a declaration from the state. That is, if the snippet is an + * {@linkplain jdk.jshell.Snippet.Status#isActive() active} + * {@linkplain jdk.jshell.PersistentSnippet persistent} snippet, remove the + * snippet and update the JShell evaluation state accordingly. + * For all active snippets, change the {@linkplain #status status} to + * {@link jdk.jshell.Snippet.Status#DROPPED DROPPED}. * @param snippet The snippet to remove * @return The list of events from updating declarations dependent on the * dropped snippet. @@ -436,7 +441,7 @@ * @throws IllegalArgumentException if the snippet is not associated with * this {@code JShell} instance. */ - public List drop(PersistentSnippet snippet) throws IllegalStateException { + public List drop(Snippet snippet) throws IllegalStateException { checkIfAlive(); checkValidSnippet(snippet); List events = eval.drop(snippet); diff -r 563c1d911dcb -r ce1843f66c03 langtools/src/jdk.jshell/share/classes/jdk/jshell/Key.java --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Key.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Key.java Mon Oct 17 15:32:44 2016 +0000 @@ -74,7 +74,7 @@ /** * Grouping for snippets which persist and influence future code. * They are keyed off at least the name. They may be Modified/Replaced - * with new input and can be dropped (JShell#drop). + * with new input. */ static abstract class PersistentKey extends Key { diff -r 563c1d911dcb -r ce1843f66c03 langtools/src/jdk.jshell/share/classes/jdk/jshell/PersistentSnippet.java --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/PersistentSnippet.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/PersistentSnippet.java Mon Oct 17 15:32:44 2016 +0000 @@ -28,8 +28,8 @@ /** * Grouping for Snippets which persist and influence future code. * A persistent snippet can be - * {@linkplain jdk.jshell.Snippet.Status#OVERWRITTEN overwritten)} - * with new input and can be dropped {@link JShell#drop}. + * {@linkplain jdk.jshell.Snippet.Status#OVERWRITTEN overwritten} + * with new input. *

    * PersistentSnippet is immutable: an access to * any of its methods will always return the same result. diff -r 563c1d911dcb -r ce1843f66c03 langtools/src/jdk.jshell/share/classes/jdk/jshell/Snippet.java --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Snippet.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Snippet.java Mon Oct 17 15:32:44 2016 +0000 @@ -443,9 +443,7 @@ /** * The snippet is inactive because of an explicit call to - * the {@link JShell#drop(PersistentSnippet)}. - * Only a {@link jdk.jshell.PersistentSnippet} can have this - * {@code Status}. + * the {@link JShell#drop(Snippet)}. *

    * The snippet is not visible to other snippets * ({@link Status#isDefined() isDefined() == false}) @@ -525,10 +523,11 @@ /** * Indicates whether the Snippet is active, that is, - * will the snippet be re-evaluated when a new + * will a {@linkplain jdk.jshell.PersistentSnippet persistent} + * snippet be re-evaluated when a new * {@link JShell#eval(java.lang.String) JShell.eval(String)} or - * {@link JShell#drop(jdk.jshell.PersistentSnippet) - * JShell.drop(PersistentSnippet)} that could change + * {@link JShell#drop(jdk.jshell.Snippet) + * JShell.drop(Snippet)} that could change * its status is invoked. This is more broad than * {@link Status#isDefined()} since a Snippet which is * {@link Status#RECOVERABLE_NOT_DEFINED} diff -r 563c1d911dcb -r ce1843f66c03 langtools/src/jdk.jshell/share/classes/jdk/jshell/SnippetEvent.java --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SnippetEvent.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SnippetEvent.java Mon Oct 17 15:32:44 2016 +0000 @@ -30,7 +30,7 @@ /** * A description of a change to a Snippet. These are generated by direct changes * to state with {@link JShell#eval(java.lang.String) JShell.eval(String)} or - * {@link JShell#drop(jdk.jshell.PersistentSnippet) JShell.drop(PersistentSnippet)}, + * {@link JShell#drop(jdk.jshell.Snippet) JShell.drop(Snippet)}, * or indirectly by these same methods as * dependencies change or Snippets are overwritten. For direct changes, the * {@link SnippetEvent#causeSnippet()} is {@code null}. @@ -108,7 +108,7 @@ * creation of a new Snippet via * {@link jdk.jshell.JShell#eval(java.lang.String) eval} or it is the * explicit drop of a Snippet with - * {@link jdk.jshell.JShell#drop(jdk.jshell.PersistentSnippet) drop}. + * {@link jdk.jshell.JShell#drop(jdk.jshell.Snippet) drop}. * * @return the Snippet which caused this change or {@code null} if * directly caused by an API action. diff -r 563c1d911dcb -r ce1843f66c03 langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java Mon Oct 17 15:32:44 2016 +0000 @@ -116,6 +116,7 @@ import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.PackageElement; import javax.lang.model.element.QualifiedNameable; +import javax.lang.model.element.TypeParameterElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.ArrayType; import javax.lang.model.type.ExecutableType; @@ -132,6 +133,7 @@ import static jdk.jshell.Util.REPL_DOESNOTMATTER_CLASS_NAME; import static java.util.stream.Collectors.joining; import static jdk.jshell.SourceCodeAnalysis.Completeness.DEFINITELY_INCOMPLETE; +import static jdk.jshell.TreeDissector.printType; /** * The concrete implementation of SourceCodeAnalysis. @@ -1185,7 +1187,7 @@ proc.debug(ex, "SourceCodeAnalysisImpl.element2String(..., " + el + ")"); } - return Util.expunge(elementHeader(el)); + return Util.expunge(elementHeader(sourceCache.originalTask, el, !hasSyntheticParameterNames(el))); } private boolean hasSyntheticParameterNames(Element el) { @@ -1248,7 +1250,7 @@ topLevelName2Signature2Method.put(binaryName, cache = createMethodCache(binaryName)); } - String handle = elementHeader(method, false); + String handle = elementHeader(originalTask, method, false); return cache.getOrDefault(handle, method); } @@ -1276,7 +1278,7 @@ Element currentMethod = trees.getElement(getCurrentPath()); if (currentMethod != null) { - signature2Method.put(elementHeader(currentMethod, false), currentMethod); + signature2Method.put(elementHeader(originalTask, currentMethod, false), currentMethod); } return null; @@ -1331,39 +1333,79 @@ return availableSources = result; } - private String elementHeader(Element el) { - return elementHeader(el, true); + private String elementHeader(AnalyzeTask at, Element el) { + return elementHeader(at, el, true); } - private String elementHeader(Element el, boolean includeParameterNames) { + private String elementHeader(AnalyzeTask at, Element el, boolean includeParameterNames) { switch (el.getKind()) { - case ANNOTATION_TYPE: case CLASS: case ENUM: case INTERFACE: - return ((TypeElement) el).getQualifiedName().toString(); + case ANNOTATION_TYPE: case CLASS: case ENUM: case INTERFACE: { + TypeElement type = (TypeElement)el; + String fullname = type.getQualifiedName().toString(); + Element pkg = at.getElements().getPackageOf(el); + String name = pkg == null ? fullname : + proc.maps.fullClassNameAndPackageToClass(fullname, ((PackageElement)pkg).getQualifiedName().toString()); + + return name + typeParametersOpt(at, type.getTypeParameters()); + } + case TYPE_PARAMETER: { + TypeParameterElement tp = (TypeParameterElement)el; + String name = tp.getSimpleName().toString(); + + List bounds = tp.getBounds(); + boolean boundIsObject = bounds.isEmpty() || + bounds.size() == 1 && at.getTypes().isSameType(bounds.get(0), Symtab.instance(at.getContext()).objectType); + + return boundIsObject + ? name + : name + " extends " + bounds.stream() + .map(bound -> printType(at, proc, bound)) + .collect(joining(" & ")); + } case FIELD: - return elementHeader(el.getEnclosingElement()) + "." + el.getSimpleName() + ":" + el.asType(); + return elementHeader(at, el.getEnclosingElement()) + "." + el.getSimpleName() + ":" + el.asType(); case ENUM_CONSTANT: - return elementHeader(el.getEnclosingElement()) + "." + el.getSimpleName(); + return elementHeader(at, el.getEnclosingElement()) + "." + el.getSimpleName(); case EXCEPTION_PARAMETER: case LOCAL_VARIABLE: case PARAMETER: case RESOURCE_VARIABLE: return el.getSimpleName() + ":" + el.asType(); - case CONSTRUCTOR: case METHOD: + case CONSTRUCTOR: case METHOD: { StringBuilder header = new StringBuilder(); - header.append(elementHeader(el.getEnclosingElement())); - if (el.getKind() == ElementKind.METHOD) { - header.append("."); - header.append(el.getSimpleName()); + + boolean isMethod = el.getKind() == ElementKind.METHOD; + ExecutableElement method = (ExecutableElement) el; + + if (isMethod) { + // return type + header.append(printType(at, proc, method.getReturnType())).append(" "); + } else { + // type parameters for the constructor + String typeParameters = typeParametersOpt(at, method.getTypeParameters()); + if (!typeParameters.isEmpty()) { + header.append(typeParameters).append(" "); + } } + + // receiver type + String clazz = elementHeader(at, el.getEnclosingElement()); + header.append(clazz); + + if (isMethod) { + //method name with type parameters + (clazz.isEmpty() ? header : header.append(".")) + .append(typeParametersOpt(at, method.getTypeParameters())) + .append(el.getSimpleName()); + } + + // arguments header.append("("); String sep = ""; - ExecutableElement method = (ExecutableElement) el; for (Iterator i = method.getParameters().iterator(); i.hasNext();) { VariableElement p = i.next(); header.append(sep); if (!i.hasNext() && method.isVarArgs()) { - header.append(unwrapArrayType(p.asType())); - header.append("..."); - + header.append(printType(at, proc, unwrapArrayType(p.asType()))).append("..."); } else { - header.append(p.asType()); + header.append(printType(at, proc, p.asType())); } if (includeParameterNames) { header.append(" "); @@ -1372,8 +1414,18 @@ sep = ", "; } header.append(")"); + + // throws + List thrownTypes = method.getThrownTypes(); + if (!thrownTypes.isEmpty()) { + header.append(" throws ") + .append(thrownTypes.stream() + .map(type -> printType(at, proc, type)) + .collect(joining(", "))); + } return header.toString(); - default: + } + default: return el.toString(); } } @@ -1383,6 +1435,12 @@ } return arrayType; } + private String typeParametersOpt(AnalyzeTask at, List typeParameters) { + return typeParameters.isEmpty() ? "" + : typeParameters.stream() + .map(tp -> elementHeader(at, tp)) + .collect(joining(", ", "<", ">")); + } @Override public String analyzeType(String code, int cursor) { diff -r 563c1d911dcb -r ce1843f66c03 langtools/src/jdk.jshell/share/classes/jdk/jshell/package-info.java --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/package-info.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/package-info.java Mon Oct 17 15:32:44 2016 +0000 @@ -46,7 +46,7 @@ * {@link jdk.jshell.SnippetEvent}. There are three major kinds of * changes to the status of a snippet: it can created with eval, * it can be dropped from the active source state with - * {@link jdk.jshell.JShell#drop(jdk.jshell.PersistentSnippet)}, and it can have + * {@link jdk.jshell.JShell#drop(jdk.jshell.Snippet)}, and it can have * its status updated as a result of a status change in another snippet. * For * example: given js, an instance of JShell, executing diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/Makefile --- a/langtools/test/Makefile Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/test/Makefile Mon Oct 17 15:32:44 2016 +0000 @@ -321,6 +321,7 @@ $(JTREG_EXCLUSIONS) \ $(JTREG_OPTIONS) \ $(JTREG_TESTDIRS) \ + 2>&1 | tee $(JTREG_OUTPUT_DIR)/output.txt \ || ( $(call EXIT_IF_FATAL,$(FATAL_JTREG_EXIT)) ; \ echo $$status > $(JTREG_OUTPUT_DIR)/status.txt \ ) diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java --- a/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/test/jdk/javadoc/doclet/testSearch/TestSearch.java Mon Oct 17 15:32:44 2016 +0000 @@ -23,7 +23,7 @@ /* * @test - * @bug 8141492 8071982 + * @bug 8141492 8071982 8141636 * @summary Test the search feature of javadoc. * @author bpatel * @library ../lib @@ -45,6 +45,7 @@ checkExit(Exit.OK); checkSearchOutput("UnnamedPkgClass.html", true); checkJqueryAndImageFiles(true); + checkSearchJS(); checkFiles(false, "package-search-index.zip", "tag-search-index.zip"); @@ -62,6 +63,7 @@ checkSearchOutput(true); checkSingleIndex(true); checkJqueryAndImageFiles(true); + checkSearchJS(); checkFiles(true, "member-search-index.zip", "package-search-index.zip", @@ -78,6 +80,7 @@ checkSearchOutput(true); checkSingleIndex(true); checkJqueryAndImageFiles(true); + checkSearchJS(); checkFiles(true, "member-search-index.zip", "package-search-index.zip", @@ -110,6 +113,7 @@ checkSearchOutput(true); checkSingleIndex(true); checkJqueryAndImageFiles(true); + checkSearchJS(); checkFiles(true, "member-search-index.zip", "package-search-index.zip", @@ -142,6 +146,7 @@ checkSearchOutput(true); checkIndexNoComment(); checkJqueryAndImageFiles(true); + checkSearchJS(); checkFiles(true, "member-search-index.zip", "package-search-index.zip", @@ -158,6 +163,7 @@ checkSearchOutput(true); checkIndexNoDeprecated(); checkJqueryAndImageFiles(true); + checkSearchJS(); checkFiles(true, "member-search-index.zip", "package-search-index.zip", @@ -174,6 +180,7 @@ checkSearchOutput(true); checkSplitIndex(); checkJqueryAndImageFiles(true); + checkSearchJS(); checkFiles(true, "member-search-index.zip", "package-search-index.zip", @@ -189,6 +196,7 @@ checkSearchOutput(true); checkJavaFXOutput(); checkJqueryAndImageFiles(true); + checkSearchJS(); checkFiles(false, "tag-search-index.zip"); checkFiles(true, @@ -420,4 +428,11 @@ "resources/x.png", "resources/glass.png"); } + + void checkSearchJS() { + checkOutput("search.js", true, + "camelCaseRegexp = ($.ui.autocomplete.escapeRegex(request.term)).split(/(?=[A-Z])/).join(\"([a-z0-9_$]*?)\");", + "var camelCaseMatcher = new RegExp(\"^\" + camelCaseRegexp);", + "camelCaseMatcher.test(item.l)"); + } } diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/jdk/jshell/CompletionSuggestionTest.java --- a/langtools/test/jdk/jshell/CompletionSuggestionTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/test/jdk/jshell/CompletionSuggestionTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -23,8 +23,8 @@ /* * @test - * @bug 8131025 8141092 8153761 - * @summary Test Completion + * @bug 8131025 8141092 8153761 8145263 + * @summary Test Completion and Documentation * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.jdeps/com.sun.tools.javap @@ -43,6 +43,8 @@ import java.util.Collections; import java.util.Set; import java.util.HashSet; +import java.util.function.BiFunction; +import java.util.function.Function; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; @@ -304,35 +306,35 @@ public void testDocumentation() throws Exception { dontReadParameterNamesFromClassFile(); assertDocumentation("System.getProperty(|", - "java.lang.System.getProperty(java.lang.String key)", - "java.lang.System.getProperty(java.lang.String key, java.lang.String def)"); + "String System.getProperty(String key)", + "String System.getProperty(String key, String def)"); assertEval("char[] chars = null;"); assertDocumentation("new String(chars, |", - "java.lang.String(char[] arg0, int arg1, int arg2)"); + "String(char[], int, int)"); assertDocumentation("String.format(|", - "java.lang.String.format(java.lang.String arg0, java.lang.Object... arg1)", - "java.lang.String.format(java.util.Locale arg0, java.lang.String arg1, java.lang.Object... arg2)"); - assertDocumentation("\"\".getBytes(\"\"|", "java.lang.String.getBytes(int arg0, int arg1, byte[] arg2, int arg3)", - "java.lang.String.getBytes(java.lang.String arg0)", - "java.lang.String.getBytes(java.nio.charset.Charset arg0)"); - assertDocumentation("\"\".getBytes(\"\" |", "java.lang.String.getBytes(int arg0, int arg1, byte[] arg2, int arg3)", - "java.lang.String.getBytes(java.lang.String arg0)", - "java.lang.String.getBytes(java.nio.charset.Charset arg0)"); + "String String.format(String, Object...)", + "String String.format(java.util.Locale, String, Object...)"); + assertDocumentation("\"\".getBytes(\"\"|", "void String.getBytes(int, int, byte[], int)", + "byte[] String.getBytes(String) throws java.io.UnsupportedEncodingException", + "byte[] String.getBytes(java.nio.charset.Charset)"); + assertDocumentation("\"\".getBytes(\"\" |", "void String.getBytes(int, int, byte[], int)", + "byte[] String.getBytes(String) throws java.io.UnsupportedEncodingException", + "byte[] String.getBytes(java.nio.charset.Charset)"); } public void testMethodsWithNoArguments() throws Exception { dontReadParameterNamesFromClassFile(); assertDocumentation("System.out.println(|", - "java.io.PrintStream.println()", - "java.io.PrintStream.println(boolean arg0)", - "java.io.PrintStream.println(char arg0)", - "java.io.PrintStream.println(int arg0)", - "java.io.PrintStream.println(long arg0)", - "java.io.PrintStream.println(float arg0)", - "java.io.PrintStream.println(double arg0)", - "java.io.PrintStream.println(char[] arg0)", - "java.io.PrintStream.println(java.lang.String arg0)", - "java.io.PrintStream.println(java.lang.Object arg0)"); + "void java.io.PrintStream.println()", + "void java.io.PrintStream.println(boolean)", + "void java.io.PrintStream.println(char)", + "void java.io.PrintStream.println(int)", + "void java.io.PrintStream.println(long)", + "void java.io.PrintStream.println(float)", + "void java.io.PrintStream.println(double)", + "void java.io.PrintStream.println(char[])", + "void java.io.PrintStream.println(String)", + "void java.io.PrintStream.println(Object)"); } public void testErroneous() { @@ -472,14 +474,14 @@ public void testDocumentationOfUserDefinedMethods() { assertEval("void f() {}"); - assertDocumentation("f(|", "f()"); + assertDocumentation("f(|", "void f()"); assertEval("void f(int i) {}"); - assertDocumentation("f(|", "f()", "f(int i)"); + assertDocumentation("f(|", "void f()", "void f(int i)"); assertEval(" void f(T... ts) {}", DiagCheck.DIAG_WARNING, DiagCheck.DIAG_OK); - assertDocumentation("f(|", "f()", "f(int i)", "f(T... ts)"); + assertDocumentation("f(|", "void f()", "void f(int i)", "void f(T... ts)"); assertEval("class A {}"); assertEval("void f(A a) {}"); - assertDocumentation("f(|", "f()", "f(int i)", "f(T... ts)", "f(A a)"); + assertDocumentation("f(|", "void f()", "void f(int i)", "void f(T... ts)", "void f(A a)"); } public void testDocumentationOfUserDefinedConstructors() { @@ -489,25 +491,25 @@ ste(MAIN_SNIPPET, VALID, VALID, true, null), ste(a, VALID, OVERWRITTEN, false, MAIN_SNIPPET))); assertDocumentation("new A(|", "A()", "A(int i)"); - assertEval("class A { A(T t) {} A(int i) {}}", + assertEval("class A { A(T a) {} A(int i) {} A(T t, U u) {}}", ste(MAIN_SNIPPET, VALID, VALID, true, null), ste(a2, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); - assertDocumentation("new A(|", "A(T t)", "A(int i)"); + assertDocumentation("new A(|", "A(T a)", "A(int i)", " A(T t, U u)"); } public void testDocumentationOfOverriddenMethods() throws Exception { dontReadParameterNamesFromClassFile(); assertDocumentation("\"\".wait(|", - "java.lang.Object.wait(long arg0)", - "java.lang.Object.wait(long arg0, int arg1)", - "java.lang.Object.wait()"); + "void Object.wait(long) throws InterruptedException", + "void Object.wait(long, int) throws InterruptedException", + "void Object.wait() throws InterruptedException"); assertEval("class Base {void method() {}}"); Snippet e = classKey(assertEval("class Extend extends Base {}")); - assertDocumentation("new Extend().method(|", "Base.method()"); + assertDocumentation("new Extend().method(|", "void Base.method()"); assertEval("class Extend extends Base {void method() {}}", ste(MAIN_SNIPPET, VALID, VALID, true, null), ste(e, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); - assertDocumentation("new Extend().method(|", "Extend.method()"); + assertDocumentation("new Extend().method(|", "void Extend.method()"); } public void testDocumentationOfInvisibleMethods() { @@ -534,13 +536,67 @@ assertEval("void method(int n, Object o) { }"); assertEval("void method(Object n, int o) { }"); assertDocumentation("method(primitive,|", - "method(int n, java.lang.Object o)", - "method(java.lang.Object n, int o)"); + "void method(int n, Object o)", + "void method(Object n, int o)"); assertDocumentation("method(boxed,|", - "method(int n, java.lang.Object o)", - "method(java.lang.Object n, int o)"); + "void method(int n, Object o)", + "void method(Object n, int o)"); assertDocumentation("method(object,|", - "method(java.lang.Object n, int o)"); + "void method(Object n, int o)"); + } + + public void testDocumentationWithGenerics() { + class TestDocumentationWithGenerics { + private final Function codeFacotry; + private final BiFunction evalFormatter; + private final BiFunction docFormatter; + int count; + + TestDocumentationWithGenerics( + Function codeFactory, + BiFunction evalFormatter, + BiFunction documentationFormatter) { + this.codeFacotry = codeFactory; + this.evalFormatter = evalFormatter; + this.docFormatter = documentationFormatter; + } + + void assertDoc(String generics) { + assertDoc(generics, generics); + } + + void assertDoc(String generics, String expectedGenerics) { + assertEval(evalFormatter.apply(generics, count)); + assertDocumentation(codeFacotry.apply(count), docFormatter.apply(expectedGenerics, count)); + count++; + } + } + + TestDocumentationWithGenerics[] tests = { + new TestDocumentationWithGenerics( + i -> "f" + i + "(|", + (g, i) -> "<" + g + "> void f" + i + "() {}", + (g, i) -> "void <" + g + ">f" + i + "()" + ), + new TestDocumentationWithGenerics( + i -> "new C" + i + "().f(|", + (g, i) -> "class C" + i + "<" + g + "> { void f() {} }", + (g, i) -> "void C" + i + "<" + g + ">.f()" + ) + }; + + Arrays.stream(tests).forEach(t -> { + t.assertDoc("T"); + t.assertDoc("T extends Object", + "T"); + t.assertDoc("T extends String"); + t.assertDoc("T extends java.lang.String", + "T extends String"); + t.assertDoc("T extends Number & Comparable"); + t.assertDoc("T extends java.io.Serializable & CharSequence"); + t.assertDoc("K, D, M extends java.util.Map", + "K, D, M extends java.util.Map"); + }); } public void testVarArgs() { diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/jdk/jshell/DropTest.java --- a/langtools/test/jdk/jshell/DropTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/test/jdk/jshell/DropTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -23,14 +23,14 @@ /* * @test - * @bug 8081431 8080069 + * @bug 8081431 8080069 8167128 * @summary Test of JShell#drop(). * @build KullaTesting TestingInputStream * @run testng DropTest */ import jdk.jshell.DeclarationSnippet; -import jdk.jshell.PersistentSnippet; +import jdk.jshell.Snippet; import jdk.jshell.VarSnippet; import org.testng.annotations.Test; @@ -40,9 +40,9 @@ public class DropTest extends KullaTesting { public void testDrop() { - PersistentSnippet var = varKey(assertEval("int x;")); - PersistentSnippet method = methodKey(assertEval("int mu() { return x * 4; }")); - PersistentSnippet clazz = classKey(assertEval("class C { String v() { return \"#\" + mu(); } }")); + Snippet var = varKey(assertEval("int x;")); + Snippet method = methodKey(assertEval("int mu() { return x * 4; }")); + Snippet clazz = classKey(assertEval("class C { String v() { return \"#\" + mu(); } }")); assertDrop(var, ste(var, VALID, DROPPED, true, null), ste(method, VALID, RECOVERABLE_DEFINED, false, var)); @@ -62,7 +62,7 @@ assertEval("int x = 10;", "10", added(VALID), ste(method, RECOVERABLE_DEFINED, VALID, false, MAIN_SNIPPET)); - PersistentSnippet c0 = varKey(assertEval("C c0 = new C();")); + Snippet c0 = varKey(assertEval("C c0 = new C();")); assertEval("c0.v();", "\"#40\""); assertEval("C c = new C();", ste(MAIN_SNIPPET, VALID, VALID, false, null), @@ -88,8 +88,8 @@ } public void testDropImport() { - PersistentSnippet imp = importKey(assertEval("import java.util.*;")); - PersistentSnippet decl = varKey( + Snippet imp = importKey(assertEval("import java.util.*;")); + Snippet decl = varKey( assertEval("List list = Arrays.asList(1, 2, 3);", "[1, 2, 3]")); assertEval("list;", "[1, 2, 3]"); assertDrop(imp, @@ -100,8 +100,13 @@ assertDeclareFail("list;", "compiler.err.cant.resolve.location"); } + public void testDropStatement() { + Snippet x = key(assertEval("if (true);")); + assertDrop(x, ste(x, VALID, DROPPED, true, null)); + } + public void testDropVarToMethod() { - PersistentSnippet x = varKey(assertEval("int x;")); + Snippet x = varKey(assertEval("int x;")); DeclarationSnippet method = methodKey(assertEval("double mu() { return x * 4; }")); assertEval("x == 0;", "true"); assertEval("mu() == 0.0;", "true"); @@ -118,7 +123,7 @@ } public void testDropMethodToMethod() { - PersistentSnippet a = methodKey(assertEval("double a() { return 2; }")); + Snippet a = methodKey(assertEval("double a() { return 2; }")); DeclarationSnippet b = methodKey(assertEval("double b() { return a() * 10; }")); assertEval("double c() { return b() * 3; }"); DeclarationSnippet d = methodKey(assertEval("double d() { return c() + 1000; }")); @@ -134,7 +139,7 @@ } public void testDropClassToMethod() { - PersistentSnippet c = classKey(assertEval("class C { int f() { return 7; } }")); + Snippet c = classKey(assertEval("class C { int f() { return 7; } }")); DeclarationSnippet m = methodKey(assertEval("int m() { return new C().f(); }")); assertDrop(c, ste(c, VALID, DROPPED, true, null), @@ -145,7 +150,7 @@ } public void testDropVarToClass() { - PersistentSnippet x = varKey(assertEval("int x;")); + Snippet x = varKey(assertEval("int x;")); DeclarationSnippet a = classKey(assertEval("class A { double a = 4 * x; }")); assertDrop(x, DiagCheck.DIAG_OK, @@ -160,7 +165,7 @@ } public void testDropMethodToClass() { - PersistentSnippet x = methodKey(assertEval("int x() { return 0; }")); + Snippet x = methodKey(assertEval("int x() { return 0; }")); DeclarationSnippet a = classKey(assertEval("class A { double a = 4 * x(); }")); assertDrop(x, DiagCheck.DIAG_OK, @@ -174,10 +179,10 @@ } public void testDropClassToClass() { - PersistentSnippet a = classKey(assertEval("class A {}")); - PersistentSnippet b = classKey(assertEval("class B extends A {}")); - PersistentSnippet c = classKey(assertEval("class C extends B {}")); - PersistentSnippet d = classKey(assertEval("class D extends C {}")); + Snippet a = classKey(assertEval("class A {}")); + Snippet b = classKey(assertEval("class B extends A {}")); + Snippet c = classKey(assertEval("class C extends B {}")); + Snippet d = classKey(assertEval("class D extends C {}")); assertDrop(a, DiagCheck.DIAG_OK, DiagCheck.DIAG_ERROR, @@ -201,9 +206,9 @@ public void testDropNoUpdate() { String as1 = "class A {}"; String as2 = "class A extends java.util.ArrayList {}"; - PersistentSnippet a = classKey(assertEval(as1, added(VALID))); - PersistentSnippet b = classKey(assertEval("class B extends A {}", added(VALID))); - PersistentSnippet ax = classKey(assertEval(as2, + Snippet a = classKey(assertEval(as1, added(VALID))); + Snippet b = classKey(assertEval("class B extends A {}", added(VALID))); + Snippet ax = classKey(assertEval(as2, ste(MAIN_SNIPPET, VALID, VALID, true, null), ste(a, VALID, OVERWRITTEN, false, MAIN_SNIPPET), ste(b, VALID, VALID, true, MAIN_SNIPPET))); diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/jdk/jshell/IdGeneratorTest.java --- a/langtools/test/jdk/jshell/IdGeneratorTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/test/jdk/jshell/IdGeneratorTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -35,7 +35,6 @@ import jdk.jshell.EvalException; import jdk.jshell.JShell; -import jdk.jshell.PersistentSnippet; import jdk.jshell.SnippetEvent; import jdk.jshell.UnresolvedReferenceException; import jdk.jshell.VarSnippet; @@ -88,7 +87,7 @@ try (JShell jShell = builder.build()) { List eval = jShell.eval("int a, b;"); checkIds(eval); - checkIds(jShell.drop((PersistentSnippet) eval.get(0).snippet())); + checkIds(jShell.drop(eval.get(0).snippet())); } } diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/jdk/jshell/IllegalArgumentExceptionTest.java --- a/langtools/test/jdk/jshell/IllegalArgumentExceptionTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/test/jdk/jshell/IllegalArgumentExceptionTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -31,7 +31,6 @@ import java.util.function.Consumer; import jdk.jshell.DeclarationSnippet; -import jdk.jshell.PersistentSnippet; import jdk.jshell.Snippet; import jdk.jshell.VarSnippet; import org.testng.annotations.Test; @@ -64,7 +63,7 @@ } public void testDrop() { - testIllegalArgumentException((key) -> getState().drop((PersistentSnippet) key)); + testIllegalArgumentException((key) -> getState().drop(key)); } public void testUnresolved() { diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/jdk/jshell/JShellStateClosedTest.java --- a/langtools/test/jdk/jshell/JShellStateClosedTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/test/jdk/jshell/JShellStateClosedTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -33,7 +33,6 @@ import jdk.jshell.DeclarationSnippet; import jdk.jshell.ImportSnippet; import jdk.jshell.MethodSnippet; -import jdk.jshell.PersistentSnippet; import jdk.jshell.Snippet; import jdk.jshell.TypeDeclSnippet; import jdk.jshell.VarSnippet; @@ -127,7 +126,7 @@ } public void testDrop() { - testStateClosedException((key) -> getState().drop((PersistentSnippet) key)); + testStateClosedException((key) -> getState().drop(key)); } public void testUnresolved() { diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/jdk/jshell/KullaTesting.java --- a/langtools/test/jdk/jshell/KullaTesting.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/test/jdk/jshell/KullaTesting.java Mon Oct 17 15:32:44 2016 +0000 @@ -54,7 +54,6 @@ import jdk.jshell.ImportSnippet; import jdk.jshell.Snippet.Kind; import jdk.jshell.MethodSnippet; -import jdk.jshell.PersistentSnippet; import jdk.jshell.Snippet.Status; import jdk.jshell.Snippet.SubKind; import jdk.jshell.TypeDeclSnippet; @@ -733,15 +732,15 @@ assertEquals(expectedSubKind.kind(), expectedKind, "Checking kind: "); } - public void assertDrop(PersistentSnippet key, STEInfo mainInfo, STEInfo... updates) { + public void assertDrop(Snippet key, STEInfo mainInfo, STEInfo... updates) { assertDrop(key, DiagCheck.DIAG_OK, DiagCheck.DIAG_OK, mainInfo, updates); } - public void assertDrop(PersistentSnippet key, DiagCheck diagMain, DiagCheck diagUpdates, STEInfo mainInfo, STEInfo... updates) { + public void assertDrop(Snippet key, DiagCheck diagMain, DiagCheck diagUpdates, STEInfo mainInfo, STEInfo... updates) { assertDrop(key, diagMain, diagUpdates, new EventChain(mainInfo, null, null, updates)); } - public void assertDrop(PersistentSnippet key, DiagCheck diagMain, DiagCheck diagUpdates, EventChain... eventChains) { + public void assertDrop(Snippet key, DiagCheck diagMain, DiagCheck diagUpdates, EventChain... eventChains) { checkEvents(() -> getState().drop(key), "drop(" + key + ")", diagMain, diagUpdates, eventChains); } diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/jdk/jshell/ReplaceTest.java --- a/langtools/test/jdk/jshell/ReplaceTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/test/jdk/jshell/ReplaceTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -33,7 +33,6 @@ import java.util.stream.Stream; import jdk.jshell.Snippet; import jdk.jshell.MethodSnippet; -import jdk.jshell.PersistentSnippet; import jdk.jshell.TypeDeclSnippet; import jdk.jshell.VarSnippet; import jdk.jshell.DeclarationSnippet; @@ -585,14 +584,14 @@ } public void testForwardSingleImportMethodToClass1() { - PersistentSnippet a = classKey(assertEval("class A { String s = format(\"%d\", 10); }", + Snippet a = classKey(assertEval("class A { String s = format(\"%d\", 10); }", added(RECOVERABLE_DEFINED))); assertEvalUnresolvedException("new A();", "A", 1, 0); assertEval("import static java.lang.String.format;", added(VALID), ste(a, RECOVERABLE_DEFINED, VALID, false, null)); assertEval("new A().s;", "\"10\""); - PersistentSnippet format = methodKey(assertEval("void format(String s, int d) { }", + Snippet format = methodKey(assertEval("void format(String s, int d) { }", DiagCheck.DIAG_OK, DiagCheck.DIAG_ERROR, added(VALID), @@ -605,14 +604,14 @@ } public void testForwardSingleImportMethodToClass2() { - PersistentSnippet a = classKey(assertEval("class A { String s() { return format(\"%d\", 10); } }", + Snippet a = classKey(assertEval("class A { String s() { return format(\"%d\", 10); } }", added(RECOVERABLE_DEFINED))); assertEvalUnresolvedException("new A();", "A", 1, 0); assertEval("import static java.lang.String.format;", added(VALID), ste(a, RECOVERABLE_DEFINED, VALID, false, null)); assertEval("new A().s();", "\"10\""); - PersistentSnippet format = methodKey(assertEval("void format(String s, int d) { }", + Snippet format = methodKey(assertEval("void format(String s, int d) { }", DiagCheck.DIAG_OK, DiagCheck.DIAG_ERROR, added(VALID), @@ -625,7 +624,7 @@ } public void testForwardSingleImportClassToClass1() { - PersistentSnippet a = classKey(assertEval("class A { static List list; }", + Snippet a = classKey(assertEval("class A { static List list; }", added(RECOVERABLE_NOT_DEFINED))); assertDeclareFail("new A();", "compiler.err.cant.resolve.location"); assertEval("import java.util.List;", @@ -634,7 +633,7 @@ assertEval("import java.util.Arrays;", added(VALID)); assertEval("A.list = Arrays.asList(1, 2, 3);", "[1, 2, 3]"); - PersistentSnippet list = classKey(assertEval("class List {}", + Snippet list = classKey(assertEval("class List {}", DiagCheck.DIAG_OK, DiagCheck.DIAG_ERROR, added(VALID), @@ -647,7 +646,7 @@ } public void testForwardSingleImportClassToClass2() { - PersistentSnippet clsA = classKey(assertEval("class A extends ArrayList { }", + Snippet clsA = classKey(assertEval("class A extends ArrayList { }", added(RECOVERABLE_NOT_DEFINED))); assertDeclareFail("new A();", "compiler.err.cant.resolve.location"); assertEval("import java.util.ArrayList;", @@ -655,7 +654,7 @@ ste(clsA, RECOVERABLE_NOT_DEFINED, VALID, true, MAIN_SNIPPET)); Snippet vara = varKey(assertEval("A a = new A();", "[]")); - PersistentSnippet arraylist = classKey(assertEval("class ArrayList {}", + Snippet arraylist = classKey(assertEval("class ArrayList {}", DiagCheck.DIAG_OK, DiagCheck.DIAG_ERROR, added(VALID), @@ -671,7 +670,7 @@ } public void testForwardImportOnDemandMethodToClass1() { - PersistentSnippet a = classKey(assertEval("class A { String s = format(\"%d\", 10); }", + Snippet a = classKey(assertEval("class A { String s = format(\"%d\", 10); }", added(RECOVERABLE_DEFINED))); assertEvalUnresolvedException("new A();", "A", 1, 0); assertEval("import static java.lang.String.*;", @@ -679,7 +678,7 @@ ste(a, RECOVERABLE_DEFINED, VALID, false, null)); assertEval("A x = new A();"); assertEval("x.s;", "\"10\""); - PersistentSnippet format = methodKey(assertEval("void format(String s, int d) { }", + Snippet format = methodKey(assertEval("void format(String s, int d) { }", DiagCheck.DIAG_OK, DiagCheck.DIAG_ERROR, added(VALID), @@ -693,14 +692,14 @@ } public void testForwardImportOnDemandMethodToClass2() { - PersistentSnippet a = classKey(assertEval("class A { String s() { return format(\"%d\", 10); } }", + Snippet a = classKey(assertEval("class A { String s() { return format(\"%d\", 10); } }", added(RECOVERABLE_DEFINED))); assertEvalUnresolvedException("new A();", "A", 1, 0); assertEval("import static java.lang.String.*;", added(VALID), ste(a, RECOVERABLE_DEFINED, VALID, false, null)); assertEval("new A().s();", "\"10\""); - PersistentSnippet format = methodKey(assertEval("void format(String s, int d) { }", + Snippet format = methodKey(assertEval("void format(String s, int d) { }", DiagCheck.DIAG_OK, DiagCheck.DIAG_ERROR, added(VALID), @@ -713,7 +712,7 @@ } public void testForwardImportOnDemandClassToClass1() { - PersistentSnippet a = classKey(assertEval("class A { static List list; }", + Snippet a = classKey(assertEval("class A { static List list; }", added(RECOVERABLE_NOT_DEFINED))); assertDeclareFail("new A();", "compiler.err.cant.resolve.location"); assertEval("import java.util.*;", @@ -721,7 +720,7 @@ ste(a, RECOVERABLE_NOT_DEFINED, VALID, true, null)); assertEval("A.list = Arrays.asList(1, 2, 3);", "[1, 2, 3]"); - PersistentSnippet list = classKey(assertEval("class List {}", + Snippet list = classKey(assertEval("class List {}", DiagCheck.DIAG_OK, DiagCheck.DIAG_ERROR, added(VALID), @@ -734,7 +733,7 @@ } public void testForwardImportOnDemandClassToClass2() { - PersistentSnippet clsA = classKey(assertEval("class A extends ArrayList { }", + Snippet clsA = classKey(assertEval("class A extends ArrayList { }", added(RECOVERABLE_NOT_DEFINED))); assertDeclareFail("new A();", "compiler.err.cant.resolve.location"); assertEval("import java.util.*;", @@ -742,7 +741,7 @@ ste(clsA, RECOVERABLE_NOT_DEFINED, VALID, true, MAIN_SNIPPET)); Snippet vara = varKey(assertEval("A a = new A();", "[]")); - PersistentSnippet arraylist = classKey(assertEval("class ArrayList {}", + Snippet arraylist = classKey(assertEval("class ArrayList {}", DiagCheck.DIAG_OK, DiagCheck.DIAG_ERROR, added(VALID), @@ -757,7 +756,7 @@ } public void testForwardSingleImportFieldToClass1() { - PersistentSnippet a = classKey(assertEval("class A { static double pi() { return PI; } }", + Snippet a = classKey(assertEval("class A { static double pi() { return PI; } }", added(RECOVERABLE_DEFINED))); assertEvalUnresolvedException("new A();", "A", 1, 0); assertEval("import static java.lang.Math.PI;", @@ -765,7 +764,7 @@ ste(a, RECOVERABLE_DEFINED, VALID, false, null)); assertEval("Math.abs(A.pi() - 3.1415) < 0.001;", "true"); - PersistentSnippet list = varKey(assertEval("String PI;", + Snippet list = varKey(assertEval("String PI;", DiagCheck.DIAG_OK, DiagCheck.DIAG_ERROR, added(VALID), @@ -778,7 +777,7 @@ } public void testForwardSingleImportFieldToClass2() { - PersistentSnippet a = classKey(assertEval("class A { static double pi = PI; }", + Snippet a = classKey(assertEval("class A { static double pi = PI; }", added(RECOVERABLE_DEFINED))); assertEvalUnresolvedException("new A();", "A", 1, 0); assertEval("import static java.lang.Math.PI;", @@ -786,7 +785,7 @@ ste(a, RECOVERABLE_DEFINED, VALID, true, null)); assertEval("Math.abs(A.pi - 3.1415) < 0.001;", "true"); - PersistentSnippet list = varKey(assertEval("String PI;", + Snippet list = varKey(assertEval("String PI;", DiagCheck.DIAG_OK, DiagCheck.DIAG_ERROR, added(VALID), @@ -799,7 +798,7 @@ } public void testForwardImportOnDemandFieldToClass1() { - PersistentSnippet a = classKey(assertEval("class A { static double pi() { return PI; } }", + Snippet a = classKey(assertEval("class A { static double pi() { return PI; } }", added(RECOVERABLE_DEFINED))); assertEvalUnresolvedException("new A();", "A", 1, 0); assertEval("import static java.lang.Math.*;", @@ -807,7 +806,7 @@ ste(a, RECOVERABLE_DEFINED, VALID, false, null)); assertEval("Math.abs(A.pi() - 3.1415) < 0.001;", "true"); - PersistentSnippet list = varKey(assertEval("String PI;", + Snippet list = varKey(assertEval("String PI;", DiagCheck.DIAG_OK, DiagCheck.DIAG_ERROR, added(VALID), @@ -820,7 +819,7 @@ } public void testForwardImportOnDemandFieldToClass2() { - PersistentSnippet a = classKey(assertEval("class A { static double pi = PI; }", + Snippet a = classKey(assertEval("class A { static double pi = PI; }", added(RECOVERABLE_DEFINED))); assertEvalUnresolvedException("new A();", "A", 1, 0); assertEval("import static java.lang.Math.*;", @@ -828,7 +827,7 @@ ste(a, RECOVERABLE_DEFINED, VALID, true, null)); assertEval("Math.abs(A.pi - 3.1415) < 0.001;", "true"); - PersistentSnippet list = varKey(assertEval("String PI;", + Snippet list = varKey(assertEval("String PI;", DiagCheck.DIAG_OK, DiagCheck.DIAG_ERROR, added(VALID), diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/jdk/jshell/ToolCommandOptionTest.java --- a/langtools/test/jdk/jshell/ToolCommandOptionTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/test/jdk/jshell/ToolCommandOptionTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -23,7 +23,7 @@ /* * @test - * @bug 8157395 8157393 8157517 8158738 + * @bug 8157395 8157393 8157517 8158738 8167128 * @summary Tests of jshell comand options, and undoing operations * @modules jdk.jshell/jdk.internal.jshell.tool * @build ToolCommandOptionTest ReplToolTesting @@ -101,13 +101,17 @@ "| Unknown option: -all -- /drop -all"), (a) -> assertCommandOutputStartsWith(a, "/drop z", "| No such snippet: z"), - (a) -> assertCommandOutputStartsWith(a, "/drop 2", - "| This command does not accept the snippet '2' : x"), + (a) -> assertCommand(a, "/drop 2", + ""), + (a) -> assertCommandOutputStartsWith(a, "23qwl", + "| Error:"), + (a) -> assertCommandOutputStartsWith(a, "/drop e1", + "| This command does not accept the snippet 'e1' : 23qwl"), (a) -> assertCommand(a, "/dr x y", "| dropped variable x\n" + "| dropped variable y"), (a) -> assertCommand(a, "/list", - "2 : x") + "") ); } diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/jdk/jshell/ToolSimpleTest.java --- a/langtools/test/jdk/jshell/ToolSimpleTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/test/jdk/jshell/ToolSimpleTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -23,7 +23,7 @@ /* * @test - * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 + * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 * @summary Simple jshell tool tests * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main @@ -217,6 +217,9 @@ a -> dropClass(a, "/drop 3", "class A", "| dropped class A"), a -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"), a -> dropImport(a, "/drop 4", "import java.util.stream.*", ""), + a -> assertCommand(a, "for (int i = 0; i < 10; ++i) {}", ""), + a -> assertCommand(a, "/drop 5", ""), + a -> assertCommand(a, "/list", ""), a -> assertCommandCheckOutput(a, "/vars", assertVariables()), a -> assertCommandCheckOutput(a, "/methods", assertMethods()), a -> assertCommandCheckOutput(a, "/types", assertClasses()), @@ -244,6 +247,7 @@ assertStartsWith("| In the /drop argument, please specify an import, variable, method, or class to drop.")), a -> assertVariable(a, "int", "a"), a -> assertCommand(a, "a", "a ==> 0"), + a -> assertCommand(a, "/drop 2", ""), a -> assertCommand(a, "/drop 2", "| This command does not accept the snippet '2' : a\n" + "| See /types, /methods, /vars, or /list") diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/tools/javac/8167000/T8167000.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/8167000/T8167000.java Mon Oct 17 15:32:44 2016 +0000 @@ -0,0 +1,34 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8167000 + * @summary Refine handling of multiple maximally specific abstract methods + * @compile/fail/ref=T8167000.out -XDrawDiagnostics -Werror -Xlint:unchecked T8167000.java + */ + +import java.util.*; + +class T8167000 { + + interface J { + List getAll(String str); + } + + interface K { + Collection getAll(String str); + } + + interface L { + List getAll(String str); + } + + interface M { + Collection getAll(String str); + } + + + static abstract class E implements J, K, L, M { + void test() { + List l = getAll(""); //check that we get an unchecked warning here + } + } +} diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/tools/javac/8167000/T8167000.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/8167000/T8167000.out Mon Oct 17 15:32:44 2016 +0000 @@ -0,0 +1,4 @@ +T8167000.java:31:36: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.List, java.util.List +- compiler.err.warnings.and.werror +1 error +1 warning diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/tools/javac/8167000/T8167000b.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/8167000/T8167000b.java Mon Oct 17 15:32:44 2016 +0000 @@ -0,0 +1,21 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8167000 + * @summary Refine handling of multiple maximally specific abstract methods + * @compile/fail/ref=T8167000b.out -XDrawDiagnostics T8167000b.java + */ +public class T8167000b { + interface A { + Integer m() throws Throwable; + } + + interface B { + Object m() throws X; + } + + static abstract class E implements A, B { + void test() { + Integer l = m(); //error: unhandled T + } + } +} diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/tools/javac/8167000/T8167000b.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/8167000/T8167000b.out Mon Oct 17 15:32:44 2016 +0000 @@ -0,0 +1,2 @@ +T8167000b.java:18:26: compiler.err.unreported.exception.need.to.catch.or.throw: T +1 error diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/tools/javac/8167000/T8167000c.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/8167000/T8167000c.java Mon Oct 17 15:32:44 2016 +0000 @@ -0,0 +1,21 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8167000 + * @summary Refine handling of multiple maximally specific abstract methods + * @compile/fail/ref=T8167000c.out -XDrawDiagnostics T8167000c.java + */ +public class T8167000c { + interface A { + Integer m() throws Throwable; + } + + interface B { + Object m() throws X; + } + + interface E extends A, B { } + + void test() { + E ex = () -> { throw new Throwable(); }; + } +} diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/tools/javac/8167000/T8167000c.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/8167000/T8167000c.out Mon Oct 17 15:32:44 2016 +0000 @@ -0,0 +1,4 @@ +T8167000c.java:19:27: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable +- compiler.note.unchecked.filename: T8167000c.java +- compiler.note.unchecked.recompile +1 error diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java --- a/langtools/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -120,10 +120,10 @@ } } - boolean moreSpecificThan(TypeArgumentKind that, boolean strict) { + boolean moreSpecificThan(TypeArgumentKind that) { switch (this) { case NONE: - return that == this || !strict; + return that == this; case UNBOUND: return that == this || that == NONE; case INTEGER: @@ -198,6 +198,7 @@ void check(Result res) { boolean errorExpected = false; + boolean loose = false; int mostSpecific = 0; //first check that either |R1| <: |R2| or |R2| <: |R1| @@ -208,39 +209,43 @@ } else { mostSpecific = rets[0].moreSpecificThan(rets[1]) ? 1 : 2; } + } else if (sigs[0] != sigs[1]) { + mostSpecific = sigs[0] == SignatureKind.GENERIC ? 2 : 1; + loose = true; } //check that either TA1 <= TA2 or TA2 <= TA1 (unless most specific return found above is raw) if (!errorExpected) { if (targs[0] != targs[1]) { - boolean useStrictCheck = targs[0].moreSpecificThan(targs[1], true) || - targs[1].moreSpecificThan(targs[0], true); - if (!targs[0].moreSpecificThan(targs[1], useStrictCheck) && - !targs[1].moreSpecificThan(targs[0], useStrictCheck)) { + boolean ta1ms = targs[0].moreSpecificThan(targs[1]); + boolean ta2ms = targs[1].moreSpecificThan(targs[0]); + if (!ta1ms && !ta2ms) { errorExpected = true; + } else if (mostSpecific != 0) { + errorExpected = !loose && targs[mostSpecific - 1] != TypeArgumentKind.NONE && + (mostSpecific == 1 ? !ta1ms : !ta2ms); } else { - int mostSpecific2 = targs[0].moreSpecificThan(targs[1], useStrictCheck) ? 1 : 2; - if (mostSpecific != 0 && mostSpecific2 != mostSpecific) { - errorExpected = mostSpecific == 1 ? - targs[0] != TypeArgumentKind.NONE : - targs[1] != TypeArgumentKind.NONE; - } else { - mostSpecific = mostSpecific2; - } + mostSpecific = ta1ms ? 1 : 2; } - } else if (mostSpecific == 0) { - //when no signature is better than the other, an arbitrary choice - //must be made - javac always picks the second signature - mostSpecific = 2; } } - //finally, check that most specific return type is compatible with expected type + if (mostSpecific == 0) { + //when no signature is better than the other, an arbitrary choice + //must be made - javac always picks the second signature + mostSpecific = 2; + } + if (!errorExpected) { ReturnTypeKind msrt = mostSpecific == 1 ? rets[0] : rets[1]; TypeArgumentKind msta = mostSpecific == 1 ? targs[0] : targs[1]; SignatureKind mssig = mostSpecific == 1 ? sigs[0] : sigs[1]; + //check that most specific is subsignature + errorExpected = sigs[0] != sigs[1] && + mssig == SignatureKind.GENERIC; + + //finally, check that most specific return type is compatible with expected type if (!msrt.moreSpecificThan(rets[2]) || !msta.assignableTo(targs[2], mssig, level)) { errorExpected = true; diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/tools/javac/modules/EdgeCases.java --- a/langtools/test/tools/javac/modules/EdgeCases.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/test/tools/javac/modules/EdgeCases.java Mon Oct 17 15:32:44 2016 +0000 @@ -23,7 +23,7 @@ /* * @test - * @bug 8154283 + * @bug 8154283 8167320 * @summary tests for multi-module mode compilation * @library /tools/lib * @modules @@ -54,6 +54,7 @@ //import com.sun.source.util.JavacTask; // conflicts with toolbox.JavacTask import com.sun.tools.javac.api.JavacTaskImpl; import com.sun.tools.javac.code.Symbol.ModuleSymbol; +import com.sun.tools.javac.code.Symtab; import toolbox.JarTask; import toolbox.JavacTask; @@ -449,4 +450,12 @@ } } + @Test + public void testGetDirectivesComplete(Path base) throws Exception { + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + JavacTaskImpl task = (JavacTaskImpl) compiler.getTask(null, null, null, null, null, null); + Symtab syms = Symtab.instance(task.getContext()); + + syms.java_base.getDirectives(); + } } diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/tools/javac/modules/ModulePathTest.java --- a/langtools/test/tools/javac/modules/ModulePathTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/langtools/test/tools/javac/modules/ModulePathTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -29,7 +29,7 @@ * jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.jdeps/com.sun.tools.javap - * jdk.jlink/jdk.tools.jmod + * jdk.jlink * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask toolbox.ModuleBuilder * ModuleTestBase * @run main ModulePathTest @@ -39,6 +39,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.spi.ToolProvider; import toolbox.JarTask; import toolbox.JavacTask; @@ -420,6 +421,9 @@ "--class-path", dir.toString(), jmod.toString() }; - jdk.tools.jmod.Main.run(args, System.out); + ToolProvider jmodTool = ToolProvider.findFirst("jmod").orElseThrow(() -> + new RuntimeException("jmod tool not found") + ); + jmodTool.run(System.out, System.err, args); } } diff -r 563c1d911dcb -r ce1843f66c03 langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestRelease.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestRelease.java Mon Oct 17 15:32:44 2016 +0000 @@ -0,0 +1,58 @@ +/* + * 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 8167965 + * @summary Test proper handling of the --release option. + * @modules jdk.jdeps/com.sun.tools.jdeprscan + * @build jdk.jdeprscan.TestRelease + * @run testng jdk.jdeprscan.TestRelease + */ + +package jdk.jdeprscan; + +import com.sun.tools.jdeprscan.Main; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +public class TestRelease { + static boolean invoke(String arg) { + return Main.call(System.out, System.err, "--list", "--release", arg); + } + + @Test + public void testSuccess() { + assertTrue(invoke("6")); + assertTrue(invoke("7")); + assertTrue(invoke("8")); + assertTrue(invoke("9")); + } + + @Test + public void testFailure() { + assertFalse(invoke("5")); + } +} diff -r 563c1d911dcb -r ce1843f66c03 make/CopyImportModules.gmk --- a/make/CopyImportModules.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/make/CopyImportModules.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -41,14 +41,14 @@ ifeq ($(OPENJDK_TARGET_OS), windows) TO_BIN_FILTER := %$(SHARED_LIBRARY_SUFFIX) %.diz %.pdb %.map - $(eval $(call SetupCopyFiles,COPY_LIBS_TO_BIN, \ + $(eval $(call SetupCopyFiles, COPY_LIBS_TO_BIN, \ SRC := $(LIBS_DIR), \ DEST := $(JDK_OUTPUTDIR)/bin, \ FILES := $(filter $(TO_BIN_FILTER), \ $(call CacheFind, $(LIBS_DIR))) \ )) - $(eval $(call SetupCopyFiles,COPY_LIBS_TO_LIB, \ + $(eval $(call SetupCopyFiles, COPY_LIBS_TO_LIB, \ SRC := $(LIBS_DIR), \ DEST := $(JDK_OUTPUTDIR)/lib, \ FILES := $(filter-out $(TO_BIN_FILTER), \ diff -r 563c1d911dcb -r ce1843f66c03 make/CreateBuildJdkCopy.gmk --- a/make/CreateBuildJdkCopy.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/make/CreateBuildJdkCopy.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -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 diff -r 563c1d911dcb -r ce1843f66c03 make/GensrcModuleInfo.gmk --- a/make/GensrcModuleInfo.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/make/GensrcModuleInfo.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -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 diff -r 563c1d911dcb -r ce1843f66c03 make/Images.gmk --- a/make/Images.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/make/Images.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -412,7 +412,7 @@ ################################################################################ # /sample dir -$(eval $(call SetupCopyFiles,COPY_SAMPLES, \ +$(eval $(call SetupCopyFiles, COPY_SAMPLES, \ SRC := $(SUPPORT_OUTPUTDIR)/sample/image, \ DEST := $(JDK_IMAGE_DIR)/sample, \ FILES := $(if $(wildcard $(SUPPORT_OUTPUTDIR)/sample/image), \ diff -r 563c1d911dcb -r ce1843f66c03 make/Init.gmk --- a/make/Init.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/make/Init.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -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 diff -r 563c1d911dcb -r ce1843f66c03 make/InitSupport.gmk --- a/make/InitSupport.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/make/InitSupport.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 diff -r 563c1d911dcb -r ce1843f66c03 make/Jprt.gmk --- a/make/Jprt.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/make/Jprt.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -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 diff -r 563c1d911dcb -r ce1843f66c03 make/JrtfsJar.gmk --- a/make/JrtfsJar.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/make/JrtfsJar.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 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 @@ -46,7 +46,7 @@ jdk/internal/jrtfs \ # -$(eval $(call SetupJavaCompilation,BUILD_JRTFS, \ +$(eval $(call SetupJavaCompilation, BUILD_JRTFS, \ SETUP := GENERATE_OLDBYTECODE, \ SRC := $(JDK_TOPDIR)/src/java.base/share/classes, \ EXCLUDE_FILES := module-info.java, \ @@ -57,7 +57,7 @@ # file will not be copied unless META-INF/services would also be added to the INCLUDES. # Adding META-INF/services would include all files in that directory when only the one # is needed, which is why this explicit copy is defined instead. -$(eval $(call SetupCopyFiles,COPY_JIMAGE_SERVICE_PROVIDER, \ +$(eval $(call SetupCopyFiles, COPY_JIMAGE_SERVICE_PROVIDER, \ SRC := $(JDK_TOPDIR)/src/java.base/share/classes, \ DEST := $(SUPPORT_OUTPUTDIR)/jrtfs_classes, \ FILES := META-INF/services/java.nio.file.spi.FileSystemProvider)) diff -r 563c1d911dcb -r ce1843f66c03 make/MacBundles.gmk --- a/make/MacBundles.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/make/MacBundles.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 diff -r 563c1d911dcb -r ce1843f66c03 make/Main.gmk --- a/make/Main.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/make/Main.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -237,7 +237,7 @@ # Build hotspot target ifeq ($(BUILD_HOTSPOT),true) -hotspot: + hotspot: +($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f BuildHotspot.gmk) endif @@ -548,7 +548,7 @@ # The demos are currently linking to libjvm and libjava, just like all other # jdk libs, even though they don't need to. To avoid warnings, make sure they # aren't built until after libjava and libjvm are available to link to. - demos-jdk: $(JAVA_TARGETS) + demos-jdk: java.base-libs exploded-image-optimize # Declare dependency from -java to -gensrc $(foreach m, $(GENSRC_MODULES), $(eval $m-java: $m-gensrc)) @@ -698,7 +698,7 @@ test-make: clean-test-make - build-test-lib: java + build-test-lib: exploded-image-optimize build-test-failure-handler: interim-langtools diff -r 563c1d911dcb -r ce1843f66c03 make/common/CORE_PKGS.gmk --- a/make/common/CORE_PKGS.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/make/common/CORE_PKGS.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2001, 2015, 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 diff -r 563c1d911dcb -r ce1843f66c03 make/common/JarArchive.gmk --- a/make/common/JarArchive.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/make/common/JarArchive.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 @@ -242,7 +242,7 @@ # potential changes. $$(if $$(filter $$($1_VARDEPS_FILE) $$($1_MANIFEST), $$?), \ $$(if $$($1_MANIFEST), \ - $(SED) -e '$(DOLLAR)$(DOLLAR)a\' $$($1_MANIFEST) > $$($1_MANIFEST_FILE) $$(NEWLINE) \ + $(CP) $$($1_MANIFEST) $$($1_MANIFEST_FILE) $$(NEWLINE) \ , \ $(RM) $$($1_MANIFEST_FILE) && $(TOUCH) $$($1_MANIFEST_FILE) $$(NEWLINE)) \ $$(if $$($1_JARMAIN), \ diff -r 563c1d911dcb -r ce1843f66c03 make/common/JavaCompilation.gmk --- a/make/common/JavaCompilation.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/make/common/JavaCompilation.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 diff -r 563c1d911dcb -r ce1843f66c03 make/common/NON_CORE_PKGS.gmk --- a/make/common/NON_CORE_PKGS.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/make/common/NON_CORE_PKGS.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2002, 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 diff -r 563c1d911dcb -r ce1843f66c03 make/common/SetupJavaCompilers.gmk --- a/make/common/SetupJavaCompilers.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/make/common/SetupJavaCompilers.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 diff -r 563c1d911dcb -r ce1843f66c03 make/devkit/Tools.gmk --- a/make/devkit/Tools.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/make/devkit/Tools.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 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 diff -r 563c1d911dcb -r ce1843f66c03 make/devkit/createWindowsDevkit.sh --- a/make/devkit/createWindowsDevkit.sh Mon Oct 17 15:31:50 2016 +0000 +++ b/make/devkit/createWindowsDevkit.sh Mon Oct 17 15:32:44 2016 +0000 @@ -1,6 +1,6 @@ #!/bin/bash # -# 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 diff -r 563c1d911dcb -r ce1843f66c03 nashorn/.hgtags --- a/nashorn/.hgtags Mon Oct 17 15:31:50 2016 +0000 +++ b/nashorn/.hgtags Mon Oct 17 15:32:44 2016 +0000 @@ -373,3 +373,4 @@ 17ed43add2f9e3528686cd786ae2ed49c8ed36e9 jdk-9+137 4a6ee1185fc821df063e4d1537fa7ad2ebe9eb02 jdk-9+138 e3b11296395b39bfeb3364f26c2ef77fa652e300 jdk-9+139 +785843878cf78d50cc2959ea2c5a4202bbe885b4 jdk-9+140 diff -r 563c1d911dcb -r ce1843f66c03 nashorn/make/BuildNashorn.gmk --- a/nashorn/make/BuildNashorn.gmk Mon Oct 17 15:31:50 2016 +0000 +++ b/nashorn/make/BuildNashorn.gmk Mon Oct 17 15:32:44 2016 +0000 @@ -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 diff -r 563c1d911dcb -r ce1843f66c03 nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CallerSensitiveDynamicMethod.java --- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CallerSensitiveDynamicMethod.java Mon Oct 17 15:31:50 2016 +0000 +++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CallerSensitiveDynamicMethod.java Mon Oct 17 15:32:44 2016 +0000 @@ -100,7 +100,6 @@ import jdk.dynalink.SecureLookupSupplier; import jdk.dynalink.internal.AccessControlContextFactory; import jdk.dynalink.linker.support.Lookup; -import jdk.internal.module.Modules; import jdk.internal.reflect.CallerSensitive; @@ -180,57 +179,10 @@ } private static MethodHandle unreflect(final MethodHandles.Lookup lookup, final Method m) { - try { - return Lookup.unreflect(lookup, m); - } catch (final IllegalAccessError iae) { - if (addModuleRead(lookup, m)) { - try { - return Lookup.unreflect(lookup, m); - } catch (final IllegalAccessError e2) { - // fall through and throw original error as cause - } - } - throw iae; - } + return Lookup.unreflect(lookup, m); } private static MethodHandle unreflectConstructor(final MethodHandles.Lookup lookup, final Constructor c) { - try { - return Lookup.unreflectConstructor(lookup, c); - } catch (final IllegalAccessError iae) { - if (addModuleRead(lookup, c)) { - try { - return Lookup.unreflectConstructor(lookup, c); - } catch (final IllegalAccessError e2) { - // fall through and throw original error as cause - } - } - throw iae; - } - } - - - private static boolean addModuleRead(final MethodHandles.Lookup lookup, final Executable e) { - // Don't add module read link if this is not a CallerSensitive member - if (!e.isAnnotationPresent(CallerSensitive.class)) { - return false; - } - - // If the lookup is public lookup, don't bother adding module read link! - // public lookup cannot unreflect caller sensitives anyway! - if (lookup == MethodHandles.publicLookup()) { - return false; - } - - // try to add missing module read from using module to declararing module! - final Class declClass = e.getDeclaringClass(); - final Module useModule = lookup.lookupClass().getModule(); - final Module declModule = declClass.getModule(); - if (useModule != null && declModule != null && declModule.isExported(declClass.getPackageName())) { - Modules.addReads(useModule, declModule); - return true; - } - - return false; + return Lookup.unreflectConstructor(lookup, c); } } diff -r 563c1d911dcb -r ce1843f66c03 nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java Mon Oct 17 15:31:50 2016 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java Mon Oct 17 15:32:44 2016 +0000 @@ -389,6 +389,15 @@ // is created, and invalidated forever once the second global is created. private final AtomicReference globalConstantsRef = new AtomicReference<>(); + // Are java.sql, java.sql.rowset modules found in the system? + static final boolean javaSqlFound, javaSqlRowsetFound; + + static { + final Layer boot = Layer.boot(); + javaSqlFound = boot.findModule("java.sql").isPresent(); + javaSqlRowsetFound = boot.findModule("java.sql.rowset").isPresent(); + } + /** * Get the current global scope * @return the current global scope diff -r 563c1d911dcb -r ce1843f66c03 nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptLoader.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptLoader.java Mon Oct 17 15:31:50 2016 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptLoader.java Mon Oct 17 15:32:44 2016 +0000 @@ -68,12 +68,23 @@ private Module createModule(final String moduleName) { final Module structMod = context.getStructLoader().getModule(); - final ModuleDescriptor descriptor - = new ModuleDescriptor.Builder(moduleName) + final ModuleDescriptor.Builder builder = + new ModuleDescriptor.Builder(moduleName) + .requires("java.base") + .requires("java.logging") .requires(NASHORN_MODULE.getName()) .requires(structMod.getName()) - .conceals(SCRIPTS_PKG) - .build(); + .conceals(SCRIPTS_PKG); + + if (Context.javaSqlFound) { + builder.requires("java.sql"); + } + + if (Context.javaSqlRowsetFound) { + builder.requires("java.sql.rowset"); + } + + final ModuleDescriptor descriptor = builder.build(); final Module mod = Context.createModuleTrusted(structMod.getLayer(), descriptor, this); loadModuleManipulator(); diff -r 563c1d911dcb -r ce1843f66c03 nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/StructureLoader.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/StructureLoader.java Mon Oct 17 15:31:50 2016 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/StructureLoader.java Mon Oct 17 15:32:44 2016 +0000 @@ -64,6 +64,7 @@ private Module createModule(final String moduleName) { final ModuleDescriptor descriptor = new ModuleDescriptor.Builder(moduleName) + .requires("java.base") .requires(NASHORN_MODULE.getName()) .conceals(SCRIPTS_PKG) .build(); diff -r 563c1d911dcb -r ce1843f66c03 nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java Mon Oct 17 15:31:50 2016 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java Mon Oct 17 15:32:44 2016 +0000 @@ -78,14 +78,17 @@ prioritizedLinkers = new GuardingDynamicLinker[] { new NashornLinker(), new NashornPrimitiveLinker(), - new NashornStaticClassLinker(beansLinker), new BoundCallableLinker(), new JavaSuperAdapterLinker(beansLinker), new JSObjectLinker(nashornBeansLinker), new BrowserJSObjectLinker(nashornBeansLinker), new ReflectionCheckLinker() }; - fallbackLinkers = new GuardingDynamicLinker[] {nashornBeansLinker, new NashornBottomLinker() }; + fallbackLinkers = new GuardingDynamicLinker[] { + new NashornStaticClassLinker(beansLinker), + nashornBeansLinker, + new NashornBottomLinker() + }; } // do not create me!! diff -r 563c1d911dcb -r ce1843f66c03 nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java Mon Oct 17 15:31:50 2016 +0000 +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java Mon Oct 17 15:32:44 2016 +0000 @@ -68,7 +68,7 @@ @Override public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices) throws Exception { final Object self = request.getReceiver(); - if (self.getClass() != StaticClass.class) { + if (self == null || self.getClass() != StaticClass.class) { return null; } final Class receiverClass = ((StaticClass) self).getRepresentedClass(); diff -r 563c1d911dcb -r ce1843f66c03 nashorn/test/src/jdk/dynalink/test/DynamicLinkerFactoryTest.java --- a/nashorn/test/src/jdk/dynalink/test/DynamicLinkerFactoryTest.java Mon Oct 17 15:31:50 2016 +0000 +++ b/nashorn/test/src/jdk/dynalink/test/DynamicLinkerFactoryTest.java Mon Oct 17 15:32:44 2016 +0000 @@ -39,6 +39,7 @@ import jdk.dynalink.NoSuchDynamicMethodException; import jdk.dynalink.Operation; import jdk.dynalink.StandardOperation; +import jdk.dynalink.beans.StaticClass; import jdk.dynalink.linker.GuardedInvocation; import jdk.dynalink.linker.GuardingDynamicLinker; import jdk.dynalink.linker.LinkRequest; @@ -234,6 +235,15 @@ @Test public void autoLoadedLinkerTest() { + testAutoLoadedLinkerInvoked(new Object(), "toString"); + } + + @Test + public void autoLoadedLinkerSeesStaticMethod() { + testAutoLoadedLinkerInvoked(StaticClass.forClass(System.class), "currentTimeMillis"); + } + + private static void testAutoLoadedLinkerInvoked(final Object target, final String methodName) { final DynamicLinkerFactory factory = newDynamicLinkerFactory(false); final DynamicLinker linker = factory.createLinker(); @@ -241,22 +251,21 @@ checkOneAutoLoadingError(factory); final MethodType mt = MethodType.methodType(Object.class, Object.class); - // create a callsite with TestLinkerOperation - final CallSite cs = linker.link(new SimpleRelinkableCallSite(new CallSiteDescriptor( - MethodHandles.publicLookup(), new TestLinkerOperation(), mt))); - boolean reachedAutoLinker = false; - + final CallSiteDescriptor testDescriptor = new CallSiteDescriptor(MethodHandles.publicLookup(), + new NamedOperation(StandardOperation.GET_METHOD, methodName), mt); + final CallSite cs = linker.link(new SimpleRelinkableCallSite(testDescriptor)); + TrustedGuardingDynamicLinkerExporter.enable(); try { - cs.getTarget().invoke(new Object()); - } catch (final ReachedAutoLoadedDynamicLinkerException e) { - // TrustedGuardingDynamicLinkerExporter threw exception on TestLinkerOperation as expected! - reachedAutoLinker = true; + cs.getTarget().invoke(target); + // The linker was loaded and it observed our invocation + Assert.assertTrue(TrustedGuardingDynamicLinkerExporter.isLastCallSiteDescriptor(testDescriptor)); } catch (final Throwable th) { throw new RuntimeException(th); + } finally { + TrustedGuardingDynamicLinkerExporter.disable(); } - Assert.assertTrue(reachedAutoLinker); } @Test diff -r 563c1d911dcb -r ce1843f66c03 nashorn/test/src/jdk/dynalink/test/ReachedAutoLoadedDynamicLinkerException.java --- a/nashorn/test/src/jdk/dynalink/test/ReachedAutoLoadedDynamicLinkerException.java Mon Oct 17 15:31:50 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.dynalink.test; - -/** - * Exception used to signal to the test method that the control has reached auto loaded - * dynamic linker. - */ -public final class ReachedAutoLoadedDynamicLinkerException extends RuntimeException { -} diff -r 563c1d911dcb -r ce1843f66c03 nashorn/test/src/jdk/dynalink/test/TestLinkerOperation.java --- a/nashorn/test/src/jdk/dynalink/test/TestLinkerOperation.java Mon Oct 17 15:31:50 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.dynalink.test; - -import jdk.dynalink.Operation; - -public final class TestLinkerOperation implements Operation { -} diff -r 563c1d911dcb -r ce1843f66c03 nashorn/test/src/jdk/dynalink/test/TrustedGuardingDynamicLinkerExporter.java --- a/nashorn/test/src/jdk/dynalink/test/TrustedGuardingDynamicLinkerExporter.java Mon Oct 17 15:31:50 2016 +0000 +++ b/nashorn/test/src/jdk/dynalink/test/TrustedGuardingDynamicLinkerExporter.java Mon Oct 17 15:32:44 2016 +0000 @@ -25,8 +25,8 @@ package jdk.dynalink.test; -import java.util.ArrayList; import java.util.List; +import jdk.dynalink.CallSiteDescriptor; import jdk.dynalink.linker.GuardingDynamicLinker; import jdk.dynalink.linker.GuardingDynamicLinkerExporter; import jdk.dynalink.linker.LinkRequest; @@ -37,20 +37,32 @@ */ public final class TrustedGuardingDynamicLinkerExporter extends GuardingDynamicLinkerExporter { + private static final ThreadLocal lastDescriptor = new ThreadLocal<>(); + private static boolean enabled = false; + + public static void enable() { + reset(true); + } + + public static void disable() { + reset(false); + } + public static boolean isLastCallSiteDescriptor(final CallSiteDescriptor desc) { + return lastDescriptor.get() == desc; + } + + private static void reset(final boolean enable) { + lastDescriptor.set(null); + enabled = enable; + } + @Override public List get() { - final ArrayList linkers = new ArrayList<>(); - linkers.add((GuardingDynamicLinker) (final LinkRequest linkRequest, final LinkerServices linkerServices) -> { - // handle only the TestLinkerOperation instances - if (linkRequest.getCallSiteDescriptor().getOperation() instanceof TestLinkerOperation) { - System.out.println("inside " + this.getClass().getName()); - // throw exception to signal to the test method that the control has reached here! - throw new ReachedAutoLoadedDynamicLinkerException(); - } else { - // any other operation! - return null; + return List.of(((GuardingDynamicLinker) (final LinkRequest linkRequest, final LinkerServices linkerServices) -> { + if (enabled) { + lastDescriptor.set(linkRequest.getCallSiteDescriptor()); } - }); - return linkers; + return null; + })); } }