diff --git a/.hgtags b/.hgtags index 9aa30d0ce28..15d336e4c5c 100644 --- a/.hgtags +++ b/.hgtags @@ -641,9 +641,8 @@ dd5198db2e5b1ebcafe065d987c03ba9fcb50fc3 jdk-15+17 7223c6d610343fd8323af9d07d501e01fa1a7696 jdk-15+22 f143729ca00ec14a98ea5c7f73acba88da97746e jdk-15+23 497fd9f9129c4928fd5a876dd55e0daf6298b511 jdk-15+24 -58833044988772ca06c97ab2f142474a8627af80 jdk-15+25 -58833044988772ca06c97ab2f142474a8627af80 jdk-15+25 90b266a84c06f1b3dc0ed8767856793e8c1c357e jdk-15+25 0a32396f7a690015d22ca3328ac441a358295d90 jdk-15+26 -506abc554caeb275928c02bf3a16e95d1978749f jdk-15+27 93813843680bbe1b7efbca56c03fd137f20a2c31 jdk-16+0 +93813843680bbe1b7efbca56c03fd137f20a2c31 jdk-15+27 +4a485c89d5a08b495961835f5308a96038678aeb jdk-16+1 diff --git a/make/Main.gmk b/make/Main.gmk index 99fc816edf3..3e5450ca3c1 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -640,6 +640,18 @@ $(eval $(call SetupTarget, test-image-jdk-jtreg-native, \ DEPS := build-test-jdk-jtreg-native, \ )) +$(eval $(call SetupTarget, build-test-libtest-jtreg-native, \ + MAKEFILE := test/JtregNativeLibTest, \ + TARGET := build-test-libtest-jtreg-native, \ + DEPS := buildtools-jdk, \ +)) + +$(eval $(call SetupTarget, test-image-libtest-jtreg-native, \ + MAKEFILE := test/JtregNativeLibTest, \ + TARGET := test-image-libtest-jtreg-native, \ + DEPS := build-test-libtest-jtreg-native, \ +)) + $(eval $(call SetupTarget, build-test-hotspot-jtreg-graal, \ MAKEFILE := test/JtregGraalUnit, \ TARGET := build-test-hotspot-jtreg-graal, \ @@ -982,6 +994,7 @@ else interim-image: $(INTERIM_JMOD_TARGETS) build-test-hotspot-jtreg-native: hotspot-$(JVM_VARIANT_MAIN)-libs + build-test-libtest-jtreg-native: hotspot-$(JVM_VARIANT_MAIN)-libs endif @@ -1105,7 +1118,7 @@ endif docs-image: docs-jdk # This target builds the test image -test-image: prepare-test-image test-image-jdk-jtreg-native test-image-demos-jdk +test-image: prepare-test-image test-image-jdk-jtreg-native test-image-demos-jdk test-image-libtest-jtreg-native ifneq ($(JVM_TEST_IMAGE_TARGETS), ) # If JVM_TEST_IMAGE_TARGETS is externally defined, use it instead of the diff --git a/make/RunTests.gmk b/make/RunTests.gmk index 805de4dd785..98df3be6e65 100644 --- a/make/RunTests.gmk +++ b/make/RunTests.gmk @@ -342,11 +342,13 @@ hotspot_JTREG_MAX_MEM := 0 hotspot_JTREG_ASSERT := false hotspot_JTREG_NATIVEPATH := $(TEST_IMAGE_DIR)/hotspot/jtreg/native jdk_JTREG_NATIVEPATH := $(TEST_IMAGE_DIR)/jdk/jtreg/native +lib-test_JTREG_NATIVEPATH := $(TEST_IMAGE_DIR)/lib-test/jtreg/native jdk_JTREG_PROBLEM_LIST += $(TOPDIR)/test/jdk/ProblemList.txt jaxp_JTREG_PROBLEM_LIST += $(TOPDIR)/test/jaxp/ProblemList.txt langtools_JTREG_PROBLEM_LIST += $(TOPDIR)/test/langtools/ProblemList.txt hotspot_JTREG_PROBLEM_LIST += $(TOPDIR)/test/hotspot/jtreg/ProblemList.txt +lib-test_JTREG_PROBLEM_LIST += $(TOPDIR)/test/lib-test/ProblemList.txt langtools_JTREG_MAX_MEM := 768m diff --git a/make/autoconf/flags-ldflags.m4 b/make/autoconf/flags-ldflags.m4 index a7c0f2fe799..a2a52f98ef7 100644 --- a/make/autoconf/flags-ldflags.m4 +++ b/make/autoconf/flags-ldflags.m4 @@ -62,17 +62,10 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER], [ # Setup basic LDFLAGS if test "x$TOOLCHAIN_TYPE" = xgcc; then - # If this is a --hash-style=gnu system, use --hash-style=both, why? - # We have previously set HAS_GNU_HASH if this is the case - if test -n "$HAS_GNU_HASH"; then - BASIC_LDFLAGS="-Wl,--hash-style=both" - LIBJSIG_HASHSTYLE_LDFLAGS="-Wl,--hash-style=both" - fi - # Add -z,defs, to forbid undefined symbols in object files. # add -z,relro (mark relocations read only) for all libs # add -z,now ("full relro" - more of the Global Offset Table GOT is marked read only) - BASIC_LDFLAGS="$BASIC_LDFLAGS -Wl,-z,defs -Wl,-z,relro -Wl,-z,now" + BASIC_LDFLAGS="-Wl,--hash-style=gnu -Wl,-z,defs -Wl,-z,relro -Wl,-z,now" # Linux : remove unused code+data in link step if test "x$ENABLE_LINKTIME_GC" = xtrue; then if test "x$OPENJDK_TARGET_CPU" = xs390x; then @@ -152,8 +145,6 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER], # Export some intermediate variables for compatibility LDFLAGS_CXX_JDK="$BASIC_LDFLAGS_ONLYCXX $BASIC_LDFLAGS_ONLYCXX_JDK_ONLY $DEBUGLEVEL_LDFLAGS_JDK_ONLY" AC_SUBST(LDFLAGS_CXX_JDK) - AC_SUBST(LIBJSIG_HASHSTYLE_LDFLAGS) - AC_SUBST(LIBJSIG_NOEXECSTACK_LDFLAGS) ]) ################################################################################ diff --git a/make/autoconf/jdk-version.m4 b/make/autoconf/jdk-version.m4 index df20f122c21..15446c1343c 100644 --- a/make/autoconf/jdk-version.m4 +++ b/make/autoconf/jdk-version.m4 @@ -179,7 +179,7 @@ AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS], AC_MSG_ERROR([--with-version-string must have a value]) elif test "x$with_version_string" != x; then # Additional [] needed to keep m4 from mangling shell constructs. - if [ [[ $with_version_string =~ ^([0-9]+)(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?(-([a-zA-Z]+))?((\+)([0-9]+)?(-([-a-zA-Z0-9.]+))?)?$ ]] ]; then + if [ [[ $with_version_string =~ ^([0-9]+)(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?(\.([0-9]+))?(-([a-zA-Z0-9]+))?(((\+)([0-9]*))?(-([-a-zA-Z0-9.]+))?)?$ ]] ]; then VERSION_FEATURE=${BASH_REMATCH[[1]]} VERSION_INTERIM=${BASH_REMATCH[[3]]} VERSION_UPDATE=${BASH_REMATCH[[5]]} @@ -188,9 +188,9 @@ AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS], VERSION_EXTRA2=${BASH_REMATCH[[11]]} VERSION_EXTRA3=${BASH_REMATCH[[13]]} VERSION_PRE=${BASH_REMATCH[[15]]} - version_plus_separator=${BASH_REMATCH[[17]]} - VERSION_BUILD=${BASH_REMATCH[[18]]} - VERSION_OPT=${BASH_REMATCH[[20]]} + version_plus_separator=${BASH_REMATCH[[18]]} + VERSION_BUILD=${BASH_REMATCH[[19]]} + VERSION_OPT=${BASH_REMATCH[[21]]} # Unspecified numerical fields are interpreted as 0. if test "x$VERSION_INTERIM" = x; then VERSION_INTERIM=0 @@ -233,8 +233,8 @@ AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS], # Interpret --without-* as empty string instead of the literal "no" VERSION_PRE= else - # Only [a-zA-Z] is allowed in the VERSION_PRE. Outer [ ] to quote m4. - [ VERSION_PRE=`$ECHO "$with_version_pre" | $TR -c -d '[a-z][A-Z]'` ] + # Only [a-zA-Z0-9] is allowed in the VERSION_PRE. Outer [ ] to quote m4. + [ VERSION_PRE=`$ECHO "$with_version_pre" | $TR -c -d '[a-zA-Z0-9]'` ] if test "x$VERSION_PRE" != "x$with_version_pre"; then AC_MSG_WARN([--with-version-pre value has been sanitized from '$with_version_pre' to '$VERSION_PRE']) fi diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in index 7b7cf98f157..380caeebd88 100644 --- a/make/autoconf/spec.gmk.in +++ b/make/autoconf/spec.gmk.in @@ -489,9 +489,6 @@ CXXFLAGS_JDKLIB:=@CXXFLAGS_JDKLIB@ CFLAGS_JDKEXE:=@CFLAGS_JDKEXE@ CXXFLAGS_JDKEXE:=@CXXFLAGS_JDKEXE@ -LIBJSIG_HASHSTYLE_LDFLAGS := @LIBJSIG_HASHSTYLE_LDFLAGS@ -LIBJSIG_NOEXECSTACK_LDFLAGS := @LIBJSIG_NOEXECSTACK_LDFLAGS@ - FDLIBM_CFLAGS := @FDLIBM_CFLAGS@ JVM_CFLAGS := @JVM_CFLAGS@ JVM_LDFLAGS := @JVM_LDFLAGS@ diff --git a/make/autoconf/toolchain.m4 b/make/autoconf/toolchain.m4 index a51757cb2ac..420cb23e815 100644 --- a/make/autoconf/toolchain.m4 +++ b/make/autoconf/toolchain.m4 @@ -972,12 +972,6 @@ AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS], fi fi - if test "x$TOOLCHAIN_TYPE" = xgcc; then - # If this is a --hash-style=gnu system, use --hash-style=both, why? - HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'` - # This is later checked when setting flags. - fi - if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then # Check if linker has -z noexecstack. HAS_NOEXECSTACK=`$CC -Wl,--help 2>/dev/null | $GREP 'z noexecstack'` @@ -1005,8 +999,27 @@ AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG], AC_MSG_CHECKING([for jtreg test harness]) AC_MSG_RESULT([no, disabled]) elif test "x$with_jtreg" != xyes && test "x$with_jtreg" != x; then - # An explicit path is specified, use it. - JT_HOME="$with_jtreg" + if test -d "$with_jtreg"; then + # An explicit path is specified, use it. + JT_HOME="$with_jtreg" + else + case "$with_jtreg" in + *.zip ) + JTREG_SUPPORT_DIR=$CONFIGURESUPPORT_OUTPUTDIR/jtreg + $RM -rf $JTREG_SUPPORT_DIR + $MKDIR -p $JTREG_SUPPORT_DIR + $UNZIP -qq -d $JTREG_SUPPORT_DIR $with_jtreg + + # Try to find jtreg to determine JT_HOME path + JTREG_PATH=`$FIND $JTREG_SUPPORT_DIR | $GREP "/bin/jtreg"` + if test "x$JTREG_PATH" != x; then + JT_HOME=$($DIRNAME $($DIRNAME $JTREG_PATH)) + fi + ;; + * ) + ;; + esac + fi UTIL_FIXUP_PATH([JT_HOME]) if test ! -d "$JT_HOME"; then AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg does not exist]) diff --git a/make/autoconf/version-numbers b/make/autoconf/version-numbers index 81874ad65f1..71bf25363b3 100644 --- a/make/autoconf/version-numbers +++ b/make/autoconf/version-numbers @@ -38,7 +38,7 @@ DEFAULT_VERSION_CLASSFILE_MAJOR=60 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`" DEFAULT_VERSION_CLASSFILE_MINOR=0 DEFAULT_ACCEPTABLE_BOOT_VERSIONS="14 15 16" DEFAULT_JDK_SOURCE_TARGET_VERSION=16 -DEFAULT_PROMOTED_VERSION_PRE=ea +DEFAULT_PROMOTED_VERSION_PRE=lworld3ea LAUNCHER_NAME=openjdk PRODUCT_NAME=OpenJDK diff --git a/make/common/FindTests.gmk b/make/common/FindTests.gmk index a823125de03..b12630349c0 100644 --- a/make/common/FindTests.gmk +++ b/make/common/FindTests.gmk @@ -43,7 +43,7 @@ $(eval $(call IncludeCustomExtension, common/FindTests.gmk)) TEST_BASEDIRS += $(TOPDIR)/test $(TOPDIR) # JTREG_TESTROOTS might have been set by a custom extension -JTREG_TESTROOTS += $(addprefix $(TOPDIR)/test/, hotspot/jtreg jdk langtools jaxp) +JTREG_TESTROOTS += $(addprefix $(TOPDIR)/test/, hotspot/jtreg jdk langtools jaxp lib-test) # Extract the names of the Jtreg group files from the TEST.ROOT files. The # TEST.ROOT files being properties files can be interpreted as makefiles so diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js index a5b947de98f..1097a0aeffe 100644 --- a/make/conf/jib-profiles.js +++ b/make/conf/jib-profiles.js @@ -1347,7 +1347,7 @@ var versionArgs = function(input, common) { args = concat(args, "--with-version-pre=" + preString, "--with-version-opt=" + optString); } else { - args = concat(args, "--with-version-pre=lworld2ea"); + args = concat(args, "--with-version-pre=" + version_numbers.get("DEFAULT_PROMOTED_VERSION_PRE")); args = concat(args, "--with-version-opt=" + common.build_id); } return args; diff --git a/make/hotspot/lib/JvmOverrideFiles.gmk b/make/hotspot/lib/JvmOverrideFiles.gmk index f606c99c812..4a89cd15157 100644 --- a/make/hotspot/lib/JvmOverrideFiles.gmk +++ b/make/hotspot/lib/JvmOverrideFiles.gmk @@ -62,6 +62,7 @@ ifeq ($(call isTargetOs, linux), true) JVM_PRECOMPILED_HEADER_EXCLUDE := \ sharedRuntimeTrig.cpp \ sharedRuntimeTrans.cpp \ + $(OPT_SPEED_SRC) \ # endif @@ -111,6 +112,7 @@ else ifeq ($(call isTargetOs, macosx), true) loopTransform.cpp \ unsafe.cpp \ jvmciCompilerToVM.cpp \ + $(OPT_SPEED_SRC) \ # endif diff --git a/make/test/JtregNativeHotspot.gmk b/make/test/JtregNativeHotspot.gmk index 5c58a042a2e..cfddb6fe0d9 100644 --- a/make/test/JtregNativeHotspot.gmk +++ b/make/test/JtregNativeHotspot.gmk @@ -872,10 +872,8 @@ BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exesigtest := -ljvm ifeq ($(call isTargetOs, windows), true) BUILD_HOTSPOT_JTREG_EXECUTABLES_CFLAGS_exeFPRegs := -MT BUILD_HOTSPOT_JTREG_EXCLUDE += exesigtest.c libterminatedThread.c - BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exejvm-test-launcher := jvm.lib BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libatExit := jvm.lib else - BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exejvm-test-launcher := -ljvm BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libbootclssearch_agent += -lpthread BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libsystemclssearch_agent += -lpthread BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libgetsysprop001 += -lpthread diff --git a/make/test/JtregNativeLibTest.gmk b/make/test/JtregNativeLibTest.gmk new file mode 100644 index 00000000000..4bae9d9189c --- /dev/null +++ b/make/test/JtregNativeLibTest.gmk @@ -0,0 +1,94 @@ +# +# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +################################################################################ +# This file builds the native component of the JTReg tests for testlibrary. +# It also covers the test-image part, where the built files are copied to the +# test image. +################################################################################ + +default: all + +include $(SPEC) +include MakeBase.gmk +include TestFilesCompilation.gmk + +$(eval $(call IncludeCustomExtension, test/JtregNativeLibTest.gmk)) + +################################################################################ +# Targets for building the native tests themselves. +################################################################################ + +# This might have been added to by a custom extension. +BUILD_LIBTEST_JTREG_NATIVE_SRC += $(TOPDIR)/test/lib-test + +BUILD_LIBTEST_JTREG_OUTPUT_DIR := $(OUTPUTDIR)/support/test/lib-test/jtreg/native + +BUILD_LIBTEST_JTREG_IMAGE_DIR := $(TEST_IMAGE_DIR)/lib-test/jtreg + +ifeq ($(call isTargetOs, windows), true) + BUILD_LIBTEST_JTREG_EXECUTABLES_LIBS_exejvm-test-launcher := jvm.lib +else + BUILD_LIBTEST_JTREG_EXECUTABLES_LIBS_exejvm-test-launcher := -ljvm +endif + +# This evaluation is expensive and should only be done if this target was +# explicitly called. +ifneq ($(filter build-test-libtest-jtreg-native, $(MAKECMDGOALS)), ) + $(eval $(call SetupTestFilesCompilation, BUILD_LIBTEST_JTREG_LIBRARIES, \ + TYPE := LIBRARY, \ + SOURCE_DIRS := $(BUILD_LIBTEST_JTREG_NATIVE_SRC), \ + OUTPUT_DIR := $(BUILD_LIBTEST_JTREG_OUTPUT_DIR), \ + EXCLUDE := $(BUILD_LIBTEST_JTREG_EXCLUDE), \ + )) + + $(eval $(call SetupTestFilesCompilation, BUILD_LIBTEST_JTREG_EXECUTABLES, \ + TYPE := PROGRAM, \ + SOURCE_DIRS := $(BUILD_LIBTEST_JTREG_NATIVE_SRC), \ + OUTPUT_DIR := $(BUILD_LIBTEST_JTREG_OUTPUT_DIR), \ + EXCLUDE := $(BUILD_LIBTEST_JTREG_EXCLUDE), \ + )) +endif + +build-test-libtest-jtreg-native: $(BUILD_LIBTEST_JTREG_LIBRARIES) $(BUILD_LIBTEST_JTREG_EXECUTABLES) + +################################################################################ +# Targets for building test-image. +################################################################################ + +# Copy to lib-test jtreg test image +$(eval $(call SetupCopyFiles, COPY_LIBTEST_JTREG_NATIVE, \ + SRC := $(BUILD_LIBTEST_JTREG_OUTPUT_DIR), \ + DEST := $(TEST_IMAGE_DIR)/lib-test/jtreg/native, \ + FILES := $(wildcard $(addprefix $(BUILD_LIBTEST_JTREG_OUTPUT_DIR), /bin/* /lib/*)), \ + FLATTEN := true, \ +)) + +test-image-libtest-jtreg-native: $(COPY_LIBTEST_JTREG_NATIVE) + +all: build-test-libtest-jtreg-native +test-image: test-image-libtest-jtreg-native + +.PHONY: default all build-test-libtest-jtreg-native test-image-libtest-jtreg-native test-image diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index 9c3739bf3d5..921d62c1b8a 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -1335,7 +1335,7 @@ void MacroAssembler::verify_oop(Register reg, const char* s) { stp(rscratch2, lr, Address(pre(sp, -2 * wordSize))); mov(r0, reg); - mov(rscratch1, (address)b); + movptr(rscratch1, (uintptr_t)(address)b); // call indirectly to solve generation ordering problem lea(rscratch2, ExternalAddress(StubRoutines::verify_oop_subroutine_entry_address())); @@ -1375,7 +1375,7 @@ void MacroAssembler::verify_oop_addr(Address addr, const char* s) { } else { ldr(r0, addr); } - mov(rscratch1, (address)b); + movptr(rscratch1, (uintptr_t)(address)b); // call indirectly to solve generation ordering problem lea(rscratch2, ExternalAddress(StubRoutines::verify_oop_subroutine_entry_address())); diff --git a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp index 3e940d5e847..4d45ce2f520 100644 --- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp @@ -1405,13 +1405,11 @@ class ComputeMoveOrder: public StackObj { }; -static void rt_call(MacroAssembler* masm, address dest, int gpargs, int fpargs, int type) { +static void rt_call(MacroAssembler* masm, address dest) { CodeBlob *cb = CodeCache::find_blob(dest); if (cb) { __ far_call(RuntimeAddress(dest)); } else { - assert((unsigned)gpargs < 256, "eek!"); - assert((unsigned)fpargs < 32, "eek!"); __ lea(rscratch1, RuntimeAddress(dest)); __ blr(rscratch1); __ maybe_isb(); @@ -2080,34 +2078,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, __ lea(rscratch2, Address(rthread, JavaThread::thread_state_offset())); __ stlrw(rscratch1, rscratch2); - { - int return_type = 0; - switch (ret_type) { - case T_VOID: break; - return_type = 0; break; - case T_CHAR: - case T_BYTE: - case T_SHORT: - case T_INT: - case T_BOOLEAN: - case T_LONG: - return_type = 1; break; - case T_ARRAY: - case T_VALUETYPE: - case T_OBJECT: - return_type = 1; break; - case T_FLOAT: - return_type = 2; break; - case T_DOUBLE: - return_type = 3; break; - default: - ShouldNotReachHere(); - } - rt_call(masm, native_func, - int_args + 2, // AArch64 passes up to 8 args in int registers - float_args, // and up to 8 float args - return_type); - } + rt_call(masm, native_func); __ bind(native_return); @@ -2318,7 +2289,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, __ ldr(r19, Address(rthread, in_bytes(Thread::pending_exception_offset()))); __ str(zr, Address(rthread, in_bytes(Thread::pending_exception_offset()))); - rt_call(masm, CAST_FROM_FN_PTR(address, SharedRuntime::complete_monitor_unlocking_C), 3, 0, 1); + rt_call(masm, CAST_FROM_FN_PTR(address, SharedRuntime::complete_monitor_unlocking_C)); #ifdef ASSERT { @@ -2345,7 +2316,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, __ bind(reguard); save_native_result(masm, ret_type, stack_slots); - rt_call(masm, CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages), 0, 0, 0); + rt_call(masm, CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages)); restore_native_result(masm, ret_type, stack_slots); // and continue __ b(reguard_done); diff --git a/src/hotspot/os/bsd/globals_bsd.hpp b/src/hotspot/os/bsd/globals_bsd.hpp index 76720ebc9cc..344a04d63c3 100644 --- a/src/hotspot/os/bsd/globals_bsd.hpp +++ b/src/hotspot/os/bsd/globals_bsd.hpp @@ -36,15 +36,7 @@ diagnostic_pd, \ notproduct, \ range, \ - constraint) \ - \ - product(bool, UseOprofile, false, \ - "enable support for Oprofile profiler") \ - \ - /* NB: The default value of UseBsdPosixThreadCPUClocks may be */ \ - /* overridden in Arguments::parse_each_vm_init_arg. */ \ - product(bool, UseBsdPosixThreadCPUClocks, true, \ - "enable fast Bsd Posix clocks where available") \ + constraint) // // Defines Bsd-specific default values. The flags are available on all diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp index 148512a7bd4..84e1e0ca465 100644 --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -1879,42 +1879,6 @@ int os::vm_allocation_granularity() { return os::Bsd::page_size(); } -// Rationale behind this function: -// current (Mon Apr 25 20:12:18 MSD 2005) oprofile drops samples without executable -// mapping for address (see lookup_dcookie() in the kernel module), thus we cannot get -// samples for JITted code. Here we create private executable mapping over the code cache -// and then we can use standard (well, almost, as mapping can change) way to provide -// info for the reporting script by storing timestamp and location of symbol -void bsd_wrap_code(char* base, size_t size) { - static volatile jint cnt = 0; - - if (!UseOprofile) { - return; - } - - char buf[PATH_MAX + 1]; - int num = Atomic::add(&cnt, 1); - - snprintf(buf, PATH_MAX + 1, "%s/hs-vm-%d-%d", - os::get_temp_directory(), os::current_process_id(), num); - unlink(buf); - - int fd = ::open(buf, O_CREAT | O_RDWR, S_IRWXU); - - if (fd != -1) { - off_t rv = ::lseek(fd, size-2, SEEK_SET); - if (rv != (off_t)-1) { - if (::write(fd, "", 1) == 1) { - mmap(base, size, - PROT_READ|PROT_WRITE|PROT_EXEC, - MAP_PRIVATE|MAP_FIXED|MAP_NORESERVE, fd, 0); - } - } - ::close(fd); - unlink(buf); - } -} - static void warn_fail_commit_memory(char* addr, size_t size, bool exec, int err) { warning("INFO: os::commit_memory(" INTPTR_FORMAT ", " SIZE_FORMAT diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index ce8cf9b780a..6176d6faa18 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -3251,10 +3251,10 @@ bool os::Linux::libnuma_init() { set_numa_interleave_bitmask(_numa_get_interleave_mask()); set_numa_membind_bitmask(_numa_get_membind()); // Create an index -> node mapping, since nodes are not always consecutive - _nindex_to_node = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(0, true); + _nindex_to_node = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(0, mtInternal); rebuild_nindex_to_node_map(); // Create a cpu -> node mapping - _cpu_to_node = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(0, true); + _cpu_to_node = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(0, mtInternal); rebuild_cpu_to_node_map(); return true; } diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index a340b62918c..be2ea26ddcf 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -71,18 +71,15 @@ #include "utilities/decoder.hpp" #include "utilities/defaultStream.hpp" #include "utilities/events.hpp" -#include "utilities/growableArray.hpp" #include "utilities/macros.hpp" #include "utilities/vmError.hpp" #include "symbolengine.hpp" #include "windbghelp.hpp" - #ifdef _DEBUG #include #endif - #include #include #include diff --git a/src/hotspot/share/aot/aotLoader.cpp b/src/hotspot/share/aot/aotLoader.cpp index 63640e2080c..cd9ca7dea2f 100644 --- a/src/hotspot/share/aot/aotLoader.cpp +++ b/src/hotspot/share/aot/aotLoader.cpp @@ -34,8 +34,8 @@ #include "runtime/os.inline.hpp" #include "runtime/timerTrace.hpp" -GrowableArray* AOTLoader::_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray (2, true); -GrowableArray* AOTLoader::_libraries = new(ResourceObj::C_HEAP, mtCode) GrowableArray (2, true); +GrowableArray* AOTLoader::_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray (2, mtCode); +GrowableArray* AOTLoader::_libraries = new(ResourceObj::C_HEAP, mtCode) GrowableArray (2, mtCode); // Iterate over all AOT CodeHeaps #define FOR_ALL_AOT_HEAPS(heap) for (GrowableArrayIterator heap = heaps()->begin(); heap != heaps()->end(); ++heap) diff --git a/src/hotspot/share/ci/ciTypeFlow.cpp b/src/hotspot/share/ci/ciTypeFlow.cpp index e6748773fff..dcd95bfded3 100644 --- a/src/hotspot/share/ci/ciTypeFlow.cpp +++ b/src/hotspot/share/ci/ciTypeFlow.cpp @@ -62,7 +62,7 @@ ciTypeFlow::JsrSet::JsrSet(Arena* arena, int default_len) { _set = new (arena) GrowableArray(arena, default_len, 0, NULL); } else { // Allocate growable array in current ResourceArea. - _set = new GrowableArray(4, 0, NULL, false); + _set = new GrowableArray(4, 0, NULL); } } diff --git a/src/hotspot/share/classfile/classListParser.cpp b/src/hotspot/share/classfile/classListParser.cpp index 047ee1032f0..3d10d1e59ad 100644 --- a/src/hotspot/share/classfile/classListParser.cpp +++ b/src/hotspot/share/classfile/classListParser.cpp @@ -63,7 +63,7 @@ ClassListParser::ClassListParser(const char* file) { vm_exit_during_initialization("Loading classlist failed", errmsg); } _line_no = 0; - _interfaces = new (ResourceObj::C_HEAP, mtClass) GrowableArray(10, true); + _interfaces = new (ResourceObj::C_HEAP, mtClass) GrowableArray(10, mtClass); } ClassListParser::~ClassListParser() { diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp index f7613012cd7..b542649937c 100644 --- a/src/hotspot/share/classfile/classLoader.cpp +++ b/src/hotspot/share/classfile/classLoader.cpp @@ -583,7 +583,7 @@ void ClassLoader::setup_patch_mod_entries() { int num_of_entries = patch_mod_args->length(); // Set up the boot loader's _patch_mod_entries list - _patch_mod_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray(num_of_entries, true); + _patch_mod_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray(num_of_entries, mtModule); for (int i = 0; i < num_of_entries; i++) { const char* module_name = (patch_mod_args->at(i))->module_name(); @@ -1609,7 +1609,7 @@ void ClassLoader::classLoader_init2(TRAPS) { // subsequently do the first class load. So, no lock is needed for this. assert(_exploded_entries == NULL, "Should only get initialized once"); _exploded_entries = new (ResourceObj::C_HEAP, mtModule) - GrowableArray(EXPLODED_ENTRY_SIZE, true); + GrowableArray(EXPLODED_ENTRY_SIZE, mtModule); add_to_exploded_build_list(vmSymbols::java_base(), CHECK); } } diff --git a/src/hotspot/share/classfile/classLoaderData.cpp b/src/hotspot/share/classfile/classLoaderData.cpp index d953da758c6..8eed69e71a3 100644 --- a/src/hotspot/share/classfile/classLoaderData.cpp +++ b/src/hotspot/share/classfile/classLoaderData.cpp @@ -817,7 +817,7 @@ void ClassLoaderData::add_to_deallocate_list(Metadata* m) { if (!m->is_shared()) { MutexLocker ml(metaspace_lock(), Mutex::_no_safepoint_check_flag); if (_deallocate_list == NULL) { - _deallocate_list = new (ResourceObj::C_HEAP, mtClass) GrowableArray(100, true); + _deallocate_list = new (ResourceObj::C_HEAP, mtClass) GrowableArray(100, mtClass); } _deallocate_list->append_if_missing(m); log_debug(class, loader, data)("deallocate added for %s", m->print_value_string()); diff --git a/src/hotspot/share/classfile/classLoaderExt.cpp b/src/hotspot/share/classfile/classLoaderExt.cpp index 701c155da19..6a328a00f26 100644 --- a/src/hotspot/share/classfile/classLoaderExt.cpp +++ b/src/hotspot/share/classfile/classLoaderExt.cpp @@ -310,7 +310,7 @@ ClassPathEntry* ClassLoaderExt::find_classpath_entry_from_cache(const char* path // This is called from dump time so it's single threaded and there's no need for a lock. assert(DumpSharedSpaces, "this function is only used with -Xshare:dump"); if (cached_path_entries == NULL) { - cached_path_entries = new (ResourceObj::C_HEAP, mtClass) GrowableArray(20, /*c heap*/ true); + cached_path_entries = new (ResourceObj::C_HEAP, mtClass) GrowableArray(20, mtClass); } CachedClassPathEntry ccpe; for (int i=0; ilength(); i++) { diff --git a/src/hotspot/share/classfile/compactHashtable.cpp b/src/hotspot/share/classfile/compactHashtable.cpp index 13ad65f33e8..07de0deb60d 100644 --- a/src/hotspot/share/classfile/compactHashtable.cpp +++ b/src/hotspot/share/classfile/compactHashtable.cpp @@ -51,7 +51,7 @@ CompactHashtableWriter::CompactHashtableWriter(int num_entries, _num_entries_written = 0; _buckets = NEW_C_HEAP_ARRAY(GrowableArray*, _num_buckets, mtSymbol); for (int i=0; i<_num_buckets; i++) { - _buckets[i] = new (ResourceObj::C_HEAP, mtSymbol) GrowableArray(0, true, mtSymbol); + _buckets[i] = new (ResourceObj::C_HEAP, mtSymbol) GrowableArray(0, mtSymbol); } _stats = stats; diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp index 16d20ce11ac..d00ea3f66f3 100644 --- a/src/hotspot/share/classfile/javaClasses.cpp +++ b/src/hotspot/share/classfile/javaClasses.cpp @@ -969,11 +969,11 @@ void java_lang_Class::set_mirror_module_field(Klass* k, Handle mirror, Handle mo // Statically allocate fixup lists because they always get created. void java_lang_Class::allocate_fixup_lists() { GrowableArray* mirror_list = - new (ResourceObj::C_HEAP, mtClass) GrowableArray(40, true); + new (ResourceObj::C_HEAP, mtClass) GrowableArray(40, mtClass); set_fixup_mirror_list(mirror_list); GrowableArray* module_list = - new (ResourceObj::C_HEAP, mtModule) GrowableArray(500, true); + new (ResourceObj::C_HEAP, mtModule) GrowableArray(500, mtModule); set_fixup_module_field_list(module_list); } diff --git a/src/hotspot/share/classfile/moduleEntry.cpp b/src/hotspot/share/classfile/moduleEntry.cpp index e394acff3db..ac962fa3f01 100644 --- a/src/hotspot/share/classfile/moduleEntry.cpp +++ b/src/hotspot/share/classfile/moduleEntry.cpp @@ -161,7 +161,7 @@ void ModuleEntry::add_read(ModuleEntry* m) { } else { if (_reads == NULL) { // Lazily create a module's reads list - _reads = new (ResourceObj::C_HEAP, mtModule)GrowableArray(MODULE_READS_SIZE, true); + _reads = new (ResourceObj::C_HEAP, mtModule) GrowableArray(MODULE_READS_SIZE, mtModule); } // Determine, based on this newly established read edge to module m, diff --git a/src/hotspot/share/classfile/packageEntry.cpp b/src/hotspot/share/classfile/packageEntry.cpp index 1856c3aaacf..cae618eb375 100644 --- a/src/hotspot/share/classfile/packageEntry.cpp +++ b/src/hotspot/share/classfile/packageEntry.cpp @@ -53,7 +53,7 @@ void PackageEntry::add_qexport(ModuleEntry* m) { if (!has_qual_exports_list()) { // Lazily create a package's qualified exports list. // Initial size is small, do not anticipate export lists to be large. - _qualified_exports = new (ResourceObj::C_HEAP, mtModule) GrowableArray(QUAL_EXP_SIZE, true); + _qualified_exports = new (ResourceObj::C_HEAP, mtModule) GrowableArray(QUAL_EXP_SIZE, mtModule); } // Determine, based on this newly established export to module m, diff --git a/src/hotspot/share/classfile/stringTable.cpp b/src/hotspot/share/classfile/stringTable.cpp index 47c0c59ebef..98c21cdd11b 100644 --- a/src/hotspot/share/classfile/stringTable.cpp +++ b/src/hotspot/share/classfile/stringTable.cpp @@ -623,7 +623,7 @@ size_t StringTable::verify_and_compare_entries() { Thread* thr = Thread::current(); GrowableArray* oops = new (ResourceObj::C_HEAP, mtInternal) - GrowableArray((int)_current_size, true); + GrowableArray((int)_current_size, mtInternal); VerifyCompStrings vcs(oops); if (!_local_table->try_scan(thr, vcs)) { diff --git a/src/hotspot/share/classfile/systemDictionaryShared.cpp b/src/hotspot/share/classfile/systemDictionaryShared.cpp index 96c53e059a9..520e8e7f86e 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.cpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp @@ -325,7 +325,7 @@ class DumpTimeLambdaProxyClassInfo { DumpTimeLambdaProxyClassInfo() : _proxy_klasses(NULL) {} void add_proxy_klass(InstanceKlass* proxy_klass) { if (_proxy_klasses == NULL) { - _proxy_klasses = new (ResourceObj::C_HEAP, mtInternal)GrowableArray(5, true); + _proxy_klasses = new (ResourceObj::C_HEAP, mtClassShared)GrowableArray(5, mtClassShared); } assert(_proxy_klasses != NULL, "sanity"); _proxy_klasses->append(proxy_klass); @@ -1547,10 +1547,10 @@ bool SystemDictionaryShared::add_verification_constraint(InstanceKlass* k, Symbo void DumpTimeSharedClassInfo::add_verification_constraint(InstanceKlass* k, Symbol* name, Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object) { if (_verifier_constraints == NULL) { - _verifier_constraints = new(ResourceObj::C_HEAP, mtClass) GrowableArray(4, true, mtClass); + _verifier_constraints = new(ResourceObj::C_HEAP, mtClass) GrowableArray(4, mtClass); } if (_verifier_constraint_flags == NULL) { - _verifier_constraint_flags = new(ResourceObj::C_HEAP, mtClass) GrowableArray(4, true, mtClass); + _verifier_constraint_flags = new(ResourceObj::C_HEAP, mtClass) GrowableArray(4, mtClass); } GrowableArray* vc_array = _verifier_constraints; for (int i = 0; i < vc_array->length(); i++) { @@ -1730,7 +1730,7 @@ void DumpTimeSharedClassInfo::record_linking_constraint(Symbol* name, Handle loa assert(loader1 != loader2, "sanity"); LogTarget(Info, class, loader, constraints) log; if (_loader_constraints == NULL) { - _loader_constraints = new (ResourceObj::C_HEAP, mtClass) GrowableArray(4, true, mtClass); + _loader_constraints = new (ResourceObj::C_HEAP, mtClass) GrowableArray(4, mtClass); } char lt1 = get_loader_type_by(loader1()); char lt2 = get_loader_type_by(loader2()); diff --git a/src/hotspot/share/classfile/verifier.cpp b/src/hotspot/share/classfile/verifier.cpp index 17e47d67cd7..ff7a6a50258 100644 --- a/src/hotspot/share/classfile/verifier.cpp +++ b/src/hotspot/share/classfile/verifier.cpp @@ -135,8 +135,15 @@ void Verifier::trace_class_resolution(Klass* resolve_class, InstanceKlass* verif void Verifier::log_end_verification(outputStream* st, const char* klassName, Symbol* exception_name, TRAPS) { if (HAS_PENDING_EXCEPTION) { st->print("Verification for %s has", klassName); - st->print_cr(" exception pending %s ", + oop message = java_lang_Throwable::message(PENDING_EXCEPTION); + if (message != NULL) { + char* ex_msg = java_lang_String::as_utf8_string(message); + st->print_cr(" exception pending '%s %s'", + PENDING_EXCEPTION->klass()->external_name(), ex_msg); + } else { + st->print_cr(" exception pending %s ", PENDING_EXCEPTION->klass()->external_name()); + } } else if (exception_name != NULL) { st->print_cr("Verification for %s failed", klassName); } diff --git a/src/hotspot/share/classfile/vmSymbols.hpp b/src/hotspot/share/classfile/vmSymbols.hpp index c9bc4630f5e..ecdc76eb487 100644 --- a/src/hotspot/share/classfile/vmSymbols.hpp +++ b/src/hotspot/share/classfile/vmSymbols.hpp @@ -604,12 +604,6 @@ template(createGCNotification_name, "createGCNotification") \ template(createGCNotification_signature, "(JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/sun/management/GcInfo;)V") \ template(createDiagnosticFrameworkNotification_name, "createDiagnosticFrameworkNotification") \ - template(createMemoryPoolMBean_name, "createMemoryPoolMBean") \ - template(createMemoryManagerMBean_name, "createMemoryManagerMBean") \ - template(createGarbageCollectorMBean_name, "createGarbageCollectorMBean") \ - template(createMemoryPoolMBean_signature, "(Ljava/lang/String;ZJJ)Ljava/lang/management/MemoryPoolMBean;") \ - template(createMemoryManagerMBean_signature, "(Ljava/lang/String;)Ljava/lang/management/MemoryManagerMBean;") \ - template(createGarbageCollectorMBean_signature, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/management/GarbageCollectorMBean;") \ template(trigger_name, "trigger") \ template(clear_name, "clear") \ template(trigger_method_signature, "(ILjava/lang/management/MemoryUsage;)V") \ diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp index 403d9870a7a..b9a63dbd97f 100644 --- a/src/hotspot/share/code/codeCache.cpp +++ b/src/hotspot/share/code/codeCache.cpp @@ -150,10 +150,10 @@ int CodeCache::_number_of_nmethods_with_dependencies = 0; ExceptionCache* volatile CodeCache::_exception_cache_purge_list = NULL; // Initialize arrays of CodeHeap subsets -GrowableArray* CodeCache::_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray (CodeBlobType::All, true); -GrowableArray* CodeCache::_compiled_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray (CodeBlobType::All, true); -GrowableArray* CodeCache::_nmethod_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray (CodeBlobType::All, true); -GrowableArray* CodeCache::_allocable_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray (CodeBlobType::All, true); +GrowableArray* CodeCache::_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray (CodeBlobType::All, mtCode); +GrowableArray* CodeCache::_compiled_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray (CodeBlobType::All, mtCode); +GrowableArray* CodeCache::_nmethod_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray (CodeBlobType::All, mtCode); +GrowableArray* CodeCache::_allocable_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray (CodeBlobType::All, mtCode); void CodeCache::check_heap_sizes(size_t non_nmethod_size, size_t profiled_size, size_t non_profiled_size, size_t cache_size, bool all_set) { size_t total_size = non_nmethod_size + profiled_size + non_profiled_size; @@ -1043,7 +1043,7 @@ static GrowableArray* old_compiled_method_table = NULL; static void add_to_old_table(CompiledMethod* c) { if (old_compiled_method_table == NULL) { - old_compiled_method_table = new (ResourceObj::C_HEAP, mtCode) GrowableArray(100, true); + old_compiled_method_table = new (ResourceObj::C_HEAP, mtCode) GrowableArray(100, mtCode); } old_compiled_method_table->push(c); } diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp index af4a2395104..79e4683e8d0 100644 --- a/src/hotspot/share/compiler/compileBroker.cpp +++ b/src/hotspot/share/compiler/compileBroker.cpp @@ -687,7 +687,7 @@ void CompileBroker::compilation_init_phase1(Thread* THREAD) { // Start the compiler thread(s) and the sweeper thread init_compiler_sweeper_threads(); // totalTime performance counter is always created as it is required - // by the implementation of java.lang.management.CompilationMBean. + // by the implementation of java.lang.management.CompilationMXBean. { // Ensure OOM leads to vm_exit_during_initialization. EXCEPTION_MARK; @@ -2478,7 +2478,7 @@ void CompileBroker::collect_statistics(CompilerThread* thread, elapsedTimer time // Compilation succeeded // update compilation ticks - used by the implementation of - // java.lang.management.CompilationMBean + // java.lang.management.CompilationMXBean _perf_total_compilation->inc(time.ticks()); _peak_compilation_time = time.milliseconds() > _peak_compilation_time ? time.milliseconds() : _peak_compilation_time; diff --git a/src/hotspot/share/compiler/compilerDefinitions.cpp b/src/hotspot/share/compiler/compilerDefinitions.cpp index d09323a3da9..d7d2ca89cc0 100644 --- a/src/hotspot/share/compiler/compilerDefinitions.cpp +++ b/src/hotspot/share/compiler/compilerDefinitions.cpp @@ -507,8 +507,8 @@ void CompilerConfig::ergo_initialize() { if (!IncrementalInline) { AlwaysIncrementalInline = false; } - if (PrintIdealGraphLevel > 0) { - FLAG_SET_ERGO(PrintIdealGraph, true); + if (FLAG_IS_CMDLINE(PrintIdealGraph) && !PrintIdealGraph) { + FLAG_SET_ERGO(PrintIdealGraphLevel, -1); } #endif if (!UseTypeSpeculation && FLAG_IS_DEFAULT(TypeProfileLevel)) { diff --git a/src/hotspot/share/compiler/compilerEvent.cpp b/src/hotspot/share/compiler/compilerEvent.cpp index 062eceba72a..5aca2de2856 100644 --- a/src/hotspot/share/compiler/compilerEvent.cpp +++ b/src/hotspot/share/compiler/compilerEvent.cpp @@ -79,7 +79,7 @@ int CompilerEvent::PhaseEvent::register_phases(GrowableArray* new_p { PhaseTypeGuard guard; if (phase_names == NULL) { - phase_names = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(100, true); + phase_names = new (ResourceObj::C_HEAP, mtCompiler) GrowableArray(100, mtCompiler); register_jfr_serializer = true; } idx = phase_names->length(); diff --git a/src/hotspot/share/compiler/disassembler.cpp b/src/hotspot/share/compiler/disassembler.cpp index 71e53433c8b..5a9f94276c9 100644 --- a/src/hotspot/share/compiler/disassembler.cpp +++ b/src/hotspot/share/compiler/disassembler.cpp @@ -266,7 +266,7 @@ void decode_env::print_hook_comments(address pc, bool newline) { } _cached_src_lines->clear(); } else { - _cached_src_lines = new (ResourceObj::C_HEAP, mtCode)GrowableArray(0, true); + _cached_src_lines = new (ResourceObj::C_HEAP, mtCode)GrowableArray(0, mtCode); } if ((fp = fopen(file, "r")) == NULL) { diff --git a/src/hotspot/share/gc/g1/g1Allocator.hpp b/src/hotspot/share/gc/g1/g1Allocator.hpp index d4b675ea725..f0702b4d6c2 100644 --- a/src/hotspot/share/gc/g1/g1Allocator.hpp +++ b/src/hotspot/share/gc/g1/g1Allocator.hpp @@ -257,7 +257,7 @@ class G1ArchiveAllocator : public CHeapObj { _allocation_region(NULL), _allocated_regions((ResourceObj::set_allocation_type((address) &_allocated_regions, ResourceObj::C_HEAP), - 2), true /* C_Heap */), + 2), mtGC), _summary_bytes_used(0), _bottom(NULL), _top(NULL), diff --git a/src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp b/src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp index 269d14d8b73..a27f7e73ad9 100644 --- a/src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp +++ b/src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp @@ -32,7 +32,7 @@ G1FullGCCompactionPoint::G1FullGCCompactionPoint() : _current_region(NULL), _threshold(NULL), _compaction_top(NULL) { - _compaction_regions = new (ResourceObj::C_HEAP, mtGC) GrowableArray(32, true, mtGC); + _compaction_regions = new (ResourceObj::C_HEAP, mtGC) GrowableArray(32, mtGC); _compaction_region_iterator = _compaction_regions->begin(); } diff --git a/src/hotspot/share/gc/g1/g1HeapVerifier.cpp b/src/hotspot/share/gc/g1/g1HeapVerifier.cpp index c9a226aac4e..fc3330f2d85 100644 --- a/src/hotspot/share/gc/g1/g1HeapVerifier.cpp +++ b/src/hotspot/share/gc/g1/g1HeapVerifier.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2020, 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 @@ -326,7 +326,7 @@ void G1HeapVerifier::verify_ready_for_archiving() { if (cl.has_holes()) { log_warning(gc, verify)("All free regions should be at the top end of the heap, but" " we found holes. This is probably caused by (unmovable) humongous" - " allocations, and may lead to fragmentation while" + " allocations or active GCLocker, and may lead to fragmentation while" " writing archive heap memory regions."); } if (cl.has_humongous()) { @@ -334,7 +334,6 @@ void G1HeapVerifier::verify_ready_for_archiving() { " may lead to fragmentation while" " writing archive heap memory regions."); } - assert(!cl.has_unexpected_holes(), "all holes should have been caused by humongous regions"); } class VerifyArchivePointerRegionClosure: public HeapRegionClosure { diff --git a/src/hotspot/share/gc/g1/g1SurvivorRegions.cpp b/src/hotspot/share/gc/g1/g1SurvivorRegions.cpp index d58df707f1b..6448cfb0bd7 100644 --- a/src/hotspot/share/gc/g1/g1SurvivorRegions.cpp +++ b/src/hotspot/share/gc/g1/g1SurvivorRegions.cpp @@ -29,7 +29,7 @@ #include "utilities/debug.hpp" G1SurvivorRegions::G1SurvivorRegions() : - _regions(new (ResourceObj::C_HEAP, mtGC) GrowableArray(8, true, mtGC)), + _regions(new (ResourceObj::C_HEAP, mtGC) GrowableArray(8, mtGC)), _used_bytes(0), _regions_on_node() {} diff --git a/src/hotspot/share/gc/parallel/mutableNUMASpace.cpp b/src/hotspot/share/gc/parallel/mutableNUMASpace.cpp index d9bf09a79cb..d980b6b893b 100644 --- a/src/hotspot/share/gc/parallel/mutableNUMASpace.cpp +++ b/src/hotspot/share/gc/parallel/mutableNUMASpace.cpp @@ -34,7 +34,7 @@ #include "utilities/align.hpp" MutableNUMASpace::MutableNUMASpace(size_t alignment) : MutableSpace(alignment), _must_use_large_pages(false) { - _lgrp_spaces = new (ResourceObj::C_HEAP, mtGC) GrowableArray(0, true); + _lgrp_spaces = new (ResourceObj::C_HEAP, mtGC) GrowableArray(0, mtGC); _page_size = os::vm_page_size(); _adaptation_cycles = 0; _samples_count = 0; diff --git a/src/hotspot/share/gc/parallel/psCompactionManager.cpp b/src/hotspot/share/gc/parallel/psCompactionManager.cpp index c807bf8e796..b7be1cbd5ea 100644 --- a/src/hotspot/share/gc/parallel/psCompactionManager.cpp +++ b/src/hotspot/share/gc/parallel/psCompactionManager.cpp @@ -96,7 +96,7 @@ void ParCompactionManager::initialize(ParMarkBitMap* mbm) { assert(ParallelScavengeHeap::heap()->workers().total_workers() != 0, "Not initialized?"); - _shadow_region_array = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(10, true); + _shadow_region_array = new (ResourceObj::C_HEAP, mtGC) GrowableArray(10, mtGC); _shadow_region_monitor = new Monitor(Mutex::barrier, "CompactionManager monitor", Mutex::_allow_vm_block_flag, Monitor::_safepoint_check_never); diff --git a/src/hotspot/share/gc/shared/collectedHeap.cpp b/src/hotspot/share/gc/shared/collectedHeap.cpp index 25368631b58..f1a7a944edd 100644 --- a/src/hotspot/share/gc/shared/collectedHeap.cpp +++ b/src/hotspot/share/gc/shared/collectedHeap.cpp @@ -240,6 +240,7 @@ void CollectedHeap::collect_as_vm_thread(GCCause::Cause cause) { do_full_collection(false); // don't clear all soft refs break; } + case GCCause::_archive_time_gc: case GCCause::_metadata_GC_clear_soft_refs: { HandleMark hm; do_full_collection(true); // do clear all soft refs diff --git a/src/hotspot/share/gc/shared/gcTimer.cpp b/src/hotspot/share/gc/shared/gcTimer.cpp index 225a0fe7982..ca835e30ed3 100644 --- a/src/hotspot/share/gc/shared/gcTimer.cpp +++ b/src/hotspot/share/gc/shared/gcTimer.cpp @@ -113,7 +113,7 @@ GCPhase::PhaseType TimePartitions::current_phase_type() const { } TimePartitions::TimePartitions() { - _phases = new (ResourceObj::C_HEAP, mtGC) GrowableArray(INITIAL_CAPACITY, true, mtGC); + _phases = new (ResourceObj::C_HEAP, mtGC) GrowableArray(INITIAL_CAPACITY, mtGC); clear(); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp index 47584b80e49..2ff408ce0e8 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp @@ -53,6 +53,9 @@ ShenandoahControlThread::ShenandoahControlThread() : create_and_start(ShenandoahCriticalControlThreadPriority ? CriticalPriority : NearMaxPriority); _periodic_task.enroll(); _periodic_satb_flush_task.enroll(); + if (ShenandoahPacing) { + _periodic_pacer_notify_task.enroll(); + } } ShenandoahControlThread::~ShenandoahControlThread() { @@ -68,6 +71,11 @@ void ShenandoahPeriodicSATBFlushTask::task() { ShenandoahHeap::heap()->force_satb_flush_all_threads(); } +void ShenandoahPeriodicPacerNotify::task() { + assert(ShenandoahPacing, "Should not be here otherwise"); + ShenandoahHeap::heap()->pacer()->notify_waiters(); +} + void ShenandoahControlThread::run_service() { ShenandoahHeap* heap = ShenandoahHeap::heap(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp index 523a1eb9be4..d141f4085cf 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp @@ -52,6 +52,13 @@ class ShenandoahPeriodicSATBFlushTask : public PeriodicTask { virtual void task(); }; +// Periodic task to notify blocked paced waiters. +class ShenandoahPeriodicPacerNotify : public PeriodicTask { +public: + ShenandoahPeriodicPacerNotify() : PeriodicTask(PeriodicTask::min_interval) {} + virtual void task(); +}; + class ShenandoahControlThread: public ConcurrentGCThread { friend class VMStructs; @@ -70,6 +77,7 @@ class ShenandoahControlThread: public ConcurrentGCThread { Monitor _gc_waiters_lock; ShenandoahPeriodicTask _periodic_task; ShenandoahPeriodicSATBFlushTask _periodic_satb_flush_task; + ShenandoahPeriodicPacerNotify _periodic_pacer_notify_task; public: void run_service(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index 56a898895ab..5bca1cafe0c 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -1297,11 +1297,16 @@ void ShenandoahHeap::object_iterate(ObjectClosure* cl) { Stack oop_stack; - // First, we process GC roots according to current GC cycle. This populates the work stack with initial objects. - ShenandoahHeapIterationRootScanner rp; ObjectIterateScanRootClosure oops(&_aux_bit_map, &oop_stack); - rp.roots_do(&oops); + { + // First, we process GC roots according to current GC cycle. + // This populates the work stack with initial objects. + // It is important to relinquish the associated locks before diving + // into heap dumper. + ShenandoahHeapIterationRootScanner rp; + rp.roots_do(&oops); + } // Work through the oop stack to traverse heap. while (! oop_stack.is_empty()) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp b/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp index d14fcd8dcd3..351f4beab92 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp @@ -193,7 +193,7 @@ void ShenandoahPacer::restart_with(size_t non_taxable_bytes, double tax_rate) { Atomic::inc(&_epoch); // Shake up stalled waiters after budget update. - notify_waiters(); + _need_notify_waiters.try_set(); } bool ShenandoahPacer::claim_for_alloc(size_t words, bool force) { @@ -222,8 +222,8 @@ void ShenandoahPacer::unpace_for_alloc(intptr_t epoch, size_t words) { return; } - intptr_t tax = MAX2(1, words * Atomic::load(&_tax_rate)); - Atomic::add(&_budget, tax); + size_t tax = MAX2(1, words * Atomic::load(&_tax_rate)); + add_budget(tax); } intptr_t ShenandoahPacer::epoch() { @@ -278,17 +278,20 @@ void ShenandoahPacer::pace_for_alloc(size_t words) { } } -void ShenandoahPacer::wait(long time_ms) { +void ShenandoahPacer::wait(size_t time_ms) { // Perform timed wait. It works like like sleep(), except without modifying // the thread interruptible status. MonitorLocker also checks for safepoints. assert(time_ms > 0, "Should not call this with zero argument, as it would stall until notify"); + assert(time_ms <= LONG_MAX, "Sanity"); MonitorLocker locker(_wait_monitor); - _wait_monitor->wait(time_ms); + _wait_monitor->wait((long)time_ms); } void ShenandoahPacer::notify_waiters() { - MonitorLocker locker(_wait_monitor); - _wait_monitor->notify_all(); + if (_need_notify_waiters.try_unset()) { + MonitorLocker locker(_wait_monitor); + _wait_monitor->notify_all(); + } } void ShenandoahPacer::print_on(outputStream* out) const { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPacer.hpp b/src/hotspot/share/gc/shenandoah/shenandoahPacer.hpp index 9d77d2f6f0c..00a047b26e8 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahPacer.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahPacer.hpp @@ -46,6 +46,7 @@ class ShenandoahPacer : public CHeapObj { BinaryMagnitudeSeq _delays; TruncatedSeq* _progress_history; Monitor* _wait_monitor; + ShenandoahSharedFlag _need_notify_waiters; // Set once per phase volatile intptr_t _epoch; @@ -89,6 +90,8 @@ class ShenandoahPacer : public CHeapObj { void pace_for_alloc(size_t words); void unpace_for_alloc(intptr_t epoch, size_t words); + void notify_waiters(); + intptr_t epoch(); void print_on(outputStream* out) const; @@ -97,12 +100,12 @@ class ShenandoahPacer : public CHeapObj { inline void report_internal(size_t words); inline void report_progress_internal(size_t words); + inline void add_budget(size_t words); void restart_with(size_t non_taxable_bytes, double tax_rate); size_t update_and_get_progress_history(); - void wait(long time_ms); - void notify_waiters(); + void wait(size_t time_ms); }; #endif // SHARE_GC_SHENANDOAH_SHENANDOAHPACER_HPP diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPacer.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahPacer.inline.hpp index 6f000d88b90..c416d85234f 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahPacer.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahPacer.inline.hpp @@ -47,21 +47,26 @@ inline void ShenandoahPacer::report_alloc(size_t words) { inline void ShenandoahPacer::report_internal(size_t words) { assert(ShenandoahPacing, "Only be here when pacing is enabled"); + add_budget(words); +} + +inline void ShenandoahPacer::report_progress_internal(size_t words) { + assert(ShenandoahPacing, "Only be here when pacing is enabled"); + STATIC_ASSERT(sizeof(size_t) <= sizeof(intptr_t)); + Atomic::add(&_progress, (intptr_t)words); +} + +inline void ShenandoahPacer::add_budget(size_t words) { STATIC_ASSERT(sizeof(size_t) <= sizeof(intptr_t)); intptr_t inc = (intptr_t) words; intptr_t new_budget = Atomic::add(&_budget, inc); // Was the budget replenished beyond zero? Then all pacing claims - // are satisfied, notify the waiters. + // are satisfied, notify the waiters. Avoid taking any locks here, + // as it can be called from hot paths and/or while holding other locks. if (new_budget >= 0 && (new_budget - inc) < 0) { - notify_waiters(); + _need_notify_waiters.try_set(); } } -inline void ShenandoahPacer::report_progress_internal(size_t words) { - assert(ShenandoahPacing, "Only be here when pacing is enabled"); - STATIC_ASSERT(sizeof(size_t) <= sizeof(intptr_t)); - Atomic::add(&_progress, (intptr_t)words); -} - #endif // SHARE_GC_SHENANDOAH_SHENANDOAHPACER_INLINE_HPP diff --git a/src/hotspot/share/interpreter/interpreterRuntime.cpp b/src/hotspot/share/interpreter/interpreterRuntime.cpp index f7cc5c6aebe..63730f53a05 100644 --- a/src/hotspot/share/interpreter/interpreterRuntime.cpp +++ b/src/hotspot/share/interpreter/interpreterRuntime.cpp @@ -1598,8 +1598,8 @@ void SignatureHandlerLibrary::initialize() { SignatureHandlerLibrary::buffer_size); _buffer = bb->code_begin(); - _fingerprints = new(ResourceObj::C_HEAP, mtCode)GrowableArray(32, true); - _handlers = new(ResourceObj::C_HEAP, mtCode)GrowableArray
(32, true); + _fingerprints = new(ResourceObj::C_HEAP, mtCode)GrowableArray(32, mtCode); + _handlers = new(ResourceObj::C_HEAP, mtCode)GrowableArray
(32, mtCode); } address SignatureHandlerLibrary::set_handler(CodeBuffer* buffer) { diff --git a/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp b/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp index 79a959872e9..2530f9ad6ae 100644 --- a/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp +++ b/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp @@ -681,7 +681,7 @@ static bool is_thread_excluded(Handle thread) { static int add_thread_to_exclusion_list(jobject thread) { ThreadExclusionListAccess lock; if (exclusion_list == NULL) { - exclusion_list = new (ResourceObj::C_HEAP, mtTracing) GrowableArray(10, true, mtTracing); + exclusion_list = new (ResourceObj::C_HEAP, mtTracing) GrowableArray(10, mtTracing); } assert(exclusion_list != NULL, "invariant"); assert(thread_is_not_excluded(thread), "invariant"); diff --git a/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.cpp b/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.cpp index b964a5f89fe..45779b14c71 100644 --- a/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.cpp +++ b/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleCheckpoint.cpp @@ -52,7 +52,7 @@ const int initial_array_size = 64; template static GrowableArray* c_heap_allocate_array(int size = initial_array_size) { - return new (ResourceObj::C_HEAP, mtTracing) GrowableArray(size, true, mtTracing); + return new (ResourceObj::C_HEAP, mtTracing) GrowableArray(size, mtTracing); } static GrowableArray* unloaded_thread_id_set = NULL; diff --git a/src/hotspot/share/jfr/periodic/jfrNetworkUtilization.cpp b/src/hotspot/share/jfr/periodic/jfrNetworkUtilization.cpp index 610abccf373..59742c0ba04 100644 --- a/src/hotspot/share/jfr/periodic/jfrNetworkUtilization.cpp +++ b/src/hotspot/share/jfr/periodic/jfrNetworkUtilization.cpp @@ -77,7 +77,7 @@ static InterfaceEntry& new_entry(const NetworkInterface* iface, GrowableArray* get_interfaces() { if (_interfaces == NULL) { - _interfaces = new(ResourceObj::C_HEAP, mtTracing) GrowableArray(10, true, mtTracing); + _interfaces = new(ResourceObj::C_HEAP, mtTracing) GrowableArray(10, mtTracing); } return _interfaces; } diff --git a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp index 5ab927b5b79..d36d9d73b2c 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp @@ -385,7 +385,6 @@ void JfrCheckpointManager::on_rotation() { } void JfrCheckpointManager::clear_type_set() { - assert(!SafepointSynchronize::is_at_safepoint(), "invariant"); assert(!JfrRecorder::is_recording(), "invariant"); Thread* t = Thread::current(); DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_native(t)); @@ -398,7 +397,6 @@ void JfrCheckpointManager::clear_type_set() { } void JfrCheckpointManager::write_type_set() { - assert(!SafepointSynchronize::is_at_safepoint(), "invariant"); { Thread* const thread = Thread::current(); DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_native(thread)); diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp index f3ed4d6cd66..107e7fa15d9 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp @@ -106,7 +106,7 @@ class JfrThreadGroupsHelper : public ResourceObj { }; JfrThreadGroupsHelper::JfrThreadGroupsHelper(const JavaThread* jt, Thread* current) { - _thread_group_hierarchy = new GrowableArray(10, false, mtTracing); + _thread_group_hierarchy = new GrowableArray(10); _current_iterator_pos = populate_thread_group_hierarchy(jt, current) - 1; } @@ -259,7 +259,7 @@ void JfrThreadGroup::JfrThreadGroupEntry::set_thread_group(JfrThreadGroupPointer } JfrThreadGroup::JfrThreadGroup() : - _list(new (ResourceObj::C_HEAP, mtTracing) GrowableArray(initial_array_size, true, mtTracing)) {} + _list(new (ResourceObj::C_HEAP, mtTracing) GrowableArray(initial_array_size, mtTracing)) {} JfrThreadGroup::~JfrThreadGroup() { if (_list != NULL) { diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.cpp index ab877ea03a6..c31854edf40 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSetUtils.cpp @@ -268,8 +268,8 @@ void JfrArtifactSet::initialize(bool class_unload, bool clear /* false */) { _symbol_id->set_class_unload(class_unload); _total_count = 0; // resource allocation - _klass_list = new GrowableArray(initial_klass_list_size, false, mtTracing); - _klass_loader_set = new GrowableArray(initial_klass_loader_set_size, false, mtTracing); + _klass_list = new GrowableArray(initial_klass_list_size); + _klass_loader_set = new GrowableArray(initial_klass_loader_set_size); } JfrArtifactSet::~JfrArtifactSet() { diff --git a/src/hotspot/share/jfr/recorder/jfrRecorder.cpp b/src/hotspot/share/jfr/recorder/jfrRecorder.cpp index b7c4e46732b..22b0955e15c 100644 --- a/src/hotspot/share/jfr/recorder/jfrRecorder.cpp +++ b/src/hotspot/share/jfr/recorder/jfrRecorder.cpp @@ -122,7 +122,7 @@ static bool validate_recording_options(TRAPS) { const int length = options->length(); assert(length >= 1, "invariant"); assert(dcmd_recordings_array == NULL, "invariant"); - dcmd_recordings_array = new (ResourceObj::C_HEAP, mtTracing)GrowableArray(length, true, mtTracing); + dcmd_recordings_array = new (ResourceObj::C_HEAP, mtTracing)GrowableArray(length, mtTracing); assert(dcmd_recordings_array != NULL, "invariant"); for (int i = 0; i < length; ++i) { JfrStartFlightRecordingDCmd* const dcmd_recording = new(ResourceObj::C_HEAP, mtTracing) JfrStartFlightRecordingDCmd(tty, true); diff --git a/src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp b/src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp index 4c9d98bf1c6..5927f7a26e5 100644 --- a/src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp +++ b/src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp @@ -296,7 +296,7 @@ RepositoryIterator::RepositoryIterator(const char* repository_path) : if (_path_buffer_file_name_offset == -1) { return; } - _file_names = new (ResourceObj::C_HEAP, mtTracing) GrowableArray(10, true, mtTracing); + _file_names = new (ResourceObj::C_HEAP, mtTracing) GrowableArray(10, mtTracing); if (_file_names == NULL) { log_error(jfr, system)("Unable to malloc memory during jfr emergency dump"); return; diff --git a/src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp b/src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp index 37d5c77a915..50831cb6c76 100644 --- a/src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp +++ b/src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp @@ -702,7 +702,7 @@ bool JfrOptionSet::parse_start_flight_recording_option(const JavaVMOption** opti const size_t value_length = strlen(value); if (start_flight_recording_options_array == NULL) { - start_flight_recording_options_array = new (ResourceObj::C_HEAP, mtTracing) GrowableArray(8, true, mtTracing); + start_flight_recording_options_array = new (ResourceObj::C_HEAP, mtTracing) GrowableArray(8, mtTracing); } assert(start_flight_recording_options_array != NULL, "invariant"); char* const startup_value = NEW_C_HEAP_ARRAY(char, value_length + 1, mtTracing); diff --git a/src/hotspot/share/jfr/support/jfrJdkJfrEvent.cpp b/src/hotspot/share/jfr/support/jfrJdkJfrEvent.cpp index 42ae943d9be..efc55c08bad 100644 --- a/src/hotspot/share/jfr/support/jfrJdkJfrEvent.cpp +++ b/src/hotspot/share/jfr/support/jfrJdkJfrEvent.cpp @@ -49,7 +49,7 @@ static const int initial_array_size = 64; template static GrowableArray* c_heap_allocate_array(int size = initial_array_size) { - return new (ResourceObj::C_HEAP, mtTracing) GrowableArray(size, true, mtTracing); + return new (ResourceObj::C_HEAP, mtTracing) GrowableArray(size, mtTracing); } static bool initialize(TRAPS) { @@ -137,7 +137,7 @@ jobject JdkJfrEvent::get_all_klasses(TRAPS) { } ResourceMark rm(THREAD); - GrowableArray event_subklasses(THREAD, initial_array_size); + GrowableArray event_subklasses(initial_array_size); fill_klasses(event_subklasses, klass, THREAD); if (event_subklasses.is_empty()) { diff --git a/src/hotspot/share/jfr/support/jfrKlassUnloading.cpp b/src/hotspot/share/jfr/support/jfrKlassUnloading.cpp index 2338c56bbe7..7d7b5ca9161 100644 --- a/src/hotspot/share/jfr/support/jfrKlassUnloading.cpp +++ b/src/hotspot/share/jfr/support/jfrKlassUnloading.cpp @@ -33,7 +33,7 @@ static const int initial_array_size = 64; template static GrowableArray* c_heap_allocate_array(int size = initial_array_size) { - return new (ResourceObj::C_HEAP, mtTracing) GrowableArray(size, true, mtTracing); + return new (ResourceObj::C_HEAP, mtTracing) GrowableArray(size, mtTracing); } // Track the set of unloaded klasses during a chunk / epoch. diff --git a/src/hotspot/share/jfr/utilities/jfrConcurrentLinkedListHost.inline.hpp b/src/hotspot/share/jfr/utilities/jfrConcurrentLinkedListHost.inline.hpp index 06badb67acc..48b54fda18a 100644 --- a/src/hotspot/share/jfr/utilities/jfrConcurrentLinkedListHost.inline.hpp +++ b/src/hotspot/share/jfr/utilities/jfrConcurrentLinkedListHost.inline.hpp @@ -63,8 +63,8 @@ Node* find_adjacent(Node* head, const Node* tail, Node** predecessor, VersionHan assert(head != NULL, "invariant"); assert(tail != NULL, "invariant"); assert(head != tail, "invariant"); + Node* predecessor_next = NULL; while (true) { - Node* predecessor_next; Node* current = head; version_handle.checkout(); assert(version_handle.is_tracked(), "invariant"); diff --git a/src/hotspot/share/memory/allocation.hpp b/src/hotspot/share/memory/allocation.hpp index ac156f0df70..5a51a90257c 100644 --- a/src/hotspot/share/memory/allocation.hpp +++ b/src/hotspot/share/memory/allocation.hpp @@ -114,33 +114,34 @@ class AllocatedObj { }; #endif -#define MEMORY_TYPES_DO(f) \ - /* Memory type by sub systems. It occupies lower byte. */ \ - f(mtJavaHeap, "Java Heap") /* Java heap */ \ - f(mtClass, "Class") /* Java classes */ \ - f(mtThread, "Thread") /* thread objects */ \ - f(mtThreadStack, "Thread Stack") \ - f(mtCode, "Code") /* generated code */ \ - f(mtGC, "GC") \ - f(mtCompiler, "Compiler") \ - f(mtJVMCI, "JVMCI") \ - f(mtInternal, "Internal") /* memory used by VM, but does not belong to */ \ - /* any of above categories, and not used by */ \ - /* NMT */ \ - f(mtOther, "Other") /* memory not used by VM */ \ - f(mtSymbol, "Symbol") \ - f(mtNMT, "Native Memory Tracking") /* memory used by NMT */ \ - f(mtClassShared, "Shared class space") /* class data sharing */ \ - f(mtChunk, "Arena Chunk") /* chunk that holds content of arenas */ \ - f(mtTest, "Test") /* Test type for verifying NMT */ \ - f(mtTracing, "Tracing") \ - f(mtLogging, "Logging") \ - f(mtStatistics, "Statistics") \ - f(mtArguments, "Arguments") \ - f(mtModule, "Module") \ - f(mtSafepoint, "Safepoint") \ - f(mtSynchronizer, "Synchronization") \ - f(mtNone, "Unknown") \ +#define MEMORY_TYPES_DO(f) \ + /* Memory type by sub systems. It occupies lower byte. */ \ + f(mtJavaHeap, "Java Heap") /* Java heap */ \ + f(mtClass, "Class") /* Java classes */ \ + f(mtThread, "Thread") /* thread objects */ \ + f(mtThreadStack, "Thread Stack") \ + f(mtCode, "Code") /* generated code */ \ + f(mtGC, "GC") \ + f(mtCompiler, "Compiler") \ + f(mtJVMCI, "JVMCI") \ + f(mtInternal, "Internal") /* memory used by VM, but does not belong to */ \ + /* any of above categories, and not used by */ \ + /* NMT */ \ + f(mtOther, "Other") /* memory not used by VM */ \ + f(mtSymbol, "Symbol") \ + f(mtNMT, "Native Memory Tracking") /* memory used by NMT */ \ + f(mtClassShared, "Shared class space") /* class data sharing */ \ + f(mtChunk, "Arena Chunk") /* chunk that holds content of arenas */ \ + f(mtTest, "Test") /* Test type for verifying NMT */ \ + f(mtTracing, "Tracing") \ + f(mtLogging, "Logging") \ + f(mtStatistics, "Statistics") \ + f(mtArguments, "Arguments") \ + f(mtModule, "Module") \ + f(mtSafepoint, "Safepoint") \ + f(mtSynchronizer, "Synchronization") \ + f(mtServiceability, "Serviceability") \ + f(mtNone, "Unknown") \ //end #define MEMORY_TYPE_DECLARE_ENUM(type, human_readable) \ diff --git a/src/hotspot/share/memory/binaryTreeDictionary.hpp b/src/hotspot/share/memory/binaryTreeDictionary.hpp index a521200562d..e8e08934bcd 100644 --- a/src/hotspot/share/memory/binaryTreeDictionary.hpp +++ b/src/hotspot/share/memory/binaryTreeDictionary.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, 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 @@ -158,7 +158,7 @@ class TreeChunk : public Chunk_t { Chunk_t* next() const { return Chunk_t::next(); } Chunk_t* prev() const { return Chunk_t::prev(); } - size_t size() const volatile { return Chunk_t::size(); } + size_t size() const { return Chunk_t::size(); } static size_t min_size(); diff --git a/src/hotspot/share/memory/dynamicArchive.cpp b/src/hotspot/share/memory/dynamicArchive.cpp index 96d4050c425..8981bbf4216 100644 --- a/src/hotspot/share/memory/dynamicArchive.cpp +++ b/src/hotspot/share/memory/dynamicArchive.cpp @@ -535,8 +535,8 @@ class DynamicArchiveBuilder : ResourceObj { public: DynamicArchiveBuilder() { - _klasses = new (ResourceObj::C_HEAP, mtClass) GrowableArray(100, true, mtInternal); - _symbols = new (ResourceObj::C_HEAP, mtClass) GrowableArray(1000, true, mtInternal); + _klasses = new (ResourceObj::C_HEAP, mtClass) GrowableArray(100, mtClass); + _symbols = new (ResourceObj::C_HEAP, mtClass) GrowableArray(1000, mtClass); _estimated_metsapceobj_bytes = 0; _estimated_hashtable_bytes = 0; diff --git a/src/hotspot/share/memory/filemap.cpp b/src/hotspot/share/memory/filemap.cpp index 3f908d0f467..808d857b1bd 100644 --- a/src/hotspot/share/memory/filemap.cpp +++ b/src/hotspot/share/memory/filemap.cpp @@ -499,7 +499,7 @@ void FileMapInfo::record_non_existent_class_path_entry(const char* path) { Arguments::assert_is_dumping_archive(); log_info(class, path)("non-existent Class-Path entry %s", path); if (_non_existent_class_paths == NULL) { - _non_existent_class_paths = new (ResourceObj::C_HEAP, mtInternal)GrowableArray(10, true); + _non_existent_class_paths = new (ResourceObj::C_HEAP, mtClass)GrowableArray(10, mtClass); } _non_existent_class_paths->append(os::strdup(path)); } @@ -626,8 +626,7 @@ int FileMapInfo::num_paths(const char* path) { } GrowableArray* FileMapInfo::create_path_array(const char* paths) { - GrowableArray* path_array = new(ResourceObj::RESOURCE_AREA, mtInternal) - GrowableArray(10); + GrowableArray* path_array = new GrowableArray(10); ClasspathStream cp_stream(paths); while (cp_stream.has_next()) { diff --git a/src/hotspot/share/memory/heapInspection.cpp b/src/hotspot/share/memory/heapInspection.cpp index 91238e47f92..c13148c471a 100644 --- a/src/hotspot/share/memory/heapInspection.cpp +++ b/src/hotspot/share/memory/heapInspection.cpp @@ -52,7 +52,7 @@ inline KlassInfoEntry::~KlassInfoEntry() { inline void KlassInfoEntry::add_subclass(KlassInfoEntry* cie) { if (_subclasses == NULL) { - _subclasses = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(4, true); + _subclasses = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(4, mtServiceability); } _subclasses->append(cie); } @@ -245,7 +245,7 @@ int KlassInfoHisto::sort_helper(KlassInfoEntry** e1, KlassInfoEntry** e2) { KlassInfoHisto::KlassInfoHisto(KlassInfoTable* cit) : _cit(cit) { - _elements = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(_histo_initial_size, true); + _elements = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(_histo_initial_size, mtServiceability); } KlassInfoHisto::~KlassInfoHisto() { @@ -551,7 +551,7 @@ static void print_field(outputStream* st, int level, int offset, FieldDesc& fd, static void print_inlined_field(outputStream* st, int level, int offset, InstanceKlass* klass) { assert(klass->is_inline_klass(), "Only inline types can be inlined"); ValueKlass* vklass = ValueKlass::cast(klass); - GrowableArray* fields = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(100, true); + GrowableArray* fields = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(100, mtServiceability); for (FieldStream fd(klass, false, false); !fd.eos(); fd.next()) { if (!fd.access_flags().is_static()) { fields->append(FieldDesc(fd.field_descriptor())); @@ -581,7 +581,7 @@ void PrintClassLayout::print_class_layout(outputStream* st, char* class_name) { Symbol* classname = SymbolTable::probe(class_name, (int)strlen(class_name)); - GrowableArray* klasses = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(100, true); + GrowableArray* klasses = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(100, mtServiceability); FindClassByNameClosure fbnc(klasses, classname); cit.iterate(&fbnc); @@ -594,7 +594,7 @@ void PrintClassLayout::print_class_layout(outputStream* st, char* class_name) { st->print_cr("Class %s [@%s]:", klass->name()->as_C_string(), klass->class_loader_data()->name()->as_C_string()); ResourceMark rm; - GrowableArray* fields = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(100, true); + GrowableArray* fields = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(100, mtServiceability); for (FieldStream fd(ik, false, false); !fd.eos(); fd.next()) { if (!fd.access_flags().is_static()) { fields->append(FieldDesc(fd.field_descriptor())); diff --git a/src/hotspot/share/memory/heapShared.cpp b/src/hotspot/share/memory/heapShared.cpp index 7eaaf74b19f..2176365fdd2 100644 --- a/src/hotspot/share/memory/heapShared.cpp +++ b/src/hotspot/share/memory/heapShared.cpp @@ -28,6 +28,7 @@ #include "classfile/symbolTable.hpp" #include "classfile/systemDictionaryShared.hpp" #include "classfile/vmSymbols.hpp" +#include "gc/shared/gcLocker.hpp" #include "logging/log.hpp" #include "logging/logMessage.hpp" #include "logging/logStream.hpp" @@ -186,6 +187,25 @@ void HeapShared::archive_klass_objects(Thread* THREAD) { } } +void HeapShared::run_full_gc_in_vm_thread() { + if (is_heap_object_archiving_allowed()) { + // Avoid fragmentation while archiving heap objects. + // We do this inside a safepoint, so that no further allocation can happen after GC + // has finished. + if (GCLocker::is_active()) { + // Just checking for safety ... + // This should not happen during -Xshare:dump. If you see this, probably the Java core lib + // has been modified such that JNI code is executed in some clean up threads after + // we have finished class loading. + log_warning(cds)("GC locker is held, unable to start extra compacting GC. This may produce suboptimal results."); + } else { + log_info(cds)("Run GC ..."); + Universe::heap()->collect_as_vm_thread(GCCause::_archive_time_gc); + log_info(cds)("Run GC done"); + } + } +} + void HeapShared::archive_java_heap_objects(GrowableArray *closed, GrowableArray *open) { if (!is_heap_object_archiving_allowed()) { @@ -289,7 +309,7 @@ void KlassSubGraphInfo::add_subgraph_entry_field( assert(DumpSharedSpaces, "dump time only"); if (_subgraph_entry_fields == NULL) { _subgraph_entry_fields = - new(ResourceObj::C_HEAP, mtClass) GrowableArray(10, true); + new(ResourceObj::C_HEAP, mtClass) GrowableArray(10, mtClass); } _subgraph_entry_fields->append((juint)static_field_offset); _subgraph_entry_fields->append(CompressedOops::encode(v)); @@ -305,7 +325,7 @@ void KlassSubGraphInfo::add_subgraph_object_klass(Klass* orig_k, Klass *relocate if (_subgraph_object_klasses == NULL) { _subgraph_object_klasses = - new(ResourceObj::C_HEAP, mtClass) GrowableArray(50, true); + new(ResourceObj::C_HEAP, mtClass) GrowableArray(50, mtClass); } assert(relocated_k->is_shared(), "must be a shared class"); diff --git a/src/hotspot/share/memory/heapShared.hpp b/src/hotspot/share/memory/heapShared.hpp index e814b4b8bec..cce28bf8c73 100644 --- a/src/hotspot/share/memory/heapShared.hpp +++ b/src/hotspot/share/memory/heapShared.hpp @@ -277,6 +277,8 @@ class HeapShared: AllStatic { #endif // INCLUDE_CDS_JAVA_HEAP public: + static void run_full_gc_in_vm_thread() NOT_CDS_JAVA_HEAP_RETURN; + static bool is_heap_object_archiving_allowed() { CDS_JAVA_HEAP_ONLY(return (UseG1GC && UseCompressedOops && UseCompressedClassPointers);) NOT_CDS_JAVA_HEAP(return false;) diff --git a/src/hotspot/share/memory/metaspace/metabase.hpp b/src/hotspot/share/memory/metaspace/metabase.hpp index 31d7c5deb0f..0f9f32021f8 100644 --- a/src/hotspot/share/memory/metaspace/metabase.hpp +++ b/src/hotspot/share/memory/metaspace/metabase.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2020, 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 @@ -48,8 +48,7 @@ class Metabase { void clear_next() { set_next(NULL); } void clear_prev() { set_prev(NULL); } - size_t size() const volatile { return _word_size; } - void set_size(size_t v) { _word_size = v; } + size_t size() const { return _word_size; } void link_next(T* ptr) { set_next(ptr); } void link_prev(T* ptr) { set_prev(ptr); } diff --git a/src/hotspot/share/memory/metaspaceShared.cpp b/src/hotspot/share/memory/metaspaceShared.cpp index 5994bfdf1a9..5c68bac5597 100644 --- a/src/hotspot/share/memory/metaspaceShared.cpp +++ b/src/hotspot/share/memory/metaspaceShared.cpp @@ -461,7 +461,7 @@ void MetaspaceShared::post_initialize(TRAPS) { static GrowableArray* _extra_interned_strings = NULL; void MetaspaceShared::read_extra_data(const char* filename, TRAPS) { - _extra_interned_strings = new (ResourceObj::C_HEAP, mtInternal)GrowableArray(10000, true); + _extra_interned_strings = new (ResourceObj::C_HEAP, mtClassShared) GrowableArray(10000, mtClassShared); HashtableTextDump reader(filename); reader.check_version("VERSION: 1.0"); @@ -1658,6 +1658,7 @@ void VM_PopulateDumpSharedSpace::relocate_to_requested_base_address(CHeapBitMap* } void VM_PopulateDumpSharedSpace::doit() { + HeapShared::run_full_gc_in_vm_thread(); CHeapBitMap ptrmap; MetaspaceShared::initialize_ptr_marker(&ptrmap); @@ -1976,14 +1977,9 @@ void MetaspaceShared::preload_and_dump(TRAPS) { link_and_cleanup_shared_classes(CATCH); log_info(cds)("Rewriting and linking classes: done"); - if (HeapShared::is_heap_object_archiving_allowed()) { - // Avoid fragmentation while archiving heap objects. - Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(true); - Universe::heap()->collect(GCCause::_archive_time_gc); - Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(false); - } - VM_PopulateDumpSharedSpace op; + MutexLocker ml(THREAD, HeapShared::is_heap_object_archiving_allowed() ? + Heap_lock : NULL); // needed by HeapShared::run_gc() VMThread::execute(&op); } } @@ -2522,8 +2518,8 @@ char* MetaspaceShared::reserve_address_space_for_archives(FileMapInfo* static_ma "CompressedClassSpaceSize malformed: " SIZE_FORMAT, CompressedClassSpaceSize); - const size_t ccs_begin_offset = align_up(archive_space_size, - class_space_alignment); + const size_t ccs_begin_offset = align_up(base_address + archive_space_size, + class_space_alignment) - base_address; const size_t gap_size = ccs_begin_offset - archive_space_size; const size_t total_range_size = diff --git a/src/hotspot/share/oops/constantPool.hpp b/src/hotspot/share/oops/constantPool.hpp index 2aa16018b12..bac0dd5ccb2 100644 --- a/src/hotspot/share/oops/constantPool.hpp +++ b/src/hotspot/share/oops/constantPool.hpp @@ -189,7 +189,7 @@ class ConstantPool : public Metadata { public: static ConstantPool* allocate(ClassLoaderData* loader_data, int length, TRAPS); - bool is_constantPool() const volatile { return true; } + virtual bool is_constantPool() const { return true; } Array* tags() const { return _tags; } Array* operands() const { return _operands; } diff --git a/src/hotspot/share/oops/klass.hpp b/src/hotspot/share/oops/klass.hpp index 619bc9f211b..14e97efb4b1 100644 --- a/src/hotspot/share/oops/klass.hpp +++ b/src/hotspot/share/oops/klass.hpp @@ -202,7 +202,7 @@ class Klass : public Metadata { enum StaticLookupMode { find_static, skip_static }; enum PrivateLookupMode { find_private, skip_private }; - bool is_klass() const volatile { return true; } + virtual bool is_klass() const { return true; } // super() cannot be InstanceKlass* -- Java arrays are covariant, and _super is used // to implement that. NB: the _super of "[Ljava/lang/Integer;" is "[Ljava/lang/Number;" diff --git a/src/hotspot/share/oops/metadata.hpp b/src/hotspot/share/oops/metadata.hpp index 1ff97ed4fad..7e6192b56e2 100644 --- a/src/hotspot/share/oops/metadata.hpp +++ b/src/hotspot/share/oops/metadata.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,17 +34,17 @@ class Metadata : public MetaspaceObj { // Debugging hook to check that the metadata has not been deleted. NOT_PRODUCT(int _valid;) public: - NOT_PRODUCT(Metadata() { _valid = 0; }) - NOT_PRODUCT(bool is_valid() const volatile { return _valid == 0; }) + NOT_PRODUCT(Metadata() : _valid(0) {}) + NOT_PRODUCT(bool is_valid() const { return _valid == 0; }) int identity_hash() { return (int)(uintptr_t)this; } - virtual bool is_metadata() const volatile { return true; } - virtual bool is_klass() const volatile { return false; } - virtual bool is_method() const volatile { return false; } - virtual bool is_methodData() const volatile { return false; } - virtual bool is_constantPool() const volatile { return false; } - virtual bool is_methodCounters() const volatile { return false; } + virtual bool is_metadata() const { return true; } + virtual bool is_klass() const { return false; } + virtual bool is_method() const { return false; } + virtual bool is_methodData() const { return false; } + virtual bool is_constantPool() const { return false; } + virtual bool is_methodCounters() const { return false; } virtual int size() const = 0; virtual MetaspaceObj::Type type() const = 0; virtual const char* internal_name() const = 0; diff --git a/src/hotspot/share/oops/method.hpp b/src/hotspot/share/oops/method.hpp index ac6ff255fbc..54acd912f34 100644 --- a/src/hotspot/share/oops/method.hpp +++ b/src/hotspot/share/oops/method.hpp @@ -136,7 +136,7 @@ class Method : public Metadata { // CDS and vtbl checking can create an empty Method to get vtbl pointer. Method(){} - bool is_method() const volatile { return true; } + virtual bool is_method() const { return true; } void restore_unshareable_info(TRAPS); diff --git a/src/hotspot/share/oops/methodCounters.hpp b/src/hotspot/share/oops/methodCounters.hpp index 267cc037ae8..eee7b780b4c 100644 --- a/src/hotspot/share/oops/methodCounters.hpp +++ b/src/hotspot/share/oops/methodCounters.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2020, 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 @@ -113,7 +113,7 @@ class MethodCounters : public Metadata { } public: - virtual bool is_methodCounters() const volatile { return true; } + virtual bool is_methodCounters() const { return true; } static MethodCounters* allocate(const methodHandle& mh, TRAPS); diff --git a/src/hotspot/share/oops/methodData.cpp b/src/hotspot/share/oops/methodData.cpp index f0b47edc52f..3a94f05c9d6 100644 --- a/src/hotspot/share/oops/methodData.cpp +++ b/src/hotspot/share/oops/methodData.cpp @@ -245,7 +245,7 @@ class ArgumentOffsetComputer : public SignatureIterator { ArgumentOffsetComputer(Symbol* signature, int max) : SignatureIterator(signature), _max(max), _offset(0), - _offsets(Thread::current(), max) { + _offsets(max) { do_parameters_on(this); // non-virtual template execution } diff --git a/src/hotspot/share/oops/methodData.hpp b/src/hotspot/share/oops/methodData.hpp index 18f70c3ac63..db25b6fe557 100644 --- a/src/hotspot/share/oops/methodData.hpp +++ b/src/hotspot/share/oops/methodData.hpp @@ -2037,7 +2037,7 @@ class MethodData : public Metadata { static MethodData* allocate(ClassLoaderData* loader_data, const methodHandle& method, TRAPS); MethodData() : _extra_data_lock(Mutex::leaf, "MDO extra data lock") {}; // For ciMethodData - bool is_methodData() const volatile { return true; } + virtual bool is_methodData() const { return true; } void initialize(); // Whole-method sticky bits and flags diff --git a/src/hotspot/share/oops/oop.hpp b/src/hotspot/share/oops/oop.hpp index 1b49d48855b..daa3681faf9 100644 --- a/src/hotspot/share/oops/oop.hpp +++ b/src/hotspot/share/oops/oop.hpp @@ -88,8 +88,8 @@ class oopDesc { inline void init_mark_raw(); inline Klass* klass() const; - inline Klass* klass_or_null() const volatile; - inline Klass* klass_or_null_acquire() const volatile; + inline Klass* klass_or_null() const; + inline Klass* klass_or_null_acquire() const; static inline Klass** klass_addr(HeapWord* mem); static inline narrowKlass* compressed_klass_addr(HeapWord* mem); inline Klass** klass_addr(); diff --git a/src/hotspot/share/oops/oop.inline.hpp b/src/hotspot/share/oops/oop.inline.hpp index 14f45c423f0..7d25e5d03aa 100644 --- a/src/hotspot/share/oops/oop.inline.hpp +++ b/src/hotspot/share/oops/oop.inline.hpp @@ -96,7 +96,7 @@ Klass* oopDesc::klass() const { } } -Klass* oopDesc::klass_or_null() const volatile { +Klass* oopDesc::klass_or_null() const { if (UseCompressedClassPointers) { return CompressedKlassPointers::decode(_metadata._compressed_klass); } else { @@ -104,12 +104,10 @@ Klass* oopDesc::klass_or_null() const volatile { } } -Klass* oopDesc::klass_or_null_acquire() const volatile { +Klass* oopDesc::klass_or_null_acquire() const { if (UseCompressedClassPointers) { - // Workaround for non-const load_acquire parameter. - const volatile narrowKlass* addr = &_metadata._compressed_klass; - volatile narrowKlass* xaddr = const_cast(addr); - return CompressedKlassPointers::decode(Atomic::load_acquire(xaddr)); + narrowKlass nklass = Atomic::load_acquire(&_metadata._compressed_klass); + return CompressedKlassPointers::decode(nklass); } else { return Atomic::load_acquire(&_metadata._klass); } diff --git a/src/hotspot/share/opto/c2_globals.hpp b/src/hotspot/share/opto/c2_globals.hpp index 9dbe8aa2e71..6cc69a0087e 100644 --- a/src/hotspot/share/opto/c2_globals.hpp +++ b/src/hotspot/share/opto/c2_globals.hpp @@ -366,10 +366,12 @@ \ notproduct(intx, PrintIdealGraphLevel, 0, \ "Level of detail of the ideal graph printout. " \ - "System-wide value, 0=nothing is printed, 4=all details printed. "\ + "System-wide value, -1=printing is disabled, " \ + "0=print nothing except IGVPrintLevel directives, " \ + "4=all details printed. " \ "Level of detail of printouts can be set on a per-method level " \ "as well by using CompileCommand=option.") \ - range(0, 4) \ + range(-1, 4) \ \ notproduct(intx, PrintIdealGraphPort, 4444, \ "Ideal graph printer to network port") \ diff --git a/src/hotspot/share/opto/cfgnode.cpp b/src/hotspot/share/opto/cfgnode.cpp index 60d160b9ead..39111659060 100644 --- a/src/hotspot/share/opto/cfgnode.cpp +++ b/src/hotspot/share/opto/cfgnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, 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 @@ -1541,20 +1541,32 @@ static Node* is_absolute( PhaseGVN *phase, PhiNode *phi_root, int true_path) { // is_diamond_phi() has guaranteed the correctness of the nodes sequence: // phi->region->if_proj->ifnode->bool->cmp BoolNode *bol = phi_root->in(0)->in(1)->in(0)->in(1)->as_Bool(); + Node *cmp = bol->in(1); // Check bool sense - switch( bol->_test._test ) { - case BoolTest::lt: cmp_zero_idx = 1; phi_x_idx = true_path; break; - case BoolTest::le: cmp_zero_idx = 2; phi_x_idx = false_path; break; - case BoolTest::gt: cmp_zero_idx = 2; phi_x_idx = true_path; break; - case BoolTest::ge: cmp_zero_idx = 1; phi_x_idx = false_path; break; - default: return NULL; break; + if (cmp->Opcode() == Op_CmpF || cmp->Opcode() == Op_CmpD) { + switch (bol->_test._test) { + case BoolTest::lt: cmp_zero_idx = 1; phi_x_idx = true_path; break; + case BoolTest::le: cmp_zero_idx = 2; phi_x_idx = false_path; break; + case BoolTest::gt: cmp_zero_idx = 2; phi_x_idx = true_path; break; + case BoolTest::ge: cmp_zero_idx = 1; phi_x_idx = false_path; break; + default: return NULL; break; + } + } else if (cmp->Opcode() == Op_CmpI || cmp->Opcode() == Op_CmpL) { + switch (bol->_test._test) { + case BoolTest::lt: + case BoolTest::le: cmp_zero_idx = 2; phi_x_idx = false_path; break; + case BoolTest::gt: + case BoolTest::ge: cmp_zero_idx = 2; phi_x_idx = true_path; break; + default: return NULL; break; + } } // Test is next - Node *cmp = bol->in(1); const Type *tzero = NULL; - switch( cmp->Opcode() ) { + switch (cmp->Opcode()) { + case Op_CmpI: tzero = TypeInt::ZERO; break; // Integer ABS + case Op_CmpL: tzero = TypeLong::ZERO; break; // Long ABS case Op_CmpF: tzero = TypeF::ZERO; break; // Float ABS case Op_CmpD: tzero = TypeD::ZERO; break; // Double ABS default: return NULL; @@ -1589,7 +1601,7 @@ static Node* is_absolute( PhaseGVN *phase, PhiNode *phi_root, int true_path) { if (flip) { x = new SubFNode(sub->in(1), phase->transform(x)); } - } else { + } else if (tzero == TypeD::ZERO) { if( sub->Opcode() != Op_SubD || sub->in(2) != x || phase->type(sub->in(1)) != tzero ) return NULL; @@ -1597,6 +1609,22 @@ static Node* is_absolute( PhaseGVN *phase, PhiNode *phi_root, int true_path) { if (flip) { x = new SubDNode(sub->in(1), phase->transform(x)); } + } else if (tzero == TypeInt::ZERO) { + if (sub->Opcode() != Op_SubI || + sub->in(2) != x || + phase->type(sub->in(1)) != tzero) return NULL; + x = new AbsINode(x); + if (flip) { + x = new SubINode(sub->in(1), phase->transform(x)); + } + } else { + if (sub->Opcode() != Op_SubL || + sub->in(2) != x || + phase->type(sub->in(1)) != tzero) return NULL; + x = new AbsLNode(x); + if (flip) { + x = new SubLNode(sub->in(1), phase->transform(x)); + } } return x; diff --git a/src/hotspot/share/opto/compile.cpp b/src/hotspot/share/opto/compile.cpp index 8a46561e3c2..fffd0063bca 100644 --- a/src/hotspot/share/opto/compile.cpp +++ b/src/hotspot/share/opto/compile.cpp @@ -537,9 +537,7 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci, _log(ci_env->log()), _failure_reason(NULL), _congraph(NULL), -#ifndef PRODUCT - _printer(IdealGraphPrinter::printer()), -#endif + NOT_PRODUCT(_printer(NULL) COMMA) _dead_node_list(comp_arena()), _dead_node_count(0), _node_arena(mtCompiler), @@ -567,11 +565,6 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci, #endif { C = this; -#ifndef PRODUCT - if (_printer != NULL) { - _printer->set_compile(this); - } -#endif CompileWrapper cw(this); if (CITimeVerbose) { @@ -731,7 +724,7 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci, // Drain the list. Finish_Warm(); #ifndef PRODUCT - if (_printer && _printer->should_print(1)) { + if (should_print(1)) { _printer->print_inlining(); } #endif @@ -831,9 +824,7 @@ Compile::Compile( ciEnv* ci_env, _log(ci_env->log()), _failure_reason(NULL), _congraph(NULL), -#ifndef PRODUCT - _printer(NULL), -#endif + NOT_PRODUCT(_printer(NULL) COMMA) _dead_node_list(comp_arena()), _dead_node_count(0), _node_arena(mtCompiler), @@ -5041,7 +5032,7 @@ void Compile::end_method(int level) { } #ifndef PRODUCT - if (_printer && _printer->should_print(level)) { + if (_method != NULL && should_print(level)) { _printer->end_method(); } #endif diff --git a/src/hotspot/share/opto/compile.hpp b/src/hotspot/share/opto/compile.hpp index 882ac2b8345..178b492b9f1 100644 --- a/src/hotspot/share/opto/compile.hpp +++ b/src/hotspot/share/opto/compile.hpp @@ -626,9 +626,9 @@ class Compile : public Phase { Ticks _latest_stage_start_counter; - void begin_method() { + void begin_method(int level = 1) { #ifndef PRODUCT - if (_printer && _printer->should_print(1)) { + if (_method != NULL && should_print(level)) { _printer->begin_method(); } #endif @@ -637,7 +637,17 @@ class Compile : public Phase { bool should_print(int level = 1) { #ifndef PRODUCT - return (_printer && _printer->should_print(level)); + if (PrintIdealGraphLevel < 0) { // disabled by the user + return false; + } + + bool need = directive()->IGVPrintLevelOption >= level; + if (need && !_printer) { + _printer = IdealGraphPrinter::printer(); + assert(_printer != NULL, "_printer is NULL when we need it!"); + _printer->set_compile(this); + } + return need; #else return false; #endif diff --git a/src/hotspot/share/opto/idealGraphPrinter.cpp b/src/hotspot/share/opto/idealGraphPrinter.cpp index 2c2fe061630..eef11f82f7e 100644 --- a/src/hotspot/share/opto/idealGraphPrinter.cpp +++ b/src/hotspot/share/opto/idealGraphPrinter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2020, 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 @@ -75,10 +75,6 @@ const char *IdealGraphPrinter::ASSEMBLY_ELEMENT = "assembly"; int IdealGraphPrinter::_file_count = 0; IdealGraphPrinter *IdealGraphPrinter::printer() { - if (!PrintIdealGraph) { - return NULL; - } - JavaThread *thread = JavaThread::current(); if (!thread->is_Compiler_thread()) return NULL; @@ -633,7 +629,7 @@ void IdealGraphPrinter::walk_nodes(Node *start, bool edges, VectorSet* temp_set) } void IdealGraphPrinter::print_method(const char *name, int level) { - if (should_print(level)) { + if (C->should_print(level)) { print(name, (Node *) C->root()); } } @@ -691,11 +687,6 @@ void IdealGraphPrinter::print(const char *name, Node *node) { _xml->flush(); } -// Should method be printed? -bool IdealGraphPrinter::should_print(int level) { - return C->directive()->IGVPrintLevelOption >= level; -} - void IdealGraphPrinter::init_file_stream(const char* file_name, bool use_multiple_files, bool append) { ThreadCritical tc; if (use_multiple_files && _file_count != 0) { diff --git a/src/hotspot/share/opto/idealGraphPrinter.hpp b/src/hotspot/share/opto/idealGraphPrinter.hpp index 71c1bb9a964..48da2b2970f 100644 --- a/src/hotspot/share/opto/idealGraphPrinter.hpp +++ b/src/hotspot/share/opto/idealGraphPrinter.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2020, 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 @@ -126,7 +126,6 @@ class IdealGraphPrinter : public CHeapObj { void end_method(); void print_method(const char *name, int level = 0); void print(const char *name, Node *root); - bool should_print(int level); void set_compile(Compile* compile) {C = compile; } void update_compiled_method(ciMethod* current_method); }; diff --git a/src/hotspot/share/opto/macro.cpp b/src/hotspot/share/opto/macro.cpp index 96b0960fa31..35ba52eba3f 100644 --- a/src/hotspot/share/opto/macro.cpp +++ b/src/hotspot/share/opto/macro.cpp @@ -408,7 +408,7 @@ Node *PhaseMacroExpand::value_from_mem_phi(Node *mem, BasicType ft, const Type * Node *alloc_mem = alloc->in(TypeFunc::Memory); uint length = mem->req(); - GrowableArray values(length, length, NULL, false); + GrowableArray values(length, length, NULL); // create a new Phi for the value PhiNode *phi = new PhiNode(mem->in(0), phi_type, NULL, mem->_idx, instance_id, alias_idx, offset); diff --git a/src/hotspot/share/opto/node.cpp b/src/hotspot/share/opto/node.cpp index d680313cd2f..7e8d433a01e 100644 --- a/src/hotspot/share/opto/node.cpp +++ b/src/hotspot/share/opto/node.cpp @@ -2163,63 +2163,79 @@ void Node::verify_edges(Unique_Node_List &visited) { } } -void Node::verify_recur(const Node *n, int verify_depth, - VectorSet &old_space, VectorSet &new_space) { - if ( verify_depth == 0 ) return; - if (verify_depth > 0) --verify_depth; - +// Verify all nodes if verify_depth is negative +void Node::verify(Node* n, int verify_depth) { + assert(verify_depth != 0, "depth should not be 0"); + ResourceMark rm; + ResourceArea* area = Thread::current()->resource_area(); + VectorSet old_space(area); + VectorSet new_space(area); + Node_List worklist(area); + worklist.push(n); Compile* C = Compile::current(); + uint last_index_on_current_depth = 0; + verify_depth--; // Visiting the first node on depth 1 + // Only add nodes to worklist if verify_depth is negative (visit all nodes) or greater than 0 + bool add_to_worklist = verify_depth != 0; - // Contained in new_space or old_space? - VectorSet *v = C->node_arena()->contains(n) ? &new_space : &old_space; - // Check for visited in the proper space. Numberings are not unique - // across spaces so we need a separate VectorSet for each space. - if( v->test_set(n->_idx) ) return; - if (n->is_Con() && n->bottom_type() == Type::TOP) { - if (C->cached_top_node() == NULL) - C->set_cached_top_node((Node*)n); - assert(C->cached_top_node() == n, "TOP node must be unique"); - } + for (uint list_index = 0; list_index < worklist.size(); list_index++) { + n = worklist[list_index]; + + if (n->is_Con() && n->bottom_type() == Type::TOP) { + if (C->cached_top_node() == NULL) { + C->set_cached_top_node((Node*)n); + } + assert(C->cached_top_node() == n, "TOP node must be unique"); + } - for( uint i = 0; i < n->len(); i++ ) { - Node *x = n->in(i); - if (!x || x->is_top()) continue; + for (uint i = 0; i < n->len(); i++) { + Node* x = n->in(i); + if (!x || x->is_top()) { + continue; + } - // Verify my input has a def-use edge to me - if (true /*VerifyDefUse*/) { + // Verify my input has a def-use edge to me // Count use-def edges from n to x int cnt = 0; - for( uint j = 0; j < n->len(); j++ ) - if( n->in(j) == x ) + for (uint j = 0; j < n->len(); j++) { + if (n->in(j) == x) { cnt++; + } + } + // Count def-use edges from x to n uint max = x->_outcnt; - for( uint k = 0; k < max; k++ ) - if (x->_out[k] == n) + for (uint k = 0; k < max; k++) { + if (x->_out[k] == n) { cnt--; - assert( cnt == 0, "mismatched def-use edge counts" ); + } + } + assert(cnt == 0, "mismatched def-use edge counts"); + + // Contained in new_space or old_space? + VectorSet* v = C->node_arena()->contains(x) ? &new_space : &old_space; + // Check for visited in the proper space. Numberings are not unique + // across spaces so we need a separate VectorSet for each space. + if (add_to_worklist && !v->test_set(x->_idx)) { + worklist.push(x); + } } - verify_recur(x, verify_depth, old_space, new_space); + if (verify_depth > 0 && list_index == last_index_on_current_depth) { + // All nodes on this depth were processed and its inputs are on the worklist. Decrement verify_depth and + // store the current last list index which is the last node in the list with the new depth. All nodes + // added afterwards will have a new depth again. Stop adding new nodes if depth limit is reached (=0). + verify_depth--; + if (verify_depth == 0) { + add_to_worklist = false; + } + last_index_on_current_depth = worklist.size() - 1; + } } - -} - -//------------------------------verify----------------------------------------- -// Check Def-Use info for my subgraph -void Node::verify() const { - Compile* C = Compile::current(); - Node* old_top = C->cached_top_node(); - ResourceMark rm; - ResourceArea *area = Thread::current()->resource_area(); - VectorSet old_space(area), new_space(area); - verify_recur(this, -1, old_space, new_space); - C->set_cached_top_node(old_top); } #endif - //------------------------------walk------------------------------------------- // Graph walk, with both pre-order and post-order functions void Node::walk(NFunc pre, NFunc post, void *env) { diff --git a/src/hotspot/share/opto/node.hpp b/src/hotspot/share/opto/node.hpp index b8e5a422398..1bc51557590 100644 --- a/src/hotspot/share/opto/node.hpp +++ b/src/hotspot/share/opto/node.hpp @@ -1165,8 +1165,7 @@ class Node { void collect_nodes_out_all_ctrl_boundary(GrowableArray *ns) const; void verify_edges(Unique_Node_List &visited); // Verify bi-directional edges - void verify() const; // Check Def-Use info for my subgraph - static void verify_recur(const Node *n, int verify_depth, VectorSet &old_space, VectorSet &new_space); + static void verify(Node* n, int verify_depth); // This call defines a class-unique string used to identify class instances virtual const char *Name() const; diff --git a/src/hotspot/share/opto/output.cpp b/src/hotspot/share/opto/output.cpp index 02a24ddffac..d918dfac7d6 100644 --- a/src/hotspot/share/opto/output.cpp +++ b/src/hotspot/share/opto/output.cpp @@ -30,6 +30,7 @@ #include "code/debugInfoRec.hpp" #include "compiler/compileBroker.hpp" #include "compiler/compilerDirectives.hpp" +#include "compiler/disassembler.hpp" #include "compiler/oopMap.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/c2/barrierSetC2.hpp" @@ -1668,8 +1669,17 @@ void PhaseOutput::fill_buffer(CodeBuffer* cb, uint* blk_starts) { } #ifdef ASSERT - if (n->size(C->regalloc()) < (current_offset-instr_offset)) { + uint n_size = n->size(C->regalloc()); + if (n_size < (current_offset-instr_offset)) { + MachNode* mach = n->as_Mach(); n->dump(); + mach->dump_format(C->regalloc(), tty); + tty->print_cr(" n_size (%d), current_offset (%d), instr_offset (%d)", n_size, current_offset, instr_offset); + Disassembler::decode(cb->insts_begin() + instr_offset, cb->insts_begin() + current_offset + 1, tty); + tty->print_cr(" ------------------- "); + BufferBlob* blob = this->scratch_buffer_blob(); + address blob_begin = blob->content_begin(); + Disassembler::decode(blob_begin, blob_begin + n_size + 1, tty); assert(false, "wrong size of mach node"); } #endif diff --git a/src/hotspot/share/opto/parse2.cpp b/src/hotspot/share/opto/parse2.cpp index 1cf7839e5ac..a84ce26aabc 100644 --- a/src/hotspot/share/opto/parse2.cpp +++ b/src/hotspot/share/opto/parse2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2020, 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 @@ -3475,8 +3475,8 @@ void Parse::do_one_bytecode() { } #ifndef PRODUCT - IdealGraphPrinter *printer = C->printer(); - if (printer && printer->should_print(1)) { + if (C->should_print(1)) { + IdealGraphPrinter* printer = C->printer(); char buffer[256]; jio_snprintf(buffer, sizeof(buffer), "Bytecode %d: %s", bci(), Bytecodes::name(bc())); bool old = printer->traverse_outs(); diff --git a/src/hotspot/share/opto/phaseX.cpp b/src/hotspot/share/opto/phaseX.cpp index 4d157f3b1eb..53793dcd420 100644 --- a/src/hotspot/share/opto/phaseX.cpp +++ b/src/hotspot/share/opto/phaseX.cpp @@ -1005,24 +1005,22 @@ void PhaseIterGVN::verify_step(Node* n) { if (VerifyIterativeGVN) { _verify_window[_verify_counter % _verify_window_size] = n; ++_verify_counter; - ResourceMark rm; - ResourceArea* area = Thread::current()->resource_area(); - VectorSet old_space(area), new_space(area); - if (C->unique() < 1000 || - 0 == _verify_counter % (C->unique() < 10000 ? 10 : 100)) { + if (C->unique() < 1000 || 0 == _verify_counter % (C->unique() < 10000 ? 10 : 100)) { ++_verify_full_passes; - Node::verify_recur(C->root(), -1, old_space, new_space); + Node::verify(C->root(), -1); } - const int verify_depth = 4; - for ( int i = 0; i < _verify_window_size; i++ ) { + for (int i = 0; i < _verify_window_size; i++) { Node* n = _verify_window[i]; - if ( n == NULL ) continue; - if( n->in(0) == NodeSentinel ) { // xform_idom + if (n == NULL) { + continue; + } + if (n->in(0) == NodeSentinel) { // xform_idom _verify_window[i] = n->in(1); - --i; continue; + --i; + continue; } // Typical fanout is 1-2, so this call visits about 6 nodes. - Node::verify_recur(n, verify_depth, old_space, new_space); + Node::verify(n, 4); } } } diff --git a/src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp b/src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp index aac8bde7933..764f37a5019 100644 --- a/src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp +++ b/src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp @@ -172,7 +172,7 @@ void CodeBlobCollector::collect() { assert(_global_code_blobs == NULL, "checking"); // create the global list - _global_code_blobs = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(50,true); + _global_code_blobs = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(50, mtServiceability); // iterate over the stub code descriptors and put them in the list first. for (StubCodeDesc* desc = StubCodeDesc::first(); desc != NULL; desc = StubCodeDesc::next(desc)) { diff --git a/src/hotspot/share/prims/jvmtiEnv.cpp b/src/hotspot/share/prims/jvmtiEnv.cpp index cb93234b3f4..fcb2f28c9cc 100644 --- a/src/hotspot/share/prims/jvmtiEnv.cpp +++ b/src/hotspot/share/prims/jvmtiEnv.cpp @@ -1204,7 +1204,7 @@ JvmtiEnv::GetOwnedMonitorInfo(JavaThread* java_thread, jint* owned_monitor_count // growable array of jvmti monitors info on the C-heap GrowableArray *owned_monitors_list = - new (ResourceObj::C_HEAP, mtInternal) GrowableArray(1, true); + new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(1, mtServiceability); // It is only safe to perform the direct operation on the current // thread. All other usage needs to use a direct handshake for safety. @@ -1249,7 +1249,7 @@ JvmtiEnv::GetOwnedMonitorStackDepthInfo(JavaThread* java_thread, jint* monitor_i // growable array of jvmti monitors info on the C-heap GrowableArray *owned_monitors_list = - new (ResourceObj::C_HEAP, mtInternal) GrowableArray(1, true); + new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(1, mtServiceability); // It is only safe to perform the direct operation on the current // thread. All other usage needs to use a direct handshake for safety. diff --git a/src/hotspot/share/prims/jvmtiEnvBase.cpp b/src/hotspot/share/prims/jvmtiEnvBase.cpp index 782d07f1068..8d2446e4bbf 100644 --- a/src/hotspot/share/prims/jvmtiEnvBase.cpp +++ b/src/hotspot/share/prims/jvmtiEnvBase.cpp @@ -1145,7 +1145,7 @@ JvmtiEnvBase::get_object_monitor_usage(JavaThread* calling_thread, jobject objec ResourceTracker::ResourceTracker(JvmtiEnv* env) { _env = env; - _allocations = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(20, true); + _allocations = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(20, mtServiceability); _failed = false; } ResourceTracker::~ResourceTracker() { diff --git a/src/hotspot/share/prims/jvmtiEnvThreadState.cpp b/src/hotspot/share/prims/jvmtiEnvThreadState.cpp index f48aa458431..55915d5839d 100644 --- a/src/hotspot/share/prims/jvmtiEnvThreadState.cpp +++ b/src/hotspot/share/prims/jvmtiEnvThreadState.cpp @@ -96,7 +96,7 @@ JvmtiFramePops::clear_to(JvmtiFramePop& fp) { // JvmtiFramePops::JvmtiFramePops() { - _pops = new (ResourceObj::C_HEAP, mtInternal) GrowableArray (2, true); + _pops = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray (2, mtServiceability); } JvmtiFramePops::~JvmtiFramePops() { diff --git a/src/hotspot/share/prims/jvmtiExport.cpp b/src/hotspot/share/prims/jvmtiExport.cpp index d4579dfa43d..1b3bbf38e58 100644 --- a/src/hotspot/share/prims/jvmtiExport.cpp +++ b/src/hotspot/share/prims/jvmtiExport.cpp @@ -2812,7 +2812,7 @@ JvmtiDynamicCodeEventCollector::~JvmtiDynamicCodeEventCollector() { // register a stub void JvmtiDynamicCodeEventCollector::register_stub(const char* name, address start, address end) { if (_code_blobs == NULL) { - _code_blobs = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(1,true); + _code_blobs = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(1, mtServiceability); } _code_blobs->append(new JvmtiCodeBlobDesc(name, start, end)); } @@ -2838,7 +2838,7 @@ void JvmtiObjectAllocEventCollector::generate_call_for_allocated() { void JvmtiObjectAllocEventCollector::record_allocation(oop obj) { assert(is_enabled(), "Object alloc event collector is not enabled"); if (_allocated == NULL) { - _allocated = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(1, true); + _allocated = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(1, mtServiceability); } _allocated->push(obj); } diff --git a/src/hotspot/share/prims/jvmtiExtensions.cpp b/src/hotspot/share/prims/jvmtiExtensions.cpp index f82b819223e..fab91559b1a 100644 --- a/src/hotspot/share/prims/jvmtiExtensions.cpp +++ b/src/hotspot/share/prims/jvmtiExtensions.cpp @@ -49,8 +49,8 @@ static jvmtiError JNICALL IsClassUnloadingEnabled(const jvmtiEnv* env, jboolean* // event. The function and the event are registered here. // void JvmtiExtensions::register_extensions() { - _ext_functions = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(1,true); - _ext_events = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(1,true); + _ext_functions = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(1, mtServiceability); + _ext_events = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(1, mtServiceability); // register our extension function static jvmtiParamInfo func_params[] = { diff --git a/src/hotspot/share/prims/jvmtiImpl.cpp b/src/hotspot/share/prims/jvmtiImpl.cpp index 84d956f052b..b7efa2c830c 100644 --- a/src/hotspot/share/prims/jvmtiImpl.cpp +++ b/src/hotspot/share/prims/jvmtiImpl.cpp @@ -146,7 +146,7 @@ GrowableCache::~GrowableCache() { void GrowableCache::initialize(void *this_obj, void listener_fun(void *, address*) ) { _this_obj = this_obj; _listener_fun = listener_fun; - _elements = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(5,true); + _elements = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(5, mtServiceability); recache(); } diff --git a/src/hotspot/share/prims/jvmtiRawMonitor.cpp b/src/hotspot/share/prims/jvmtiRawMonitor.cpp index 437b98c9c5a..0e8d38498fc 100644 --- a/src/hotspot/share/prims/jvmtiRawMonitor.cpp +++ b/src/hotspot/share/prims/jvmtiRawMonitor.cpp @@ -36,7 +36,7 @@ JvmtiRawMonitor::QNode::QNode(Thread* thread) : _next(NULL), _prev(NULL), } GrowableArray* JvmtiPendingMonitors::_monitors = - new (ResourceObj::C_HEAP, mtInternal) GrowableArray(1, true); + new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(1, mtServiceability); void JvmtiPendingMonitors::transition_raw_monitors() { assert((Threads::number_of_threads()==1), diff --git a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp index 57fa3ffa107..ec459d47234 100644 --- a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp +++ b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp @@ -1307,10 +1307,20 @@ jvmtiError VM_RedefineClasses::load_new_class_versions(TRAPS) { the_class->link_class(THREAD); if (HAS_PENDING_EXCEPTION) { Symbol* ex_name = PENDING_EXCEPTION->klass()->name(); - log_info(redefine, class, load, exceptions)("link_class exception: '%s'", ex_name->as_C_string()); + oop message = java_lang_Throwable::message(PENDING_EXCEPTION); + if (message != NULL) { + char* ex_msg = java_lang_String::as_utf8_string(message); + log_info(redefine, class, load, exceptions)("link_class exception: '%s %s'", + ex_name->as_C_string(), ex_msg); + } else { + log_info(redefine, class, load, exceptions)("link_class exception: '%s'", + ex_name->as_C_string()); + } CLEAR_PENDING_EXCEPTION; if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) { return JVMTI_ERROR_OUT_OF_MEMORY; + } else if (ex_name == vmSymbols::java_lang_NoClassDefFoundError()) { + return JVMTI_ERROR_INVALID_CLASS; } else { return JVMTI_ERROR_INTERNAL; } diff --git a/src/hotspot/share/prims/jvmtiTagMap.cpp b/src/hotspot/share/prims/jvmtiTagMap.cpp index 352786a8d6c..d88cdaf7c54 100644 --- a/src/hotspot/share/prims/jvmtiTagMap.cpp +++ b/src/hotspot/share/prims/jvmtiTagMap.cpp @@ -821,8 +821,8 @@ class ClassFieldMap: public CHeapObj { }; ClassFieldMap::ClassFieldMap() { - _fields = new (ResourceObj::C_HEAP, mtInternal) - GrowableArray(initial_field_count, true); + _fields = new (ResourceObj::C_HEAP, mtServiceability) + GrowableArray(initial_field_count, mtServiceability); } ClassFieldMap::~ClassFieldMap() { @@ -958,8 +958,8 @@ bool ClassFieldMapCacheMark::_is_active; // record that the given InstanceKlass is caching a field map void JvmtiCachedClassFieldMap::add_to_class_list(InstanceKlass* ik) { if (_class_list == NULL) { - _class_list = new (ResourceObj::C_HEAP, mtInternal) - GrowableArray(initial_class_count, true); + _class_list = new (ResourceObj::C_HEAP, mtServiceability) + GrowableArray(initial_class_count, mtServiceability); } _class_list->push(ik); } @@ -1531,8 +1531,8 @@ class TagObjectCollector : public JvmtiTagHashmapEntryClosure { _env = env; _tags = (jlong*)tags; _tag_count = tag_count; - _object_results = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(1,true); - _tag_results = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(1,true); + _object_results = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(1, mtServiceability); + _tag_results = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(1, mtServiceability); } ~TagObjectCollector() { @@ -1674,8 +1674,8 @@ void ObjectMarker::init() { Universe::heap()->ensure_parsability(false); // no need to retire TLABs // create stacks for interesting headers - _saved_mark_stack = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(4000, true); - _saved_oop_stack = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(4000, true); + _saved_mark_stack = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(4000, mtServiceability); + _saved_oop_stack = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(4000, mtServiceability); if (UseBiasedLocking) { BiasedLocking::preserve_marks(); @@ -2663,7 +2663,7 @@ class VM_HeapWalkOperation: public VM_Operation { bool _reporting_string_values; GrowableArray* create_visit_stack() { - return new (ResourceObj::C_HEAP, mtInternal) GrowableArray(initial_visit_stack_size, true); + return new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(initial_visit_stack_size, mtServiceability); } // accessors diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index bfd408c2e16..42461550fe4 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -548,24 +548,10 @@ static SpecialFlag const special_jvm_flags[] = { { "SharedReadOnlySize", JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() }, { "SharedMiscDataSize", JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() }, { "SharedMiscCodeSize", JDK_Version::undefined(), JDK_Version::jdk(10), JDK_Version::undefined() }, - { "BindGCTaskThreadsToCPUs", JDK_Version::undefined(), JDK_Version::jdk(14), JDK_Version::jdk(16) }, - { "UseGCTaskAffinity", JDK_Version::undefined(), JDK_Version::jdk(14), JDK_Version::jdk(16) }, - { "GCTaskTimeStampEntries", JDK_Version::undefined(), JDK_Version::jdk(14), JDK_Version::jdk(16) }, - { "G1RSetScanBlockSize", JDK_Version::jdk(14), JDK_Version::jdk(15), JDK_Version::jdk(16) }, - { "UseParallelOldGC", JDK_Version::jdk(14), JDK_Version::jdk(15), JDK_Version::jdk(16) }, - { "CompactFields", JDK_Version::jdk(14), JDK_Version::jdk(15), JDK_Version::jdk(16) }, - { "FieldsAllocationStyle", JDK_Version::jdk(14), JDK_Version::jdk(15), JDK_Version::jdk(16) }, -#ifndef X86 - { "UseSSE", JDK_Version::undefined(), JDK_Version::jdk(15), JDK_Version::jdk(16) }, -#endif // !X86 - { "UseAdaptiveGCBoundary", JDK_Version::undefined(), JDK_Version::jdk(15), JDK_Version::jdk(16) }, - { "MonitorBound", JDK_Version::jdk(14), JDK_Version::jdk(15), JDK_Version::jdk(16) }, -#ifdef AARCH64 - { "UseBarriersForVolatile", JDK_Version::undefined(), JDK_Version::jdk(15), JDK_Version::jdk(16) }, +#ifdef BSD + { "UseBsdPosixThreadCPUClocks", JDK_Version::undefined(), JDK_Version::jdk(16), JDK_Version::jdk(17) }, + { "UseOprofile", JDK_Version::undefined(), JDK_Version::jdk(16), JDK_Version::jdk(17) }, #endif - { "UseLWPSynchronization", JDK_Version::undefined(), JDK_Version::jdk(15), JDK_Version::jdk(16) }, - { "BranchOnRegister", JDK_Version::undefined(), JDK_Version::jdk(15), JDK_Version::jdk(16) }, - { "LIRFillDelaySlots", JDK_Version::undefined(), JDK_Version::jdk(15), JDK_Version::jdk(16) }, #ifdef TEST_VERIFY_SPECIAL_JVM_FLAGS // These entries will generate build errors. Their purpose is to test the macros. @@ -1467,11 +1453,13 @@ bool Arguments::add_property(const char* prop, PropertyWriteable writeable, Prop value = &prop[key_len + 1]; } +#if INCLUDE_CDS if (is_internal_module_property(key) || strcmp(key, "jdk.module.main") == 0) { MetaspaceShared::disable_optimized_module_handling(); log_info(cds)("Using optimized module handling disabled due to incompatible property: %s=%s", key, value); } +#endif if (strcmp(key, "java.compiler") == 0) { process_java_compiler_argument(value); @@ -2526,8 +2514,10 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m // -bootclasspath/a: } else if (match_option(option, "-Xbootclasspath/a:", &tail)) { Arguments::append_sysclasspath(tail); +#if INCLUDE_CDS MetaspaceShared::disable_optimized_module_handling(); log_info(cds)("Using optimized module handling disabled due to bootclasspath was appended"); +#endif // -bootclasspath/p: } else if (match_option(option, "-Xbootclasspath/p:", &tail)) { jio_fprintf(defaultStream::output_stream(), @@ -3148,7 +3138,7 @@ void Arguments::add_patch_mod_prefix(const char* module_name, const char* path, // Create GrowableArray lazily, only if --patch-module has been specified if (_patch_mod_prefix == NULL) { - _patch_mod_prefix = new (ResourceObj::C_HEAP, mtArguments) GrowableArray(10, true); + _patch_mod_prefix = new (ResourceObj::C_HEAP, mtArguments) GrowableArray(10, mtArguments); } _patch_mod_prefix->push(new ModulePatchPath(module_name, path)); @@ -3404,7 +3394,7 @@ class ScopedVMInitArgs : public StackObj { int length = args->nOptions + args_to_insert->nOptions - 1; GrowableArray *options = new (ResourceObj::C_HEAP, mtArguments) - GrowableArray(length, true); // Construct new option array + GrowableArray(length, mtArguments); // Construct new option array for (int i = 0; i < args->nOptions; i++) { if (i == vm_options_file_pos) { // insert the new options starting at the same place as the @@ -3516,7 +3506,7 @@ jint Arguments::parse_vm_options_file(const char* file_name, ScopedVMInitArgs* v } jint Arguments::parse_options_buffer(const char* name, char* buffer, const size_t buf_len, ScopedVMInitArgs* vm_args) { - GrowableArray *options = new (ResourceObj::C_HEAP, mtArguments) GrowableArray(2, true); // Construct option array + GrowableArray *options = new (ResourceObj::C_HEAP, mtArguments) GrowableArray(2, mtArguments); // Construct option array // some pointers to help with parsing char *buffer_end = buffer + buf_len; diff --git a/src/hotspot/share/runtime/biasedLocking.cpp b/src/hotspot/share/runtime/biasedLocking.cpp index 0577e772a11..67156f036bb 100644 --- a/src/hotspot/share/runtime/biasedLocking.cpp +++ b/src/hotspot/share/runtime/biasedLocking.cpp @@ -905,8 +905,8 @@ void BiasedLocking::preserve_marks() { // monitors in a prepass and, if they are biased, preserve their // mark words here. This should be a relatively small set of objects // especially compared to the number of objects in the heap. - _preserved_mark_stack = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(10, true); - _preserved_oop_stack = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(10, true); + _preserved_mark_stack = new (ResourceObj::C_HEAP, mtGC) GrowableArray(10, mtGC); + _preserved_oop_stack = new (ResourceObj::C_HEAP, mtGC) GrowableArray(10, mtGC); ResourceMark rm; Thread* cur = Thread::current(); diff --git a/src/hotspot/share/runtime/flags/jvmFlagConstraintList.cpp b/src/hotspot/share/runtime/flags/jvmFlagConstraintList.cpp index 7475e1b58cd..3d21cfdf060 100644 --- a/src/hotspot/share/runtime/flags/jvmFlagConstraintList.cpp +++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintList.cpp @@ -250,7 +250,7 @@ JVMFlagConstraint::ConstraintType JVMFlagConstraintList::_validating_type = JVMF // Check the ranges of all flags that have them or print them out and exit if requested void JVMFlagConstraintList::init(void) { - _constraints = new (ResourceObj::C_HEAP, mtArguments) GrowableArray(INITIAL_CONSTRAINTS_SIZE, true); + _constraints = new (ResourceObj::C_HEAP, mtArguments) GrowableArray(INITIAL_CONSTRAINTS_SIZE, mtArguments); EMIT_CONSTRAINT_START diff --git a/src/hotspot/share/runtime/flags/jvmFlagRangeList.cpp b/src/hotspot/share/runtime/flags/jvmFlagRangeList.cpp index 564072e2dfe..1751a92056f 100644 --- a/src/hotspot/share/runtime/flags/jvmFlagRangeList.cpp +++ b/src/hotspot/share/runtime/flags/jvmFlagRangeList.cpp @@ -315,7 +315,7 @@ GrowableArray* JVMFlagRangeList::_ranges = NULL; // Check the ranges of all flags that have them void JVMFlagRangeList::init(void) { - _ranges = new (ResourceObj::C_HEAP, mtArguments) GrowableArray(INITIAL_RANGES_SIZE, true); + _ranges = new (ResourceObj::C_HEAP, mtArguments) GrowableArray(INITIAL_RANGES_SIZE, mtArguments); EMIT_RANGE_START diff --git a/src/hotspot/share/runtime/perfData.cpp b/src/hotspot/share/runtime/perfData.cpp index d410e337bca..9ce8f3fff93 100644 --- a/src/hotspot/share/runtime/perfData.cpp +++ b/src/hotspot/share/runtime/perfData.cpp @@ -563,12 +563,12 @@ PerfLongCounter* PerfDataManager::create_long_counter(CounterNS ns, PerfDataList::PerfDataList(int length) { - _set = new(ResourceObj::C_HEAP, mtInternal) PerfDataArray(length, true); + _set = new(ResourceObj::C_HEAP, mtInternal) PerfDataArray(length, mtInternal); } PerfDataList::PerfDataList(PerfDataList* p) { - _set = new(ResourceObj::C_HEAP, mtInternal) PerfDataArray(p->length(), true); + _set = new(ResourceObj::C_HEAP, mtInternal) PerfDataArray(p->length(), mtInternal); _set->appendAll(p->get_impl()); } diff --git a/src/hotspot/share/runtime/reflectionUtils.cpp b/src/hotspot/share/runtime/reflectionUtils.cpp index a5fac98bad2..77274e05a8d 100644 --- a/src/hotspot/share/runtime/reflectionUtils.cpp +++ b/src/hotspot/share/runtime/reflectionUtils.cpp @@ -69,7 +69,7 @@ bool KlassStream::eos() { GrowableArray *FilteredFieldsMap::_filtered_fields = - new (ResourceObj::C_HEAP, mtInternal) GrowableArray(3,true); + new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(3, mtServiceability); void FilteredFieldsMap::initialize() { diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp index 55e44e9026a..fb00c453fe3 100644 --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -2971,7 +2971,7 @@ AdapterHandlerEntry* AdapterHandlerLibrary::get_adapter0(const methodHandle& met StubRoutines::throw_AbstractMethodError_entry(), wrong_method_abstract, wrong_method_abstract, wrong_method_abstract, wrong_method_abstract, wrong_method_abstract); - GrowableArray* heap_sig = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(sig_cc_ro.length(), true); + GrowableArray* heap_sig = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(sig_cc_ro.length(), mtInternal); heap_sig->appendAll(&sig_cc_ro); entry->set_sig_cc(heap_sig); return entry; @@ -3027,7 +3027,7 @@ AdapterHandlerEntry* AdapterHandlerLibrary::get_adapter0(const methodHandle& met if (ces.has_scalarized_args()) { // Save a C heap allocated version of the scalarized signature and store it in the adapter - GrowableArray* heap_sig = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(sig_cc.length(), true); + GrowableArray* heap_sig = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(sig_cc.length(), mtInternal); heap_sig->appendAll(&sig_cc); entry->set_sig_cc(heap_sig); } diff --git a/src/hotspot/share/runtime/thread.cpp b/src/hotspot/share/runtime/thread.cpp index 0fe8f8eccb2..a1444f87f98 100644 --- a/src/hotspot/share/runtime/thread.cpp +++ b/src/hotspot/share/runtime/thread.cpp @@ -233,7 +233,7 @@ Thread::Thread() { set_resource_area(new (mtThread)ResourceArea()); DEBUG_ONLY(_current_resource_mark = NULL;) set_handle_area(new (mtThread) HandleArea(NULL)); - set_metadata_handles(new (ResourceObj::C_HEAP, mtClass) GrowableArray(30, true)); + set_metadata_handles(new (ResourceObj::C_HEAP, mtClass) GrowableArray(30, mtClass)); set_active_handles(NULL); set_free_handle_block(NULL); set_last_handle_mark(NULL); diff --git a/src/hotspot/share/runtime/unhandledOops.cpp b/src/hotspot/share/runtime/unhandledOops.cpp index b92e01d99a4..c2ff6b32361 100644 --- a/src/hotspot/share/runtime/unhandledOops.cpp +++ b/src/hotspot/share/runtime/unhandledOops.cpp @@ -35,8 +35,8 @@ const int free_list_size = 256; UnhandledOops::UnhandledOops(Thread* thread) { _thread = thread; - _oop_list = new (ResourceObj::C_HEAP, mtInternal) - GrowableArray(free_list_size, true); + _oop_list = new (ResourceObj::C_HEAP, mtThread) + GrowableArray(free_list_size, mtThread); _level = 0; } diff --git a/src/hotspot/share/runtime/vframe_hp.cpp b/src/hotspot/share/runtime/vframe_hp.cpp index d9fcd7973f9..0a80237d0cb 100644 --- a/src/hotspot/share/runtime/vframe_hp.cpp +++ b/src/hotspot/share/runtime/vframe_hp.cpp @@ -117,7 +117,7 @@ void compiledVFrame::update_deferred_value(BasicType type, int index, jvalue val } else { // No deferred updates pending for this thread. // allocate in C heap - deferred = new(ResourceObj::C_HEAP, mtCompiler) GrowableArray (1, true); + deferred = new(ResourceObj::C_HEAP, mtCompiler) GrowableArray (1, mtCompiler); thread()->set_deferred_locals(deferred); } if (locals == NULL) { @@ -329,7 +329,7 @@ jvmtiDeferredLocalVariableSet::jvmtiDeferredLocalVariableSet(Method* method, int _id = id; _vframe_id = vframe_id; // Alway will need at least one, must be on C heap - _locals = new(ResourceObj::C_HEAP, mtCompiler) GrowableArray (1, true); + _locals = new(ResourceObj::C_HEAP, mtCompiler) GrowableArray (1, mtCompiler); } jvmtiDeferredLocalVariableSet::~jvmtiDeferredLocalVariableSet() { diff --git a/src/hotspot/share/services/diagnosticArgument.cpp b/src/hotspot/share/services/diagnosticArgument.cpp index f1337801f46..f10fe6c4641 100644 --- a/src/hotspot/share/services/diagnosticArgument.cpp +++ b/src/hotspot/share/services/diagnosticArgument.cpp @@ -30,7 +30,7 @@ #include "services/diagnosticArgument.hpp" StringArrayArgument::StringArrayArgument() { - _array = new(ResourceObj::C_HEAP, mtInternal)GrowableArray(32, true); + _array = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(32, mtServiceability); assert(_array != NULL, "Sanity check"); } diff --git a/src/hotspot/share/services/heapDumper.cpp b/src/hotspot/share/services/heapDumper.cpp index d58e6155f69..fee88404f1f 100644 --- a/src/hotspot/share/services/heapDumper.cpp +++ b/src/hotspot/share/services/heapDumper.cpp @@ -1536,7 +1536,7 @@ class VM_HeapDumper : public VM_GC_Operation, public AbstractGangTask { AbstractGangTask("dump heap") { _local_writer = writer; _gc_before_heap_dump = gc_before_heap_dump; - _klass_map = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(INITIAL_CLASS_COUNT, true); + _klass_map = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(INITIAL_CLASS_COUNT, mtServiceability); _stack_traces = NULL; _num_threads = 0; if (oome) { diff --git a/src/hotspot/share/services/memoryService.cpp b/src/hotspot/share/services/memoryService.cpp index 1e65d8a75c3..c5342eaed37 100644 --- a/src/hotspot/share/services/memoryService.cpp +++ b/src/hotspot/share/services/memoryService.cpp @@ -44,13 +44,13 @@ #include "utilities/macros.hpp" GrowableArray* MemoryService::_pools_list = - new (ResourceObj::C_HEAP, mtInternal) GrowableArray(init_pools_list_size, true); + new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(init_pools_list_size, mtServiceability); GrowableArray* MemoryService::_managers_list = - new (ResourceObj::C_HEAP, mtInternal) GrowableArray(init_managers_list_size, true); + new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(init_managers_list_size, mtServiceability); MemoryManager* MemoryService::_code_cache_manager = NULL; GrowableArray* MemoryService::_code_heap_pools = - new (ResourceObj::C_HEAP, mtInternal) GrowableArray(init_code_heap_pools_size, true); + new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(init_code_heap_pools_size, mtServiceability); MemoryPool* MemoryService::_metaspace_pool = NULL; MemoryPool* MemoryService::_compressed_class_pool = NULL; diff --git a/src/hotspot/share/services/threadService.cpp b/src/hotspot/share/services/threadService.cpp index 5a7a9e2674b..6b92e5c585f 100644 --- a/src/hotspot/share/services/threadService.cpp +++ b/src/hotspot/share/services/threadService.cpp @@ -589,7 +589,7 @@ StackFrameInfo::StackFrameInfo(javaVFrame* jvf, bool with_lock_info) { GrowableArray* list = jvf->locked_monitors(); int length = list->length(); if (length > 0) { - _locked_monitors = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(length, true); + _locked_monitors = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(length, mtServiceability); for (int i = 0; i < length; i++) { MonitorInfo* monitor = list->at(i); assert(monitor->owner() != NULL, "This monitor must have an owning object"); @@ -646,11 +646,11 @@ class InflatedMonitorsClosure: public MonitorClosure { ThreadStackTrace::ThreadStackTrace(JavaThread* t, bool with_locked_monitors) { _thread = t; - _frames = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(INITIAL_ARRAY_SIZE, true); + _frames = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(INITIAL_ARRAY_SIZE, mtServiceability); _depth = 0; _with_locked_monitors = with_locked_monitors; if (_with_locked_monitors) { - _jni_locked_monitors = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(INITIAL_ARRAY_SIZE, true); + _jni_locked_monitors = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(INITIAL_ARRAY_SIZE, mtServiceability); } else { _jni_locked_monitors = NULL; } @@ -776,7 +776,7 @@ void ConcurrentLocksDump::dump_at_safepoint() { // dump all locked concurrent locks assert(SafepointSynchronize::is_at_safepoint(), "all threads are stopped"); - GrowableArray* aos_objects = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(INITIAL_ARRAY_SIZE, true /* C_heap */); + GrowableArray* aos_objects = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(INITIAL_ARRAY_SIZE, mtServiceability); // Find all instances of AbstractOwnableSynchronizer HeapInspection::find_instances_at_safepoint(SystemDictionary::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass(), @@ -850,7 +850,7 @@ void ConcurrentLocksDump::print_locks_on(JavaThread* t, outputStream* st) { ThreadConcurrentLocks::ThreadConcurrentLocks(JavaThread* thread) { _thread = thread; - _owned_locks = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(INITIAL_ARRAY_SIZE, true); + _owned_locks = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(INITIAL_ARRAY_SIZE, mtServiceability); _next = NULL; } @@ -962,7 +962,7 @@ void ThreadSnapshot::metadata_do(void f(Metadata*)) { DeadlockCycle::DeadlockCycle() { _is_deadlock = false; - _threads = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(INITIAL_ARRAY_SIZE, true); + _threads = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(INITIAL_ARRAY_SIZE, mtServiceability); _next = NULL; } diff --git a/src/hotspot/share/utilities/growableArray.hpp b/src/hotspot/share/utilities/growableArray.hpp index 74725ad8e42..49003d0192f 100644 --- a/src/hotspot/share/utilities/growableArray.hpp +++ b/src/hotspot/share/utilities/growableArray.hpp @@ -107,15 +107,14 @@ class GenericGrowableArray : public ResourceObj { // This GA will use the resource stack for storage if c_heap==false, // Else it will use the C heap. Use clear_and_deallocate to avoid leaks. - GenericGrowableArray(int initial_size, int initial_len, bool c_heap, MEMFLAGS flags = mtNone) { + GenericGrowableArray(int initial_size, int initial_len, MEMFLAGS flags) { _len = initial_len; _max = initial_size; _memflags = flags; - // memory type has to be specified for C heap allocation - assert(!(c_heap && flags == mtNone), "memory type not specified for C heap object"); - assert(_len >= 0 && _len <= _max, "initial_len too big"); + + const bool c_heap = flags != mtNone; _arena = (c_heap ? (Arena*)1 : NULL); set_nesting(); assert(!on_C_heap() || allocated_on_C_heap(), "growable array must be on C heap if elements are"); @@ -142,12 +141,6 @@ class GenericGrowableArray : public ResourceObj { void* raw_allocate(int elementSize); - // some uses pass the Thread explicitly for speed (4990299 tuning) - void* raw_allocate(Thread* thread, int elementSize) { - assert(on_stack(), "fast ResourceObj path only"); - return (void*)resource_allocate_bytes(thread, elementSize * _max); - } - void free_C_heap(void* elements); }; @@ -169,14 +162,10 @@ template class GrowableArray : public GenericGrowableArray { void grow(int j); void raw_at_put_grow(int i, const E& p, const E& fill); void clear_and_deallocate(); - public: - GrowableArray(Thread* thread, int initial_size) : GenericGrowableArray(initial_size, 0, false) { - _data = (E*)raw_allocate(thread, sizeof(E)); - for (int i = 0; i < _max; i++) ::new ((void*)&_data[i]) E(); - } - GrowableArray(int initial_size, bool C_heap = false, MEMFLAGS F = mtInternal) - : GenericGrowableArray(initial_size, 0, C_heap, F) { +public: + GrowableArray(int initial_size, MEMFLAGS F = mtNone) + : GenericGrowableArray(initial_size, 0, F) { _data = (E*)raw_allocate(sizeof(E)); // Needed for Visual Studio 2012 and older #ifdef _MSC_VER @@ -185,8 +174,8 @@ template class GrowableArray : public GenericGrowableArray { for (int i = 0; i < _max; i++) ::new ((void*)&_data[i]) E(); } - GrowableArray(int initial_size, int initial_len, const E& filler, bool C_heap = false, MEMFLAGS memflags = mtInternal) - : GenericGrowableArray(initial_size, initial_len, C_heap, memflags) { + GrowableArray(int initial_size, int initial_len, const E& filler, MEMFLAGS memflags = mtNone) + : GenericGrowableArray(initial_size, initial_len, memflags) { _data = (E*)raw_allocate(sizeof(E)); int i = 0; for (; i < _len; i++) ::new ((void*)&_data[i]) E(filler); @@ -204,7 +193,7 @@ template class GrowableArray : public GenericGrowableArray { for (; i < _max; i++) ::new ((void*)&_data[i]) E(); } - GrowableArray() : GenericGrowableArray(2, 0, false) { + GrowableArray() : GenericGrowableArray(2, 0, mtNone) { _data = (E*)raw_allocate(sizeof(E)); ::new ((void*)&_data[0]) E(); ::new ((void*)&_data[1]) E(); diff --git a/src/hotspot/share/utilities/hashtable.inline.hpp b/src/hotspot/share/utilities/hashtable.inline.hpp index 89a87eb3d5f..11c5d33719b 100644 --- a/src/hotspot/share/utilities/hashtable.inline.hpp +++ b/src/hotspot/share/utilities/hashtable.inline.hpp @@ -73,7 +73,7 @@ template inline void BasicHashtable::initialize(int table_size, _first_free_entry = NULL; _end_block = NULL; _number_of_entries = number_of_entries; - _entry_blocks = new(ResourceObj::C_HEAP, F) GrowableArray(4, true, F); + _entry_blocks = new(ResourceObj::C_HEAP, F) GrowableArray(4, F); } diff --git a/src/hotspot/share/utilities/histogram.cpp b/src/hotspot/share/utilities/histogram.cpp index 6787fce2f33..e2bff72e59a 100644 --- a/src/hotspot/share/utilities/histogram.cpp +++ b/src/hotspot/share/utilities/histogram.cpp @@ -70,7 +70,7 @@ int Histogram::sort_helper(HistogramElement** e1, HistogramElement** e2) { Histogram::Histogram(const char* title,int estimatedCount) { _title = title; - _elements = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(estimatedCount,true); + _elements = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(estimatedCount, mtServiceability); } void Histogram::add_element(HistogramElement* element) { diff --git a/src/java.base/share/classes/com/sun/crypto/provider/HmacCore.java b/src/java.base/share/classes/com/sun/crypto/provider/HmacCore.java index 8542cbce055..baa85ab20d7 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/HmacCore.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/HmacCore.java @@ -75,6 +75,7 @@ abstract class HmacCore extends MacSpi implements Cloneable { } else { String noCloneProv = md.getProvider().getName(); // if no Sun provider, use provider list + md = null; Provider[] provs = Security.getProviders(); for (Provider p : provs) { try { @@ -90,6 +91,10 @@ abstract class HmacCore extends MacSpi implements Cloneable { continue; } } + if (md == null) { + throw new NoSuchAlgorithmException + ("No Cloneable digest found for " + digestAlgo); + } } } this.md = md; diff --git a/src/java.base/share/classes/java/lang/Class.java b/src/java.base/share/classes/java/lang/Class.java index b2181209e8b..61ef4bcc1e5 100644 --- a/src/java.base/share/classes/java/lang/Class.java +++ b/src/java.base/share/classes/java/lang/Class.java @@ -4459,9 +4459,11 @@ public Optional describeConstable() { * features of the Java language.} * * Returns an array containing {@code ClassDesc} objects representing all the - * direct subclasses or direct implementation classes permitted to extend or implement this class or interface - * if it is sealed. If this {@code Class} object represents a primitive type, {@code void}, an array type, - * or a class or interface that is not sealed, an empty array is returned. + * direct subclasses or direct implementation classes permitted to extend or + * implement this class or interface if it is sealed. The order of such elements + * is unspecified. If this {@code Class} object represents a primitive type, + * {@code void}, an array type, or a class or interface that is not sealed, + * an empty array is returned. * * @return an array of class descriptors of all the permitted subclasses of this class or interface * diff --git a/src/java.base/share/classes/java/lang/StringConcatHelper.java b/src/java.base/share/classes/java/lang/StringConcatHelper.java index 7e676307865..641def5bb93 100644 --- a/src/java.base/share/classes/java/lang/StringConcatHelper.java +++ b/src/java.base/share/classes/java/lang/StringConcatHelper.java @@ -406,6 +406,14 @@ static String newString(byte[] buf, long indexCoder) { static String simpleConcat(Object first, Object second) { String s1 = stringOf(first); String s2 = stringOf(second); + if (s1.isEmpty()) { + // newly created string required, see JLS 15.18.1 + return new String(s2); + } + if (s2.isEmpty()) { + // newly created string required, see JLS 15.18.1 + return new String(s1); + } // start "mixing" in length and coder or arguments, order is not // important long indexCoder = mix(initialCoder(), s1); diff --git a/src/java.base/share/classes/java/security/KeyStore.java b/src/java.base/share/classes/java/security/KeyStore.java index eeb1ee559b1..bec6886b28d 100644 --- a/src/java.base/share/classes/java/security/KeyStore.java +++ b/src/java.base/share/classes/java/security/KeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, 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 @@ -1762,35 +1762,33 @@ private static final KeyStore getInstance(File file, char[] password, dataStream.mark(Integer.MAX_VALUE); // Detect the keystore type - for (String type : Security.getAlgorithms("KeyStore")) { - Object[] objs = null; - - try { - objs = Security.getImpl(type, "KeyStore", (String)null); - - KeyStoreSpi impl = (KeyStoreSpi)objs[0]; - if (impl.engineProbe(dataStream)) { - - if (kdebug != null) { - kdebug.println(type + " keystore detected: " + - file); + for (Provider p : Security.getProviders()) { + for (Provider.Service s : p.getServices()) { + if (s.getType().equals("KeyStore")) { + try { + KeyStoreSpi impl = (KeyStoreSpi) s.newInstance(null); + if (impl.engineProbe(dataStream)) { + if (kdebug != null) { + kdebug.println(s.getAlgorithm() + + " keystore detected: " + file); + } + keystore = new KeyStore(impl, p, s.getAlgorithm()); + break; + } + } catch (NoSuchAlgorithmException e) { + // ignore + if (kdebug != null) { + kdebug.println("not found - " + e); + } + } catch (IOException e) { + // ignore + if (kdebug != null) { + kdebug.println("I/O error in " + file + " - " + e); + } } - - keystore = new KeyStore(impl, (Provider)objs[1], type); - break; - } - } catch (NoSuchAlgorithmException | NoSuchProviderException e) { - // ignore - if (kdebug != null) { - kdebug.println(type + " not found - " + e); - } - } catch (IOException e) { - // ignore - if (kdebug != null) { - kdebug.println("I/O error in " + file + " - " + e); + dataStream.reset(); // prepare the stream for the next probe } } - dataStream.reset(); // prepare the stream for the next probe } // Load the keystore data diff --git a/src/java.base/share/classes/java/security/MessageDigest.java b/src/java.base/share/classes/java/security/MessageDigest.java index 6bc1ce48160..3660e8e2b40 100644 --- a/src/java.base/share/classes/java/security/MessageDigest.java +++ b/src/java.base/share/classes/java/security/MessageDigest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, 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 @@ -131,6 +131,12 @@ protected MessageDigest(String algorithm) { this.algorithm = algorithm; } + // private constructor used only by Delegate class + private MessageDigest(String algorithm, Provider p) { + this.algorithm = algorithm; + this.provider = p; + } + /** * Returns a MessageDigest object that implements the specified digest * algorithm. @@ -178,10 +184,11 @@ public static MessageDigest getInstance(String algorithm) (String)null); if (objs[0] instanceof MessageDigest) { md = (MessageDigest)objs[0]; + md.provider = (Provider)objs[1]; } else { - md = new Delegate((MessageDigestSpi)objs[0], algorithm); + md = Delegate.of((MessageDigestSpi)objs[0], algorithm, + (Provider) objs[1]); } - md.provider = (Provider)objs[1]; if (!skipDebug && pdebug != null) { pdebug.println("MessageDigest." + algorithm + @@ -245,8 +252,8 @@ public static MessageDigest getInstance(String algorithm, String provider) return md; } else { MessageDigest delegate = - new Delegate((MessageDigestSpi)objs[0], algorithm); - delegate.provider = (Provider)objs[1]; + Delegate.of((MessageDigestSpi)objs[0], algorithm, + (Provider)objs[1]); return delegate; } } @@ -298,8 +305,8 @@ public static MessageDigest getInstance(String algorithm, return md; } else { MessageDigest delegate = - new Delegate((MessageDigestSpi)objs[0], algorithm); - delegate.provider = (Provider)objs[1]; + Delegate.of((MessageDigestSpi)objs[0], algorithm, + (Provider)objs[1]); return delegate; } } @@ -547,8 +554,6 @@ public Object clone() throws CloneNotSupportedException { } - - /* * The following class allows providers to extend from MessageDigestSpi * rather than from MessageDigest. It represents a MessageDigest with an @@ -563,14 +568,45 @@ public Object clone() throws CloneNotSupportedException { * and its original parent (Object). */ - static class Delegate extends MessageDigest implements MessageDigestSpi2 { + private static class Delegate extends MessageDigest + implements MessageDigestSpi2 { + // use this class for spi objects which implements Cloneable + private static final class CloneableDelegate extends Delegate + implements Cloneable { + + private CloneableDelegate(MessageDigestSpi digestSpi, + String algorithm, Provider p) { + super(digestSpi, algorithm, p); + } + } // The provider implementation (delegate) - private MessageDigestSpi digestSpi; + private final MessageDigestSpi digestSpi; + + // factory method used by MessageDigest class to create Delegate objs + static Delegate of(MessageDigestSpi digestSpi, String algo, + Provider p) { + Objects.requireNonNull(digestSpi); + boolean isCloneable = (digestSpi instanceof Cloneable); + // Spi impls from SunPKCS11 provider implement Cloneable but their + // clone() may throw CloneNotSupportException + if (isCloneable && p.getName().startsWith("SunPKCS11") && + p.getClass().getModule().getName().equals + ("jdk.crypto.cryptoki")) { + try { + digestSpi.clone(); + } catch (CloneNotSupportedException cnse) { + isCloneable = false; + } + } + return (isCloneable? new CloneableDelegate(digestSpi, algo, p) : + new Delegate(digestSpi, algo, p)); + } - // constructor - public Delegate(MessageDigestSpi digestSpi, String algorithm) { - super(algorithm); + // private constructor + private Delegate(MessageDigestSpi digestSpi, String algorithm, + Provider p) { + super(algorithm, p); this.digestSpi = digestSpi; } @@ -582,17 +618,16 @@ public Delegate(MessageDigestSpi digestSpi, String algorithm) { * @throws CloneNotSupportedException if this is called on a * delegate that does not support {@code Cloneable}. */ + @Override public Object clone() throws CloneNotSupportedException { - if (digestSpi instanceof Cloneable) { - MessageDigestSpi digestSpiClone = - (MessageDigestSpi)digestSpi.clone(); + if (this instanceof Cloneable) { // Because 'algorithm', 'provider', and 'state' are private // members of our supertype, we must perform a cast to // access them. - MessageDigest that = - new Delegate(digestSpiClone, - ((MessageDigest)this).algorithm); - that.provider = ((MessageDigest)this).provider; + MessageDigest that = new CloneableDelegate( + (MessageDigestSpi)digestSpi.clone(), + ((MessageDigest)this).algorithm, + ((MessageDigest)this).provider); that.state = ((MessageDigest)this).state; return that; } else { @@ -600,22 +635,27 @@ public Object clone() throws CloneNotSupportedException { } } + @Override protected int engineGetDigestLength() { return digestSpi.engineGetDigestLength(); } + @Override protected void engineUpdate(byte input) { digestSpi.engineUpdate(input); } + @Override protected void engineUpdate(byte[] input, int offset, int len) { digestSpi.engineUpdate(input, offset, len); } + @Override protected void engineUpdate(ByteBuffer input) { digestSpi.engineUpdate(input); } + @Override public void engineUpdate(SecretKey key) throws InvalidKeyException { if (digestSpi instanceof MessageDigestSpi2) { ((MessageDigestSpi2)digestSpi).engineUpdate(key); @@ -624,15 +664,19 @@ public void engineUpdate(SecretKey key) throws InvalidKeyException { ("Digest does not support update of SecretKey object"); } } + + @Override protected byte[] engineDigest() { return digestSpi.engineDigest(); } + @Override protected int engineDigest(byte[] buf, int offset, int len) throws DigestException { return digestSpi.engineDigest(buf, offset, len); } + @Override protected void engineReset() { digestSpi.engineReset(); } diff --git a/src/java.base/share/classes/java/security/Provider.java b/src/java.base/share/classes/java/security/Provider.java index 5ec8370aa88..6a7512018e8 100644 --- a/src/java.base/share/classes/java/security/Provider.java +++ b/src/java.base/share/classes/java/security/Provider.java @@ -858,10 +858,18 @@ private void check(String directive) { // serviceMap changed since last call to getServices() private volatile transient boolean servicesChanged; + // Map used to keep track of legacy registration + private transient Map legacyStrings; + // Map // used for services added via putService(), initialized on demand private transient Map serviceMap; + // For backward compatibility, the registration ordering of + // SecureRandom (RNG) algorithms needs to be preserved for + // "new SecureRandom()" calls when this provider is used + private transient Set prngServices; + // Map // used for services added via legacy methods, init on demand private transient Map legacyMap; @@ -913,12 +921,18 @@ private void readObject(ObjectInputStream in) putAll(copy); } - private static boolean isProviderInfo(Object key) { + // check whether to update 'legacyString' with the specified key + private boolean checkLegacy(Object key) { String keyString = (String)key; if (keyString.startsWith("Provider.")) { - return true; + return false; + } + + legacyChanged = true; + if (legacyStrings == null) { + legacyStrings = new LinkedHashMap<>(); } - return false; + return true; } /** @@ -934,20 +948,20 @@ private void implPutAll(Map t) { private Object implRemove(Object key) { if (key instanceof String) { - if (isProviderInfo(key)) { + if (!checkLegacy(key)) { return null; } - legacyChanged = true; + legacyStrings.remove((String)key); } return super.remove(key); } private boolean implRemove(Object key, Object value) { if (key instanceof String && value instanceof String) { - if (isProviderInfo(key)) { + if (!checkLegacy(key)) { return false; } - legacyChanged = true; + legacyStrings.remove((String)key, (String)value); } return super.remove(key, value); } @@ -955,20 +969,21 @@ private boolean implRemove(Object key, Object value) { private boolean implReplace(Object key, Object oldValue, Object newValue) { if ((key instanceof String) && (oldValue instanceof String) && (newValue instanceof String)) { - if (isProviderInfo(key)) { + if (!checkLegacy(key)) { return false; } - legacyChanged = true; + legacyStrings.replace((String)key, (String)oldValue, + (String)newValue); } return super.replace(key, oldValue, newValue); } private Object implReplace(Object key, Object value) { if ((key instanceof String) && (value instanceof String)) { - if (isProviderInfo(key)) { + if (!checkLegacy(key)) { return null; } - legacyChanged = true; + legacyStrings.replace((String)key, (String)value); } return super.replace(key, value); } @@ -977,17 +992,26 @@ private Object implReplace(Object key, Object value) { private void implReplaceAll(BiFunction function) { legacyChanged = true; + if (legacyStrings == null) { + legacyStrings = new LinkedHashMap<>(); + } else { + legacyStrings.replaceAll((BiFunction) function); + } super.replaceAll(function); } @SuppressWarnings("unchecked") // Function must actually operate over strings - private Object implMerge(Object key, Object value, BiFunction remappingFunction) { + private Object implMerge(Object key, Object value, + BiFunction + remappingFunction) { if ((key instanceof String) && (value instanceof String)) { - if (isProviderInfo(key)) { + if (!checkLegacy(key)) { return null; } - legacyChanged = true; + legacyStrings.merge((String)key, (String)value, + (BiFunction) remappingFunction); } return super.merge(key, value, remappingFunction); } @@ -996,10 +1020,12 @@ private Object implMerge(Object key, Object value, BiFunction remappingFunction) { if (key instanceof String) { - if (isProviderInfo(key)) { + if (!checkLegacy(key)) { return null; } - legacyChanged = true; + legacyStrings.compute((String) key, + (BiFunction) remappingFunction); } return super.compute(key, remappingFunction); } @@ -1008,10 +1034,12 @@ private Object implCompute(Object key, BiFunction mappingFunction) { if (key instanceof String) { - if (isProviderInfo(key)) { + if (!checkLegacy(key)) { return null; } - legacyChanged = true; + legacyStrings.computeIfAbsent((String) key, + (Function) + mappingFunction); } return super.computeIfAbsent(key, mappingFunction); } @@ -1020,35 +1048,40 @@ private Object implComputeIfAbsent(Object key, Function remappingFunction) { if (key instanceof String) { - if (isProviderInfo(key)) { + if (!checkLegacy(key)) { return null; } - legacyChanged = true; + legacyStrings.computeIfPresent((String) key, + (BiFunction) remappingFunction); } return super.computeIfPresent(key, remappingFunction); } private Object implPut(Object key, Object value) { if ((key instanceof String) && (value instanceof String)) { - if (isProviderInfo(key)) { + if (!checkLegacy(key)) { return null; } - legacyChanged = true; + legacyStrings.put((String)key, (String)value); } return super.put(key, value); } private Object implPutIfAbsent(Object key, Object value) { if ((key instanceof String) && (value instanceof String)) { - if (isProviderInfo(key)) { + if (!checkLegacy(key)) { return null; } - legacyChanged = true; + legacyStrings.putIfAbsent((String)key, (String)value); } return super.putIfAbsent(key, value); } private void implClear() { + if (legacyStrings != null) { + legacyStrings.clear(); + } if (legacyMap != null) { legacyMap.clear(); } @@ -1056,6 +1089,7 @@ private void implClear() { legacyChanged = false; servicesChanged = false; serviceSet = null; + prngServices = null; super.clear(); putId(); } @@ -1095,7 +1129,7 @@ boolean matches(String type, String algorithm) { * service objects. */ private void ensureLegacyParsed() { - if (legacyChanged == false) { + if (legacyChanged == false || (legacyStrings == null)) { return; } serviceSet = null; @@ -1104,7 +1138,7 @@ private void ensureLegacyParsed() { } else { legacyMap.clear(); } - for (Map.Entry entry : super.entrySet()) { + for (Map.Entry entry : legacyStrings.entrySet()) { parseLegacyPut(entry.getKey(), entry.getValue()); } removeInvalidServices(legacyMap); @@ -1125,12 +1159,12 @@ private void removeInvalidServices(Map map) { } } - private String[] getTypeAndAlgorithm(String key) { + private static String[] getTypeAndAlgorithm(String key) { int i = key.indexOf('.'); if (i < 1) { if (debug != null) { - debug.println("Ignoring invalid entry in provider " - + name + ":" + key); + debug.println("Ignoring invalid entry in provider: " + + key); } return null; } @@ -1143,15 +1177,7 @@ private String[] getTypeAndAlgorithm(String key) { private static final String ALIAS_PREFIX_LOWER = "alg.alias."; private static final int ALIAS_LENGTH = ALIAS_PREFIX.length(); - private void parseLegacyPut(Object k, Object v) { - if (!(k instanceof String) || !(v instanceof String)) { - return; - } - String name = (String) k; - String value = (String) v; - if (isProviderInfo(name)) { - return; - } + private void parseLegacyPut(String name, String value) { if (name.toLowerCase(ENGLISH).startsWith(ALIAS_PREFIX_LOWER)) { // e.g. put("Alg.Alias.MessageDigest.SHA", "SHA-1"); // aliasKey ~ MessageDigest.SHA @@ -1193,6 +1219,10 @@ private void parseLegacyPut(Object k, Object v) { legacyMap.put(key, s); } s.className = className; + + if (type.equals("SecureRandom")) { + updateSecureRandomEntries(true, s); + } } else { // attribute // e.g. put("MessageDigest.SHA-1 ImplementedIn", "Software"); String attributeValue = value; @@ -1352,9 +1382,46 @@ protected void putService(Service s) { servicesChanged = true; synchronized (this) { putPropertyStrings(s); + if (type.equals("SecureRandom")) { + updateSecureRandomEntries(true, s); + } } } + private void updateSecureRandomEntries(boolean doAdd, Service s) { + Objects.requireNonNull(s); + if (doAdd) { + if (prngServices == null) { + prngServices = new LinkedHashSet(); + } + prngServices.add(s); + } else { + prngServices.remove(s); + } + + if (debug != null) { + debug.println((doAdd? "Add":"Remove") + " SecureRandom algo " + + s.getAlgorithm()); + } + } + + // used by new SecureRandom() to find out the default SecureRandom + // service for this provider + synchronized Service getDefaultSecureRandomService() { + checkInitialized(); + + if (legacyChanged) { + prngServices = null; + ensureLegacyParsed(); + } + + if (prngServices != null && !prngServices.isEmpty()) { + return prngServices.iterator().next(); + } + + return null; + } + /** * Put the string properties for this Service in this Provider's * Hashtable. @@ -1448,6 +1515,9 @@ private void implRemoveService(Service s) { } synchronized (this) { removePropertyStrings(s); + if (type.equals("SecureRandom")) { + updateSecureRandomEntries(false, s); + } } } diff --git a/src/java.base/share/classes/java/security/SecureRandom.java b/src/java.base/share/classes/java/security/SecureRandom.java index a454d47dd10..5a9ce618de5 100644 --- a/src/java.base/share/classes/java/security/SecureRandom.java +++ b/src/java.base/share/classes/java/security/SecureRandom.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, 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 @@ -259,35 +259,51 @@ public SecureRandom(byte[] seed) { } private void getDefaultPRNG(boolean setSeed, byte[] seed) { - String prng = getPrngAlgorithm(); - if (prng == null) { - // bummer, get the SUN implementation - prng = "SHA1PRNG"; + Service prngService = null; + String prngAlgorithm = null; + for (Provider p : Providers.getProviderList().providers()) { + // SUN provider uses the SunEntries.DEF_SECURE_RANDOM_ALGO + // as the default SecureRandom algorithm; for other providers, + // Provider.getDefaultSecureRandom() will use the 1st + // registered SecureRandom algorithm + if (p.getName().equals("SUN")) { + prngAlgorithm = SunEntries.DEF_SECURE_RANDOM_ALGO; + prngService = p.getService("SecureRandom", prngAlgorithm); + break; + } else { + prngService = p.getDefaultSecureRandomService(); + if (prngService != null) { + prngAlgorithm = prngService.getAlgorithm(); + break; + } + } + } + // per javadoc, if none of the Providers support a RNG algorithm, + // then an implementation-specific default is returned. + if (prngService == null) { + prngAlgorithm = "SHA1PRNG"; this.secureRandomSpi = new sun.security.provider.SecureRandom(); this.provider = Providers.getSunProvider(); - if (setSeed) { - this.secureRandomSpi.engineSetSeed(seed); - } } else { try { - SecureRandom random = SecureRandom.getInstance(prng); - this.secureRandomSpi = random.getSecureRandomSpi(); - this.provider = random.getProvider(); - if (setSeed) { - this.secureRandomSpi.engineSetSeed(seed); - } + this.secureRandomSpi = (SecureRandomSpi) + prngService.newInstance(null); + this.provider = prngService.getProvider(); } catch (NoSuchAlgorithmException nsae) { - // never happens, because we made sure the algorithm exists + // should not happen throw new RuntimeException(nsae); } } + if (setSeed) { + this.secureRandomSpi.engineSetSeed(seed); + } // JDK 1.1 based implementations subclass SecureRandom instead of // SecureRandomSpi. They will also go through this code path because // they must call a SecureRandom constructor as it is their superclass. // If we are dealing with such an implementation, do not set the // algorithm value as it would be inaccurate. if (getClass() == SecureRandom.class) { - this.algorithm = prng; + this.algorithm = prngAlgorithm; } } @@ -620,13 +636,6 @@ public static SecureRandom getInstance(String algorithm, instance.provider, algorithm); } - /** - * Returns the {@code SecureRandomSpi} of this {@code SecureRandom} object. - */ - SecureRandomSpi getSecureRandomSpi() { - return secureRandomSpi; - } - /** * Returns the provider of this {@code SecureRandom} object. * @@ -868,30 +877,6 @@ private static byte[] longToByteArray(long l) { return retVal; } - /** - * Gets a default PRNG algorithm by looking through all registered - * providers. Returns the first PRNG algorithm of the first provider that - * has registered a {@code SecureRandom} implementation, or null if none of - * the registered providers supplies a {@code SecureRandom} implementation. - */ - private static String getPrngAlgorithm() { - for (Provider p : Providers.getProviderList().providers()) { - // For SUN provider, we use SunEntries.DEFF_SECURE_RANDOM_ALGO - // as the default SecureRandom algorithm; for other providers, - // we continue to iterate through to the 1st SecureRandom - // service - if (p.getName().equals("SUN")) { - return SunEntries.DEF_SECURE_RANDOM_ALGO; - } - for (Service s : p.getServices()) { - if (s.getType().equals("SecureRandom")) { - return s.getAlgorithm(); - } - } - } - return null; - } - /* * Lazily initialize since Pattern.compile() is heavy. * Effective Java (2nd Edition), Item 71. diff --git a/src/java.base/share/classes/java/security/Signature.java b/src/java.base/share/classes/java/security/Signature.java index 88ef284becc..d493d8d40b7 100644 --- a/src/java.base/share/classes/java/security/Signature.java +++ b/src/java.base/share/classes/java/security/Signature.java @@ -272,7 +272,7 @@ public static Signature getInstance(String algorithm) NoSuchAlgorithmException failure; do { Service s = t.next(); - if (isSpi(s)) { + if (isSpi(s)) { // delayed provider selection return new Delegate(s, t, algorithm); } else { // must be a subclass of Signature, disable dynamic selection @@ -295,7 +295,7 @@ private static Signature getInstance(Instance instance, String algorithm) { sig.algorithm = algorithm; } else { SignatureSpi spi = (SignatureSpi)instance.impl; - sig = new Delegate(spi, algorithm); + sig = Delegate.of(spi, algorithm); } sig.provider = instance.provider; return sig; @@ -464,7 +464,7 @@ private static Signature getInstanceRSA(Provider p) // check Cipher try { Cipher c = Cipher.getInstance(RSA_CIPHER, p); - return new Delegate(new CipherAdapter(c), RSA_SIGNATURE); + return Delegate.of(new CipherAdapter(c), RSA_SIGNATURE); } catch (GeneralSecurityException e) { // throw Signature style exception message to avoid confusion, // but append Cipher exception as cause @@ -1092,6 +1092,14 @@ public Object clone() throws CloneNotSupportedException { @SuppressWarnings("deprecation") private static class Delegate extends Signature { + // use this class for spi objects which implements Cloneable + private static final class CloneableDelegate extends Delegate + implements Cloneable { + private CloneableDelegate(SignatureSpi digestSpi, + String algorithm) { + super(digestSpi, algorithm); + } + } // The provider implementation (delegate) // filled in once the provider is selected @@ -1108,15 +1116,24 @@ private static class Delegate extends Signature { // null once provider is selected private Iterator serviceIterator; - // constructor - Delegate(SignatureSpi sigSpi, String algorithm) { + // factory method used by Signature class to create Delegate objs + static Delegate of(SignatureSpi sigSpi, String algorithm) { + if (sigSpi instanceof Cloneable) { + return new CloneableDelegate(sigSpi, algorithm); + } else { + return new Delegate(sigSpi, algorithm); + } + } + + // private constructor + private Delegate(SignatureSpi sigSpi, String algorithm) { super(algorithm); this.sigSpi = sigSpi; this.lock = null; // no lock needed } - // used with delayed provider selection - Delegate(Service service, + // constructor used with delayed provider selection + private Delegate(Service service, Iterator iterator, String algorithm) { super(algorithm); this.firstService = service; @@ -1132,15 +1149,16 @@ private static class Delegate extends Signature { * @throws CloneNotSupportedException if this is called on a * delegate that does not support {@code Cloneable}. */ + @Override public Object clone() throws CloneNotSupportedException { chooseFirstProvider(); if (sigSpi instanceof Cloneable) { - SignatureSpi sigSpiClone = (SignatureSpi)sigSpi.clone(); // Because 'algorithm' and 'provider' are private // members of our supertype, we must perform a cast to // access them. - Signature that = - new Delegate(sigSpiClone, ((Signature)this).algorithm); + Signature that = new CloneableDelegate( + (SignatureSpi)sigSpi.clone(), + ((Signature)this).algorithm); that.provider = ((Signature)this).provider; return that; } else { diff --git a/src/java.base/share/classes/java/time/Year.java b/src/java.base/share/classes/java/time/Year.java index ccc6c45b580..37fd428e7cc 100644 --- a/src/java.base/share/classes/java/time/Year.java +++ b/src/java.base/share/classes/java/time/Year.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2020, 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 @@ -153,7 +153,8 @@ public final class Year * Parser. */ private static final DateTimeFormatter PARSER = new DateTimeFormatterBuilder() - .appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD) + .parseLenient() + .appendValue(YEAR, 1, 10, SignStyle.NORMAL) .toFormatter(); /** @@ -268,7 +269,6 @@ public static Year from(TemporalAccessor temporal) { * Obtains an instance of {@code Year} from a text string such as {@code 2007}. *

* The string must represent a valid year. - * Years outside the range 0000 to 9999 must be prefixed by the plus or minus symbol. * * @param text the text to parse such as "2007", not null * @return the parsed year, not null diff --git a/src/java.base/share/classes/sun/security/provider/DigestBase.java b/src/java.base/share/classes/sun/security/provider/DigestBase.java index 54eb85527bb..26fd6672eeb 100644 --- a/src/java.base/share/classes/sun/security/provider/DigestBase.java +++ b/src/java.base/share/classes/sun/security/provider/DigestBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, 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 @@ -233,6 +233,7 @@ protected final int engineDigest(byte[] out, int ofs, int len) public Object clone() throws CloneNotSupportedException { DigestBase copy = (DigestBase) super.clone(); copy.buffer = copy.buffer.clone(); + copy.oneByte = null; return copy; } diff --git a/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java b/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java index b088c818ca0..9e8b95564ee 100644 --- a/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java +++ b/src/java.base/share/classes/sun/security/provider/JavaKeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, 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 @@ -75,6 +75,22 @@ public static final class DualFormatJKS extends KeyStoreDelegator { public DualFormatJKS() { super("JKS", JKS.class, "PKCS12", PKCS12KeyStore.class); } + + /** + * Probe the first few bytes of the keystore data stream for a valid + * JKS keystore encoding. + */ + @Override + public boolean engineProbe(InputStream stream) throws IOException { + DataInputStream dataStream; + if (stream instanceof DataInputStream) { + dataStream = (DataInputStream)stream; + } else { + dataStream = new DataInputStream(stream); + } + + return MAGIC == dataStream.readInt(); + } } private static final Debug debug = Debug.getInstance("keystore"); @@ -828,20 +844,4 @@ private byte[] convertToBytes(char[] password) { } return passwdBytes; } - - /** - * Probe the first few bytes of the keystore data stream for a valid - * JKS keystore encoding. - */ - @Override - public boolean engineProbe(InputStream stream) throws IOException { - DataInputStream dataStream; - if (stream instanceof DataInputStream) { - dataStream = (DataInputStream)stream; - } else { - dataStream = new DataInputStream(stream); - } - - return MAGIC == dataStream.readInt(); - } } diff --git a/src/java.desktop/windows/native/libawt/java2d/windows/GDIBlitLoops.cpp b/src/java.desktop/windows/native/libawt/java2d/windows/GDIBlitLoops.cpp index 90e0c8abc89..b41c4a22691 100644 --- a/src/java.desktop/windows/native/libawt/java2d/windows/GDIBlitLoops.cpp +++ b/src/java.desktop/windows/native/libawt/java2d/windows/GDIBlitLoops.cpp @@ -41,6 +41,68 @@ typedef struct tagBitmapheader { } colors; } BmiType; +/* + * Some GDI functions functions will fail if they operate on memory which spans + * virtual allocations as used by modern garbage collectors (ie ZGC). + * So if the call to SetDIBitsToDevice fails, we will re-try it on malloced + * memory rather than the pinned Java heap memory. + * Once Microsoft fix the GDI bug, the small performance penalty of this retry + * will be gone. + */ +static void retryingSetDIBitsToDevice( + HDC hdc, + int xDest, + int yDest, + DWORD w, + DWORD h, + int xSrc, + int ySrc, + UINT StartScan, + UINT cLines, + const VOID *lpvBits, + BITMAPINFO *lpbmi, + UINT ColorUse) { + +#ifdef DEBUG_PERF + LARGE_INTEGER ts1, ts2; + QueryPerformanceCounter(&ts1); +#endif + + int ret = + SetDIBitsToDevice(hdc, xDest, yDest, w, h, + xSrc, ySrc, StartScan, cLines, lpvBits, + lpbmi, ColorUse); + + if (ret != 0 || h == 0) { +#ifdef DEBUG_PERF + QueryPerformanceCounter(&ts2); + printf("success time: %zd\n", (ts2.QuadPart-ts1.QuadPart)); +#endif + return; + } + + size_t size = lpbmi->bmiHeader.biSizeImage; + void* imageData = NULL; + try { + imageData = safe_Malloc(size); + } catch (std::bad_alloc&) { + } + if (imageData == NULL) { + return; + } + memcpy(imageData, lpvBits, size); // this is the most expensive part. + SetDIBitsToDevice(hdc, xDest, yDest, w, h, + xSrc, ySrc, StartScan, cLines, imageData, + lpbmi, ColorUse); + free(imageData); + +#ifdef DEBUG_PERF + QueryPerformanceCounter(&ts2); + printf("with retry time: %zd\n", (ts2.QuadPart-ts1.QuadPart)); +#endif + +}; + /* * Class: sun_java2d_windows_GDIBlitLoops * Method: nativeBlit @@ -127,7 +189,6 @@ Java_sun_java2d_windows_GDIBlitLoops_nativeBlit // then we can do the work much faster. This is due to a constraint // in the way DIBs are structured and parsed by GDI jboolean fastBlt = ((srcInfo.scanStride & 0x03) == 0); - bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader); bmi.bmiHeader.biWidth = srcInfo.scanStride/srcInfo.pixelStride; // fastBlt copies whole image in one call; else copy line-by-line @@ -190,7 +251,7 @@ Java_sun_java2d_windows_GDIBlitLoops_nativeBlit // Could also call StretchDIBits. Testing showed slight // performance advantage of SetDIBits instead, so since we // have no need of scaling, might as well use SetDIBits. - SetDIBitsToDevice(hDC, dstx, dsty, width, height, + retryingSetDIBitsToDevice(hDC, dstx, dsty, width, height, 0, 0, 0, height, rasBase, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); } @@ -198,7 +259,7 @@ Java_sun_java2d_windows_GDIBlitLoops_nativeBlit // Source scanlines not DWORD-aligned - copy each scanline individually for (int i = 0; i < height; i += 1) { if (::IsWindowVisible(dstOps->window)) { - SetDIBitsToDevice(hDC, dstx, dsty+i, width, 1, + retryingSetDIBitsToDevice(hDC, dstx, dsty+i, width, 1, 0, 0, 0, 1, rasBase, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); rasBase = (void*)((char*)rasBase + srcInfo.scanStride); diff --git a/src/java.desktop/windows/native/libawt/windows/awt_Cursor.cpp b/src/java.desktop/windows/native/libawt/windows/awt_Cursor.cpp index 36ceb1a4956..642c9e9b14c 100644 --- a/src/java.desktop/windows/native/libawt/windows/awt_Cursor.cpp +++ b/src/java.desktop/windows/native/libawt/windows/awt_Cursor.cpp @@ -373,23 +373,21 @@ Java_sun_awt_windows_WCustomCursor_createCursorIndirect( int *cols = SAFE_SIZE_NEW_ARRAY2(int, nW, nH); - jint *intRasterDataPtr = NULL; + /* Copy the raster data because GDI may fail on some Java heap + * allocated memory. + */ + length = env->GetArrayLength(intRasterData); + jint *intRasterDataPtr = new jint[length]; HBITMAP hColor = NULL; try { - intRasterDataPtr = - (jint *)env->GetPrimitiveArrayCritical(intRasterData, 0); + env->GetIntArrayRegion(intRasterData, 0, length, intRasterDataPtr); hColor = create_BMP(NULL, (int *)intRasterDataPtr, nSS, nW, nH); memcpy(cols, intRasterDataPtr, nW*nH*sizeof(int)); } catch (...) { - if (intRasterDataPtr != NULL) { - env->ReleasePrimitiveArrayCritical(intRasterData, - intRasterDataPtr, 0); - } + delete[] intRasterDataPtr; throw; } - - env->ReleasePrimitiveArrayCritical(intRasterData, intRasterDataPtr, 0); - intRasterDataPtr = NULL; + delete[] intRasterDataPtr; HCURSOR hCursor = NULL; diff --git a/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp b/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp index 653fff7efb1..618ae9e1a82 100644 --- a/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp +++ b/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp @@ -1739,11 +1739,18 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WEmbeddedFrame_printBand // ::PatBlt(hDC, destX+1, destY+1, destWidth-2, destHeight-2, PATCOPY); // ::SelectObject(hDC, oldBrush); + /* This code is rarely used now. It used to be invoked by Java plugin browser + * printing. Today embedded frames are used only when a toolkit such as SWT + * needs to embed + */ TRY; jbyte *image = NULL; try { - image = (jbyte *)env->GetPrimitiveArrayCritical(imageArray, 0); + int length = env->GetArrayLength(imageArray); + image = new jbyte[length]; CHECK_NULL(image); + env->GetByteArrayRegion(imageArray, 0, length, image); + struct { BITMAPINFOHEADER bmiHeader; DWORD* bmiColors; @@ -1777,13 +1784,11 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WEmbeddedFrame_printBand fclose(file); #endif //DEBUG_PRINTING } catch (...) { - if (image != NULL) { - env->ReleasePrimitiveArrayCritical(imageArray, image, 0); - } + delete[] image; throw; } - env->ReleasePrimitiveArrayCritical(imageArray, image, 0); + delete[] image; CATCH_BAD_ALLOC; } @@ -2803,100 +2808,6 @@ static jbyte* reverseDIB(jbyte* imageBits, long srcWidth, long srcHeight, return NULL; } -#if 0 - -/* - * Class: sun_awt_windows_WPrinterJob - * Method: drawImageIntRGB - * Signature: (J[IFFFFFFFFII)V - */ -JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_drawImageIntRGB - (JNIEnv *env, jobject self, - jlong printDC, jintArray image, - jfloat destX, jfloat destY, - jfloat destWidth, jfloat destHeight, - jfloat srcX, jfloat srcY, - jfloat srcWidth, jfloat srcHeight, - jint srcBitMapWidth, jint srcBitMapHeight) { - - int result = 0; - - assert(printDC != NULL); - assert(image != NULL); - assert(srcX >= 0); - assert(srcY >= 0); - assert(srcWidth > 0); - assert(srcHeight > 0); - assert(srcBitMapWidth > 0); - assert(srcBitMapHeight > 0); - - - static int alphaMask = 0xff000000; - static int redMask = 0x00ff0000; - static int greenMask = 0x0000ff00; - static int blueMask = 0x000000ff; - - struct { - BITMAPV4HEADER header; - DWORD masks[256]; - } dib; - - - - memset(&dib,0,sizeof(dib)); - dib.header.bV4Size = sizeof(dib.header); - dib.header.bV4Width = srcBitMapWidth; - dib.header.bV4Height = -srcBitMapHeight; // Top down DIB - dib.header.bV4Planes = 1; - dib.header.bV4BitCount = 32; - dib.header.bV4V4Compression = BI_BITFIELDS; - dib.header.bV4SizeImage = 0; // It's the default size. - dib.header.bV4XPelsPerMeter = 0; - dib.header.bV4YPelsPerMeter = 0; - dib.header.bV4ClrUsed = 0; - dib.header.bV4ClrImportant = 0; - dib.header.bV4RedMask = redMask; - dib.header.bV4GreenMask = greenMask; - dib.header.bV4BlueMask = blueMask; - dib.header.bV4AlphaMask = alphaMask; - dib.masks[0] = redMask; - dib.masks[1] = greenMask; - dib.masks[2] = blueMask; - dib.masks[3] = alphaMask; - - jint *imageBits = NULL; - - try { - imageBits = (jint *)env->GetPrimitiveArrayCritical(image, 0); - - if (printDC){ - result = ::StretchDIBits( (HDC)printDC, - ROUND_TO_LONG(destX), - ROUND_TO_LONG(destY), - ROUND_TO_LONG(destWidth), - ROUND_TO_LONG(destHeight), - ROUND_TO_LONG(srcX), - ROUND_TO_LONG(srcY), - ROUND_TO_LONG(srcWidth), - ROUND_TO_LONG(srcHeight), - imageBits, - (BITMAPINFO *)&dib, - DIB_RGB_COLORS, - SRCCOPY); - - } - } catch (...) { - if (imageBits != NULL) { - env->ReleasePrimitiveArrayCritical(image, imageBits, 0); - } - throw; - } - - env->ReleasePrimitiveArrayCritical(image, imageBits, 0); - -} -#else - /* * Class: sun_awt_windows_WPrinterJob * Method: drawDIBImage @@ -2991,7 +2902,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_drawDIBImage env->ReleasePrimitiveArrayCritical(image, imageBits, 0); } -#endif /* * An utility function to print passed image byte array to @@ -3059,7 +2969,7 @@ static void doPrintBand(JNIEnv *env, jboolean browserPrinting, CATCH_BAD_ALLOC; } -static FILE* outfile = NULL; + static int bitsToDevice(HDC printDC, jbyte *image, long destX, long destY, long width, long height) { int result = 0; @@ -3072,6 +2982,9 @@ static int bitsToDevice(HDC printDC, jbyte *image, long destX, long destY, /* height could be negative to indicate that this is a top-down DIB */ // assert(height > 0); + if (!printDC || height == 0) { + return result; + } struct { BITMAPINFOHEADER bmiHeader; DWORD* bmiColors; @@ -3099,11 +3012,9 @@ static int bitsToDevice(HDC printDC, jbyte *image, long destX, long destY, if (bitMapHeader.bmiHeader.biHeight < 0) { jbyte *dibImage = reverseDIB(image, width, height, 24); if (dibImage != NULL) { - bitMapHeader.bmiHeader.biWidth = ROUND_TO_LONG(width); - bitMapHeader.bmiHeader.biHeight = ROUND_TO_LONG(height); - - if (printDC){ - result = ::SetDIBitsToDevice(printDC, + bitMapHeader.bmiHeader.biWidth = ROUND_TO_LONG(width); + bitMapHeader.bmiHeader.biHeight = ROUND_TO_LONG(height); + result = ::SetDIBitsToDevice(printDC, ROUND_TO_LONG(destX), // left of dest rect ROUND_TO_LONG(destY), // top of dest rect ROUND_TO_LONG(width), // width of dest rect @@ -3115,12 +3026,9 @@ static int bitsToDevice(HDC printDC, jbyte *image, long destX, long destY, dibImage, // points to the DIB (BITMAPINFO *)&bitMapHeader, DIB_RGB_COLORS); - } - - free (dibImage); + free (dibImage); } } else { - if (printDC){ result = ::SetDIBitsToDevice(printDC, destX, // left of dest rect destY, // top of dest rect @@ -3133,9 +3041,30 @@ static int bitsToDevice(HDC printDC, jbyte *image, long destX, long destY, image, // points to the DIB (BITMAPINFO *)&bitMapHeader, DIB_RGB_COLORS); - } + if (result == 0) { + size_t size = width * height * 3; // Always 24bpp, also DWORD aligned. + void *imageData = NULL; + try { + imageData = safe_Malloc(size); + } catch (std::bad_alloc&) { + return result; + } + memcpy(imageData, image, size); + result = ::SetDIBitsToDevice(printDC, + destX, // left of dest rect + destY, // top of dest rect + width, // width of dest rect + height, // height of dest rect + 0, // left of source rect + 0, // top of source rect + 0, // line number of 1st source scan line + height, // number of source scan lines + imageData, // points to the DIB + (BITMAPINFO *)&bitMapHeader, + DIB_RGB_COLORS); + free(imageData); + } } - return result; } diff --git a/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp b/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp index 616b40519e2..dd95d4d2eb4 100644 --- a/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp +++ b/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp @@ -1001,25 +1001,21 @@ Java_sun_awt_windows_WTrayIconPeer_setNativeIcon(JNIEnv *env, jobject self, delete[] andMaskPtr; - jint *intRasterDataPtr = NULL; + /* Copy the raster data because GDI may fail on some Java heap + * allocated memory. + */ + length = env->GetArrayLength(intRasterData); + jint *intRasterDataPtr = new jint[length]; HBITMAP hColor = NULL; try { - intRasterDataPtr = (jint *)env->GetPrimitiveArrayCritical(intRasterData, 0); - if (intRasterDataPtr == NULL) { - ::DeleteObject(hMask); - return; - } + env->GetIntArrayRegion(intRasterData, 0, length, intRasterDataPtr); hColor = AwtTrayIcon::CreateBMP(NULL, (int *)intRasterDataPtr, nSS, nW, nH); } catch (...) { - if (intRasterDataPtr != NULL) { - env->ReleasePrimitiveArrayCritical(intRasterData, intRasterDataPtr, 0); - } + delete[] intRasterDataPtr; ::DeleteObject(hMask); throw; } - - env->ReleasePrimitiveArrayCritical(intRasterData, intRasterDataPtr, 0); - intRasterDataPtr = NULL; + delete[] intRasterDataPtr; HICON hIcon = NULL; diff --git a/src/java.management/share/classes/sun/management/HotspotThreadMBean.java b/src/java.management/share/classes/sun/management/HotspotThreadMBean.java index e69e2377086..8f7fe079160 100644 --- a/src/java.management/share/classes/sun/management/HotspotThreadMBean.java +++ b/src/java.management/share/classes/sun/management/HotspotThreadMBean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, 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 @@ -50,7 +50,7 @@ public interface HotspotThreadMBean { * @throws java.lang.UnsupportedOperationException if the Java virtual * machine does not support CPU time measurement. * - * @see java.lang.management.ThreadMBean#isThreadCpuTimeSupported + * @see java.lang.management.ThreadMXBean#isThreadCpuTimeSupported */ public java.util.Map getInternalThreadCpuTimes(); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/Main.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/Main.java index 47a2e954e52..a07ac014f1f 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/Main.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/Main.java @@ -38,6 +38,8 @@ public class Main { /** Main entry point for the launcher. * Note: This method calls System.exit. * @param args command line arguments + * @throws Exception only if an uncaught internal exception occurs; + * just retained for historical compatibility */ public static void main(String[] args) throws Exception { System.exit(compile(args)); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java index 3db23c99a6a..479ee4ca776 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java @@ -1006,11 +1006,13 @@ protected void runPhase(Env env) { ClassSymbol sym = tree.sym; ClassType ct = (ClassType)sym.type; + JCTree defaultConstructor = null; + // Add default constructor if needed. DefaultConstructorHelper helper = getDefaultConstructorHelper(env); if (helper != null) { - JCTree constrDef = defaultConstructor(make.at(tree.pos), helper); - tree.defs = tree.defs.prepend(constrDef); + defaultConstructor = defaultConstructor(make.at(tree.pos), helper); + tree.defs = tree.defs.prepend(defaultConstructor); } if (!sym.isRecord()) { enterThisAndSuper(sym, env); @@ -1022,7 +1024,7 @@ protected void runPhase(Env env) { } } - finishClass(tree, env); + finishClass(tree, defaultConstructor, env); if (allowTypeAnnos) { typeAnnotations.organizeTypeAnnotationsSignatures(env, (JCClassDecl)env.tree); @@ -1063,7 +1065,7 @@ DefaultConstructorHelper getDefaultConstructorHelper(Env env) { /** Enter members for a class. */ - void finishClass(JCClassDecl tree, Env env) { + void finishClass(JCClassDecl tree, JCTree defaultConstructor, Env env) { if ((tree.mods.flags & Flags.ENUM) != 0 && !tree.sym.type.hasTag(ERROR) && (types.supertype(tree.sym.type).tsym.flags() & Flags.ENUM) == 0) { @@ -1074,9 +1076,7 @@ void finishClass(JCClassDecl tree, Env env) { if (isRecord) { alreadyEntered = List.convert(JCTree.class, TreeInfo.recordFields(tree)); alreadyEntered = alreadyEntered.prependList(tree.defs.stream() - .filter(t -> TreeInfo.isConstructor(t) && - ((JCMethodDecl)t).sym != null && - (((JCMethodDecl)t).sym.flags_field & Flags.GENERATEDCONSTR) == 0).collect(List.collector())); + .filter(t -> TreeInfo.isConstructor(t) && t != defaultConstructor).collect(List.collector())); } List defsToEnter = isRecord ? tree.defs.diff(alreadyEntered) : tree.defs; diff --git a/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java b/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java index 61cf85646ec..99668e61bf9 100644 --- a/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java +++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,9 @@ import java.lang.System.Logger; import java.lang.System.Logger.Level; import java.text.*; +import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; import java.util.stream.Stream; import com.sun.net.httpserver.*; @@ -55,16 +58,12 @@ class ExchangeImpl { boolean http10 = false; /* for formatting the Date: header */ - private static final String pattern = "EEE, dd MMM yyyy HH:mm:ss zzz"; - private static final TimeZone gmtTZ = TimeZone.getTimeZone("GMT"); - private static final ThreadLocal dateFormat = - new ThreadLocal() { - @Override protected DateFormat initialValue() { - DateFormat df = new SimpleDateFormat(pattern, Locale.US); - df.setTimeZone(gmtTZ); - return df; - } - }; + private static final DateTimeFormatter FORMATTER; + static { + String pattern = "EEE, dd MMM yyyy HH:mm:ss zzz"; + FORMATTER = DateTimeFormatter.ofPattern(pattern, Locale.US) + .withZone(ZoneId.of("GMT")); + } private static final String HEAD = "HEAD"; @@ -212,7 +211,7 @@ public void sendResponseHeaders (int rCode, long contentLen) tmpout.write (bytes(statusLine, 0), 0, statusLine.length()); boolean noContentToSend = false; // assume there is content boolean noContentLengthHeader = false; // must not send Content-length is set - rspHdrs.set ("Date", dateFormat.get().format (new Date())); + rspHdrs.set("Date", FORMATTER.format(Instant.now())); /* check for response type that is not allowed to send a body */ diff --git a/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/StandardBundlerParam.java b/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/StandardBundlerParam.java index dbd6baab3ea..30c626d6a58 100644 --- a/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/StandardBundlerParam.java +++ b/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/StandardBundlerParam.java @@ -484,6 +484,16 @@ static void copyPredefinedRuntimeImage(Map params, PREDEFINED_RUNTIME_IMAGE.getID())); } + if (Platform.isMac()) { + // On Mac topImage can be runtime root or runtime home. + Path runtimeHome = topImage.toPath().resolve("Contents/Home"); + if (Files.isDirectory(runtimeHome)) { + // topImage references runtime root, adjust it to pick data from + // runtime home + topImage = runtimeHome.toFile(); + } + } + // copy whole runtime, need to skip jmods and src.zip final List excludes = Arrays.asList("jmods", "src.zip"); IOUtils.copyRecursive(topImage.toPath(), diff --git a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java index bd13e936b3e..d7e203d98a8 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, 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 @@ -54,6 +54,7 @@ static final class Internals { final ResolvedJavaField methodHandleFormField; final ResolvedJavaField lambdaFormVmentryField; final HotSpotResolvedJavaField callSiteTargetField; + final HotSpotResolvedJavaField constantCallSiteFrozenField; final ResolvedJavaField methodField; final HotSpotResolvedJavaField vmtargetField; @@ -94,6 +95,9 @@ private Internals() { ResolvedJavaType callSiteType = resolveType("Ljava/lang/invoke/CallSite;"); callSiteTargetField = (HotSpotResolvedJavaField) findFieldInClass(callSiteType, "target", methodHandleType); + ResolvedJavaType constantCallSiteType = resolveType("Ljava/lang/invoke/ConstantCallSite;"); + ResolvedJavaType booleanType = resolveType("Z"); + constantCallSiteFrozenField = (HotSpotResolvedJavaField) findFieldInClass(constantCallSiteType, "isFrozen", booleanType); } catch (Throwable ex) { throw new JVMCIError(ex); } diff --git a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java index 839c7c80c21..b1139f9e42f 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2020, 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 @@ -65,18 +65,39 @@ public HotSpotResolvedObjectType getType() { @Override public abstract int getIdentityHashCode(); + static class Fields { + // Initializing these too early causes a hang, so do it here in a subclass + static final HotSpotResolvedJavaField callSiteTargetField = HotSpotMethodHandleAccessProvider.Internals.instance().callSiteTargetField; + static final HotSpotResolvedJavaField constantCallSiteFrozenField = HotSpotMethodHandleAccessProvider.Internals.instance().constantCallSiteFrozenField; + } + + private boolean isFullyInitializedConstantCallSite() { + if (!runtime().getConstantCallSite().isInstance(this)) { + return false; + } + // read ConstantCallSite.isFrozen as a volatile field + boolean isFrozen = readFieldValue(Fields.constantCallSiteFrozenField, true /* volatile */).asBoolean(); + // isFrozen true implies fully-initialized + return isFrozen; + } + + private HotSpotObjectConstantImpl readTarget() { + // read CallSite.target as a volatile field + return (HotSpotObjectConstantImpl) readFieldValue(Fields.callSiteTargetField, true /* volatile */); + } + @Override public JavaConstant getCallSiteTarget(Assumptions assumptions) { if (runtime().getCallSite().isInstance(this)) { - HotSpotObjectConstantImpl target = (HotSpotObjectConstantImpl) runtime().getHostJVMCIBackend().getConstantReflection().readFieldValue( - HotSpotMethodHandleAccessProvider.Internals.instance().callSiteTargetField, this); - if (!runtime().getConstantCallSite().isInstance(this)) { + // For ConstantCallSites, we need to read "isFrozen" before reading "target" + // isFullyInitializedConstantCallSite() reads "isFrozen" + if (!isFullyInitializedConstantCallSite()) { if (assumptions == null) { return null; } - assumptions.record(new Assumptions.CallSiteTargetValue(this, target)); + assumptions.record(new Assumptions.CallSiteTargetValue(this, readTarget())); } - return target; + return readTarget(); } return null; } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/DocletEnvironment.java b/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/DocletEnvironment.java index 77f298fe907..7ae401e66bf 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/DocletEnvironment.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/DocletEnvironment.java @@ -138,6 +138,9 @@ public interface DocletEnvironment { */ Kind getFileKind(TypeElement type); + /** + * The mode specifying the level of detail of module documentation. + */ enum ModuleMode { /** Indicate API level documentation is required */ API, diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/StandardDoclet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/StandardDoclet.java index 70abc7342c3..756227aafc1 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/StandardDoclet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/StandardDoclet.java @@ -70,6 +70,10 @@ public class StandardDoclet implements Doclet { private final HtmlDoclet htmlDoclet; + /** + * Creates an instance of the standard doclet, used to generate HTML-formatted + * documentation. + */ public StandardDoclet() { htmlDoclet = new HtmlDoclet(this); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java index 3eb9d1cd53a..41262280e82 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java @@ -159,6 +159,7 @@ protected void addElementDescription(IndexItem indexItem, Content dlTree, Search break; case CLASS: case ENUM: + case RECORD: case ANNOTATION_TYPE: case INTERFACE: dt = HtmlTree.DT(getLink(new LinkInfoImpl(configuration, diff --git a/src/jdk.management.agent/share/conf/management.properties b/src/jdk.management.agent/share/conf/management.properties index 7442af641f5..ecb088235a3 100644 --- a/src/jdk.management.agent/share/conf/management.properties +++ b/src/jdk.management.agent/share/conf/management.properties @@ -41,7 +41,7 @@ # # This option enables thread contention monitoring if the # Java virtual machine supports such instrumentation. -# Refer to the specification for the java.lang.management.ThreadMBean +# Refer to the specification for the java.lang.management.ThreadMXBean # interface - see isThreadContentionMonitoringSupported() method. # @@ -228,7 +228,7 @@ # com.sun.management.jmxremote.password.toHashes = true|false # Default for this property is true. # Specifies if passwords in the password file should be hashed or not. -# If this property is true, and if the password file is writable, and if the +# If this property is true, and if the password file is writable, and if the # system security policy allows writing into the password file, # all the clear passwords in the password file will be replaced by # their SHA3-512 hash when the file is read by the server @@ -267,7 +267,7 @@ # ################ Filter for ObjectInputStream ############################# # com.sun.management.jmxremote.serial.filter.pattern= # A filter, if configured, is used by java.io.ObjectInputStream during -# deserialization of parameters sent to the JMX default agent to validate the +# deserialization of parameters sent to the JMX default agent to validate the # contents of the stream. # A filter is configured as a sequence of patterns, each pattern is either # matched against the name of a class in the stream or defines a limit. diff --git a/src/jdk.management/aix/native/libmanagement_ext/UnixOperatingSystem.c b/src/jdk.management/aix/native/libmanagement_ext/UnixOperatingSystem.c index c3ee8446f96..01227414dc6 100644 --- a/src/jdk.management/aix/native/libmanagement_ext/UnixOperatingSystem.c +++ b/src/jdk.management/aix/native/libmanagement_ext/UnixOperatingSystem.c @@ -1,6 +1,6 @@ /* - * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015 SAP SE. All rights reserved. + * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020 SAP SE. 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 @@ -57,3 +57,10 @@ Java_com_sun_management_internal_OperatingSystemImpl_getHostConfiguredCpuCount0 { return -1; } + +JNIEXPORT jint JNICALL +Java_com_sun_management_internal_OperatingSystemImpl_getHostOnlineCpuCount0 +(JNIEnv *env, jobject mbean) +{ + return -1; +} diff --git a/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c b/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c index e74bc777f5e..e27cc6605be 100644 --- a/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c +++ b/src/jdk.management/linux/native/libmanagement_ext/UnixOperatingSystem.c @@ -362,3 +362,15 @@ Java_com_sun_management_internal_OperatingSystemImpl_getHostConfiguredCpuCount0 return -1; } } + +JNIEXPORT jint JNICALL +Java_com_sun_management_internal_OperatingSystemImpl_getHostOnlineCpuCount0 +(JNIEnv *env, jobject mbean) +{ + int n = sysconf(_SC_NPROCESSORS_ONLN); + if (n <= 0) { + n = 1; + } + return n; +} + diff --git a/src/jdk.management/macosx/native/libmanagement_ext/UnixOperatingSystem.c b/src/jdk.management/macosx/native/libmanagement_ext/UnixOperatingSystem.c index e06e00f7095..3f4ba6a75c2 100644 --- a/src/jdk.management/macosx/native/libmanagement_ext/UnixOperatingSystem.c +++ b/src/jdk.management/macosx/native/libmanagement_ext/UnixOperatingSystem.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2020, 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 @@ -173,3 +173,11 @@ Java_com_sun_management_internal_OperatingSystemImpl_getHostConfiguredCpuCount0 { return -1; } + +JNIEXPORT jint JNICALL +Java_com_sun_management_internal_OperatingSystemImpl_getHostOnlineCpuCount0 +(JNIEnv *env, jobject mbean) +{ + return -1; +} + diff --git a/src/jdk.management/share/native/libmanagement_ext/GarbageCollectorExtImpl.c b/src/jdk.management/share/native/libmanagement_ext/GarbageCollectorExtImpl.c index f34d1959a32..7d85da51953 100644 --- a/src/jdk.management/share/native/libmanagement_ext/GarbageCollectorExtImpl.c +++ b/src/jdk.management/share/native/libmanagement_ext/GarbageCollectorExtImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, 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 @@ -31,7 +31,7 @@ JNIEXPORT void JNICALL Java_com_sun_management_internal_GarbageCollectorExtImpl_ (JNIEnv *env, jobject dummy, jobject gc,jboolean enabled) { if (gc == NULL) { - JNU_ThrowNullPointerException(env, "Invalid GarbageCollectorMBean"); + JNU_ThrowNullPointerException(env, "Invalid GarbageCollectorMXBean"); return; } if((jmm_version > JMM_VERSION_1_2) diff --git a/src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c b/src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c index b457950e0d9..ebd53958055 100644 --- a/src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c +++ b/src/jdk.management/share/native/libmanagement_ext/GcInfoBuilder.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ JNIEXPORT jint JNICALL Java_com_sun_management_internal_GcInfoBuilder_getNumGcEx jlong value; if (gc == NULL) { - JNU_ThrowNullPointerException(env, "Invalid GarbageCollectorMBean"); + JNU_ThrowNullPointerException(env, "Invalid GarbageCollectorMXBean"); return 0; } value = jmm_interface->GetLongAttribute(env, gc, @@ -55,7 +55,7 @@ JNIEXPORT void JNICALL Java_com_sun_management_internal_GcInfoBuilder_fillGcAttr jint i; if (gc == NULL) { - JNU_ThrowNullPointerException(env, "Invalid GarbageCollectorMBean"); + JNU_ThrowNullPointerException(env, "Invalid GarbageCollectorMXBean"); return; } @@ -207,7 +207,7 @@ JNIEXPORT jobject JNICALL Java_com_sun_management_internal_GcInfoBuilder_getLast jvalue v; if (gc == NULL) { - JNU_ThrowNullPointerException(env, "Invalid GarbageCollectorMBean"); + JNU_ThrowNullPointerException(env, "Invalid GarbageCollectorMXBean"); return 0; } diff --git a/src/jdk.management/unix/classes/com/sun/management/internal/OperatingSystemImpl.java b/src/jdk.management/unix/classes/com/sun/management/internal/OperatingSystemImpl.java index 47f5616cb93..18a99c19933 100644 --- a/src/jdk.management/unix/classes/com/sun/management/internal/OperatingSystemImpl.java +++ b/src/jdk.management/unix/classes/com/sun/management/internal/OperatingSystemImpl.java @@ -158,6 +158,10 @@ public double getCpuLoad() { return getCpuLoad0(); } else { int[] cpuSet = containerMetrics.getEffectiveCpuSetCpus(); + // in case the effectiveCPUSetCpus are not available, attempt to use just cpusets.cpus + if (cpuSet == null || cpuSet.length <= 0) { + cpuSet = containerMetrics.getCpuSetCpus(); + } if (cpuSet != null && cpuSet.length > 0) { double systemLoad = 0.0; for (int cpu : cpuSet) { @@ -182,7 +186,7 @@ public double getProcessCpuLoad() { private boolean isCpuSetSameAsHostCpuSet() { if (containerMetrics != null && containerMetrics.getCpuSetCpus() != null) { - return containerMetrics.getCpuSetCpus().length == getHostConfiguredCpuCount0(); + return containerMetrics.getCpuSetCpus().length == getHostOnlineCpuCount0(); } return false; } @@ -200,6 +204,7 @@ private boolean isCpuSetSameAsHostCpuSet() { private native long getTotalSwapSpaceSize0(); private native double getSingleCpuLoad0(int cpuNum); private native int getHostConfiguredCpuCount0(); + private native int getHostOnlineCpuCount0(); static { initialize0(); diff --git a/test/hotspot/jtreg/ProblemList-Xcomp.txt b/test/hotspot/jtreg/ProblemList-Xcomp.txt index fe27515400d..35cc36d97e0 100644 --- a/test/hotspot/jtreg/ProblemList-Xcomp.txt +++ b/test/hotspot/jtreg/ProblemList-Xcomp.txt @@ -27,3 +27,4 @@ # ############################################################################# +vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/TestDescription.java 8205957 generic-all diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups index 826b8590075..339dd7e5a92 100644 --- a/test/hotspot/jtreg/TEST.groups +++ b/test/hotspot/jtreg/TEST.groups @@ -324,7 +324,6 @@ tier1_runtime = \ -runtime/Thread/TestThreadDumpMonitorContention.java \ -runtime/Unsafe/RangeCheck.java \ sanity/ \ - testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java \ -:tier1_runtime_appcds_exclude \ -runtime/signal diff --git a/test/hotspot/jtreg/compiler/codecache/stress/ReturnBlobToWrongHeapTest.java b/test/hotspot/jtreg/compiler/codecache/stress/ReturnBlobToWrongHeapTest.java index 73b8f2fdc32..73829c5cfd2 100644 --- a/test/hotspot/jtreg/compiler/codecache/stress/ReturnBlobToWrongHeapTest.java +++ b/test/hotspot/jtreg/compiler/codecache/stress/ReturnBlobToWrongHeapTest.java @@ -63,13 +63,22 @@ private static void free(long address) { public static void main(String[] args) { if (codeCacheMinBlockLength == 1) { + // start with allocating a small block + long firstSegmentSizedAddress = 0; + firstSegmentSizedAddress = allocate(0); + if (firstSegmentSizedAddress == 0) { + throw new RuntimeException("Test failed: Failed allocating first segment-sized blob"); + } + // Fill first code heap with large blobs until allocation fails. long address; while ((address = allocate((int)largeBlobSize)) != 0) { } - // Allocate segment-sized blocks in first code heap. - long lastSegmentSizedAddress = 0; // Address of the last segment-sized blob allocated + // Allocate segment-sized blocks in first code heap until it runs out + // Remember the last one + // Use the pre-allocated one as backup if the code cache is already completely full. + long lastSegmentSizedAddress = firstSegmentSizedAddress; while ((address = allocate(0)) != 0) { lastSegmentSizedAddress = address; } diff --git a/test/hotspot/jtreg/compiler/loopopts/TestDeepGraphVerifyIterativeGVN.java b/test/hotspot/jtreg/compiler/loopopts/TestDeepGraphVerifyIterativeGVN.java new file mode 100644 index 00000000000..e51bbd9f322 --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestDeepGraphVerifyIterativeGVN.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2020, 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 8246203 + * @requires vm.debug == true & vm.flavor == "server" + * @summary Test which causes a stack overflow segmentation fault with -XX:+VerifyIterativeGVN due to a too deep recursion in Node::verify_recur(). + * + * @run main/othervm/timeout=600 -Xcomp -XX:+VerifyIterativeGVN -XX:CompileCommand=compileonly,compiler.loopopts.TestDeepGraphVerifyIterativeGVN::* + * compiler.loopopts.TestDeepGraphVerifyIterativeGVN + */ + +package compiler.loopopts; + +public class TestDeepGraphVerifyIterativeGVN +{ + static volatile int[] iArr; + static volatile int x; + + public static void main(String[] arr) { + /* + * Just enough statements to create a deep enough graph (i.e. many nodes in one chain). The current recursive verification in Node::verify_recur() will follow this chain + * and call itself again for each newly discovered input node. The current implementation can only handle up to around 10000 recursive calls and will then crash with a + * stack overflow segementation fault. The iterative fix needs much less memory and does not result in a segementation fault anymore. + */ + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; iArr = new int[] { x % 2 }; + } +} diff --git a/test/hotspot/jtreg/runtime/cds/SharedBaseAddress.java b/test/hotspot/jtreg/runtime/cds/SharedBaseAddress.java index ad3fb6577a9..6f662038deb 100644 --- a/test/hotspot/jtreg/runtime/cds/SharedBaseAddress.java +++ b/test/hotspot/jtreg/runtime/cds/SharedBaseAddress.java @@ -41,6 +41,7 @@ public class SharedBaseAddress { "1g", "8g", "64g","512g", "4t", "32t", "128t", "0", "1", "64k", "64M", + "0x800001000", // Default base address + 1 page - probably valid but unaligned to metaspace alignment, see JDK 8247522 "0xfffffffffff00000", // archive top wraps around 64-bit address space "0xfff80000", // archive top wraps around 32-bit address space "0xffffffffffffffff", // archive bottom wraps around 64-bit address space -- due to align_up() diff --git a/test/hotspot/jtreg/runtime/cds/appcds/SharedBaseAddress.java b/test/hotspot/jtreg/runtime/cds/appcds/SharedBaseAddress.java index 14ee0207e2d..5d981c01794 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/SharedBaseAddress.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/SharedBaseAddress.java @@ -41,7 +41,8 @@ public class SharedBaseAddress { private static final String[] testTable = { "1g", "8g", "64g","512g", "4t", "32t", "128t", "0", - "1", "64k", "64M", "320g" + "1", "64k", "64M", "320g", + "0x800001000" // Default base address + 1 page - probably valid but unaligned to metaspace alignment, see JDK 8247522 }; public static void main(String[] args) throws Exception { diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/AppendClasspath.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/AppendClasspath.java index 5072a57c930..4a2d3d45da7 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/AppendClasspath.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/AppendClasspath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, 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 @@ -30,7 +30,7 @@ * @compile ../test-classes/Hello.java * @compile ../test-classes/HelloMore.java * @build sun.hotspot.WhiteBox - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. AppendClasspath */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ArrayKlasses.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ArrayKlasses.java index 75ebcfc4b8b..c5f56a4752b 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ArrayKlasses.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ArrayKlasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, 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 @@ -31,7 +31,7 @@ * @build ArrayKlassesApp * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller -jar ArrayKlasses.jar ArrayKlassesApp - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. ArrayKlasses */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ClassResolutionFailure.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ClassResolutionFailure.java index 5bf97ec44c6..666003fa78e 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ClassResolutionFailure.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ClassResolutionFailure.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ * @build MissingDependent * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller -jar missingDependent.jar MissingDependent - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. ClassResolutionFailure */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicArchiveRelocationTest.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicArchiveRelocationTest.java index 5f8527159f3..d3c53f2acca 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicArchiveRelocationTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicArchiveRelocationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ * @build HelloRelocation * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller -jar hello.jar HelloRelocation HelloInlineClassApp HelloInlineClassApp$Point HelloInlineClassApp$Point$ref - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. DynamicArchiveRelocationTest */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicLotsOfClasses.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicLotsOfClasses.java index 384fdc49c15..ce2a214ddea 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicLotsOfClasses.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicLotsOfClasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ * @build LoadClasses * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller -jar loadclasses.jar LoadClasses - * @run driver ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox * @run main/othervm/timeout=500 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:./whitebox.jar DynamicLotsOfClasses */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ExcludedClasses.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ExcludedClasses.java index 1b6d29627ad..9c9d3b5f2b4 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ExcludedClasses.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ExcludedClasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, 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 @@ -35,7 +35,7 @@ * ExcludedClassesApp$NotLinkedSuper * ExcludedClassesApp$NotLinkedChild * ExcludedClassesApp$NotLinkedInterface - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. ExcludedClasses */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/HelloDynamic.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/HelloDynamic.java index 586c2aab7b5..2a71937460e 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/HelloDynamic.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/HelloDynamic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, 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 @@ -30,7 +30,7 @@ * @build Hello * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller -jar hello.jar Hello - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. HelloDynamic */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/HelloDynamicCustom.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/HelloDynamicCustom.java index 3b57792a56c..2dc36726768 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/HelloDynamicCustom.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/HelloDynamicCustom.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, 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 @@ -31,7 +31,7 @@ * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller -jar hello.jar HelloUnload ClassUnloadCommon ClassUnloadCommon$1 ClassUnloadCommon$TestFailure * @run driver ClassFileInstaller -jar hello_custom.jar CustomLoadee - * @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:./WhiteBox.jar HelloDynamicCustom */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/HelloDynamicCustomUnload.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/HelloDynamicCustomUnload.java index 69c99f5d953..d4ada452a18 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/HelloDynamicCustomUnload.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/HelloDynamicCustomUnload.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller -jar hello.jar HelloUnload ClassUnloadCommon ClassUnloadCommon$1 ClassUnloadCommon$TestFailure * @run driver ClassFileInstaller -jar hello_custom.jar CustomLoadee - * @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:./WhiteBox.jar HelloDynamicCustomUnload */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/JITInteraction.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/JITInteraction.java index 5912f87d895..09cfbfcec08 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/JITInteraction.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/JITInteraction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, 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 @@ -29,7 +29,7 @@ * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes * @build TestJIT * @build sun.hotspot.WhiteBox - * @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox * @run driver ClassFileInstaller -jar testjit.jar TestJIT * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:./WhiteBox.jar JITInteraction */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaForClassInBaseArchive.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaForClassInBaseArchive.java index 6ec64c8f6ee..e68bf028d7f 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaForClassInBaseArchive.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaForClassInBaseArchive.java @@ -95,7 +95,7 @@ private static void doTestCustomBase(String baseArchiveName, String topArchiveNa .assertNormalExit(out -> { out.shouldHaveExitValue(0) .shouldContain("SimpleApp source: shared objects file") - .shouldMatch(".class.load. SimpleApp[$][$]Lambda[$]1/0x.*source:.*shared.*objects.*file.*(top)"); + .shouldMatch(".class.load. SimpleApp[$][$]Lambda[$].*/0x.*source:.*shared.*objects.*file.*(top)"); }); } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LinkClassTest.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LinkClassTest.java index 9b2ca6f964f..ccf7cfb02d8 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LinkClassTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LinkClassTest.java @@ -32,7 +32,7 @@ * @build LinkClassApp * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller -jar link_class_app.jar LinkClassApp Parent Child Parent2 Child2 MyShutdown - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. LinkClassTest */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MethodSorting.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MethodSorting.java index a85b62a6550..84507e20cb2 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MethodSorting.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MethodSorting.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, 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 @@ -45,7 +45,7 @@ * MethodSortingApp$ImplementorA1 * MethodSortingApp$ImplementorB * MethodSortingApp$ImplementorB1 - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodSorting */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MissingArchive.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MissingArchive.java index 3e7829ce544..eb75c1322e6 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MissingArchive.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MissingArchive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, 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 @@ -30,7 +30,7 @@ * @requires vm.cds * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes * @build GenericTestApp sun.hotspot.WhiteBox - * @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox * @run driver ClassFileInstaller -jar GenericTestApp.jar GenericTestApp * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:./WhiteBox.jar MissingArchive */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NestTest.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NestTest.java index 07d79748964..ecb7c4a7823 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NestTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NestTest.java @@ -67,7 +67,7 @@ static void test() throws Exception { "-Xlog:class+load=debug,class+resolve=debug,class+unload=info", "-cp", appJar, mainClass, "run") .assertNormalExit(output -> { - output.shouldMatch(".class.load.* NestApp[$]InnerA[$]InnerInnerA[$][$]Lambda[$]1/0x.*source:.*shared.*objects.*file.*(top)") + output.shouldMatch(".class.load.* NestApp[$]InnerA[$]InnerInnerA[$][$]Lambda[$].*/0x.*source:.*shared.*objects.*file.*(top)") .shouldHaveExitValue(0); }); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NoClassToArchive.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NoClassToArchive.java index 7330837e471..1568f60efba 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NoClassToArchive.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NoClassToArchive.java @@ -40,7 +40,7 @@ * @build StrConcatApp * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller -jar strConcatApp.jar StrConcatApp - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. NoClassToArchive */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/RelativePath.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/RelativePath.java index e51ae5f789b..463c7d582c2 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/RelativePath.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/RelativePath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, 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 @@ -30,7 +30,7 @@ * @build sun.hotspot.WhiteBox * @compile ../test-classes/Hello.java * @compile ../test-classes/HelloMore.java - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. RelativePath */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/SharedArchiveFileOption.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/SharedArchiveFileOption.java index afceb30094f..cfe3791006a 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/SharedArchiveFileOption.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/SharedArchiveFileOption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, 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 @@ -30,7 +30,7 @@ * @build Hello * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller -jar hello.jar Hello - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. SharedArchiveFileOption */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/StaticInnerTest.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/StaticInnerTest.java index be50a155c65..5d24b7e290a 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/StaticInnerTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/StaticInnerTest.java @@ -61,7 +61,7 @@ static void test() throws Exception { .assertNormalExit(output -> { output.shouldHaveExitValue(0) .shouldContain("HelloStaticInner source: shared objects file (top)") - .shouldMatch(".class.load. HelloStaticInner[$]InnerHello[$][$]Lambda[$]1/0x.*source:.*shared.*objects.*file.*(top)"); + .shouldMatch(".class.load. HelloStaticInner[$]InnerHello[$][$]Lambda[$].*/0x.*source:.*shared.*objects.*file.*(top)"); }); } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/UnsupportedBaseArchive.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/UnsupportedBaseArchive.java index b6a88007a98..dfb2e562a9d 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/UnsupportedBaseArchive.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/UnsupportedBaseArchive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes * @compile ../test-classes/Hello.java * @build sun.hotspot.WhiteBox - * @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:./WhiteBox.jar UnsupportedBaseArchive */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/UnusedCPDuringDump.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/UnusedCPDuringDump.java index a6a991dc353..42396767230 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/UnusedCPDuringDump.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/UnusedCPDuringDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, 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 @@ -31,7 +31,7 @@ * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @build sun.hotspot.WhiteBox * @compile ../test-classes/Hello.java - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -Dtest.cds.copy.child.stdout=false -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. UnusedCPDuringDump */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/CDSMHTest_generate.sh b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/CDSMHTest_generate.sh index 77d7941db02..def90c398fc 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/CDSMHTest_generate.sh +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/CDSMHTest_generate.sh @@ -50,8 +50,8 @@ do * ../../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java * ../test-classes/TestMHApp.java * @build sun.hotspot.WhiteBox - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox\$WhiteBoxPermission - * @run junit/othervm/timeout=240 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. $i + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * @run junit/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. $i */ import org.junit.Test; diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesAsCollectorTest.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesAsCollectorTest.java index 65bea8c0c1f..20f73d444f9 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesAsCollectorTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesAsCollectorTest.java @@ -40,8 +40,8 @@ * ../../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java * ../test-classes/TestMHApp.java * @build sun.hotspot.WhiteBox - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission - * @run junit/othervm/timeout=240 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesAsCollectorTest + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * @run junit/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesAsCollectorTest */ import org.junit.Test; diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesCastFailureTest.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesCastFailureTest.java index fdae6d7bca9..3405a31b744 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesCastFailureTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesCastFailureTest.java @@ -40,8 +40,8 @@ * ../../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java * ../test-classes/TestMHApp.java * @build sun.hotspot.WhiteBox - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission - * @run junit/othervm/timeout=240 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesCastFailureTest + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * @run junit/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesCastFailureTest */ import org.junit.Test; diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesGeneralTest.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesGeneralTest.java index a2e753691cc..0a0655c0c81 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesGeneralTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesGeneralTest.java @@ -40,8 +40,8 @@ * ../../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java * ../test-classes/TestMHApp.java * @build sun.hotspot.WhiteBox - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission - * @run junit/othervm/timeout=240 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesGeneralTest + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * @run junit/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesGeneralTest */ import org.junit.Test; diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesInvokersTest.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesInvokersTest.java index 5e99f3d10a6..95b369e2554 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesInvokersTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesInvokersTest.java @@ -40,8 +40,8 @@ * ../../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java * ../test-classes/TestMHApp.java * @build sun.hotspot.WhiteBox - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission - * @run junit/othervm/timeout=240 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesInvokersTest + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * @run junit/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesInvokersTest */ import org.junit.Test; diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesPermuteArgumentsTest.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesPermuteArgumentsTest.java index b38ed056834..f612171432a 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesPermuteArgumentsTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesPermuteArgumentsTest.java @@ -40,8 +40,8 @@ * ../../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java * ../test-classes/TestMHApp.java * @build sun.hotspot.WhiteBox - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission - * @run junit/othervm/timeout=240 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesPermuteArgumentsTest + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * @run junit/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesPermuteArgumentsTest */ import org.junit.Test; diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesSpreadArgumentsTest.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesSpreadArgumentsTest.java index 77f1895b25f..f9962b6499e 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesSpreadArgumentsTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/methodHandles/MethodHandlesSpreadArgumentsTest.java @@ -40,8 +40,8 @@ * ../../../../../../../jdk/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java * ../test-classes/TestMHApp.java * @build sun.hotspot.WhiteBox - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission - * @run junit/othervm/timeout=240 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesSpreadArgumentsTest + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * @run junit/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. MethodHandlesSpreadArgumentsTest */ import org.junit.Test; diff --git a/test/hotspot/jtreg/runtime/cds/appcds/javaldr/GCDuringDump.java b/test/hotspot/jtreg/runtime/cds/appcds/javaldr/GCDuringDump.java index e7ac82cbbfe..37f07ca8027 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/javaldr/GCDuringDump.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/javaldr/GCDuringDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,6 +41,7 @@ public class GCDuringDump { }; public static String agentClasses[] = { GCDuringDumpTransformer.class.getName(), + GCDuringDumpTransformer.MyCleaner.class.getName(), }; public static void main(String[] args) throws Throwable { @@ -55,15 +56,18 @@ public static void main(String[] args) throws Throwable { String gcLog = Boolean.getBoolean("test.cds.verbose.gc") ? "-Xlog:gc*=info,gc+region=trace,gc+alloc+region=debug" : "-showversion"; - for (int i=0; i<2; i++) { + for (int i=0; i<3; i++) { // i = 0 -- run without agent = no extra GCs // i = 1 -- run with agent = cause extra GCs + // i = 2 -- run with agent = cause extra GCs + use java.lang.ref.Cleaner String extraArg = (i == 0) ? "-showversion" : "-javaagent:" + agentJar; String extraOption = (i == 0) ? "-showversion" : "-XX:+AllowArchivingWithJavaAgent"; + String extraOption2 = (i != 2) ? "-showversion" : "-Dtest.with.cleaner=true"; TestCommon.testDump(appJar, TestCommon.list(Hello.class.getName()), - "-XX:+UnlockDiagnosticVMOptions", extraOption, + "-XX:+UnlockDiagnosticVMOptions", extraOption, extraOption2, + "-Xlog:exceptions=trace", extraArg, "-Xmx32m", gcLog); TestCommon.run( diff --git a/test/hotspot/jtreg/runtime/cds/appcds/javaldr/GCDuringDumpTransformer.java b/test/hotspot/jtreg/runtime/cds/appcds/javaldr/GCDuringDumpTransformer.java index a9e18daf123..c523f2cc7b9 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/javaldr/GCDuringDumpTransformer.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/javaldr/GCDuringDumpTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,18 +25,40 @@ import java.lang.instrument.ClassFileTransformer; import java.lang.instrument.Instrumentation; import java.lang.instrument.IllegalClassFormatException; +import java.lang.ref.Cleaner; import java.security.ProtectionDomain; public class GCDuringDumpTransformer implements ClassFileTransformer { + static boolean TEST_WITH_CLEANER = Boolean.getBoolean("test.with.cleaner"); + static Cleaner cleaner; + static Thread thread; + static Object garbage; + + static { + if (TEST_WITH_CLEANER) { + cleaner = Cleaner.create(); + garbage = new Object(); + cleaner.register(garbage, new MyCleaner()); + System.out.println("Registered cleaner"); + } + } + public byte[] transform(ClassLoader loader, String name, Class classBeingRedefined, ProtectionDomain pd, byte[] buffer) throws IllegalClassFormatException { - try { - makeGarbage(); - } catch (Throwable t) { - t.printStackTrace(); + if (TEST_WITH_CLEANER) { + if (name.equals("Hello")) { + garbage = null; + System.out.println("Unreferenced GCDuringDumpTransformer.garbage"); + } + } else { try { - Thread.sleep(200); // let GC to have a chance to run - } catch (Throwable t2) {} + makeGarbage(); + } catch (Throwable t) { + t.printStackTrace(); + try { + Thread.sleep(200); // let GC to have a chance to run + } catch (Throwable t2) {} + } } return null; @@ -45,7 +67,7 @@ public byte[] transform(ClassLoader loader, String name, Class classBeingRede private static Instrumentation savedInstrumentation; public static void premain(String agentArguments, Instrumentation instrumentation) { - System.out.println("ClassFileTransformer.premain() is called"); + System.out.println("ClassFileTransformer.premain() is called: TEST_WITH_CLEANER = " + TEST_WITH_CLEANER); instrumentation.addTransformer(new GCDuringDumpTransformer(), /*canRetransform=*/true); savedInstrumentation = instrumentation; } @@ -63,4 +85,15 @@ public static void makeGarbage() { Object[] a = new Object[10000]; } } + + static class MyCleaner implements Runnable { + static int count = 0; + int i = count++; + public void run() { + // Allocate something. This will cause G1 to allocate an EDEN region. + // See JDK-8245925 + Object o = new Object(); + System.out.println("cleaning " + i); + } + } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/OptimizeModuleHandlingTest.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/OptimizeModuleHandlingTest.java index 9343b8c19a6..836f0d444e6 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/OptimizeModuleHandlingTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/OptimizeModuleHandlingTest.java @@ -24,7 +24,7 @@ /** * @test - * @requires vm.cds + * @requires vm.cds & !vm.jvmci * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @run driver OptimizeModuleHandlingTest * @summary test module path changes for optimization of diff --git a/test/hotspot/jtreg/runtime/cds/appcds/loaderConstraints/DynamicLoaderConstraintsTest.java b/test/hotspot/jtreg/runtime/cds/appcds/loaderConstraints/DynamicLoaderConstraintsTest.java index b2c7154818b..07003806c3d 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/loaderConstraints/DynamicLoaderConstraintsTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/loaderConstraints/DynamicLoaderConstraintsTest.java @@ -32,7 +32,7 @@ * @modules java.base/jdk.internal.misc * jdk.httpserver * @build sun.hotspot.WhiteBox - * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. DynamicLoaderConstraintsTest */ diff --git a/test/hotspot/jtreg/serviceability/dcmd/gc/HeapDumpCompressedTest.java b/test/hotspot/jtreg/serviceability/dcmd/gc/HeapDumpCompressedTest.java index 9032d610cf6..cb0a19a65b2 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/gc/HeapDumpCompressedTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/gc/HeapDumpCompressedTest.java @@ -79,7 +79,7 @@ * java.compiler * java.management * jdk.internal.jvmstat/sun.jvmstat.monitor - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseZGC HeapDumpCompressedTest + * @run main/othervm -XX:+UseZGC HeapDumpCompressedTest */ /* @@ -91,7 +91,7 @@ * java.compiler * java.management * jdk.internal.jvmstat/sun.jvmstat.monitor - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC HeapDumpCompressedTest + * @run main/othervm -XX:+UseShenandoahGC HeapDumpCompressedTest */ /* diff --git a/test/hotspot/jtreg/testlibrary/jvmti/libSimpleClassFileLoadHook.c b/test/hotspot/jtreg/testlibrary/jvmti/libSimpleClassFileLoadHook.c index a95d7b28a89..ffa457323f7 100644 --- a/test/hotspot/jtreg/testlibrary/jvmti/libSimpleClassFileLoadHook.c +++ b/test/hotspot/jtreg/testlibrary/jvmti/libSimpleClassFileLoadHook.c @@ -22,7 +22,7 @@ */ /* - * A simple way to test JVMTI ClassFileLoadHook. See ../testlibrary_tests/SimpleClassFileLoadHookTest.java + * A simple way to test JVMTI ClassFileLoadHook. See ../testlibrary_tests/jvmti/SimpleClassFileLoadHookTest.java * for an example. */ #include diff --git a/test/hotspot/jtreg/testlibrary_tests/AssertsTest.java b/test/hotspot/jtreg/testlibrary_tests/AssertsTest.java deleted file mode 100644 index fd0ca96c270..00000000000 --- a/test/hotspot/jtreg/testlibrary_tests/AssertsTest.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * 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 - * 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. - */ - -import static jdk.test.lib.Asserts.*; - -/* @test - * @summary Tests the different assertions in the Assert class - * @modules java.base/jdk.internal.misc - * @library /test/lib - */ -public class AssertsTest { - private static class Foo implements Comparable { - final int id; - public Foo(int id) { - this.id = id; - } - - public int compareTo(Foo f) { - return new Integer(id).compareTo(new Integer(f.id)); - } - } - - public static void main(String[] args) throws Exception { - testLessThan(); - testLessThanOrEqual(); - testEquals(); - testGreaterThanOrEqual(); - testGreaterThan(); - testNotEquals(); - testNull(); - testNotNull(); - testTrue(); - testFalse(); - } - - private static void testLessThan() throws Exception { - expectPass(Assertion.LT, 1, 2); - - expectFail(Assertion.LT, 2, 2); - expectFail(Assertion.LT, 2, 1); - expectFail(Assertion.LT, null, 2); - expectFail(Assertion.LT, 2, null); - } - - private static void testLessThanOrEqual() throws Exception { - expectPass(Assertion.LTE, 1, 2); - expectPass(Assertion.LTE, 2, 2); - - expectFail(Assertion.LTE, 3, 2); - expectFail(Assertion.LTE, null, 2); - expectFail(Assertion.LTE, 2, null); - } - - private static void testEquals() throws Exception { - expectPass(Assertion.EQ, 1, 1); - expectPass(Assertion.EQ, null, null); - - Foo f1 = new Foo(1); - expectPass(Assertion.EQ, f1, f1); - - Foo f2 = new Foo(1); - expectFail(Assertion.EQ, f1, f2); - expectFail(Assertion.LTE, null, 2); - expectFail(Assertion.LTE, 2, null); - } - - private static void testGreaterThanOrEqual() throws Exception { - expectPass(Assertion.GTE, 1, 1); - expectPass(Assertion.GTE, 2, 1); - - expectFail(Assertion.GTE, 1, 2); - expectFail(Assertion.GTE, null, 2); - expectFail(Assertion.GTE, 2, null); - } - - private static void testGreaterThan() throws Exception { - expectPass(Assertion.GT, 2, 1); - - expectFail(Assertion.GT, 1, 1); - expectFail(Assertion.GT, 1, 2); - expectFail(Assertion.GT, null, 2); - expectFail(Assertion.GT, 2, null); - } - - private static void testNotEquals() throws Exception { - expectPass(Assertion.NE, null, 1); - expectPass(Assertion.NE, 1, null); - - Foo f1 = new Foo(1); - Foo f2 = new Foo(1); - expectPass(Assertion.NE, f1, f2); - - expectFail(Assertion.NE, null, null); - expectFail(Assertion.NE, f1, f1); - expectFail(Assertion.NE, 1, 1); - } - - private static void testNull() throws Exception { - expectPass(Assertion.NULL, null); - - expectFail(Assertion.NULL, 1); - } - - private static void testNotNull() throws Exception { - expectPass(Assertion.NOTNULL, 1); - - expectFail(Assertion.NOTNULL, null); - } - - private static void testTrue() throws Exception { - expectPass(Assertion.TRUE, true); - - expectFail(Assertion.TRUE, false); - } - - private static void testFalse() throws Exception { - expectPass(Assertion.FALSE, false); - - expectFail(Assertion.FALSE, true); - } - - private static > void expectPass(Assertion assertion, T ... args) - throws Exception { - Assertion.run(assertion, args); - } - - private static > void expectFail(Assertion assertion, T ... args) - throws Exception { - try { - Assertion.run(assertion, args); - } catch (RuntimeException e) { - return; - } - throw new Exception("Expected " + Assertion.format(assertion, (Object[]) args) + - " to throw a RuntimeException"); - } - -} - -enum Assertion { - LT, LTE, EQ, GTE, GT, NE, NULL, NOTNULL, FALSE, TRUE; - - public static > void run(Assertion assertion, T ... args) { - String msg = "Expected " + format(assertion, args) + " to pass"; - switch (assertion) { - case LT: - assertLessThan(args[0], args[1], msg); - break; - case LTE: - assertLessThanOrEqual(args[0], args[1], msg); - break; - case EQ: - assertEquals(args[0], args[1], msg); - break; - case GTE: - assertGreaterThanOrEqual(args[0], args[1], msg); - break; - case GT: - assertGreaterThan(args[0], args[1], msg); - break; - case NE: - assertNotEquals(args[0], args[1], msg); - break; - case NULL: - assertNull(args == null ? args : args[0], msg); - break; - case NOTNULL: - assertNotNull(args == null ? args : args[0], msg); - break; - case FALSE: - assertFalse((Boolean) args[0], msg); - break; - case TRUE: - assertTrue((Boolean) args[0], msg); - break; - default: - // do nothing - } - } - - public static String format(Assertion assertion, Object ... args) { - switch (assertion) { - case LT: - return asString("assertLessThan", args); - case LTE: - return asString("assertLessThanOrEqual", args); - case EQ: - return asString("assertEquals", args); - case GTE: - return asString("assertGreaterThanOrEquals", args); - case GT: - return asString("assertGreaterThan", args); - case NE: - return asString("assertNotEquals", args); - case NULL: - return asString("assertNull", args); - case NOTNULL: - return asString("assertNotNull", args); - case FALSE: - return asString("assertFalse", args); - case TRUE: - return asString("assertTrue", args); - default: - return ""; - } - } - - private static String asString(String assertion, Object ... args) { - if (args == null) { - return String.format("%s(null)", assertion); - } - if (args.length == 1) { - return String.format("%s(%s)", assertion, args[0]); - } else { - return String.format("%s(%s, %s)", assertion, args[0], args[1]); - } - } -} diff --git a/test/hotspot/jtreg/testlibrary_tests/OutputAnalyzerReportingTest.java b/test/hotspot/jtreg/testlibrary_tests/OutputAnalyzerReportingTest.java deleted file mode 100644 index c8abc6f50f1..00000000000 --- a/test/hotspot/jtreg/testlibrary_tests/OutputAnalyzerReportingTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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 - * 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 - * @summary Test the OutputAnalyzer reporting functionality, - * such as printing additional diagnostic info - * (exit code, stdout, stderr, command line, etc.) - * @library /test/lib - * @modules java.base/jdk.internal.misc - * java.management - */ - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; - -import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; - - -public class OutputAnalyzerReportingTest { - - public static void main(String[] args) throws Exception { - // Create the output analyzer under test - String stdout = "aaaaaa"; - String stderr = "bbbbbb"; - OutputAnalyzer output = new OutputAnalyzer(stdout, stderr); - - // Expected summary values should be the same for all cases, - // since the outputAnalyzer object is the same - String expectedExitValue = "-1"; - String expectedSummary = - " stdout: [" + stdout + "];\n" + - " stderr: [" + stderr + "]\n" + - " exitValue = " + expectedExitValue + "\n"; - - - DiagnosticSummaryTestRunner testRunner = - new DiagnosticSummaryTestRunner(); - - // should have exit value - testRunner.init(expectedSummary); - int unexpectedExitValue = 2; - try { - output.shouldHaveExitValue(unexpectedExitValue); - } catch (RuntimeException e) { } - testRunner.closeAndCheckResults(); - - // should not contain - testRunner.init(expectedSummary); - try { - output.shouldNotContain(stdout); - } catch (RuntimeException e) { } - testRunner.closeAndCheckResults(); - - // should contain - testRunner.init(expectedSummary); - try { - output.shouldContain("unexpected-stuff"); - } catch (RuntimeException e) { } - testRunner.closeAndCheckResults(); - - // should not match - testRunner.init(expectedSummary); - try { - output.shouldNotMatch("[a]"); - } catch (RuntimeException e) { } - testRunner.closeAndCheckResults(); - - // should match - testRunner.init(expectedSummary); - try { - output.shouldMatch("[qwerty]"); - } catch (RuntimeException e) { } - testRunner.closeAndCheckResults(); - - } - - private static class DiagnosticSummaryTestRunner { - private ByteArrayOutputStream byteStream = - new ByteArrayOutputStream(10000); - - private String expectedSummary = ""; - private PrintStream errStream; - - - public void init(String expectedSummary) { - this.expectedSummary = expectedSummary; - byteStream.reset(); - errStream = new PrintStream(byteStream); - System.setErr(errStream); - } - - public void closeAndCheckResults() { - // check results - errStream.close(); - String stdErrStr = byteStream.toString(); - if (!stdErrStr.contains(expectedSummary)) { - throw new RuntimeException("The output does not contain " - + "the diagnostic message, or the message is incorrect"); - } - } - } - -} diff --git a/test/hotspot/jtreg/testlibrary_tests/OutputAnalyzerTest.java b/test/hotspot/jtreg/testlibrary_tests/OutputAnalyzerTest.java deleted file mode 100644 index 6faedf4a8c5..00000000000 --- a/test/hotspot/jtreg/testlibrary_tests/OutputAnalyzerTest.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * 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 - * 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 - * @summary Test the OutputAnalyzer utility class - * @library /test/lib - * @modules java.base/jdk.internal.misc - * java.management - */ - -import jdk.test.lib.process.OutputAnalyzer; - -public class OutputAnalyzerTest { - - public static void main(String args[]) throws Exception { - - String stdout = "aaaaaa"; - String stderr = "bbbbbb"; - - // Regexps used for testing pattern matching of the test input - String stdoutPattern = "[a]"; - String stderrPattern = "[b]"; - String nonExistingPattern = "[c]"; - - OutputAnalyzer output = new OutputAnalyzer(stdout, stderr); - - if (!stdout.equals(output.getStdout())) { - throw new Exception("getStdout() returned '" + output.getStdout() + "', expected '" + stdout + "'"); - } - - if (!stderr.equals(output.getStderr())) { - throw new Exception("getStderr() returned '" + output.getStderr() + "', expected '" + stderr + "'"); - } - - try { - output.shouldContain(stdout); - output.stdoutShouldContain(stdout); - output.shouldContain(stderr); - output.stderrShouldContain(stderr); - } catch (RuntimeException e) { - throw new Exception("shouldContain() failed", e); - } - - try { - output.shouldContain("cccc"); - throw new Exception("shouldContain() failed to throw exception"); - } catch (RuntimeException e) { - // expected - } - - try { - output.stdoutShouldContain(stderr); - throw new Exception("stdoutShouldContain() failed to throw exception"); - } catch (RuntimeException e) { - // expected - } - - try { - output.stderrShouldContain(stdout); - throw new Exception("stdoutShouldContain() failed to throw exception"); - } catch (RuntimeException e) { - // expected - } - - try { - output.shouldNotContain("cccc"); - output.stdoutShouldNotContain("cccc"); - output.stderrShouldNotContain("cccc"); - } catch (RuntimeException e) { - throw new Exception("shouldNotContain() failed", e); - } - - try { - output.shouldNotContain(stdout); - throw new Exception("shouldContain() failed to throw exception"); - } catch (RuntimeException e) { - // expected - } - - try { - output.stdoutShouldNotContain(stdout); - throw new Exception("shouldContain() failed to throw exception"); - } catch (RuntimeException e) { - // expected - } - - try { - output.stderrShouldNotContain(stderr); - throw new Exception("shouldContain() failed to throw exception"); - } catch (RuntimeException e) { - // expected - } - - // Should match - try { - output.shouldMatch(stdoutPattern); - output.stdoutShouldMatch(stdoutPattern); - output.shouldMatch(stderrPattern); - output.stderrShouldMatch(stderrPattern); - } catch (RuntimeException e) { - throw new Exception("shouldMatch() failed", e); - } - - try { - output.shouldMatch(nonExistingPattern); - throw new Exception("shouldMatch() failed to throw exception"); - } catch (RuntimeException e) { - // expected - } - - try { - output.stdoutShouldMatch(stderrPattern); - throw new Exception( - "stdoutShouldMatch() failed to throw exception"); - } catch (RuntimeException e) { - // expected - } - - try { - output.stderrShouldMatch(stdoutPattern); - throw new Exception( - "stderrShouldMatch() failed to throw exception"); - } catch (RuntimeException e) { - // expected - } - - // Should not match - try { - output.shouldNotMatch(nonExistingPattern); - output.stdoutShouldNotMatch(nonExistingPattern); - output.stderrShouldNotMatch(nonExistingPattern); - } catch (RuntimeException e) { - throw new Exception("shouldNotMatch() failed", e); - } - - try { - output.shouldNotMatch(stdoutPattern); - throw new Exception("shouldNotMatch() failed to throw exception"); - } catch (RuntimeException e) { - // expected - } - - try { - output.stdoutShouldNotMatch(stdoutPattern); - throw new Exception("shouldNotMatch() failed to throw exception"); - } catch (RuntimeException e) { - // expected - } - - try { - output.stderrShouldNotMatch(stderrPattern); - throw new Exception("shouldNotMatch() failed to throw exception"); - } catch (RuntimeException e) { - // expected - } - - { - String aaaa = "aaaa"; - String result = output.firstMatch(aaaa); - if (!aaaa.equals(result)) { - throw new Exception("firstMatch(String) faild to match. Expected: " + aaaa + " got: " + result); - } - } - - { - String aa = "aa"; - String aa_grouped_aa = aa + "(" + aa + ")"; - String result = output.firstMatch(aa_grouped_aa, 1); - if (!aa.equals(result)) { - throw new Exception("firstMatch(String, int) failed to match. Expected: " + aa + " got: " + result); - } - } - } -} diff --git a/test/hotspot/jtreg/testlibrary_tests/SimpleClassFileLoadHookTest.java b/test/hotspot/jtreg/testlibrary_tests/jvmti/SimpleClassFileLoadHookTest.java similarity index 100% rename from test/hotspot/jtreg/testlibrary_tests/SimpleClassFileLoadHookTest.java rename to test/hotspot/jtreg/testlibrary_tests/jvmti/SimpleClassFileLoadHookTest.java diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon001/comptimemon001.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon001/comptimemon001.java index f5211afb136..05aec212923 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon001/comptimemon001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon001/comptimemon001.java @@ -32,7 +32,7 @@ * VM Testbase readme: * DESCRIPTION * The test checks that - * CompilationMBean.isCompilationTimeMonitoringSupported() + * CompilationMXBean.isCompilationTimeMonitoringSupported() * method returns true. The test performs directly access to management * metrics within the same JVM. * Note, that the test is correct ONLY against Sun's Hotspot VM. This diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon002/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon002/TestDescription.java index d0a710610ba..dfd40658596 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon002/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon002/TestDescription.java @@ -31,7 +31,7 @@ * VM Testbase readme: * DESCRIPTION * The test checks that - * CompilationMBean.isCompilationTimeMonitoringSupported() + * CompilationMXBean.isCompilationTimeMonitoringSupported() * method returns true. The test performs access to management metrics * through default MBeanServer. * Note, that the test is correct ONLY against Sun's Hotspot VM. This @@ -50,4 +50,3 @@ * nsk.monitoring.CompilationMXBean.comptimemon001.comptimemon001 * -testMode=server */ - diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon003/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon003/TestDescription.java index ed543854a02..6901d483c92 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon003/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon003/TestDescription.java @@ -31,7 +31,7 @@ * VM Testbase readme: * DESCRIPTION * The test checks that - * CompilationMBean.isCompilationTimeMonitoringSupported() + * CompilationMXBean.isCompilationTimeMonitoringSupported() * method returns true. The test performs access to management metrics * through custom MBeanServer (developed and saved in * $TESTBASE/src/nsk/monitoring/share). @@ -52,4 +52,3 @@ * -testMode=server * -MBeanServer=custom */ - diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon004/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon004/TestDescription.java index a4d85cc0243..f289a6161d3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon004/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon004/TestDescription.java @@ -31,7 +31,7 @@ * VM Testbase readme: * DESCRIPTION * The test checks that - * CompilationMBean.isCompilationTimeMonitoringSupported() + * CompilationMXBean.isCompilationTimeMonitoringSupported() * method returns true. The test performs access to management metrics * through default MBeanServer proxy. * Note, that the test is correct ONLY against Sun's Hotspot VM. This @@ -50,4 +50,3 @@ * nsk.monitoring.CompilationMXBean.comptimemon001.comptimemon001 * -testMode=proxy */ - diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon005/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon005/TestDescription.java index 2bdf1018c28..c70deb02403 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon005/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/CompilationMXBean/comptimemon005/TestDescription.java @@ -31,7 +31,7 @@ * VM Testbase readme: * DESCRIPTION * The test checks that - * CompilationMBean.isCompilationTimeMonitoringSupported() + * CompilationMXBean.isCompilationTimeMonitoringSupported() * method returns true. The test performs access to management metrics * through custom MBeanServer proxy (developed and saved in * $TESTBASE/src/nsk/monitoring/share). @@ -52,4 +52,3 @@ * -testMode=proxy * -MBeanServer=custom */ - diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 0000fda1c13..de2f7a6c286 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -859,6 +859,7 @@ sanity/client/SwingSet/src/ScrollPaneDemoTest.java 8225013 linux-all # core_tools tools/jlink/JLinkReproducibleTest.java 8217166 windows-all +tools/jlink/plugins/CompressorPluginTest.java 8247407 generic-all ############################################################################ diff --git a/test/jdk/com/sun/crypto/provider/Mac/DigestCloneabilityTest.java b/test/jdk/com/sun/crypto/provider/Mac/DigestCloneabilityTest.java new file mode 100644 index 00000000000..2c54237fac5 --- /dev/null +++ b/test/jdk/com/sun/crypto/provider/Mac/DigestCloneabilityTest.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2020, 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 8246077 + * @summary Ensure a cloneable digest can be accepted/used by HmacCore + */ +import java.security.*; +import java.security.spec.AlgorithmParameterSpec; +import javax.crypto.*; +import javax.crypto.spec.*; + +public class DigestCloneabilityTest { + + private static String ALGO = "HmacSHA512"; + + public static void main(String[] args) throws Exception { + Provider p = new SampleProvider(); + // make SampleProvider the most preferred, so its digest impl is picked + int status = Security.insertProviderAt(p, 1); + try { + Mac mac = Mac.getInstance(ALGO, "SunJCE"); + // do a complete mac generation and check if the supplied + // digest is used + mac.init(new SecretKeySpec(new byte[512>>3], ALGO)); + mac.update((byte)0x12); + byte[] macBytes = mac.doFinal(); + if (!SampleProvider.CloneableDigest.isUsed) { + throw new RuntimeException("Expected Digest impl not used"); + } + } finally { + if (status != -1) { + Security.removeProvider(p.getName()); + } + } + System.out.println("Test Passed"); + } + + public static class SampleProvider extends Provider { + + public SampleProvider() { + super("Sample", "1.0", "test provider"); + putService(new Provider.Service(this, "MessageDigest", "SHA-512", + "DigestCloneabilityTest$SampleProvider$CloneableDigest", + null, null)); + } + public static class CloneableDigest extends MessageDigestSpi + implements Cloneable { + private MessageDigest md; + static boolean isUsed = false; + + public CloneableDigest() throws NoSuchAlgorithmException { + try { + md = MessageDigest.getInstance("SHA-512", "SUN"); + } catch (NoSuchProviderException nspe) { + // should never happen + } + } + + public byte[] engineDigest() { + isUsed = true; + return md.digest(); + } + + public void engineReset() { + isUsed = true; + md.reset(); + } + + public void engineUpdate(byte input) { + isUsed = true; + md.update(input); + } + + public void engineUpdate(byte[] b, int ofs, int len) { + isUsed = true; + md.update(b, ofs, len); + } + + public Object clone() throws CloneNotSupportedException { + return this; + } + } + } +} diff --git a/test/jdk/com/sun/net/httpserver/DateFormatterTest.java b/test/jdk/com/sun/net/httpserver/DateFormatterTest.java new file mode 100644 index 00000000000..47ff79e26e7 --- /dev/null +++ b/test/jdk/com/sun/net/httpserver/DateFormatterTest.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2020, 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. + */ + +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.concurrent.Executors; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import jdk.test.lib.net.URIBuilder; +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; +import static java.net.http.HttpResponse.BodyHandlers.ofString; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; + +/** + * @test + * @bug 8245307 + * @summary Test for DateFormatter in ExchangeImpl + * @modules java.net.http + * @library /test/lib + * @build DateFormatterTest + * @run testng/othervm DateFormatterTest + */ +public class DateFormatterTest { + + private HttpServer server; + + static URI httpURI; + static final Integer ITERATIONS = 10; + static String format; + static Pattern pattern; + + @BeforeTest + public void setUp() throws IOException, URISyntaxException { + String days = "(Mon|Tue|Wed|Thu|Fri|Sat|Sun)(,)"; + String dayNo = "(\\s\\d\\d\\s)"; + String month = "(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"; + String hour = "(\\s\\d\\d\\d\\d\\s\\d\\d)(:)(\\d\\d)(:)(\\d\\d\\s)"; + String zone = "(GMT)"; + format = days + dayNo + month + hour + zone; + pattern = Pattern.compile(format); + server = HttpServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 10); + server.createContext("/server", new DateFormatHandler()); + server.setExecutor(Executors.newCachedThreadPool()); + httpURI = URIBuilder.newBuilder() + .host(server.getAddress().getAddress()) + .port(server.getAddress().getPort()) + .scheme("http") + .path("/server") + .build(); + server.start(); + } + + @AfterTest + public void cleanUp() { + server.stop(1); + } + + @Test + public void testDateFormat() throws Exception { + HttpClient client = HttpClient.newBuilder() + .build(); + HttpRequest request = HttpRequest.newBuilder(httpURI) + .GET() + .build(); + for (int i = 0; i < ITERATIONS; i++) { + HttpResponse response = client.send(request, ofString()); + String date = response.headers().firstValue("Date").orElse("null"); + if (date.equals("null")) + fail("Date not present"); + Matcher matcher = pattern.matcher(date); + assertTrue(matcher.matches()); + } + } + + public static class DateFormatHandler implements HttpHandler { + + @Override + public void handle(HttpExchange exchange) throws IOException { + try (InputStream is = exchange.getRequestBody(); + OutputStream os = exchange.getResponseBody()) { + byte[] bytes = is.readAllBytes(); + exchange.sendResponseHeaders(200, bytes.length); + os.write(bytes); + } + } + } +} diff --git a/test/jdk/java/awt/Graphics2D/LargeWindowPaintTest.java b/test/jdk/java/awt/Graphics2D/LargeWindowPaintTest.java new file mode 100644 index 00000000000..3b9bb15fc5c --- /dev/null +++ b/test/jdk/java/awt/Graphics2D/LargeWindowPaintTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2020, 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 8240654 + * @summary Test painting a large window works + * @key headful + * @requires (os.family == "windows") + * @requires vm.gc.Z + * @run main/othervm -Dsun.java2d.uiScale=1 LargeWindowPaintTest + * @run main/othervm -Dsun.java2d.uiScale=1 -Dsun.java2d.d3d=false LargeWindowPaintTest + * @run main/othervm -XX:+UseZGC -Dsun.java2d.uiScale=1 LargeWindowPaintTest + * @run main/othervm -XX:+UseZGC -Dsun.java2d.uiScale=1 -Dsun.java2d.d3d=false LargeWindowPaintTest + */ + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Rectangle; +import java.awt.Robot; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.WindowConstants; + +public class LargeWindowPaintTest extends JPanel { + + static volatile JFrame frame = null; + static volatile LargeWindowPaintTest comp = null; + static Color color = Color.red; + + public static void main(String[] args) throws Exception { + + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame("Large Window Paint Test"); + frame.add(comp = new LargeWindowPaintTest()); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + frame.setExtendedState(Frame.MAXIMIZED_BOTH); + frame.setVisible(true); + }); + + Thread.sleep(2000); + Robot robot = new Robot(); + robot.setAutoDelay(500); + robot.waitForIdle(); + Rectangle r = comp.getBounds(); + System.out.println("Component bounds = " + r); + Color c = robot.getPixelColor((int)r.getWidth()-100, (int)r.getHeight()-100); + + SwingUtilities.invokeAndWait(() -> frame.dispose()); + + if (!c.equals(color)) { + throw new RuntimeException("Color was " + c + " expected " + color); + } + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + g.setColor(color); + g.fillRect(0, 0, getSize().width, getSize().height); + }; +} diff --git a/test/jdk/java/awt/print/PrinterJob/AlphaPrintTest.java b/test/jdk/java/awt/print/PrinterJob/AlphaPrintTest.java new file mode 100644 index 00000000000..8d986adfb88 --- /dev/null +++ b/test/jdk/java/awt/print/PrinterJob/AlphaPrintTest.java @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2020, 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 8240654 + * @summary Test printing alpha colors - banded printing works with ZGC. + * @key headful printer + * @requires (os.family == "windows") + * @requires vm.gc.Z + * @run main/manual/othervm -XX:+UseZGC -Dsun.java2d.d3d=false AlphaPrintTest + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GridLayout; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import java.awt.print.PageFormat; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; +import javax.swing.WindowConstants; + +public class AlphaPrintTest extends JPanel implements Printable { + + static final int W=400, H=600; + + static volatile JFrame frame = null; + static volatile AlphaPrintTest comp = null; + static Color color = Color.red; + static volatile boolean passed = false; + static volatile boolean printInvoked = false; + static volatile boolean done = false; + + public static void main(String[] args) throws Exception { + + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame("Alpha Color Print Test"); + frame.setLayout(new GridLayout(1, 2)); + frame.add(comp = new AlphaPrintTest()); + frame.add(new InstructionPanel()); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + frame.pack(); + frame.setVisible(true); + }); + + while (!done || !printInvoked) { + Thread.sleep(1000); + } + + SwingUtilities.invokeAndWait(() -> frame.dispose()); + + if (!passed) { + throw new RuntimeException("Test failed."); + } + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(W, H); + } + + + @Override + public Dimension getMinimumSize() { + return getPreferredSize(); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + paintContent(g); + }; + + private void paintContent(Graphics g) { + Color c = new Color(255, 0, 0, 240); // not a solid color. + g.setColor(c); + g.drawLine(0, 0, W, H); + g.drawLine(W, 0, 0, H); + + for (int i=10; i < 150; i+=10) { + g.drawRect(i, i, W-(i*2), H-(i*2)); + } + g.drawString("Alpha Paint Test", W/2-30, H/2); + } + + public int print(Graphics g, PageFormat pf, int pageIndex) { + if (pageIndex == 0) { + Graphics2D g2d = (Graphics2D)g; + g2d.translate(pf.getImageableX(), pf.getImageableY()); + paintContent(g); + return Printable.PAGE_EXISTS; + } + return Printable.NO_SUCH_PAGE; + } + + public void doPrint() { + printInvoked = true; + PrinterJob pj = PrinterJob.getPrinterJob(); + pj.setPrintable(this); + if (pj.printDialog()) { + try { + pj.print(); + } catch (PrinterException e) { + e.printStackTrace(); + done = true; + } + } + } + + public void doClose(boolean pass) { + if (printInvoked) { + passed = pass; + done = true; + } + } +} + +class InstructionPanel extends JPanel implements ActionListener { + + static final String INSTRUCTIONS = + "You must have a printer to peform this test.\n" + + "Press the print button which will bring up a print dialog." + + "Select a suitable printer, and confirm to print. " + + "Examine the printed output. It should closely resemble the rendering in" + + " the panel to the left. If yes, press PASS, else press FAIL"; + + InstructionPanel() { + GridLayout gl1 = new GridLayout(2, 1); + setLayout(gl1); + JTextArea ta = new JTextArea(INSTRUCTIONS); + ta.setEditable(false); + ta.setLineWrap(true); + ta.setWrapStyleWord(true); + add(ta); + JPanel p = new JPanel(); + JButton print = new JButton("Print"); + JButton pass = new JButton("PASS"); + JButton fail = new JButton("FAIL"); + print.addActionListener(this); + pass.addActionListener(this); + fail.addActionListener(this); + p.add(print); + p.add(pass); + p.add(fail); + add(p); + } + @Override + public Dimension getPreferredSize() { + return new Dimension(200, 600); + } + + + @Override + public Dimension getMinimumSize() { + return getPreferredSize(); + } + public void actionPerformed(ActionEvent e) { + String cmd = e.getActionCommand(); + switch (cmd) { + case "Print" -> AlphaPrintTest.comp.doPrint(); + case "PASS" -> AlphaPrintTest.comp.doClose(true); + case "FAIL" -> AlphaPrintTest.comp.doClose(false); + } + + } + +} diff --git a/test/jdk/java/net/DatagramSocket/UnreferencedDatagramSockets.java b/test/jdk/java/net/DatagramSocket/UnreferencedDatagramSockets.java index 1619af1decc..429a127e8f7 100644 --- a/test/jdk/java/net/DatagramSocket/UnreferencedDatagramSockets.java +++ b/test/jdk/java/net/DatagramSocket/UnreferencedDatagramSockets.java @@ -25,7 +25,7 @@ * @test * @library /test/lib * @modules java.management java.base/java.io:+open java.base/java.net:+open - * java.base/sun.net + * java.base/sun.net java.base/sun.nio.ch:+open * @run main/othervm UnreferencedDatagramSockets * @run main/othervm -Djava.net.preferIPv4Stack=true UnreferencedDatagramSockets * @run main/othervm -Djdk.net.usePlainDatagramSocketImpl UnreferencedDatagramSockets diff --git a/test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java b/test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java index 0dd22b47cd7..b86b271c11a 100644 --- a/test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java +++ b/test/jdk/java/net/MulticastSocket/UnreferencedMulticastSockets.java @@ -25,7 +25,7 @@ * @test * @library /test/lib * @modules java.management java.base/java.io:+open java.base/java.net:+open - * java.base/sun.net + * java.base/sun.net java.base/sun.nio.ch:+open * @run main/othervm -Djava.net.preferIPv4Stack=true UnreferencedMulticastSockets * @run main/othervm -Djdk.net.usePlainDatagramSocketImpl UnreferencedMulticastSockets * @run main/othervm UnreferencedMulticastSockets diff --git a/test/jdk/java/nio/channels/etc/OpenAndConnect.java b/test/jdk/java/nio/channels/etc/OpenAndConnect.java index 01c38c2ec91..b183076e49d 100644 --- a/test/jdk/java/nio/channels/etc/OpenAndConnect.java +++ b/test/jdk/java/nio/channels/etc/OpenAndConnect.java @@ -94,12 +94,23 @@ public void setup() { @DataProvider(name = "openConnect") public Object[][] openConnect() { LinkedList l = new LinkedList<>(); - l.addAll(openConnectGenTests); - if (IA4LOCAL != null) { - l.addAll(openConnectV4LocalTests); + if (IPSupport.hasIPv4()) { + l.addAll(openConnectV4Tests); + if (IA4LOCAL != null) { + l.addAll(openConnectV4LocalTests); + } + } + if (IPSupport.hasIPv6()) { + l.addAll(openConnectV6Tests); + if (IA6LOCAL != null) { + l.addAll(openConnectV6LocalTests); + } } - if (IA6LOCAL != null) { - l.addAll(openConnectV6LocalTests); + if (IPSupport.hasIPv4() && IPSupport.hasIPv6()) { + l.addAll(openConnectV4AndV6Tests); + if (IA4LOCAL != null) { + l.addAll(openConnectV4LocalAndV6Tests); + } } return l.toArray(new Object[][]{}); } @@ -122,40 +133,20 @@ public Object[][] openConnect() { // + + + + // { sfam, saddr, cfam, caddr, } - public static List openConnectGenTests = + // Basic tests for when an IPv4 is available + public static List openConnectV4Tests = Arrays.asList(new Object[][] { { INET, IA4LOOPBACK, INET, IA4LOOPBACK }, { INET, IA4LOOPBACK, null, IA4LOOPBACK }, { INET, IA4ANYLOCAL, null, IA4LOOPBACK }, { INET, IA4ANYLOCAL, INET, IA4LOOPBACK }, - { INET6, IA6ANYLOCAL, null, IA6LOOPBACK }, - { INET6, IA6ANYLOCAL, INET6, IA6LOOPBACK }, - { INET6, IA6LOOPBACK, INET6, IA6LOOPBACK }, { null, IA4LOOPBACK, INET, IA4ANYLOCAL }, { null, IA4LOOPBACK, INET, IA4LOOPBACK }, { null, IA4LOOPBACK, INET, null }, - { null, IA4LOOPBACK, INET6, IA6ANYLOCAL }, - { null, IA6LOOPBACK, INET6, IA6ANYLOCAL }, - { null, IA6LOOPBACK, INET6, IA6LOOPBACK }, - { null, IA6LOOPBACK, INET6, DONT_BIND }, - { null, IA4LOOPBACK, INET6, DONT_BIND }, - { null, IA4LOOPBACK, INET6, null }, - { null, IA6LOOPBACK, INET6, null }, - { null, IA4LOOPBACK, null, IA6ANYLOCAL }, - { null, IA6LOOPBACK, null, IA6ANYLOCAL }, - { null, IA6LOOPBACK, null, IA6LOOPBACK }, - { null, IA4LOOPBACK, null, null }, - { null, IA6LOOPBACK, null, null }, - { null, IA6ANYLOCAL, null, IA6LOCAL }, - { null, IA6ANYLOCAL, null, IA6LOOPBACK }, - { null, IA6ANYLOCAL, INET6, IA6LOCAL }, - { null, IA6ANYLOCAL, INET6, IA6LOOPBACK }, - { INET6, IA6LOOPBACK, INET6, IA6LOOPBACK } + { null, IA4LOOPBACK, null, null } }); - // Additional tests for when an IPv4 local address or V6 - // local address is available - + // Additional tests for when an IPv4 local address is available public List openConnectV4LocalTests = Arrays.asList(new Object[][] { { INET, IA4LOCAL, INET, IA4LOCAL }, @@ -166,11 +157,28 @@ public Object[][] openConnect() { { null, IA4LOCAL, INET, IA4ANYLOCAL }, { null, IA4LOCAL, INET, IA4LOCAL }, { null, IA4LOCAL, INET, null }, - { null, IA4LOCAL, INET6, IA6ANYLOCAL }, - { null, IA4LOCAL, INET6, null }, - { null, IA4LOCAL, null, IA6ANYLOCAL } + { null, IA4LOCAL, null, null } }); + // Basic tests for when an IPv6 is available + public List openConnectV6Tests = + Arrays.asList(new Object[][] { + { INET6, IA6ANYLOCAL, null, IA6LOOPBACK }, + { INET6, IA6ANYLOCAL, INET6, IA6LOOPBACK }, + { INET6, IA6LOOPBACK, INET6, IA6LOOPBACK }, + { INET6, IA6LOOPBACK, INET6, IA6LOOPBACK }, + { null, IA6ANYLOCAL, null, IA6LOOPBACK }, + { null, IA6ANYLOCAL, INET6, IA6LOOPBACK }, + { null, IA6LOOPBACK, INET6, IA6LOOPBACK }, + { null, IA6LOOPBACK, INET6, DONT_BIND }, + { null, IA6LOOPBACK, INET6, null }, + { null, IA6LOOPBACK, null, IA6LOOPBACK }, + { null, IA6LOOPBACK, null, null }, + { null, IA6LOOPBACK, INET6, IA6ANYLOCAL }, + { null, IA6LOOPBACK, null, IA6ANYLOCAL } + }); + + // Additional tests for when an IPv6 local address is available public List openConnectV6LocalTests = Arrays.asList(new Object[][] { { INET6, IA6ANYLOCAL, null, IA6LOCAL }, @@ -178,16 +186,33 @@ public Object[][] openConnect() { { INET6, IA6LOCAL, INET6, IA6LOCAL }, { INET6, IA6LOCAL, null, IA6LOCAL }, { INET6, IA6LOCAL, null, DONT_BIND }, + { INET6, IA6LOCAL, INET6, IA6LOCAL }, + { null, IA6ANYLOCAL, null, IA6LOCAL }, + { null, IA6ANYLOCAL, INET6, IA6LOCAL }, { null, IA6LOCAL, INET6, IA6LOCAL }, { null, IA6LOCAL, INET6, IA6ANYLOCAL }, { null, IA6LOCAL, null, IA6ANYLOCAL }, { null, IA6LOCAL, null, IA6LOCAL }, { null, IA6LOCAL, INET6, null }, - { null, IA6LOCAL, null, null }, - { null, IA4LOCAL, null, null }, - { INET6, IA6LOCAL, INET6, IA6LOCAL } + { null, IA6LOCAL, null, null } }); + // Additional tests for when IPv4 and IPv6 are available + public List openConnectV4AndV6Tests = + Arrays.asList(new Object[][] { + { null, IA4LOOPBACK, INET6, IA6ANYLOCAL }, + { null, IA4LOOPBACK, null, IA6ANYLOCAL }, + { null, IA4LOOPBACK, INET6, DONT_BIND }, + { null, IA4LOOPBACK, INET6, null } + }); + + // Additional tests for when IPv4 local address and IPv6 are available + public List openConnectV4LocalAndV6Tests = + Arrays.asList(new Object[][] { + { null, IA4LOCAL, INET6, IA6ANYLOCAL }, + { null, IA4LOCAL, INET6, null }, + { null, IA4LOCAL, null, IA6ANYLOCAL } + }); /** * If the destination address is the wildcard, it is replaced by the alternate diff --git a/test/jdk/java/security/KeyStore/OneProbeOneNot.java b/test/jdk/java/security/KeyStore/OneProbeOneNot.java new file mode 100644 index 00000000000..3e340ab928a --- /dev/null +++ b/test/jdk/java/security/KeyStore/OneProbeOneNot.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2020, 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 8245679 + * @summary KeyStore cannot probe PKCS12 keystore if BouncyCastle is the top security provider + * @run main/othervm OneProbeOneNot + */ + +import java.io.File; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.security.*; +import java.security.cert.Certificate; +import java.util.Date; +import java.util.Enumeration; + +public class OneProbeOneNot { + public static final void main(String[] args) throws Exception { + Files.write(Path.of("ks"), "".getBytes()); + // 1st provider do not support probe + Security.insertProviderAt(new P1(), 1); + // 2nd provider support probe + Security.insertProviderAt(new P2(), 2); + KeyStore ks = KeyStore.getInstance(new File("ks"), (char[])null); + System.out.println(ks.getProvider().getName()); + System.out.println(ks.getType()); + } + + public static class P1 extends Provider { + public P1() { + super("P1", "P1", "P1"); + putService(new Service(this, "KeyStore", "Oops", + K1.class.getName(), null, null)); + } + } + public static class P2 extends Provider { + public P2() { + super("P2", "P2", "P2"); + putService(new Service(this, "KeyStore", "Oops", + K2.class.getName(), null, null)); + } + } + + public static class K1 extends KeyStoreSpi { + public Key engineGetKey(String a, char[] p) { return null; } + public Certificate[] engineGetCertificateChain(String a) { return null; } + public Certificate engineGetCertificate(String a) { return null; } + public Date engineGetCreationDate(String a) { return null; } + public void engineSetKeyEntry(String a, Key k, char[] p, Certificate[] c) { } + public void engineSetKeyEntry(String a, byte[] k, Certificate[] c) { } + public void engineSetCertificateEntry(String a, Certificate c) { } + public void engineDeleteEntry(String a) { } + public Enumeration engineAliases() { return null; } + public boolean engineContainsAlias(String a) { return false; } + public int engineSize() { return 0; } + public boolean engineIsKeyEntry(String a) { return false; } + public boolean engineIsCertificateEntry(String a) { return false; } + public String engineGetCertificateAlias(Certificate c) { return null; } + public void engineStore(OutputStream stream, char[] password) { } + public void engineLoad(InputStream stream, char[] password) { } + } + + public static class K2 extends K1 { + public boolean engineProbe(InputStream s) { + return true; + } + } +} diff --git a/test/jdk/java/security/MessageDigest/TestCloneable.java b/test/jdk/java/security/MessageDigest/TestCloneable.java new file mode 100644 index 00000000000..915f0c0996e --- /dev/null +++ b/test/jdk/java/security/MessageDigest/TestCloneable.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2020, 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 8246077 + * @summary Make sure that digest spi and the resulting digest impl are + * consistent in the impl of Cloneable interface + * @run testng TestCloneable + */ +import java.security.*; +import java.util.Objects; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import org.testng.Assert; + +public class TestCloneable { + + private static final Class CNSE = + CloneNotSupportedException.class; + + @DataProvider + public Object[][] testData() { + return new Object[][] { + { "MD2", "SUN" }, { "MD5", "SUN" }, { "SHA-1", "SUN" }, + { "SHA-224", "SUN" }, { "SHA-256", "SUN" }, + { "SHA-384", "SUN" }, { "SHA-512", "SUN" }, + { "SHA3-224", "SUN" }, { "SHA3-256", "SUN" }, + { "SHA3-384", "SUN" }, { "SHA3-512", "SUN" } + }; + } + + @Test(dataProvider = "testData") + public void test(String algo, String provName) + throws NoSuchProviderException, NoSuchAlgorithmException, + CloneNotSupportedException { + System.out.print("Testing " + algo + " impl from " + provName); + Provider p = Security.getProvider(provName); + Provider.Service s = p.getService("MessageDigest", algo); + Objects.requireNonNull(s); + MessageDigestSpi spi = (MessageDigestSpi) s.newInstance(null); + MessageDigest md = MessageDigest.getInstance(algo, provName); + if (spi instanceof Cloneable) { + System.out.println(": Cloneable"); + Assert.assertTrue(md instanceof Cloneable); + MessageDigest md2 = (MessageDigest) md.clone(); + Assert.assertEquals(md2.getAlgorithm(), algo); + Assert.assertEquals(md2.getProvider().getName(), provName); + Assert.assertTrue(md2 instanceof Cloneable); + } else { + System.out.println(": NOT Cloneable"); + Assert.assertThrows(CNSE, ()->md.clone()); + } + System.out.println("Test Passed"); + } +} diff --git a/test/jdk/java/security/SecureRandom/DefaultAlgo.java b/test/jdk/java/security/SecureRandom/DefaultAlgo.java index d29aa87b202..d85d73b2cba 100644 --- a/test/jdk/java/security/SecureRandom/DefaultAlgo.java +++ b/test/jdk/java/security/SecureRandom/DefaultAlgo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, 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 @@ -22,33 +22,96 @@ */ import static java.lang.System.out; +import java.security.Provider; +import java.security.Security; import java.security.SecureRandom; +import java.security.Provider.Service; +import java.util.Objects; +import java.util.Arrays; import sun.security.provider.SunEntries; /** * @test - * @bug 8228613 - * @summary Ensure that the default SecureRandom algo matches - * SunEntries.DEF_SECURE_RANDOM_ALGO when SUN provider is used + * @bug 8228613 8246613 + * @summary Ensure that the default SecureRandom algo used is based + * on the registration ordering, and falls to next provider + * if none are found * @modules java.base/sun.security.provider */ public class DefaultAlgo { public static void main(String[] args) throws Exception { - SecureRandom sr = new SecureRandom(); - String actualAlg = sr.getAlgorithm(); - out.println("Default SecureRandom algo: " + actualAlg); - if (sr.getProvider().getName().equals("SUN")) { - // when using Sun provider, compare and check if the algorithm - // matches SunEntries.DEF_SECURE_RANDOM_ALGO - if (actualAlg.equals(SunEntries.DEF_SECURE_RANDOM_ALGO)) { - out.println("Test Passed"); - } else { - throw new RuntimeException("Failed: Expected " + + String[] algos = { "A", "B", "C" }; + test3rdParty(algos); + // reverse the order and re-check + String[] algosReversed = { "C", "B", "A" }; + test3rdParty(algosReversed); + } + + private static void test3rdParty(String[] algos) { + Provider[] provs = { + new SampleLegacyProvider(algos), + new SampleServiceProvider(algos) + }; + for (Provider p : provs) { + checkDefault(p, algos); + } + } + + // validate the specified SecureRandom obj to be from the specified + // provider and matches the specified algorithm + private static void validate(SecureRandom sr, String pName, String algo) { + if (!sr.getProvider().getName().equals(pName)) { + throw new RuntimeException("Failed provider check, exp: " + + pName + ", got " + sr.getProvider().getName()); + } + if (!sr.getAlgorithm().equals(algo)) { + throw new RuntimeException("Failed algo check, exp: " + + algo + ", got " + sr.getAlgorithm()); + } + } + + private static void checkDefault(Provider p, String ... algos) { + out.println(p.getName() + " with " + Arrays.toString(algos)); + int pos = Security.insertProviderAt(p, 1); + String pName = p.getName(); + boolean isLegacy = pName.equals("SampleLegacy"); + try { + if (isLegacy) { + for (String s : algos) { + validate(new SecureRandom(), pName, s); + p.remove("SecureRandom." + s); + out.println("removed " + s); + } + validate(new SecureRandom(), "SUN", SunEntries.DEF_SECURE_RANDOM_ALGO); + } else { + validate(new SecureRandom(), pName, algos[0]); + } + out.println("=> Test Passed"); + } finally { + if (pos != -1) { + Security.removeProvider(p.getName()); + } + } + } + + private static class SampleLegacyProvider extends Provider { + SampleLegacyProvider(String[] listOfSupportedRNGs) { + super("SampleLegacy", "1.0", "test provider using legacy put"); + for (String s : listOfSupportedRNGs) { + put("SecureRandom." + s, "sun.security.provider.SecureRandom"); + } + } + } + + private static class SampleServiceProvider extends Provider { + SampleServiceProvider(String[] listOfSupportedRNGs) { + super("SampleService", "1.0", "test provider using putService"); + for (String s : listOfSupportedRNGs) { + putService(new Provider.Service(this, "SecureRandom", s, + "sun.security.provider.SecureRandom", null, null)); } - } else { - out.println("Skip test for non-Sun provider: " + sr.getProvider()); } } } diff --git a/test/jdk/java/security/Signature/TestCloneable.java b/test/jdk/java/security/Signature/TestCloneable.java new file mode 100644 index 00000000000..33e2383cfa4 --- /dev/null +++ b/test/jdk/java/security/Signature/TestCloneable.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2020, 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 8246077 + * @summary Make sure that signature objects which are cloneable + * implement the Cloneable interface + * @run testng TestCloneable + */ +import java.security.NoSuchProviderException; +import java.security.NoSuchAlgorithmException; +import java.security.Signature; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import org.testng.Assert; + +public class TestCloneable { + + private static final Class CNSE = + CloneNotSupportedException.class; + + @DataProvider + public Object[][] testData() { + return new Object[][] { + { "SHA1withDSA", "SUN" }, { "NONEwithDSA", "SUN" }, + { "SHA224withDSA", "SUN" }, { "SHA256withDSA", "SUN" }, + { "EdDSA", "SunEC" }, { "Ed25519", "SunEC" }, { "Ed448", "SunEC" }, + { "SHA1withECDSA", "SunEC" }, { "SHA224withECDSA", "SunEC" }, + { "SHA256withECDSA", "SunEC" }, { "SHA384withECDSA", "SunEC" }, + { "SHA512withECDSA", "SunEC" }, { "NONEwithECDSA", "SunEC" }, + { "MD2withRSA", "SunRsaSign" }, { "MD5withRSA", "SunRsaSign" }, + { "SHA1withRSA", "SunRsaSign" }, { "SHA224withRSA", "SunRsaSign" }, + { "SHA256withRSA", "SunRsaSign" }, + { "SHA384withRSA", "SunRsaSign" }, + { "SHA512withRSA", "SunRsaSign" }, + { "SHA512/224withRSA", "SunRsaSign" }, + { "SHA512/256withRSA", "SunRsaSign" }, + { "RSASSA-PSS", "SunRsaSign" }, + { "NONEwithRSA", "SunMSCAPI" }, + { "SHA1withRSA", "SunMSCAPI" }, { "SHA256withRSA", "SunMSCAPI" }, + { "SHA384withRSA", "SunMSCAPI" }, { "SHA512withRSA", "SunMSCAPI" }, + { "RSASSA-PSS", "SunMSCAPI" }, + { "MD5withRSA", "SunMSCAPI" }, { "MD2withRSA", "SunMSCAPI" }, + { "SHA1withECDSA", "SunMSCAPI" }, + { "SHA224withECDSA", "SunMSCAPI" }, + { "SHA256withECDSA", "SunMSCAPI" }, + { "SHA384withECDSA", "SunMSCAPI" }, + { "SHA512withECDSA", "SunMSCAPI" } + }; + } + + @Test(dataProvider = "testData") + public void test(String algo, String provName) + throws NoSuchAlgorithmException, CloneNotSupportedException { + System.out.print("Testing " + algo + " impl from " + provName); + try { + Signature sig = Signature.getInstance(algo, provName); + if (sig instanceof Cloneable) { + System.out.println(": Cloneable"); + Signature sig2 = (Signature) sig.clone(); + Assert.assertEquals(sig2.getAlgorithm(), algo); + Assert.assertEquals(sig2.getProvider().getName(), provName); + Assert.assertTrue(sig2 instanceof Cloneable); + } else { + System.out.println(": NOT Cloneable"); + Assert.assertThrows(CNSE, ()->sig.clone()); + } + System.out.println("Test Passed"); + } catch (NoSuchProviderException nspe) { + // skip testing + System.out.println("Skip " + provName + " - not available"); + } + } +} diff --git a/test/jdk/java/time/tck/java/time/TCKYear.java b/test/jdk/java/time/tck/java/time/TCKYear.java index 75ed80e13ea..b86f3b567ac 100644 --- a/test/jdk/java/time/tck/java/time/TCKYear.java +++ b/test/jdk/java/time/tck/java/time/TCKYear.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2020, 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 @@ -248,10 +248,32 @@ public void test_from_TemporalAccessor_null() { @DataProvider(name="goodParseData") Object[][] provider_goodParseData() { return new Object[][] { - {"0000", Year.of(0)}, {"9999", Year.of(9999)}, {"2000", Year.of(2000)}, + {"0", Year.of(0)}, + {"00", Year.of(0)}, + {"000", Year.of(0)}, + {"0000", Year.of(0)}, + {"00000", Year.of(0)}, + {"+00000", Year.of(0)}, + {"-0", Year.of(0)}, + {"-00", Year.of(0)}, + {"-000", Year.of(0)}, + {"-0000", Year.of(0)}, + {"-00000", Year.of(0)}, + {"1", Year.of(1)}, + {"01", Year.of(1)}, + {"001", Year.of(1)}, + {"0001", Year.of(1)}, + {"00001", Year.of(1)}, + {"+00001", Year.of(1)}, + {"-1", Year.of(-1)}, + {"-01", Year.of(-1)}, + {"-001", Year.of(-1)}, + {"-0001", Year.of(-1)}, + {"-00001", Year.of(-1)}, + {"+12345678", Year.of(12345678)}, {"+123456", Year.of(123456)}, {"-1234", Year.of(-1234)}, @@ -272,20 +294,18 @@ public void factory_parse_success(String text, Year expected) { Object[][] provider_badParseData() { return new Object[][] { {"", 0}, - {"-00", 1}, {"--01-0", 1}, {"A01", 0}, - {"200", 0}, {"2009/12", 4}, - {"-0000-10", 0}, - {"-12345678901-10", 11}, - {"+1-10", 1}, - {"+12-10", 1}, - {"+123-10", 1}, - {"+1234-10", 0}, - {"12345-10", 0}, - {"+12345678901-10", 11}, + {"-0000-10", 5}, + {"-12345678901-10", 10}, + {"+1-10", 2}, + {"+12-10", 3}, + {"+123-10", 4}, + {"+1234-10", 5}, + {"12345-10", 5}, + {"+12345678901-10", 10}, }; } diff --git a/test/jdk/javax/management/MBeanServer/OldMBeanServerTest.java b/test/jdk/javax/management/MBeanServer/OldMBeanServerTest.java index 0080fbe44da..a3d952b8aff 100644 --- a/test/jdk/javax/management/MBeanServer/OldMBeanServerTest.java +++ b/test/jdk/javax/management/MBeanServer/OldMBeanServerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2020, 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 @@ -92,11 +92,14 @@ import javax.management.remote.JMXConnectorServerFactory; import javax.management.remote.JMXServiceURL; +import jdk.test.lib.Utils; + /* * @test OldMBeanServerTest.java * @bug 5072268 * @summary Test that nothing assumes a post-1.2 MBeanServer * @author Eamonn McManus + * @library /test/lib * @modules java.management.rmi * @run main/othervm -ea OldMBeanServerTest */ @@ -278,7 +281,7 @@ public void handleNotification(Notification n, Object h) { count += (Integer) h; } void waitForCount(int expect) throws InterruptedException { - long deadline = System.currentTimeMillis() + 2000L; + long deadline = System.currentTimeMillis() + Utils.adjustTimeout(2000); while (count < expect && System.currentTimeMillis() < deadline) Thread.sleep(1); assert count == expect; diff --git a/test/jdk/javax/net/ssl/SSLEngine/IllegalHandshakeMessage.java b/test/jdk/javax/net/ssl/SSLEngine/IllegalHandshakeMessage.java index 83f80660dd0..475879a3262 100644 --- a/test/jdk/javax/net/ssl/SSLEngine/IllegalHandshakeMessage.java +++ b/test/jdk/javax/net/ssl/SSLEngine/IllegalHandshakeMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2020, 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 @@ -70,7 +70,7 @@ public static void main(String args[]) throws Exception { cliToSrv.put(7, (byte)0x80); // use illegal message length } else { // unlikely - throw new Exception("No handshage message generated."); + throw new Exception("No handshake message is generated."); } try { diff --git a/test/jdk/sun/management/jmxremote/bootstrap/rmiregistry.properties b/test/jdk/sun/management/jmxremote/bootstrap/rmiregistry.properties index dbe75c4405f..7e58a5c9ec5 100644 --- a/test/jdk/sun/management/jmxremote/bootstrap/rmiregistry.properties +++ b/test/jdk/sun/management/jmxremote/bootstrap/rmiregistry.properties @@ -39,7 +39,7 @@ com.sun.management.jmxremote.port=${getFreePort} # # This option enables thread contention monitoring if the # Java virtual machine supports such instrumentation. -# Refer to the specification for the java.lang.management.ThreadMBean +# Refer to the specification for the java.lang.management.ThreadMXBean # interface - see isThreadContentionMonitoringSupported() method. # diff --git a/test/jdk/sun/management/jmxremote/bootstrap/rmiregistryssl.properties b/test/jdk/sun/management/jmxremote/bootstrap/rmiregistryssl.properties index 5d01de0977c..eba629f16cd 100644 --- a/test/jdk/sun/management/jmxremote/bootstrap/rmiregistryssl.properties +++ b/test/jdk/sun/management/jmxremote/bootstrap/rmiregistryssl.properties @@ -39,7 +39,7 @@ com.sun.management.jmxremote.port=${getFreePort} # # This option enables thread contention monitoring if the # Java virtual machine supports such instrumentation. -# Refer to the specification for the java.lang.management.ThreadMBean +# Refer to the specification for the java.lang.management.ThreadMXBean # interface - see isThreadContentionMonitoringSupported() method. # diff --git a/test/jdk/tools/jpackage/macosx/base/SigningCheck.java b/test/jdk/tools/jpackage/macosx/base/SigningCheck.java index 734f7a07410..2f247b07263 100644 --- a/test/jdk/tools/jpackage/macosx/base/SigningCheck.java +++ b/test/jdk/tools/jpackage/macosx/base/SigningCheck.java @@ -84,16 +84,21 @@ private static void validateCertificate(String key) { } private static void validateCertificateTrust(String name) { - List result = new Executor() - .setExecutable("security") - .addArguments("dump-trust-settings") - .executeWithoutExitCodeCheckAndGetOutput(); - result.stream().forEachOrdered(TKit::trace); - TKit.assertTextStream(name) - .predicate((line, what) -> line.trim().endsWith(what)) - .orElseThrow(() -> TKit.throwSkippedException( - "Certifcate not trusted by current user: " + name)) - .apply(result.stream()); + // Certificates using the default user name must be trusted by user. + // User supplied certs whose trust is set to "Use System Defaults" + // will not be listed as trusted by dump-trust-settings + if (SigningBase.DEV_NAME.equals("jpackage.openjdk.java.net")) { + List result = new Executor() + .setExecutable("security") + .addArguments("dump-trust-settings") + .executeWithoutExitCodeCheckAndGetOutput(); + result.stream().forEachOrdered(TKit::trace); + TKit.assertTextStream(name) + .predicate((line, what) -> line.trim().endsWith(what)) + .orElseThrow(() -> TKit.throwSkippedException( + "Certifcate not trusted by current user: " + name)) + .apply(result.stream()); + } } } diff --git a/test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java b/test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java index 5eae5608f99..d6509dd9393 100644 --- a/test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java +++ b/test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java @@ -303,59 +303,6 @@ public void testAtFile() throws IOException { HelloApp.executeLauncherAndVerifyOutput(cmd); } - @Parameter("Hello") - @Parameter("com.foo/com.foo.main.Aloha") - @Test - public void testJLinkRuntime(String javaAppDesc) throws IOException { - JavaAppDesc appDesc = JavaAppDesc.parse(javaAppDesc); - - JPackageCommand cmd = JPackageCommand.helloAppImage(appDesc); - - final String moduleName = appDesc.moduleName(); - - if (moduleName != null) { - // Build module jar. - cmd.executePrerequisiteActions(); - } - - final Path runtimeDir = TKit.createTempDirectory("runtime").resolve("data"); - - // List of modules required for test app. - final var modules = new String[] { - "java.base", - "java.desktop" - }; - - Executor jlink = getToolProvider(JavaTool.JLINK) - .saveOutput(false) - .addArguments( - "--add-modules", String.join(",", modules), - "--output", runtimeDir.toString(), - "--strip-debug", - "--no-header-files", - "--no-man-pages"); - - TKit.trace("jlink output BEGIN"); - try (Stream paths = Files.walk(runtimeDir)) { - paths.filter(Files::isRegularFile) - .map(runtimeDir::relativize) - .map(Path::toString) - .forEach(TKit::trace); - } - TKit.trace("jlink output END"); - - if (moduleName != null) { - jlink.addArguments("--add-modules", moduleName, "--module-path", - Path.of(cmd.getArgumentValue("--module-path")).resolve( - "hello.jar").toString()); - } - - jlink.execute(); - - cmd.addArguments("--runtime-image", runtimeDir); - cmd.executeAndAssertHelloAppImageCreated(); - } - private static Executor getJPackageToolProvider() { return getToolProvider(JavaTool.JPACKAGE); } diff --git a/test/jdk/tools/jpackage/share/jdk/jpackage/tests/CookedRuntimeTest.java b/test/jdk/tools/jpackage/share/jdk/jpackage/tests/CookedRuntimeTest.java new file mode 100644 index 00000000000..382836f07a9 --- /dev/null +++ b/test/jdk/tools/jpackage/share/jdk/jpackage/tests/CookedRuntimeTest.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2020, 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 jdk.jpackage.tests; + +import java.io.IOException; +import java.nio.file.Files; +import java.util.Collection; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; +import java.nio.file.Path; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.Executor; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.JavaAppDesc; +import jdk.jpackage.test.JavaTool; +import jdk.jpackage.test.TKit; + + +/* + * @test + * @summary test '--runtime-image' option of jpackage + * @library ../../../../helpers + * @build jdk.jpackage.test.* + * @modules jdk.incubator.jpackage/jdk.incubator.jpackage.internal + * @compile CookedRuntimeTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=jdk.jpackage.tests.CookedRuntimeTest + */ + +public final class CookedRuntimeTest { + + public CookedRuntimeTest(String javaAppDesc, String jlinkOutputSubdir, + String runtimeSubdir) { + this.javaAppDesc = javaAppDesc; + this.jlinkOutputSubdir = Path.of(jlinkOutputSubdir); + this.runtimeSubdir = Path.of(runtimeSubdir); + } + + @Test + public void test() throws IOException { + JavaAppDesc appDesc = JavaAppDesc.parse(javaAppDesc); + + JPackageCommand cmd = JPackageCommand.helloAppImage(appDesc); + + final String moduleName = appDesc.moduleName(); + + if (moduleName != null) { + // Build module jar. + cmd.executePrerequisiteActions(); + } + + final Path workDir = TKit.createTempDirectory("runtime").resolve("data"); + final Path jlinkOutputDir = workDir.resolve(jlinkOutputSubdir); + Files.createDirectories(jlinkOutputDir.getParent()); + + // List of modules required for test app. + final var modules = new String[] { + "java.base", + "java.desktop" + }; + + Executor jlink = new Executor() + .setToolProvider(JavaTool.JLINK) + .dumpOutput() + .addArguments( + "--add-modules", String.join(",", modules), + "--output", jlinkOutputDir.toString(), + "--strip-debug", + "--no-header-files", + "--no-man-pages"); + + if (moduleName != null) { + jlink.addArguments("--add-modules", moduleName, "--module-path", + Path.of(cmd.getArgumentValue("--module-path")).resolve( + "hello.jar").toString()); + } + + jlink.execute(); + + TKit.trace("jlink output BEGIN"); + try (Stream paths = Files.walk(jlinkOutputDir)) { + paths.filter(Files::isRegularFile) + .map(jlinkOutputDir::relativize) + .map(Path::toString) + .forEach(TKit::trace); + } + TKit.trace("jlink output END"); + + cmd.setArgumentValue("--runtime-image", workDir.resolve(runtimeSubdir)); + cmd.executeAndAssertHelloAppImageCreated(); + } + + @Parameters + public static Collection data() { + final List javaAppDescs = List.of("Hello", + "com.foo/com.foo.main.Aloha"); + + final List paths = new ArrayList<>(); + paths.add(new String[] { "", "" }); + if (TKit.isOSX()) { + // On OSX jpackage should accept both runtime root and runtime home + // directories. + paths.add(new String[] { "Contents/Home", "" }); + } + + List data = new ArrayList<>(); + for (var javaAppDesc : javaAppDescs) { + for (var pathCfg : paths) { + data.add(new Object[] { javaAppDesc, pathCfg[0], pathCfg[1] }); + } + } + + return data; + } + + private final String javaAppDesc; + private final Path jlinkOutputSubdir; + private final Path runtimeSubdir; +} diff --git a/test/langtools/ProblemList.txt b/test/langtools/ProblemList.txt index f096990f04b..35edcf1ee4d 100644 --- a/test/langtools/ProblemList.txt +++ b/test/langtools/ProblemList.txt @@ -26,9 +26,6 @@ ########################################################################### # # javadoc -jdk/javadoc/tool/enum/docComments/Main.java 8152313 generic-all convert to doclet test framework -jdk/javadoc/tool/enum/enumType/Main.java 8152313 generic-all convert to doclet test framework -jdk/javadoc/tool/varArgs/Main.java 8152313 generic-all convert to doclet test framework jdk/javadoc/doclet/testIOException/TestIOException.java 8164597 windows-all ########################################################################### diff --git a/test/langtools/jdk/javadoc/doclet/testRecordLinks/TestRecordLinks.java b/test/langtools/jdk/javadoc/doclet/testRecordLinks/TestRecordLinks.java new file mode 100644 index 00000000000..4e404f5f18c --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testRecordLinks/TestRecordLinks.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2020, 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 8236539 + * @summary Relative link tags in record javadoc don't resolve + * @library /tools/lib ../../lib + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @build toolbox.ToolBox javadoc.tester.* + * @compile --enable-preview --source ${jdk.version} TestRecordLinks.java + * @run main/othervm --enable-preview TestRecordLinks + */ + +import java.nio.file.Path; + +import javadoc.tester.JavadocTester; +import toolbox.ToolBox; + +public class TestRecordLinks extends JavadocTester { + public static void main(String... args) throws Exception { + TestRecordLinks tester = new TestRecordLinks(); + tester.runTests(m -> new Object[] { Path.of(m.getName()) }); + } + + private final ToolBox tb = new ToolBox(); + + @Test + public void testCrash(Path base) throws Exception { + // from JDK-8236539 + String example = """ + package example; + public class JavadocTest { + /** + * {@link #foo()} + * {@link Bar} + */ + public static class Foo { + public void foo() { } + } + + /** + * {@link #bar()} + * {@link Foo} + */ + public record Bar() { + public void bar() { } + } + } + """; + + Path src = base.resolve("src"); + tb.writeJavaFiles(src, example); + + javadoc("-d", base.resolve("out").toString(), + "-sourcepath", src.toString(), + "--enable-preview", "--source", thisRelease, + "example"); + checkExit(Exit.OK); + + checkOutput("example/JavadocTest.Foo.html", true, + """ +

Class JavadocTest.Foo

+ """, + """ + + """); + + checkOutput("example/JavadocTest.Bar.html", true, + """ +

Record JavadocTest.Bar

+ """, + """ + + """); + } +} diff --git a/test/hotspot/jtreg/testlibrary_tests/process/Test.java b/test/langtools/jdk/javadoc/lib/javadoc/tester/TestDoclet.java similarity index 52% rename from test/hotspot/jtreg/testlibrary_tests/process/Test.java rename to test/langtools/jdk/javadoc/lib/javadoc/tester/TestDoclet.java index 17375e305dd..03b7050de6f 100644 --- a/test/hotspot/jtreg/testlibrary_tests/process/Test.java +++ b/test/langtools/jdk/javadoc/lib/javadoc/tester/TestDoclet.java @@ -21,8 +21,43 @@ * questions. */ -public class Test { - public static void test() { - System.out.println ("Hello Test"); +package javadoc.tester; + +import java.util.Locale; +import java.util.Set; +import javax.lang.model.SourceVersion; + +import jdk.javadoc.doclet.Doclet; +import jdk.javadoc.doclet.DocletEnvironment; +import jdk.javadoc.doclet.Reporter; + +/** + * A minimal base class for test doclets. + * + * The {@link Doclet#run(DocletEnvironment) run} method must still be provided by subtypes. + */ +public abstract class TestDoclet implements Doclet { + protected Locale locale; + protected Reporter reporter; + + @Override + public void init(Locale locale, Reporter reporter) { + this.locale = locale; + this.reporter = reporter; + } + + @Override + public String getName() { + return getClass().getSimpleName(); + } + + @Override + public Set getSupportedOptions() { + return Set.of(); + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latestSupported(); } } diff --git a/test/langtools/jdk/javadoc/tool/enum/docComments/EnumCommentTest.java b/test/langtools/jdk/javadoc/tool/enum/docComments/EnumCommentTest.java new file mode 100644 index 00000000000..997b000da54 --- /dev/null +++ b/test/langtools/jdk/javadoc/tool/enum/docComments/EnumCommentTest.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4421066 + * @summary Verify the comments in an enum type. + * @library ../../../lib + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @build javadoc.tester.* + * @run main EnumCommentTest + */ + +import javax.lang.model.element.ElementKind; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; +import javax.lang.model.util.ElementFilter; +import javax.lang.model.util.Elements; + +import javadoc.tester.JavadocTester; +import javadoc.tester.TestDoclet; +import jdk.javadoc.doclet.DocletEnvironment; + +public class EnumCommentTest extends JavadocTester { + + public static void main(String[] args) throws Exception { + JavadocTester t = new EnumCommentTest(); + t.runTests(); + } + + @Test + public void testEnumComments() { + javadoc("-sourcepath", testSrc, + "-docletpath", System.getProperty("test.class.path"), + "-doclet", "EnumCommentTest$ThisDoclet", + "pkg1"); + checkExit(Exit.OK); + } + + public static class ThisDoclet extends TestDoclet { + public boolean run(DocletEnvironment env) { + Elements elements = env.getElementUtils(); + + System.err.println("incl " + env.getIncludedElements()); + TypeElement operation = env.getIncludedElements() + .stream() + .filter(e -> e.getKind() == ElementKind.ENUM) + .map(e -> (TypeElement) e) + .findFirst() + .orElseThrow(() -> new Error("can't find enum Operation")); + + boolean ok = checkComment(elements.getDocComment(operation).trim(), + "Arithmetic operations."); + + for (VariableElement f : ElementFilter.fieldsIn(operation.getEnclosedElements())) { + if (f.getSimpleName().contentEquals("plus")) { + ok = checkComment(elements.getDocComment(f).trim(), + "Addition") + && ok; + for (ExecutableElement m : ElementFilter.methodsIn(operation.getEnclosedElements())) { + if (m.getSimpleName().contentEquals("eval")) { + ok = checkComment(elements.getDocComment(m).trim(), + "Perform arithmetic operation represented by this constant.") + && ok; + break; + } + } + break; + } + } + if (!ok) { + throw new Error("Comments don't match expectations."); + } else { + return true; + } + } + + private boolean checkComment(String found, String expected) { + System.out.println("expected: \"" + expected + "\""); + System.out.println("found: \"" + found + "\""); + return expected.equals(found); + } + } +} diff --git a/test/langtools/jdk/javadoc/tool/enum/docComments/Main.java b/test/langtools/jdk/javadoc/tool/enum/docComments/Main.java deleted file mode 100644 index 1abd5317350..00000000000 --- a/test/langtools/jdk/javadoc/tool/enum/docComments/Main.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * 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 4421066 - * @summary Verify the comments in an enum type. - * @ignore 8152313 convert to doclet test framework - * @library ../../lib - * @modules jdk.javadoc - * @compile ../../lib/Tester.java Main.java - * @run main Main - */ - -import java.io.IOException; - -import com.sun.javadoc.*; -import jdk.javadoc.doclet.DocletEnvironment; - -public class Main extends Tester.Doclet { - - private static final Tester tester = - new Tester("Main", "-package", "pkg1"); - - public static void main(String[] args) throws IOException { - tester.run(); - } - - public static boolean run(DocletEnvironment root) { - ClassDoc operation = root.classes()[0]; - boolean ok = - checkComment(operation.commentText(), "Arithmetic operations."); - - for (FieldDoc f : operation.fields()) { - if (f.name().equals("plus")) { - ok = checkComment(f.commentText(), "Addition") && ok; - for (MethodDoc m : operation.methods()) { - if (m.name().equals("eval")) { - ok = checkComment(m.commentText(), - "Perform arithmetic operation " + - "represented by this constant.") && - ok; - break; - } - } - break; - } - } - if (!ok) { - throw new Error("Comments don't match expectations."); - } else { - return true; - } - } - - private static boolean checkComment(String found, String expected) { - System.out.println("expected: \"" + expected + "\""); - System.out.println("found: \"" + found + "\""); - return expected.equals(found); - } -} diff --git a/test/langtools/jdk/javadoc/tool/enum/docComments/pkg1/Operation.java b/test/langtools/jdk/javadoc/tool/enum/docComments/pkg1/Operation.java index 5fa18a26f8c..d035837546c 100644 --- a/test/langtools/jdk/javadoc/tool/enum/docComments/pkg1/Operation.java +++ b/test/langtools/jdk/javadoc/tool/enum/docComments/pkg1/Operation.java @@ -30,7 +30,7 @@ /** * Arithmetic operations. */ -public abstract enum Operation { +public enum Operation { /** Addition */ plus { /** Add 'em up. */ diff --git a/test/langtools/jdk/javadoc/tool/enum/enumType/EnumContentsTest.java b/test/langtools/jdk/javadoc/tool/enum/enumType/EnumContentsTest.java new file mode 100644 index 00000000000..cfa0afd7e52 --- /dev/null +++ b/test/langtools/jdk/javadoc/tool/enum/enumType/EnumContentsTest.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4421066 + * @summary Verify the contents of an enum type. + * @library ../../../lib + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @build javadoc.tester.* + * @run main EnumContentsTest + */ + +import java.io.PrintStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.stream.Collectors; +import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.DeclaredType; + +import jdk.javadoc.doclet.DocletEnvironment; + +import javadoc.tester.JavadocTester; +import javadoc.tester.TestDoclet; + +public class EnumContentsTest extends JavadocTester { + + public static void main(String[] args) throws Exception { + JavadocTester t = new EnumContentsTest(); + t.runTests(); + } + + @Test + public void testEnumContents() throws Exception { + javadoc("-sourcepath", testSrc, + "-docletpath", System.getProperty("test.class.path"), + "-doclet", "EnumContentsTest$ThisDoclet", + "pkg1"); + checkExit(Exit.OK); + + String expect = Files.readAllLines(Path.of(testSrc).resolve("expected.out")) + .stream() + .collect(Collectors.joining("\n")); + checkOutput(Output.STDOUT, true, expect); + } + + + public static class ThisDoclet extends TestDoclet { + public boolean run(DocletEnvironment root) { + try { + for (Element e : root.getIncludedElements()) { + if (e.getKind() == ElementKind.ENUM) { + printClass((TypeElement) e); + } + } + + return true; + } catch (Exception e) { + return false; + } + } + + // this method mimics the printClass method from the old + // tester framework + void printClass(TypeElement te) { + PrintStream out = System.out; + out.format("%s %s%n", + te.getKind().toString().toLowerCase(), + te.getQualifiedName()); + out.format(" name: %s / %s / %s%n", + te.getSimpleName(), te.asType(), te.getQualifiedName()); + out.format(" superclass:%n %s%n", + te.getSuperclass()); + out.format(" enum constants:%n"); + te.getEnclosedElements().stream() + .filter(e -> e.getKind() == ElementKind.ENUM_CONSTANT) + .forEach(e -> out.format(" %s%n", e.getSimpleName())); + out.format(" methods:%n"); + te.getEnclosedElements().stream() + .filter(e -> e.getKind() == ElementKind.METHOD) + .map(e -> (ExecutableElement) e) + .forEach(e -> out.format(" %s %s(%s)%n", + e.getReturnType(), + e.getSimpleName(), + e.getParameters().stream() + .map(this::paramToString) + .collect(Collectors.joining(", ")) + )); + + } + private String paramToString(Element e) { + return ((DeclaredType) e.asType()).asElement().getSimpleName().toString(); + } + } +} diff --git a/test/langtools/jdk/javadoc/tool/enum/enumType/Main.java b/test/langtools/jdk/javadoc/tool/enum/enumType/Main.java deleted file mode 100644 index b6f1a4bfd01..00000000000 --- a/test/langtools/jdk/javadoc/tool/enum/enumType/Main.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * 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 4421066 - * @summary Verify the contents of an enum type. - * @ignore 8152313 convert to doclet test framework - * @library ../../lib - * @modules jdk.javadoc - * @compile ../../lib/Tester.java Main.java - * @run main Main - */ - -import java.io.IOException; -import com.sun.javadoc.*; - -public class Main extends Tester.Doclet { - - private static final Tester tester = new Tester("Main", "pkg1"); - - public static void main(String[] args) throws IOException { - tester.run(); - tester.verify(); - } - - public static boolean run(DocletEnvironment root) { - try { - for (ClassDoc cd : root.classes()) { - tester.printClass(cd); - } - - return true; - } catch (IOException e) { - return false; - } - } -} diff --git a/test/langtools/jdk/javadoc/tool/enum/enumType/expected.out b/test/langtools/jdk/javadoc/tool/enum/enumType/expected.out index 43dbdb95660..73be0aa170b 100644 --- a/test/langtools/jdk/javadoc/tool/enum/enumType/expected.out +++ b/test/langtools/jdk/javadoc/tool/enum/enumType/expected.out @@ -1,5 +1,5 @@ enum pkg1.QuotablePerson - name: QuotablePerson / QuotablePerson / pkg1.QuotablePerson + name: QuotablePerson / pkg1.QuotablePerson / pkg1.QuotablePerson superclass: java.lang.Enum enum constants: @@ -15,4 +15,4 @@ enum pkg1.QuotablePerson Eco methods: pkg1.QuotablePerson[] values() - QuotablePerson valueOf(String) + pkg1.QuotablePerson valueOf(String) diff --git a/test/langtools/jdk/javadoc/tool/varArgs/Main.java b/test/langtools/jdk/javadoc/tool/varArgs/Main.java deleted file mode 100644 index 503e9c017fc..00000000000 --- a/test/langtools/jdk/javadoc/tool/varArgs/Main.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * 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 4421066 5006659 - * @summary Verify the contents of a ClassDoc containing a varArgs method. - * Verify that see/link tags can use "..." notation. - * @ignore 8152313 convert to doclet test framework - * @library ../lib - * @modules jdk.javadoc - * @compile ../lib/Tester.java Main.java - * @run main Main - */ - -import java.io.IOException; - -import com.sun.javadoc.*; -import jdk.javadoc.doclet.DocletEnvironment; - -public class Main extends Tester.Doclet { - - private static final Tester tester = - new Tester("Main", "-Xwerror", "pkg1"); - - public static void main(String[] args) throws IOException { - tester.run(); - tester.verify(); - } - - public static boolean run(DocletEnvironment root) { - try { - for (ClassDoc cd : root.classes()) { - tester.printClass(cd); - - for (SeeTag tag : cd.seeTags()) { - if (tag.referencedMember() != cd.methods()[0]) { - throw new Error("5006659: @see tag meets varArgs"); - } - } - } - - return true; - } catch (IOException e) { - return false; - } - } -} diff --git a/test/langtools/jdk/javadoc/tool/varArgs/VarArgsTest.java b/test/langtools/jdk/javadoc/tool/varArgs/VarArgsTest.java new file mode 100644 index 00000000000..842efd08317 --- /dev/null +++ b/test/langtools/jdk/javadoc/tool/varArgs/VarArgsTest.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 4421066 5006659 + * @summary Verify the contents of a ClassDoc containing a varArgs method. + * Verify that see/link tags can use "..." notation. + * @library ../../lib + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @build javadoc.tester.* + * @run main VarArgsTest + */ + +import java.io.IOException; +import java.io.PrintStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.stream.Collectors; + +import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.ArrayType; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.ElementFilter; + +import com.sun.source.doctree.DocCommentTree; +import com.sun.source.doctree.DocTree; +import com.sun.source.doctree.SeeTree; +import com.sun.source.util.DocTreePath; +import com.sun.source.util.DocTrees; +import com.sun.source.util.TreePath; +import javadoc.tester.TestDoclet; +import jdk.javadoc.doclet.DocletEnvironment; + +import javadoc.tester.JavadocTester; + +public class VarArgsTest extends JavadocTester { + + public static void main(String[] args) throws Exception { + JavadocTester t = new VarArgsTest(); + t.runTests(); + } + + @Test + public void testVarArgs() throws Exception { + javadoc("-sourcepath", testSrc, + "-docletpath", System.getProperty("test.class.path"), + "-doclet", "VarArgsTest$ThisDoclet", + "pkg1"); + checkExit(Exit.OK); + + String expect = Files.readAllLines(Path.of(testSrc).resolve("expected.out")) + .stream() + .collect(Collectors.joining("\n")); + checkOutput(Output.STDOUT, true, expect); + } + + + public static class ThisDoclet extends TestDoclet { + public boolean run(DocletEnvironment env) { + DocTrees trees = env.getDocTrees(); + try { + for (Element e : env.getIncludedElements()) { + if (e.getKind() == ElementKind.INTERFACE) { + printClass((TypeElement) e); + + TreePath tp = trees.getPath(e); + DocCommentTree dct = trees.getDocCommentTree(e); + DocTreePath dtp = new DocTreePath(tp, dct); + + ExecutableElement m0 = ElementFilter.methodsIn(e.getEnclosedElements()).get(0); + for (DocTree t : dct.getBlockTags()) { + if (t.getKind() == DocTree.Kind.SEE) { + SeeTree st = (SeeTree) t; + DocTreePath sp = new DocTreePath(dtp, st.getReference().get(0)); + Element se = trees.getElement(sp); + System.err.println("Expect: " + m0); + System.err.println("Found: " + se); + if (se != m0) { + throw new Error("unexpected value for @see reference"); + } + } + } + } + } + + return true; + } catch (Exception e) { + return false; + } + } + + // this method mimics the printClass method from the old + // tester framework + void printClass(TypeElement te) { + PrintStream out = System.out; + out.format("%s %s%n", + te.getKind().toString().toLowerCase(), + te.getQualifiedName()); + out.format(" name: %s / %s / %s%n", + te.getSimpleName(), te.asType(), te.getQualifiedName()); + out.format(" methods:%n"); + te.getEnclosedElements().stream() + .filter(e -> e.getKind() == ElementKind.METHOD) + .map(e -> (ExecutableElement) e) + .forEach(e -> out.format(" %s %s(%s)%n", + e.getReturnType(), + e.getSimpleName(), + e.getParameters().stream() + .map(this::paramToString) + .collect(Collectors.joining(", ")) + )); + + } + + private String paramToString(Element e) { + System.err.println("paramToString " + e); + ExecutableElement m = (ExecutableElement) e.getEnclosingElement(); + return typeToString(m, e.asType()); + } + + private String typeToString(ExecutableElement method, TypeMirror t) { + System.err.println("typeToString " + method + " " + t + " " + t.getKind()); + switch (t.getKind()) { + case INT: + return t.getKind().toString().toLowerCase(); + + case DECLARED: + return ((DeclaredType) t).asElement().getSimpleName().toString(); + + case ARRAY: + String cs = typeToString(method, ((ArrayType) t).getComponentType()); + String suffix = method.isVarArgs() ? "..." : "[]"; + return cs + suffix; + + default: + throw new IllegalArgumentException(t.getKind() + " " + t); + } + } + } +} diff --git a/test/langtools/jdk/javadoc/tool/varArgs/expected.out b/test/langtools/jdk/javadoc/tool/varArgs/expected.out index 705bb0c3a30..e8489b15c09 100644 --- a/test/langtools/jdk/javadoc/tool/varArgs/expected.out +++ b/test/langtools/jdk/javadoc/tool/varArgs/expected.out @@ -1,4 +1,4 @@ interface pkg1.A - name: A / A / pkg1.A + name: A / pkg1.A / pkg1.A methods: void m1(int, String...) diff --git a/test/langtools/tools/javac/api/TestGetScopeResult.java b/test/langtools/tools/javac/api/TestGetScopeResult.java index 56c13b181e1..cb0457f14b2 100644 --- a/test/langtools/tools/javac/api/TestGetScopeResult.java +++ b/test/langtools/tools/javac/api/TestGetScopeResult.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8205418 8207229 8207230 8230847 8245786 + * @bug 8205418 8207229 8207230 8230847 8245786 8247334 * @summary Test the outcomes from Trees.getScope * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.comp @@ -42,6 +42,7 @@ import javax.tools.StandardJavaFileManager; import javax.tools.ToolProvider; +import com.sun.source.tree.AnnotationTree; import com.sun.source.tree.BlockTree; import com.sun.source.tree.ClassTree; import com.sun.source.tree.CompilationUnitTree; @@ -80,6 +81,7 @@ public static void main(String... args) throws IOException { new TestGetScopeResult().testAnnotationsLazy(); new TestGetScopeResult().testCircular(); new TestGetScopeResult().testRecord(); + new TestGetScopeResult().testLocalRecordAnnotation(); } public void run() throws IOException { @@ -562,6 +564,78 @@ public Void visitClass(ClassTree node, Void p) { } } + void testLocalRecordAnnotation() throws IOException { + JavacTool c = JavacTool.create(); + try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) { + class Variant { + final String code; + final List> expectedScopeContent; + public Variant(String code, List> expectedScopeContent) { + this.code = code; + this.expectedScopeContent = expectedScopeContent; + } + } + Variant[] variants = new Variant[] { + new Variant(""" + class Test { + void t() { + record R(@Annotation int i) { + void stop () {} + } + } + } + @interface Annotation {} + """, + List.of( + List.of("super:java.lang.Object", "this:Test"), + List.of("super:java.lang.Object", "this:Test") + )), + new Variant(""" + record Test(@Annotation int i) {} + @interface Annotation {} + """, + List.of( + List.of("i:int", "super:java.lang.Record", "this:Test"), + List.of("super:java.lang.Record", "this:Test") + )) + }; + for (Variant currentVariant : variants) { + class MyFileObject extends SimpleJavaFileObject { + MyFileObject() { + super(URI.create("myfo:///Test.java"), SOURCE); + } + @Override + public String getCharContent(boolean ignoreEncodingErrors) { + return currentVariant.code; + } + } + Context ctx = new Context(); + TestAnalyzer.preRegister(ctx); + List options = List.of("--enable-preview", + "-source", System.getProperty("java.specification.version")); + JavacTask t = (JavacTask) c.getTask(null, fm, null, options, null, + List.of(new MyFileObject()), ctx); + CompilationUnitTree cut = t.parse().iterator().next(); + t.analyze(); + + List> actual = new ArrayList<>(); + + new TreePathScanner() { + @Override + public Void visitAnnotation(AnnotationTree node, Void p) { + Scope scope = Trees.instance(t).getScope(getCurrentPath()); + actual.add(dumpScope(scope)); + return super.visitAnnotation(node, p); + } + }.scan(cut, null); + + if (!currentVariant.expectedScopeContent.equals(actual)) { + throw new AssertionError("Unexpected Scope content: " + actual); + } + } + } + } + private List dumpScope(Scope scope) { List content = new ArrayList<>(); while (scope.getEnclosingClass() != null) { diff --git a/test/langtools/tools/javac/api/T6395981.java b/test/langtools/tools/javac/api/TestGetSourceVersions.java similarity index 80% rename from test/langtools/tools/javac/api/T6395981.java rename to test/langtools/tools/javac/api/TestGetSourceVersions.java index e4c9d2c4446..cef53b7b2d7 100644 --- a/test/langtools/tools/javac/api/T6395981.java +++ b/test/langtools/tools/javac/api/TestGetSourceVersions.java @@ -28,13 +28,13 @@ * @author Peter von der Ah\u00e9 * @modules java.compiler * jdk.compiler - * @run main/fail T6395981 - * @run main/fail T6395981 RELEASE_3 RELEASE_5 RELEASE_6 - * @run main/fail T6395981 RELEASE_0 RELEASE_1 RELEASE_2 RELEASE_3 RELEASE_4 - * RELEASE_5 RELEASE_6 - * @run main T6395981 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6 RELEASE_7 - * RELEASE_8 RELEASE_9 RELEASE_10 RELEASE_11 RELEASE_12 - * RELEASE_13 RELEASE_14 RELEASE_15 RELEASE_16 + * @run main/fail TestGetSourceVersions + * @run main/fail TestGetSourceVersions RELEASE_3 RELEASE_5 RELEASE_6 + * @run main/fail TestGetSourceVersions RELEASE_0 RELEASE_1 RELEASE_2 RELEASE_3 RELEASE_4 + * RELEASE_5 RELEASE_6 + * @run main TestGetSourceVersions RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6 RELEASE_7 + * RELEASE_8 RELEASE_9 RELEASE_10 RELEASE_11 RELEASE_12 + * RELEASE_13 RELEASE_14 RELEASE_15 RELEASE_16 */ import java.util.EnumSet; @@ -44,7 +44,7 @@ import javax.tools.ToolProvider; import static javax.lang.model.SourceVersion.*; -public class T6395981 { +public class TestGetSourceVersions { public static void main(String... args) { Tool compiler = ToolProvider.getSystemJavaCompiler(); Set expected = EnumSet.noneOf(SourceVersion.class); diff --git a/test/lib-test/ProblemList.txt b/test/lib-test/ProblemList.txt new file mode 100644 index 00000000000..3d3ff27ad2f --- /dev/null +++ b/test/lib-test/ProblemList.txt @@ -0,0 +1,40 @@ +# +# Copyright (c) 2020, 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. +# + +############################################################################# +# +# List of quarantined tests -- tests that should not be run by default, because +# they may fail due to known reason. The reason (CR#) must be mandatory specified. +# +# List items are testnames followed by labels, all MUST BE commented +# as to why they are here and use a label: +# generic-all Problems on all platforms +# generic-ARCH Where ARCH is one of: x64, i586, ppc64, ppc64le, s390x etc. +# OSNAME-all Where OSNAME is one of: linux, windows, macosx, aix +# OSNAME-ARCH Specific on to one OSNAME and ARCH, e.g. macosx-x64 +# OSNAME-REV Specific on to one OSNAME and REV, e.g. macosx-10.7.4 +# +# More than one label is allowed but must be on the same line. +# +############################################################################# + diff --git a/test/hotspot/jtreg/testlibrary_tests/RedefineClassTest.java b/test/lib-test/RedefineClassTest.java similarity index 100% rename from test/hotspot/jtreg/testlibrary_tests/RedefineClassTest.java rename to test/lib-test/RedefineClassTest.java diff --git a/test/lib-test/TEST.ROOT b/test/lib-test/TEST.ROOT index 130e7aa2355..927dc437ebc 100644 --- a/test/lib-test/TEST.ROOT +++ b/test/lib-test/TEST.ROOT @@ -1,9 +1,38 @@ +# +# Copyright (c) 2020, 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. +# + # This file identifies the root of the test-suite hierarchy. # It also contains test-suite configuration information. +# The list of keywords supported in this test suite +# randomness: test uses randomness, test cases differ from run to run +keys=randomness + # Minimum jtreg version requiredVersion=5.1 b1 # Path to libraries in the topmost test directory. This is needed so @library # does not need ../../ notation to reach them external.lib.roots = ../../ + +groups=TEST.groups diff --git a/test/lib-test/TEST.groups b/test/lib-test/TEST.groups new file mode 100644 index 00000000000..eb0c9b317ae --- /dev/null +++ b/test/lib-test/TEST.groups @@ -0,0 +1,24 @@ +# +# Copyright (c) 2020, 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. +# + +tier1 = . diff --git a/test/jdk/lib/testlibrary/AssertsTest.java b/test/lib-test/jdk/test/lib/AssertsTest.java similarity index 100% rename from test/jdk/lib/testlibrary/AssertsTest.java rename to test/lib-test/jdk/test/lib/AssertsTest.java diff --git a/test/hotspot/jtreg/testlibrary_tests/RandomGeneratorTest.java b/test/lib-test/jdk/test/lib/RandomGeneratorTest.java similarity index 100% rename from test/hotspot/jtreg/testlibrary_tests/RandomGeneratorTest.java rename to test/lib-test/jdk/test/lib/RandomGeneratorTest.java diff --git a/test/hotspot/jtreg/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java b/test/lib-test/jdk/test/lib/TestMutuallyExclusivePlatformPredicates.java similarity index 100% rename from test/hotspot/jtreg/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java rename to test/lib-test/jdk/test/lib/TestMutuallyExclusivePlatformPredicates.java diff --git a/test/hotspot/jtreg/testlibrary_tests/TestPlatformIsTieredSupported.java b/test/lib-test/jdk/test/lib/TestPlatformIsTieredSupported.java similarity index 97% rename from test/hotspot/jtreg/testlibrary_tests/TestPlatformIsTieredSupported.java rename to test/lib-test/jdk/test/lib/TestPlatformIsTieredSupported.java index 529632214b9..bbf5ca12f5c 100644 --- a/test/hotspot/jtreg/testlibrary_tests/TestPlatformIsTieredSupported.java +++ b/test/lib-test/jdk/test/lib/TestPlatformIsTieredSupported.java @@ -28,7 +28,6 @@ /** * @test * @summary Verifies that Platform::isTieredSupported returns correct value. - * @requires vm.opt.final.TieredCompilation * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/lib-test/jdk/test/lib/apps/LingeredAppTest.java b/test/lib-test/jdk/test/lib/apps/LingeredAppTest.java index dfbc8830b63..600d05189c6 100644 --- a/test/lib-test/jdk/test/lib/apps/LingeredAppTest.java +++ b/test/lib-test/jdk/test/lib/apps/LingeredAppTest.java @@ -24,9 +24,9 @@ /* * @test * @summary Unit test for LingeredApp - * @compile LingeredAppTest.java - * @compile LingeredApp.java - * @run main LingeredAppTest + * @library /test/lib + * @build jdk.test.lib.apps.LingeredAppTest jdk.test.lib.apps.LingeredApp + * @run main jdk.test.lib.apps.LingeredAppTest */ package jdk.test.lib.apps; @@ -52,13 +52,13 @@ public static void main(String[] args) { cmd.add("-XX:+PrintFlagsFinal"); - LingeredApp a = LingeredApp.startApp(cmd.toArray(new String[cmd.length]); + LingeredApp a = LingeredApp.startApp(cmd.toArray(new String[cmd.size()])); System.out.printf("App pid: %d\n", a.getPid()); a.stopApp(); System.out.println("App output:"); int count = 0; - for (String line : a.getAppOutput()) { + for (String line : a.getOutput().getStdoutAsList()) { count += 1; } System.out.println("Found " + count + " lines in VM output"); diff --git a/test/lib-test/jdk/test/lib/hexdump/HexPrinterTest.java b/test/lib-test/jdk/test/lib/hexdump/HexPrinterTest.java index fff06dd0c99..3cf4b760719 100644 --- a/test/lib-test/jdk/test/lib/hexdump/HexPrinterTest.java +++ b/test/lib-test/jdk/test/lib/hexdump/HexPrinterTest.java @@ -77,9 +77,9 @@ Object[][] columnParams() { Object[][] builtinParams() { return new Object[][]{ {"minimal", "", "%02x", 16, "", 64, HexPrinter.Formatters.NONE, ""}, - {"canonical", "%08x ", "%02x ", 16, "|", 31, HexPrinter.Formatters.PRINTABLE, "|\n"}, - {"simple", "%5d: ", "%02x ", 16, " // ", 64, HexPrinter.Formatters.ASCII, "\n"}, - {"source", " ", "(byte)%3d, ", 8, " // ", 64, HexPrinter.Formatters.PRINTABLE, "\n"}, + {"canonical", "%08x ", "%02x ", 16, "|", 31, HexPrinter.Formatters.PRINTABLE, "|" + System.lineSeparator()}, + {"simple", "%5d: ", "%02x ", 16, " // ", 64, HexPrinter.Formatters.ASCII, System.lineSeparator()}, + {"source", " ", "(byte)%3d, ", 8, " // ", 64, HexPrinter.Formatters.PRINTABLE, System.lineSeparator()}, }; } diff --git a/test/jdk/lib/testlibrary/OutputAnalyzerReportingTest.java b/test/lib-test/jdk/test/lib/process/OutputAnalyzerReportingTest.java similarity index 100% rename from test/jdk/lib/testlibrary/OutputAnalyzerReportingTest.java rename to test/lib-test/jdk/test/lib/process/OutputAnalyzerReportingTest.java diff --git a/test/jdk/lib/testlibrary/OutputAnalyzerTest.java b/test/lib-test/jdk/test/lib/process/OutputAnalyzerTest.java similarity index 90% rename from test/jdk/lib/testlibrary/OutputAnalyzerTest.java rename to test/lib-test/jdk/test/lib/process/OutputAnalyzerTest.java index 7a252e62445..2e1bd159ebd 100644 --- a/test/jdk/lib/testlibrary/OutputAnalyzerTest.java +++ b/test/lib-test/jdk/test/lib/process/OutputAnalyzerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2020, 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 @@ -199,6 +199,23 @@ public static void main(String args[]) throws Exception { } catch (RuntimeException e) { // expected } + + { + String aaaa = "aaaa"; + String result = output.firstMatch(aaaa); + if (!aaaa.equals(result)) { + throw new Exception("firstMatch(String) failed to match. Expected: " + aaaa + " got: " + result); + } + } + + { + String aa = "aa"; + String aa_grouped_aa = aa + "(" + aa + ")"; + String result = output.firstMatch(aa_grouped_aa, 1); + if (!aa.equals(result)) { + throw new Exception("firstMatch(String, int) failed to match. Expected: " + aa + " got: " + result); + } + } } } diff --git a/test/hotspot/jtreg/testlibrary_tests/process/TestNativeProcessBuilder.java b/test/lib-test/jdk/test/lib/process/TestNativeProcessBuilder.java similarity index 88% rename from test/hotspot/jtreg/testlibrary_tests/process/TestNativeProcessBuilder.java rename to test/lib-test/jdk/test/lib/process/TestNativeProcessBuilder.java index 9acd6a64c18..6c2f53d31eb 100644 --- a/test/hotspot/jtreg/testlibrary_tests/process/TestNativeProcessBuilder.java +++ b/test/lib-test/jdk/test/lib/process/TestNativeProcessBuilder.java @@ -25,7 +25,6 @@ * @test * @summary Test the native process builder API. * @library /test/lib - * @build Test * @run main/native TestNativeProcessBuilder */ @@ -39,6 +38,13 @@ public static void main(String args[]) throws Exception { ProcessBuilder pb = ProcessTools.createNativeTestProcessBuilder("jvm-test-launcher"); pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH); new OutputAnalyzer(pb.start()) - .shouldHaveExitValue(0); + .shouldHaveExitValue(0) + .stdoutShouldContain("Hello Test"); + } + + public static class Test { + public static void test() { + System.out.println("Hello Test"); + } } } diff --git a/test/hotspot/jtreg/testlibrary_tests/process/exejvm-test-launcher.c b/test/lib-test/jdk/test/lib/process/exejvm-test-launcher.c similarity index 92% rename from test/hotspot/jtreg/testlibrary_tests/process/exejvm-test-launcher.c rename to test/lib-test/jdk/test/lib/process/exejvm-test-launcher.c index dee0bb0ff5a..550f0f3c9dc 100644 --- a/test/hotspot/jtreg/testlibrary_tests/process/exejvm-test-launcher.c +++ b/test/lib-test/jdk/test/lib/process/exejvm-test-launcher.c @@ -42,8 +42,9 @@ JNIEnv* create_vm(JavaVM **jvm) args.ignoreUnrecognized = 0; int ret = JNI_CreateJavaVM(jvm, (void**)&env, &args); - if (ret < 0) + if (ret < 0) { exit(10); + } return env; } @@ -53,13 +54,15 @@ void run(JNIEnv *env) { jclass test_class; jmethodID test_method; - test_class = (*env)->FindClass(env, "Test"); - if (test_class == NULL) + test_class = (*env)->FindClass(env, "TestNativeProcessBuilder$Test"); + if (test_class == NULL) { exit(11); + } test_method = (*env)->GetStaticMethodID(env, test_class, "test", "()V"); - if (test_method == NULL) + if (test_method == NULL) { exit(12); + } (*env)->CallStaticVoidMethod(env, test_class, test_method); } diff --git a/test/hotspot/jtreg/testlibrary_tests/whitebox/BlobSanityTest.java b/test/lib-test/sun/hotspot/whitebox/BlobSanityTest.java similarity index 100% rename from test/hotspot/jtreg/testlibrary_tests/whitebox/BlobSanityTest.java rename to test/lib-test/sun/hotspot/whitebox/BlobSanityTest.java diff --git a/test/jdk/lib/testlibrary/CPUInfoTest.java b/test/lib-test/sun/hotspot/whitebox/CPUInfoTest.java similarity index 100% rename from test/jdk/lib/testlibrary/CPUInfoTest.java rename to test/lib-test/sun/hotspot/whitebox/CPUInfoTest.java diff --git a/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/BooleanTest.java b/test/lib-test/sun/hotspot/whitebox/vm_flags/BooleanTest.java similarity index 100% rename from test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/BooleanTest.java rename to test/lib-test/sun/hotspot/whitebox/vm_flags/BooleanTest.java diff --git a/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/DoubleTest.java b/test/lib-test/sun/hotspot/whitebox/vm_flags/DoubleTest.java similarity index 100% rename from test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/DoubleTest.java rename to test/lib-test/sun/hotspot/whitebox/vm_flags/DoubleTest.java diff --git a/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/IntxTest.java b/test/lib-test/sun/hotspot/whitebox/vm_flags/IntxTest.java similarity index 100% rename from test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/IntxTest.java rename to test/lib-test/sun/hotspot/whitebox/vm_flags/IntxTest.java diff --git a/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/SizeTTest.java b/test/lib-test/sun/hotspot/whitebox/vm_flags/SizeTTest.java similarity index 100% rename from test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/SizeTTest.java rename to test/lib-test/sun/hotspot/whitebox/vm_flags/SizeTTest.java diff --git a/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/StringTest.java b/test/lib-test/sun/hotspot/whitebox/vm_flags/StringTest.java similarity index 100% rename from test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/StringTest.java rename to test/lib-test/sun/hotspot/whitebox/vm_flags/StringTest.java diff --git a/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/Uint64Test.java b/test/lib-test/sun/hotspot/whitebox/vm_flags/Uint64Test.java similarity index 100% rename from test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/Uint64Test.java rename to test/lib-test/sun/hotspot/whitebox/vm_flags/Uint64Test.java diff --git a/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/UintxTest.java b/test/lib-test/sun/hotspot/whitebox/vm_flags/UintxTest.java similarity index 100% rename from test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/UintxTest.java rename to test/lib-test/sun/hotspot/whitebox/vm_flags/UintxTest.java diff --git a/test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/VmFlagTest.java b/test/lib-test/sun/hotspot/whitebox/vm_flags/VmFlagTest.java similarity index 100% rename from test/hotspot/jtreg/testlibrary_tests/whitebox/vm_flags/VmFlagTest.java rename to test/lib-test/sun/hotspot/whitebox/vm_flags/VmFlagTest.java diff --git a/test/micro/org/openjdk/bench/java/lang/StringConcat.java b/test/micro/org/openjdk/bench/java/lang/StringConcat.java index dffff9b5d8a..b15b1d0a0c0 100644 --- a/test/micro/org/openjdk/bench/java/lang/StringConcat.java +++ b/test/micro/org/openjdk/bench/java/lang/StringConcat.java @@ -28,11 +28,8 @@ import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Param; import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; -import org.openjdk.jmh.infra.Blackhole; -import java.util.Random; import java.util.concurrent.TimeUnit; /** @@ -54,6 +51,8 @@ public class StringConcat { public byte byteValue = (byte)-128; + public String emptyString = ""; + @Benchmark public String concatConstInt() { return "string" + intValue; @@ -64,6 +63,16 @@ public String concatConstString() { return "string" + stringValue; } + @Benchmark + public String concatEmptyRight() { + return stringValue + emptyString; + } + + @Benchmark + public String concatEmptyLeft() { + return emptyString + stringValue; + } + @Benchmark public String concatMethodConstString() { return "string".concat(stringValue);