aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Robbin Ehn <robbin.ehn@oracle.com> 2021-04-21 09:53:35 +0200
committerGravatar Robbin Ehn <robbin.ehn@oracle.com> 2021-04-21 09:53:35 +0200
commitec3446614f15e2a182cc47797953d745ea01d9dc (patch)
treeaf03eb0acae19bdb6f45aa86b4f7b0ebef5aae69
parent56dc3df036c774b956b2c96fcb536dce01253ef9 (diff)
parent7146104fdaffb5037f5380eed9786fe154705150 (diff)
downloadjdk-pr/3191.tar.gz
jdk-pr/3191.zip
Merge branch 'master' into SuspendInHandshakepr/3191
-rw-r--r--make/Docs.gmk20
-rw-r--r--make/conf/jib-profiles.js2
-rw-r--r--make/conf/test-dependencies22
-rw-r--r--make/conf/version-numbers.conf2
-rw-r--r--src/hotspot/share/classfile/classFileParser.cpp2
-rw-r--r--src/hotspot/share/classfile/systemDictionaryShared.cpp2
-rw-r--r--src/hotspot/share/classfile/vmIntrinsics.cpp40
-rw-r--r--src/hotspot/share/classfile/vmIntrinsics.hpp4
-rw-r--r--src/hotspot/share/code/dependencies.cpp35
-rw-r--r--src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp47
-rw-r--r--src/hotspot/share/gc/g1/g1FullGCPrepareTask.hpp7
-rw-r--r--src/hotspot/share/gc/z/zCollectedHeap.cpp9
-rw-r--r--src/hotspot/share/gc/z/zHeap.cpp8
-rw-r--r--src/hotspot/share/gc/z/zHeap.hpp5
-rw-r--r--src/hotspot/share/gc/z/zServiceability.cpp49
-rw-r--r--src/hotspot/share/gc/z/zServiceability.hpp17
-rw-r--r--src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp14
-rw-r--r--src/hotspot/share/jvmci/jvmciCompilerToVM.cpp4
-rw-r--r--src/hotspot/share/oops/method.cpp13
-rw-r--r--src/hotspot/share/oops/method.hpp2
-rw-r--r--src/hotspot/share/opto/block.cpp20
-rw-r--r--src/hotspot/share/opto/lcm.cpp36
-rw-r--r--src/hotspot/share/opto/reg_split.cpp2
-rw-r--r--src/hotspot/share/runtime/os.cpp2
-rw-r--r--src/java.base/share/classes/java/io/File.java47
-rw-r--r--src/java.base/share/classes/java/security/cert/CertPathHelperImpl.java6
-rw-r--r--src/java.base/share/classes/java/security/cert/TrustAnchor.java23
-rw-r--r--src/java.base/share/classes/java/util/jar/JarFile.java1
-rw-r--r--src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java14
-rw-r--r--src/java.base/share/classes/sun/security/pkcs/SignerInfo.java138
-rw-r--r--src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java135
-rw-r--r--src/java.base/share/classes/sun/security/provider/certpath/CertPathConstraintsParameters.java125
-rw-r--r--src/java.base/share/classes/sun/security/provider/certpath/CertPathHelper.java11
-rw-r--r--src/java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java25
-rw-r--r--src/java.base/share/classes/sun/security/provider/certpath/OCSP.java3
-rw-r--r--src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java9
-rw-r--r--src/java.base/share/classes/sun/security/provider/certpath/PKIX.java23
-rw-r--r--src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java19
-rw-r--r--src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java5
-rw-r--r--src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java2
-rw-r--r--src/java.base/share/classes/sun/security/ssl/X509KeyManagerImpl.java3
-rw-r--r--src/java.base/share/classes/sun/security/util/AnchorCertificates.java23
-rw-r--r--src/java.base/share/classes/sun/security/util/ConstraintsParameters.java179
-rw-r--r--src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java222
-rw-r--r--src/java.base/share/classes/sun/security/util/JarConstraintsParameters.java188
-rw-r--r--src/java.base/share/classes/sun/security/util/ManifestEntryVerifier.java59
-rw-r--r--src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java66
-rw-r--r--src/java.base/share/classes/sun/security/validator/PKIXValidator.java2
-rw-r--r--src/java.base/share/classes/sun/security/validator/SimpleValidator.java2
-rw-r--r--src/java.base/share/classes/sun/security/x509/AlgorithmId.java53
-rw-r--r--src/java.base/share/conf/security/java.security23
-rw-r--r--src/java.base/share/man/java.16
-rw-r--r--src/java.base/windows/classes/java/lang/ProcessImpl.java27
-rw-r--r--src/java.naming/share/classes/com/sun/jndi/ldap/Obj.java5
-rw-r--r--src/java.naming/share/classes/com/sun/jndi/ldap/VersionHelper.java41
-rw-r--r--src/java.naming/share/classes/com/sun/naming/internal/ObjectFactoriesFilter.java114
-rw-r--r--src/java.naming/share/classes/com/sun/naming/internal/VersionHelper.java13
-rw-r--r--src/java.naming/share/classes/javax/naming/spi/NamingManager.java13
-rw-r--r--src/java.naming/share/classes/module-info.java35
-rw-r--r--src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java18
-rw-r--r--src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/MarkUnsafeAccessTest.java3
-rw-r--r--src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java2
-rw-r--r--src/jdk.management.jfr/share/classes/jdk/management/jfr/RemoteRecordingStream.java5
-rw-r--r--src/jdk.naming.rmi/share/classes/module-info.java20
-rw-r--r--src/utils/IdealGraphVisualizer/Data/src/main/java/com/sun/hotspot/igv/data/serialization/Parser.java3
-rw-r--r--src/utils/IdealGraphVisualizer/Data/src/test/java/com/sun/hotspot/igv/data/serialization/ParserTest.java6
-rw-r--r--src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/DiagramViewModel.java7
-rw-r--r--src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/EditorTopComponent.java18
-rw-r--r--src/utils/LogCompilation/src/test/java/com/sun/hotspot/tools/compiler/TestLogCompilation.java2
-rw-r--r--test/hotspot/gtest/metaspace/test_metaspaceUtils.cpp15
-rw-r--r--test/hotspot/jtreg/compiler/exceptions/TestSpilling.java65
-rw-r--r--test/hotspot/jtreg/gc/TestFullGCCount.java5
-rw-r--r--test/hotspot/jtreg/gc/g1/TestG1SkipCompaction.java5
-rw-r--r--test/hotspot/jtreg/gc/z/TestGarbageCollectorMXBean.java91
-rw-r--r--test/hotspot/jtreg/gc/z/TestMemoryManagerMXBean.java38
-rw-r--r--test/hotspot/jtreg/gtest/MetaspaceUtilsGtests.java40
-rw-r--r--test/hotspot/jtreg/runtime/cds/appcds/CDSandJFR.java8
-rw-r--r--test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java4
-rw-r--r--test/hotspot/jtreg/runtime/cds/appcds/TestWithProfiler.java2
-rw-r--r--test/hotspot/jtreg/runtime/cds/appcds/customLoader/HelloCustom_JFR.java4
-rw-r--r--test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/ModulePathAndCP_JFR.java6
-rw-r--r--test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/FlagCombo.java4
-rw-r--r--test/hotspot/jtreg/testlibrary_tests/ctw/CtwTest.java8
-rw-r--r--test/jdk/com/sun/jdi/JdbOptions.java20
-rw-r--r--test/jdk/java/io/Serializable/serialFilter/GlobalFilterTest.java2
-rw-r--r--test/jdk/java/lang/String/StringRepeat.java24
-rw-r--r--test/jdk/java/lang/annotation/AnnotationTypeMismatchException/AnnotationTypeMismatchTest.java87
-rw-r--r--test/jdk/java/lang/annotation/AnnotationTypeMismatchException/EnumTypeMismatchTest.java85
-rw-r--r--test/jdk/java/lang/management/MemoryMXBean/MemoryTest.java4
-rw-r--r--test/jdk/java/security/cert/X509Certificate/GetSigAlgParams.java47
-rw-r--r--test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetEncoded.java104
-rw-r--r--test/jdk/jdk/jfr/api/metadata/annotations/TestRegisteredFalseAndRunning.java4
-rw-r--r--test/jdk/jdk/jfr/event/gc/stacktrace/TestMetaspaceSerialGCAllocationPendingStackTrace.java4
-rw-r--r--test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelMarkSweepAllocationPendingStackTrace.java4
-rw-r--r--test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelScavengeAllocationPendingStackTrace.java4
-rw-r--r--test/jdk/jdk/jfr/event/runtime/TestSafepointEvents.java2
-rw-r--r--test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java4
-rw-r--r--test/jdk/jdk/jfr/event/runtime/TestThrowableInstrumentation.java2
-rw-r--r--test/jdk/jdk/jfr/jcmd/TestJcmdStartPathToGCRoots.java8
-rw-r--r--test/jdk/jdk/jfr/jcmd/TestJcmdStartWithOptions.java4
-rw-r--r--test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java4
-rw-r--r--test/jdk/jdk/jfr/jvm/TestJfrJavaBase.java4
-rw-r--r--test/jdk/jdk/jfr/jvm/TestLogOutput.java4
-rw-r--r--test/jdk/jdk/jfr/startupargs/TestBadOptionValues.java6
-rw-r--r--test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java10
-rw-r--r--test/jdk/jdk/jfr/startupargs/TestFlushInterval.java4
-rw-r--r--test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java6
-rw-r--r--test/jdk/jdk/jfr/startupargs/TestOldObjectQueueSize.java10
-rw-r--r--test/jdk/jdk/jfr/startupargs/TestRepositoryPath.java4
-rw-r--r--test/jdk/jdk/jfr/startupargs/TestRepositoryPathLong.java4
-rw-r--r--test/jdk/jdk/jfr/startupargs/TestRetransform.java6
-rw-r--r--test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java4
-rw-r--r--test/jdk/jdk/jfr/startupargs/TestStartDelay.java4
-rw-r--r--test/jdk/jdk/jfr/startupargs/TestStartDelayRunning.java4
-rw-r--r--test/jdk/jdk/jfr/startupargs/TestStartDuration.java6
-rw-r--r--test/jdk/jdk/jfr/startupargs/TestStartMaxAgeSize.java4
-rw-r--r--test/jdk/jdk/jfr/startupargs/TestStartName.java4
-rw-r--r--test/jdk/jdk/jfr/startupargs/TestStartNoSettings.java6
-rw-r--r--test/jdk/jdk/jfr/startupargs/TestStartRecording.java4
-rw-r--r--test/jdk/sun/security/pkcs/pkcs8/PKCS8Test.java10
-rw-r--r--test/jdk/sun/security/tools/jarsigner/TimestampCheck.java5
-rw-r--r--test/jdk/sun/security/x509/AlgorithmId/AlgorithmIdEqualsHashCode.java48
122 files changed, 2138 insertions, 835 deletions
diff --git a/make/Docs.gmk b/make/Docs.gmk
index 83ffe2e4df5..612880df2f8 100644
--- a/make/Docs.gmk
+++ b/make/Docs.gmk
@@ -154,13 +154,14 @@ COPYRIGHT_BOTTOM = \
<a href="$(REDISTRIBUTION_URL)">documentation redistribution policy</a>. \
$(DRAFT_MARKER_STR) <!-- Version $(VERSION_STRING) -->
-JAVADOC_BOTTOM := \
+# $1 - Optional "Other Versions" link
+JAVADOC_BOTTOM = \
<a href="$(BUG_SUBMIT_URL)">Report a bug or suggest an enhancement</a><br> \
For further API reference and developer documentation see the \
<a href="$(JAVADOC_BASE_URL)" target="_blank">Java SE \
Documentation</a>, which contains more detailed, \
developer-targeted descriptions with conceptual overviews, definitions \
- of terms, workarounds, and working code examples.<br> \
+ of terms, workarounds, and working code examples. $1<br> \
Java is a trademark or registered trademark of $(FULL_COMPANY_NAME) in \
the US and other countries.<br> \
$(call COPYRIGHT_BOTTOM, {@docroot}/../)
@@ -300,22 +301,21 @@ define SetupApiDocsGenerationBody
$1_OPTIONS += -Xdoclint/package:$$(call CommaList, $$(addprefix -, \
$$(JAVADOC_DISABLED_DOCLINT_PACKAGES)))
- ifneq ($$($1_OTHER_VERSIONS), )
- $1_LINKED_SHORT_NAME = <a href="$$($1_OTHER_VERSIONS)">$$($1_SHORT_NAME)</a>
- else
- $1_LINKED_SHORT_NAME = $$($1_SHORT_NAME)
- endif
-
$1_DOC_TITLE := $$($1_LONG_NAME)<br>Version $$(VERSION_SPECIFICATION) API \
Specification
$1_WINDOW_TITLE := $$(subst &amp;,&,$$($1_SHORT_NAME))$$(DRAFT_MARKER_TITLE)
- $1_HEADER_TITLE := <div $$(HEADER_STYLE)><strong>$$($1_LINKED_SHORT_NAME)</strong> \
+ $1_HEADER_TITLE := <div $$(HEADER_STYLE)><strong>$$($1_SHORT_NAME)</strong> \
$$(DRAFT_MARKER_STR)</div>
+ ifneq ($$($1_OTHER_VERSIONS), )
+ $1_JAVADOC_BOTTOM := $$(call JAVADOC_BOTTOM, <a href="$$($1_OTHER_VERSIONS)">Other versions.</a>)
+ else
+ $1_JAVADOC_BOTTOM := $$(call JAVADOC_BOTTOM, )
+ endif
$1_OPTIONS += -doctitle '$$($1_DOC_TITLE)'
$1_OPTIONS += -windowtitle '$$($1_WINDOW_TITLE)'
$1_OPTIONS += -header '$$($1_HEADER_TITLE)'
- $1_OPTIONS += -bottom '$$(JAVADOC_BOTTOM)'
+ $1_OPTIONS += -bottom '$$($1_JAVADOC_BOTTOM)'
ifeq ($$(IS_DRAFT), true)
$1_OPTIONS += -top '$$(JAVADOC_TOP)'
endif
diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js
index ff6d69fa2e7..a1676bf77d5 100644
--- a/make/conf/jib-profiles.js
+++ b/make/conf/jib-profiles.js
@@ -396,7 +396,7 @@ var getJibProfilesCommon = function (input, data) {
};
};
- common.boot_jdk_version = (input.build_os == 'macosx' && input.build_cpu == 'aarch64') ? "16" : "15";
+ common.boot_jdk_version = "16";
common.boot_jdk_build_number = "36";
common.boot_jdk_home = input.get("boot_jdk", "install_path") + "/jdk-"
+ common.boot_jdk_version
diff --git a/make/conf/test-dependencies b/make/conf/test-dependencies
index 4cc4610daed..159b6073a5f 100644
--- a/make/conf/test-dependencies
+++ b/make/conf/test-dependencies
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2020, 2021, 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,19 +25,19 @@
# Versions and download locations for dependencies used by pre-submit testing.
-BOOT_JDK_VERSION=15
+BOOT_JDK_VERSION=16
JTREG_VERSION=5.1
JTREG_BUILD=b01
GTEST_VERSION=1.8.1
-LINUX_X64_BOOT_JDK_FILENAME=openjdk-15_linux-x64_bin.tar.gz
-LINUX_X64_BOOT_JDK_URL=https://download.java.net/java/GA/jdk15/779bf45e88a44cbd9ea6621d33e33db1/36/GPL/openjdk-15_linux-x64_bin.tar.gz
-LINUX_X64_BOOT_JDK_SHA256=bb67cadee687d7b486583d03c9850342afea4593be4f436044d785fba9508fb7
+LINUX_X64_BOOT_JDK_FILENAME=openjdk-16_linux-x64_bin.tar.gz
+LINUX_X64_BOOT_JDK_URL=https://download.java.net/java/GA/jdk16/7863447f0ab643c585b9bdebf67c69db/36/GPL/openjdk-16_linux-x64_bin.tar.gz
+LINUX_X64_BOOT_JDK_SHA256=e952958f16797ad7dc7cd8b724edd69ec7e0e0434537d80d6b5165193e33b931
-WINDOWS_X64_BOOT_JDK_FILENAME=openjdk-15_windows-x64_bin.zip
-WINDOWS_X64_BOOT_JDK_URL=https://download.java.net/java/GA/jdk15/779bf45e88a44cbd9ea6621d33e33db1/36/GPL/openjdk-15_windows-x64_bin.zip
-WINDOWS_X64_BOOT_JDK_SHA256=764e39a71252a9791118a31ae56a4247c049463bda5eb72497122ec50b1d07f8
+WINDOWS_X64_BOOT_JDK_FILENAME=openjdk-16_windows-x64_bin.zip
+WINDOWS_X64_BOOT_JDK_URL=https://download.java.net/java/GA/jdk16/7863447f0ab643c585b9bdebf67c69db/36/GPL/openjdk-16_windows-x64_bin.zip
+WINDOWS_X64_BOOT_JDK_SHA256=a78bdeaad186297601edac6772d931224d7af6f682a43372e693c37020bd37d6
-MACOS_X64_BOOT_JDK_FILENAME=openjdk-115_osx-x64_bin.tar.gz
-MACOS_X64_BOOT_JDK_URL=https://download.java.net/java/GA/jdk15/779bf45e88a44cbd9ea6621d33e33db1/36/GPL/openjdk-15_osx-x64_bin.tar.gz
-MACOS_X64_BOOT_JDK_SHA256=ab842c8c0953b816be308c098c1a021177a4776bef24da85b6bafbbd657c7e1a
+MACOS_X64_BOOT_JDK_FILENAME=openjdk-16_osx-x64_bin.tar.gz
+MACOS_X64_BOOT_JDK_URL=https://download.java.net/java/GA/jdk16/7863447f0ab643c585b9bdebf67c69db/36/GPL/openjdk-16_osx-x64_bin.tar.gz
+MACOS_X64_BOOT_JDK_SHA256=16f3e39a31e86f3f51b0b4035a37494a47ed3c4ead760eafc6afd7afdf2ad9f2
diff --git a/make/conf/version-numbers.conf b/make/conf/version-numbers.conf
index 98ed69ff35a..422fc795908 100644
--- a/make/conf/version-numbers.conf
+++ b/make/conf/version-numbers.conf
@@ -36,6 +36,6 @@ DEFAULT_VERSION_EXTRA3=0
DEFAULT_VERSION_DATE=2021-09-14
DEFAULT_VERSION_CLASSFILE_MAJOR=61 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`"
DEFAULT_VERSION_CLASSFILE_MINOR=0
-DEFAULT_ACCEPTABLE_BOOT_VERSIONS="15 16 17"
+DEFAULT_ACCEPTABLE_BOOT_VERSIONS="16 17"
DEFAULT_JDK_SOURCE_TARGET_VERSION=17
DEFAULT_PROMOTED_VERSION_PRE=ea
diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp
index 2c775f1d12f..b3aad59373a 100644
--- a/src/hotspot/share/classfile/classFileParser.cpp
+++ b/src/hotspot/share/classfile/classFileParser.cpp
@@ -5260,7 +5260,7 @@ static void check_methods_for_intrinsics(const InstanceKlass* ik,
if (klass_id != vmSymbolID::NO_SID) {
for (int j = 0; j < methods->length(); ++j) {
Method* method = methods->at(j);
- method->init_intrinsic_id();
+ method->init_intrinsic_id(klass_id);
if (CheckIntrinsics) {
// Check if an intrinsic is defined for method 'method',
diff --git a/src/hotspot/share/classfile/systemDictionaryShared.cpp b/src/hotspot/share/classfile/systemDictionaryShared.cpp
index e8b8f46a804..4ab5b6425a4 100644
--- a/src/hotspot/share/classfile/systemDictionaryShared.cpp
+++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp
@@ -1361,7 +1361,7 @@ bool SystemDictionaryShared::should_be_excluded(InstanceKlass* k) {
}
if (is_jfr_event_class(k)) {
// We cannot include JFR event classes because they need runtime-specific
- // instrumentation in order to work with -XX:FlightRecorderOptions=retransform=false.
+ // instrumentation in order to work with -XX:FlightRecorderOptions:retransform=false.
// There are only a small number of these classes, so it's not worthwhile to
// support them and make CDS more complicated.
warn_excluded(k, "JFR event class");
diff --git a/src/hotspot/share/classfile/vmIntrinsics.cpp b/src/hotspot/share/classfile/vmIntrinsics.cpp
index df826eff7c2..a8089610633 100644
--- a/src/hotspot/share/classfile/vmIntrinsics.cpp
+++ b/src/hotspot/share/classfile/vmIntrinsics.cpp
@@ -678,6 +678,46 @@ vmIntrinsics::ID vmIntrinsics::find_id_impl(vmSymbolID holder,
#undef VM_INTRINSIC_CASE
}
+class vmIntrinsicsLookup {
+ bool _class_map[vmSymbols::number_of_symbols()];
+
+ constexpr int as_index(vmSymbolID id) const {
+ int index = vmSymbols::as_int(id);
+ assert(0 <= index && index < int(sizeof(_class_map)), "must be");
+ return index;
+ }
+
+ constexpr void set_class_map(vmSymbolID id) {
+ _class_map[as_index(id)] = true;
+ }
+
+public:
+ constexpr vmIntrinsicsLookup() : _class_map() {
+
+#define VM_INTRINSIC_CLASS_MAP(id, klass, name, sig, fcode) \
+ set_class_map(SID_ENUM(klass));
+
+ VM_INTRINSICS_DO(VM_INTRINSIC_CLASS_MAP,
+ VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_ALIAS_IGNORE);
+#undef VM_INTRINSIC_CLASS_MAP
+
+
+ // A few slightly irregular cases. See Method::init_intrinsic_id
+ set_class_map(SID_ENUM(java_lang_StrictMath));
+ set_class_map(SID_ENUM(java_lang_invoke_MethodHandle));
+ set_class_map(SID_ENUM(java_lang_invoke_VarHandle));
+ }
+
+ bool class_has_intrinsics(vmSymbolID holder) const {
+ return _class_map[as_index(holder)];
+ }
+};
+
+constexpr vmIntrinsicsLookup _intrinsics_lookup;
+
+bool vmIntrinsics::class_has_intrinsics(vmSymbolID holder) {
+ return _intrinsics_lookup.class_has_intrinsics(holder);
+}
const char* vmIntrinsics::short_name_as_C_string(vmIntrinsics::ID id, char* buf, int buflen) {
const char* str = name_at(id);
diff --git a/src/hotspot/share/classfile/vmIntrinsics.hpp b/src/hotspot/share/classfile/vmIntrinsics.hpp
index b06a078d323..e8c97a92ef4 100644
--- a/src/hotspot/share/classfile/vmIntrinsics.hpp
+++ b/src/hotspot/share/classfile/vmIntrinsics.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021, 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
@@ -1141,6 +1141,8 @@ public:
static Flags flags_for(ID id);
#endif
+ static bool class_has_intrinsics(vmSymbolID holder);
+
static const char* short_name_as_C_string(ID id, char* buf, int size);
// The methods below provide information related to compiling intrinsics.
diff --git a/src/hotspot/share/code/dependencies.cpp b/src/hotspot/share/code/dependencies.cpp
index b7a727416e6..f787d6f183e 100644
--- a/src/hotspot/share/code/dependencies.cpp
+++ b/src/hotspot/share/code/dependencies.cpp
@@ -1172,6 +1172,7 @@ class ClassHierarchyWalker {
Klass* find_witness_in(KlassDepChange& changes,
InstanceKlass* context_type,
bool participants_hide_witnesses);
+ bool witnessed_reabstraction_in_supers(Klass* k);
public:
Klass* find_witness_subtype(InstanceKlass* context_type, KlassDepChange* changes = NULL) {
assert(doing_subtype_search(), "must set up a subtype search");
@@ -1319,6 +1320,11 @@ Klass* ClassHierarchyWalker::find_witness_in(KlassDepChange& changes,
if (is_witness(new_type)) {
return new_type;
+ } else if (!doing_subtype_search()) {
+ // No witness found, but is_witness() doesn't detect method re-abstraction in case of spot-checking.
+ if (witnessed_reabstraction_in_supers(new_type)) {
+ return new_type;
+ }
}
return NULL;
@@ -1377,6 +1383,32 @@ Klass* ClassHierarchyWalker::find_witness_anywhere(InstanceKlass* context_type,
return NULL;
}
+bool ClassHierarchyWalker::witnessed_reabstraction_in_supers(Klass* k) {
+ if (!k->is_instance_klass()) {
+ return false; // no methods to find in an array type
+ } else {
+ // Looking for a case when an abstract method is inherited into a concrete class.
+ if (Dependencies::is_concrete_klass(k) && !k->is_interface()) {
+ Method* m = InstanceKlass::cast(k)->find_instance_method(_name, _signature, Klass::PrivateLookupMode::skip);
+ if (m != NULL) {
+ return false; // no reabstraction possible: local method found
+ }
+ for (InstanceKlass* super = k->java_super(); super != NULL; super = super->java_super()) {
+ m = super->find_instance_method(_name, _signature, Klass::PrivateLookupMode::skip);
+ if (m != NULL) { // inherited method found
+ if (m->is_abstract() || m->is_overpass()) {
+ _found_methods[_num_participants] = m;
+ return true; // abstract method found
+ }
+ return false;
+ }
+ }
+ assert(false, "root method not found");
+ return true;
+ }
+ return false;
+ }
+}
bool Dependencies::is_concrete_klass(Klass* k) {
if (k->is_abstract()) return false;
@@ -1409,7 +1441,6 @@ bool Dependencies::is_concrete_method(Method* m, Klass* k) {
return true;
}
-
Klass* Dependencies::find_finalizable_subclass(Klass* k) {
if (k->is_interface()) return NULL;
if (k->has_finalizer()) return k;
@@ -1422,7 +1453,6 @@ Klass* Dependencies::find_finalizable_subclass(Klass* k) {
return NULL;
}
-
bool Dependencies::is_concrete_klass(ciInstanceKlass* k) {
if (k->is_abstract()) return false;
// We could also return false if k does not yet appear to be
@@ -1435,7 +1465,6 @@ bool Dependencies::has_finalizable_subclass(ciInstanceKlass* k) {
return k->has_finalizable_subclass();
}
-
// Any use of the contents (bytecodes) of a method must be
// marked by an "evol_method" dependency, if those contents
// can change. (Note: A method is always dependent on itself.)
diff --git a/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp b/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp
index 34cebe238c1..1d62ba00043 100644
--- a/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp
+++ b/src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp
@@ -39,6 +39,17 @@
#include "oops/oop.inline.hpp"
#include "utilities/ticks.hpp"
+template<bool is_humongous>
+void G1FullGCPrepareTask::G1CalculatePointersClosure::free_pinned_region(HeapRegion* hr) {
+ _regions_freed = true;
+ if (is_humongous) {
+ _g1h->free_humongous_region(hr, nullptr);
+ } else {
+ _g1h->free_region(hr, nullptr);
+ }
+ prepare_for_compaction(hr);
+}
+
bool G1FullGCPrepareTask::G1CalculatePointersClosure::do_heap_region(HeapRegion* hr) {
bool force_not_compacted = false;
if (should_compact(hr)) {
@@ -48,15 +59,16 @@ bool G1FullGCPrepareTask::G1CalculatePointersClosure::do_heap_region(HeapRegion*
// There is no need to iterate and forward objects in pinned regions ie.
// prepare them for compaction. The adjust pointers phase will skip
// work for them.
+ assert(hr->containing_set() == nullptr, "already cleared by PrepareRegionsClosure");
if (hr->is_humongous()) {
oop obj = cast_to_oop(hr->humongous_start_region()->bottom());
if (!_bitmap->is_marked(obj)) {
- free_humongous_region(hr);
+ free_pinned_region<true>(hr);
}
} else if (hr->is_open_archive()) {
bool is_empty = _collector->live_words(hr->hrm_index()) == 0;
if (is_empty) {
- free_open_archive_region(hr);
+ free_pinned_region<false>(hr);
}
} else if (hr->is_closed_archive()) {
// nothing to do with closed archive region
@@ -74,7 +86,7 @@ bool G1FullGCPrepareTask::G1CalculatePointersClosure::do_heap_region(HeapRegion*
// performance during scanning their card tables in the collection pauses later.
update_bot(hr);
}
- log_debug(gc, phases)("Phase 2: skip compaction region index: %u, live words: " SIZE_FORMAT,
+ log_trace(gc, phases)("Phase 2: skip compaction region index: %u, live words: " SIZE_FORMAT,
hr->hrm_index(), _collector->live_words(hr->hrm_index()));
}
}
@@ -125,35 +137,6 @@ G1FullGCPrepareTask::G1CalculatePointersClosure::G1CalculatePointersClosure(G1Fu
_cp(cp),
_regions_freed(false) { }
-void G1FullGCPrepareTask::G1CalculatePointersClosure::free_humongous_region(HeapRegion* hr) {
- assert(hr->is_humongous(), "must be but region %u is %s", hr->hrm_index(), hr->get_short_type_str());
-
- FreeRegionList dummy_free_list("Humongous Dummy Free List for G1MarkSweep");
-
- hr->set_containing_set(NULL);
- _regions_freed = true;
-
- _g1h->free_humongous_region(hr, &dummy_free_list);
- prepare_for_compaction(hr);
- dummy_free_list.remove_all();
-}
-
-void G1FullGCPrepareTask::G1CalculatePointersClosure::free_open_archive_region(HeapRegion* hr) {
- assert(hr->is_pinned(), "must be");
- assert(!hr->is_humongous(), "handled elsewhere");
- assert(hr->is_open_archive(),
- "Only Open archive regions may be freed here.");
-
- FreeRegionList dummy_free_list("Pinned Dummy Free List for G1MarkSweep");
-
- hr->set_containing_set(NULL);
- _regions_freed = true;
-
- _g1h->free_region(hr, &dummy_free_list);
- prepare_for_compaction(hr);
- dummy_free_list.remove_all();
-}
-
bool G1FullGCPrepareTask::G1CalculatePointersClosure::should_compact(HeapRegion* hr) {
if (hr->is_pinned()) {
return false;
diff --git a/src/hotspot/share/gc/g1/g1FullGCPrepareTask.hpp b/src/hotspot/share/gc/g1/g1FullGCPrepareTask.hpp
index c27dc4a7866..97fdd9e98d2 100644
--- a/src/hotspot/share/gc/g1/g1FullGCPrepareTask.hpp
+++ b/src/hotspot/share/gc/g1/g1FullGCPrepareTask.hpp
@@ -51,6 +51,9 @@ public:
protected:
class G1CalculatePointersClosure : public HeapRegionClosure {
+ private:
+ template<bool is_humongous>
+ void free_pinned_region(HeapRegion* hr);
protected:
G1CollectedHeap* _g1h;
G1FullCollector* _collector;
@@ -59,10 +62,8 @@ protected:
bool _regions_freed;
bool should_compact(HeapRegion* hr);
- virtual void prepare_for_compaction(HeapRegion* hr);
+ void prepare_for_compaction(HeapRegion* hr);
void prepare_for_compaction_work(G1FullGCCompactionPoint* cp, HeapRegion* hr);
- void free_humongous_region(HeapRegion* hr);
- void free_open_archive_region(HeapRegion* hr);
void update_bot(HeapRegion* hr);
void reset_region_metadata(HeapRegion* hr);
diff --git a/src/hotspot/share/gc/z/zCollectedHeap.cpp b/src/hotspot/share/gc/z/zCollectedHeap.cpp
index 24bd1e31816..a0bc162458c 100644
--- a/src/hotspot/share/gc/z/zCollectedHeap.cpp
+++ b/src/hotspot/share/gc/z/zCollectedHeap.cpp
@@ -227,11 +227,16 @@ bool ZCollectedHeap::uses_stack_watermark_barrier() const {
}
GrowableArray<GCMemoryManager*> ZCollectedHeap::memory_managers() {
- return GrowableArray<GCMemoryManager*>(1, 1, _heap.serviceability_memory_manager());
+ GrowableArray<GCMemoryManager*> memory_managers(2);
+ memory_managers.append(_heap.serviceability_cycle_memory_manager());
+ memory_managers.append(_heap.serviceability_pause_memory_manager());
+ return memory_managers;
}
GrowableArray<MemoryPool*> ZCollectedHeap::memory_pools() {
- return GrowableArray<MemoryPool*>(1, 1, _heap.serviceability_memory_pool());
+ GrowableArray<MemoryPool*> memory_pools(1);
+ memory_pools.append(_heap.serviceability_memory_pool());
+ return memory_pools;
}
void ZCollectedHeap::object_iterate(ObjectClosure* cl) {
diff --git a/src/hotspot/share/gc/z/zHeap.cpp b/src/hotspot/share/gc/z/zHeap.cpp
index ef53d4725d0..7626b93081e 100644
--- a/src/hotspot/share/gc/z/zHeap.cpp
+++ b/src/hotspot/share/gc/z/zHeap.cpp
@@ -455,8 +455,12 @@ void ZHeap::serviceability_initialize() {
_serviceability.initialize();
}
-GCMemoryManager* ZHeap::serviceability_memory_manager() {
- return _serviceability.memory_manager();
+GCMemoryManager* ZHeap::serviceability_cycle_memory_manager() {
+ return _serviceability.cycle_memory_manager();
+}
+
+GCMemoryManager* ZHeap::serviceability_pause_memory_manager() {
+ return _serviceability.pause_memory_manager();
}
MemoryPool* ZHeap::serviceability_memory_pool() {
diff --git a/src/hotspot/share/gc/z/zHeap.hpp b/src/hotspot/share/gc/z/zHeap.hpp
index 061f8e254fa..52e0a404e14 100644
--- a/src/hotspot/share/gc/z/zHeap.hpp
+++ b/src/hotspot/share/gc/z/zHeap.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2021, 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
@@ -146,7 +146,8 @@ public:
// Serviceability
void serviceability_initialize();
- GCMemoryManager* serviceability_memory_manager();
+ GCMemoryManager* serviceability_cycle_memory_manager();
+ GCMemoryManager* serviceability_pause_memory_manager();
MemoryPool* serviceability_memory_pool();
ZServiceabilityCounters* serviceability_counters();
diff --git a/src/hotspot/share/gc/z/zServiceability.cpp b/src/hotspot/share/gc/z/zServiceability.cpp
index 927f39515fc..d02558bc851 100644
--- a/src/hotspot/share/gc/z/zServiceability.cpp
+++ b/src/hotspot/share/gc/z/zServiceability.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2021, 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
@@ -110,8 +110,10 @@ MemoryUsage ZServiceabilityMemoryPool::get_memory_usage() {
return MemoryUsage(initial_size(), used, committed, max_size());
}
-ZServiceabilityMemoryManager::ZServiceabilityMemoryManager(ZServiceabilityMemoryPool* pool)
- : GCMemoryManager("ZGC", "end of major GC") {
+ZServiceabilityMemoryManager::ZServiceabilityMemoryManager(const char* name,
+ const char* end_message,
+ ZServiceabilityMemoryPool* pool) :
+ GCMemoryManager(name, end_message) {
add_pool(pool);
}
@@ -119,7 +121,8 @@ ZServiceability::ZServiceability(size_t min_capacity, size_t max_capacity) :
_min_capacity(min_capacity),
_max_capacity(max_capacity),
_memory_pool(_min_capacity, _max_capacity),
- _memory_manager(&_memory_pool),
+ _cycle_memory_manager("ZGC Cycles", "end of GC cycle", &_memory_pool),
+ _pause_memory_manager("ZGC Pauses", "end of GC pause", &_memory_pool),
_counters(NULL) {}
void ZServiceability::initialize() {
@@ -130,8 +133,12 @@ MemoryPool* ZServiceability::memory_pool() {
return &_memory_pool;
}
-GCMemoryManager* ZServiceability::memory_manager() {
- return &_memory_manager;
+GCMemoryManager* ZServiceability::cycle_memory_manager() {
+ return &_cycle_memory_manager;
+}
+
+GCMemoryManager* ZServiceability::pause_memory_manager() {
+ return &_pause_memory_manager;
}
ZServiceabilityCounters* ZServiceability::counters() {
@@ -139,20 +146,30 @@ ZServiceabilityCounters* ZServiceability::counters() {
}
ZServiceabilityCycleTracer::ZServiceabilityCycleTracer() :
- _memory_manager_stats(ZHeap::heap()->serviceability_memory_manager(),
+ _memory_manager_stats(ZHeap::heap()->serviceability_cycle_memory_manager(),
ZCollectedHeap::heap()->gc_cause(),
- true /* allMemoryPoolsAffected */,
- true /* recordGCBeginTime */,
- true /* recordPreGCUsage */,
- true /* recordPeakUsage */,
- true /* recordPostGCUsage */,
- true /* recordAccumulatedGCTime */,
- true /* recordGCEndTime */,
- true /* countCollection */) {}
+ true /* allMemoryPoolsAffected */,
+ true /* recordGCBeginTime */,
+ true /* recordPreGCUsage */,
+ true /* recordPeakUsage */,
+ true /* recordPostGCUsage */,
+ true /* recordAccumulatedGCTime */,
+ true /* recordGCEndTime */,
+ true /* countCollection */) {}
ZServiceabilityPauseTracer::ZServiceabilityPauseTracer() :
_svc_gc_marker(SvcGCMarker::CONCURRENT),
- _counters_stats(ZHeap::heap()->serviceability_counters()->collector_counters()) {}
+ _counters_stats(ZHeap::heap()->serviceability_counters()->collector_counters()),
+ _memory_manager_stats(ZHeap::heap()->serviceability_pause_memory_manager(),
+ ZCollectedHeap::heap()->gc_cause(),
+ true /* allMemoryPoolsAffected */,
+ true /* recordGCBeginTime */,
+ false /* recordPreGCUsage */,
+ false /* recordPeakUsage */,
+ false /* recordPostGCUsage */,
+ true /* recordAccumulatedGCTime */,
+ true /* recordGCEndTime */,
+ true /* countCollection */) {}
ZServiceabilityPauseTracer::~ZServiceabilityPauseTracer() {
ZHeap::heap()->serviceability_counters()->update_sizes();
diff --git a/src/hotspot/share/gc/z/zServiceability.hpp b/src/hotspot/share/gc/z/zServiceability.hpp
index edb41b51955..3947038c4ce 100644
--- a/src/hotspot/share/gc/z/zServiceability.hpp
+++ b/src/hotspot/share/gc/z/zServiceability.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,9 @@ public:
class ZServiceabilityMemoryManager : public GCMemoryManager {
public:
- ZServiceabilityMemoryManager(ZServiceabilityMemoryPool* pool);
+ ZServiceabilityMemoryManager(const char* name,
+ const char* end_message,
+ ZServiceabilityMemoryPool* pool);
};
class ZServiceability {
@@ -51,7 +53,8 @@ private:
const size_t _min_capacity;
const size_t _max_capacity;
ZServiceabilityMemoryPool _memory_pool;
- ZServiceabilityMemoryManager _memory_manager;
+ ZServiceabilityMemoryManager _cycle_memory_manager;
+ ZServiceabilityMemoryManager _pause_memory_manager;
ZServiceabilityCounters* _counters;
public:
@@ -60,7 +63,8 @@ public:
void initialize();
MemoryPool* memory_pool();
- GCMemoryManager* memory_manager();
+ GCMemoryManager* cycle_memory_manager();
+ GCMemoryManager* pause_memory_manager();
ZServiceabilityCounters* counters();
};
@@ -74,8 +78,9 @@ public:
class ZServiceabilityPauseTracer : public StackObj {
private:
- SvcGCMarker _svc_gc_marker;
- TraceCollectorStats _counters_stats;
+ SvcGCMarker _svc_gc_marker;
+ TraceCollectorStats _counters_stats;
+ TraceMemoryManagerStats _memory_manager_stats;
public:
ZServiceabilityPauseTracer();
diff --git a/src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp b/src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp
index 6d56e01ef11..9d84ae135df 100644
--- a/src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp
+++ b/src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp
@@ -46,13 +46,13 @@ struct ObsoleteOption {
static const ObsoleteOption OBSOLETE_OPTIONS[] = {
{"checkpointbuffersize", ""},
- {"maxsize", "Use -XX:StartFlightRecording=maxsize=... instead."},
- {"maxage", "Use -XX:StartFlightRecording=maxage=... instead."},
- {"settings", "Use -XX:StartFlightRecording=settings=... instead."},
- {"defaultrecording", "Use -XX:StartFlightRecording=disk=false to create an in-memory recording."},
- {"disk", "Use -XX:StartFlightRecording=disk=... instead."},
- {"dumponexit", "Use -XX:StartFlightRecording=dumponexit=... instead."},
- {"dumponexitpath", "Use -XX:StartFlightRecording=filename=... instead."},
+ {"maxsize", "Use -XX:StartFlightRecording:maxsize=... instead."},
+ {"maxage", "Use -XX:StartFlightRecording:maxage=... instead."},
+ {"settings", "Use -XX:StartFlightRecording:settings=... instead."},
+ {"defaultrecording", "Use -XX:StartFlightRecording:disk=false to create an in-memory recording."},
+ {"disk", "Use -XX:StartFlightRecording:disk=... instead."},
+ {"dumponexit", "Use -XX:StartFlightRecording:dumponexit=... instead."},
+ {"dumponexitpath", "Use -XX:StartFlightRecording:filename=... instead."},
{"loglevel", "Use -Xlog:jfr=... instead."}
};
diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
index f849c6815bd..55ab7acecb1 100644
--- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
+++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
@@ -468,6 +468,10 @@ C2V_VMENTRY_NULL(jobject, findUniqueConcreteMethod, (JNIEnv* env, jobject, jobje
JVMCI_THROW_MSG_NULL(InternalError, err_msg("Effectively static method %s.%s should be handled in Java code", method->method_holder()->external_name(), method->external_name()));
}
+ if (method->is_abstract()) {
+ return NULL;
+ }
+
methodHandle ucm;
{
MutexLocker locker(Compile_lock);
diff --git a/src/hotspot/share/oops/method.cpp b/src/hotspot/share/oops/method.cpp
index ea450b2fddd..7ef8e2fd35b 100644
--- a/src/hotspot/share/oops/method.cpp
+++ b/src/hotspot/share/oops/method.cpp
@@ -1404,7 +1404,7 @@ methodHandle Method::make_method_handle_intrinsic(vmIntrinsics::ID iid,
assert(MethodHandles::is_signature_polymorphic_name(m->name()), "");
assert(m->signature() == signature, "");
m->compute_from_signature(signature);
- m->init_intrinsic_id();
+ m->init_intrinsic_id(klass_id_for_intrinsics(m->method_holder()));
assert(m->is_method_handle_intrinsic(), "");
#ifdef ASSERT
if (!MethodHandles::is_signature_polymorphic(m->intrinsic_id())) m->print();
@@ -1558,17 +1558,22 @@ vmSymbolID Method::klass_id_for_intrinsics(const Klass* holder) {
// see if the klass name is well-known:
Symbol* klass_name = ik->name();
- return vmSymbols::find_sid(klass_name);
+ vmSymbolID id = vmSymbols::find_sid(klass_name);
+ if (id != vmSymbolID::NO_SID && vmIntrinsics::class_has_intrinsics(id)) {
+ return id;
+ } else {
+ return vmSymbolID::NO_SID;
+ }
}
-void Method::init_intrinsic_id() {
+void Method::init_intrinsic_id(vmSymbolID klass_id) {
assert(_intrinsic_id == static_cast<int>(vmIntrinsics::_none), "do this just once");
const uintptr_t max_id_uint = right_n_bits((int)(sizeof(_intrinsic_id) * BitsPerByte));
assert((uintptr_t)vmIntrinsics::ID_LIMIT <= max_id_uint, "else fix size");
assert(intrinsic_id_size_in_bytes() == sizeof(_intrinsic_id), "");
// the klass name is well-known:
- vmSymbolID klass_id = klass_id_for_intrinsics(method_holder());
+ assert(klass_id == klass_id_for_intrinsics(method_holder()), "must be");
assert(klass_id != vmSymbolID::NO_SID, "caller responsibility");
// ditto for method and signature:
diff --git a/src/hotspot/share/oops/method.hpp b/src/hotspot/share/oops/method.hpp
index f83df992855..85578da5dcd 100644
--- a/src/hotspot/share/oops/method.hpp
+++ b/src/hotspot/share/oops/method.hpp
@@ -838,7 +838,7 @@ public:
void set_intrinsic_id(vmIntrinsicID id) { _intrinsic_id = (u2) id; }
// Helper routines for intrinsic_id() and vmIntrinsics::method().
- void init_intrinsic_id(); // updates from _none if a match
+ void init_intrinsic_id(vmSymbolID klass_id); // updates from _none if a match
static vmSymbolID klass_id_for_intrinsics(const Klass* holder);
bool caller_sensitive() {
diff --git a/src/hotspot/share/opto/block.cpp b/src/hotspot/share/opto/block.cpp
index 56371e574f4..d4227df0b4f 100644
--- a/src/hotspot/share/opto/block.cpp
+++ b/src/hotspot/share/opto/block.cpp
@@ -1245,12 +1245,18 @@ void PhaseCFG::verify() const {
for (uint k = 0; k < n->req(); k++) {
Node *def = n->in(k);
if (def && def != n) {
- assert(get_block_for_node(def) || def->is_Con(), "must have block; constants for debug info ok");
- // Verify that instructions in the block is in correct order.
+ Block* def_block = get_block_for_node(def);
+ assert(def_block || def->is_Con(), "must have block; constants for debug info ok");
+ // Verify that all definitions dominate their uses (except for virtual
+ // instructions merging multiple definitions).
+ assert(n->is_Root() || n->is_Region() || n->is_Phi() || n->is_MachMerge() ||
+ def_block->dominates(block),
+ "uses must be dominated by definitions");
+ // Verify that instructions in the block are in correct order.
// Uses must follow their definition if they are at the same block.
// Mostly done to check that MachSpillCopy nodes are placed correctly
// when CreateEx node is moved in build_ifg_physical().
- if (get_block_for_node(def) == block && !(block->head()->is_Loop() && n->is_Phi()) &&
+ if (def_block == block && !(block->head()->is_Loop() && n->is_Phi()) &&
// See (+++) comment in reg_split.cpp
!(n->jvms() != NULL && n->jvms()->is_monitor_use(k))) {
bool is_loop = false;
@@ -1266,6 +1272,14 @@ void PhaseCFG::verify() const {
}
}
}
+ if (n->is_Proj()) {
+ assert(j >= 1, "a projection cannot be the first instruction in a block");
+ Node* pred = block->get_node(j - 1);
+ Node* parent = n->in(0);
+ assert(parent != NULL, "projections must have a parent");
+ assert(pred == parent || (pred->is_Proj() && pred->in(0) == parent),
+ "projections must follow their parents or other sibling projections");
+ }
}
j = block->end_idx();
diff --git a/src/hotspot/share/opto/lcm.cpp b/src/hotspot/share/opto/lcm.cpp
index cf45ff971f7..28116653f94 100644
--- a/src/hotspot/share/opto/lcm.cpp
+++ b/src/hotspot/share/opto/lcm.cpp
@@ -1390,14 +1390,40 @@ void PhaseCFG::call_catch_cleanup(Block* block) {
}
// If the successor blocks have a CreateEx node, move it back to the top
- for(uint i4 = 0; i4 < block->_num_succs; i4++ ) {
+ for (uint i4 = 0; i4 < block->_num_succs; i4++) {
Block *sb = block->_succs[i4];
uint new_cnt = end - beg;
- // Remove any newly created, but dead, nodes.
- for( uint j = new_cnt; j > 0; j-- ) {
+ // Remove any newly created, but dead, nodes by traversing their schedule
+ // backwards. Here, a dead node is a node whose only outputs (if any) are
+ // unused projections.
+ for (uint j = new_cnt; j > 0; j--) {
Node *n = sb->get_node(j);
- if (n->outcnt() == 0 &&
- (!n->is_Proj() || n->as_Proj()->in(0)->outcnt() == 1) ){
+ // Individual projections are examined together with all siblings when
+ // their parent is visited.
+ if (n->is_Proj()) {
+ continue;
+ }
+ bool dead = true;
+ for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
+ Node* out = n->fast_out(i);
+ // n is live if it has a non-projection output or a used projection.
+ if (!out->is_Proj() || out->outcnt() > 0) {
+ dead = false;
+ break;
+ }
+ }
+ if (dead) {
+ // n's only outputs (if any) are unused projections scheduled next to n
+ // (see PhaseCFG::select()). Remove these projections backwards.
+ for (uint k = j + n->outcnt(); k > j; k--) {
+ Node* proj = sb->get_node(k);
+ assert(proj->is_Proj() && proj->in(0) == n,
+ "projection should correspond to dead node");
+ proj->disconnect_inputs(C);
+ sb->remove_node(k);
+ new_cnt--;
+ }
+ // Now remove the node itself.
n->disconnect_inputs(C);
sb->remove_node(j);
new_cnt--;
diff --git a/src/hotspot/share/opto/reg_split.cpp b/src/hotspot/share/opto/reg_split.cpp
index ca5c9eaf7f8..1d2717e7556 100644
--- a/src/hotspot/share/opto/reg_split.cpp
+++ b/src/hotspot/share/opto/reg_split.cpp
@@ -114,6 +114,8 @@ void PhaseChaitin::insert_proj( Block *b, uint i, Node *spill, uint maxlrg ) {
// Do not insert between a call and his Catch
if( b->get_node(i)->is_Catch() ) {
// Put the instruction at the top of the fall-thru block.
+ // This assumes that the instruction is not used in the other exception
+ // blocks. Global code motion is responsible for maintaining this invariant.
// Find the fall-thru projection
while( 1 ) {
const CatchProjNode *cp = b->get_node(++i)->as_CatchProj();
diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp
index f4868134b64..47cf712ba68 100644
--- a/src/hotspot/share/runtime/os.cpp
+++ b/src/hotspot/share/runtime/os.cpp
@@ -853,7 +853,7 @@ int os::random() {
while (true) {
unsigned int seed = _rand_seed;
unsigned int rand = next_random(seed);
- if (Atomic::cmpxchg(&_rand_seed, seed, rand) == seed) {
+ if (Atomic::cmpxchg(&_rand_seed, seed, rand, memory_order_relaxed) == seed) {
return static_cast<int>(rand);
}
}
diff --git a/src/java.base/share/classes/java/io/File.java b/src/java.base/share/classes/java/io/File.java
index 9166b802214..aa06bd50ca9 100644
--- a/src/java.base/share/classes/java/io/File.java
+++ b/src/java.base/share/classes/java/io/File.java
@@ -500,6 +500,9 @@ public class File
public File getParentFile() {
String p = this.getParent();
if (p == null) return null;
+ if (getClass() != File.class) {
+ p = fs.normalize(p);
+ }
return new File(p, this.prefixLength);
}
@@ -572,6 +575,9 @@ public class File
*/
public File getAbsoluteFile() {
String absPath = getAbsolutePath();
+ if (getClass() != File.class) {
+ absPath = fs.normalize(absPath);
+ }
return new File(absPath, fs.prefixLength(absPath));
}
@@ -643,6 +649,9 @@ public class File
*/
public File getCanonicalFile() throws IOException {
String canonPath = getCanonicalPath();
+ if (getClass() != File.class) {
+ canonPath = fs.normalize(canonPath);
+ }
return new File(canonPath, fs.prefixLength(canonPath));
}
@@ -1125,6 +1134,26 @@ public class File
* the directory
*/
public String[] list() {
+ return normalizedList();
+ }
+
+ /**
+ * Returns an array of strings naming the files and directories in the
+ * directory denoted by this abstract pathname. The strings are
+ * ensured to represent normalized paths.
+ *
+ * @return An array of strings naming the files and directories in the
+ * directory denoted by this abstract pathname. The array will be
+ * empty if the directory is empty. Returns {@code null} if
+ * this abstract pathname does not denote a directory, or if an
+ * I/O error occurs.
+ *
+ * @throws SecurityException
+ * If a security manager exists and its {@link
+ * SecurityManager#checkRead(String)} method denies read access to
+ * the directory
+ */
+ private final String[] normalizedList() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
@@ -1132,7 +1161,15 @@ public class File
if (isInvalid()) {
return null;
}
- return fs.list(this);
+ String[] s = fs.list(this);
+ if (s != null && getClass() != File.class) {
+ String[] normalized = new String[s.length];
+ for (int i = 0; i < s.length; i++) {
+ normalized[i] = fs.normalize(s[i]);
+ }
+ s = normalized;
+ }
+ return s;
}
/**
@@ -1165,7 +1202,7 @@ public class File
* @see java.nio.file.Files#newDirectoryStream(Path,String)
*/
public String[] list(FilenameFilter filter) {
- String names[] = list();
+ String names[] = normalizedList();
if ((names == null) || (filter == null)) {
return names;
}
@@ -1217,7 +1254,7 @@ public class File
* @since 1.2
*/
public File[] listFiles() {
- String[] ss = list();
+ String[] ss = normalizedList();
if (ss == null) return null;
int n = ss.length;
File[] fs = new File[n];
@@ -1258,7 +1295,7 @@ public class File
* @see java.nio.file.Files#newDirectoryStream(Path,String)
*/
public File[] listFiles(FilenameFilter filter) {
- String ss[] = list();
+ String ss[] = normalizedList();
if (ss == null) return null;
ArrayList<File> files = new ArrayList<>();
for (String s : ss)
@@ -1296,7 +1333,7 @@ public class File
* @see java.nio.file.Files#newDirectoryStream(Path,java.nio.file.DirectoryStream.Filter)
*/
public File[] listFiles(FileFilter filter) {
- String ss[] = list();
+ String ss[] = normalizedList();
if (ss == null) return null;
ArrayList<File> files = new ArrayList<>();
for (String s : ss) {
diff --git a/src/java.base/share/classes/java/security/cert/CertPathHelperImpl.java b/src/java.base/share/classes/java/security/cert/CertPathHelperImpl.java
index 24507e2bbd3..bd6545a7357 100644
--- a/src/java.base/share/classes/java/security/cert/CertPathHelperImpl.java
+++ b/src/java.base/share/classes/java/security/cert/CertPathHelperImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -63,4 +63,8 @@ class CertPathHelperImpl extends CertPathHelper {
protected void implSetDateAndTime(X509CRLSelector sel, Date date, long skew) {
sel.setDateAndTime(date, skew);
}
+
+ protected boolean implIsJdkCA(TrustAnchor anchor) {
+ return anchor.isJdkCA();
+ }
}
diff --git a/src/java.base/share/classes/java/security/cert/TrustAnchor.java b/src/java.base/share/classes/java/security/cert/TrustAnchor.java
index 78ff2f04e12..2fee634ec41 100644
--- a/src/java.base/share/classes/java/security/cert/TrustAnchor.java
+++ b/src/java.base/share/classes/java/security/cert/TrustAnchor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2014, 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
@@ -30,6 +30,7 @@ import java.security.PublicKey;
import javax.security.auth.x500.X500Principal;
+import sun.security.util.AnchorCertificates;
import sun.security.x509.NameConstraintsExtension;
import sun.security.x509.X500Name;
@@ -68,6 +69,12 @@ public class TrustAnchor {
private final X509Certificate trustedCert;
private byte[] ncBytes;
private NameConstraintsExtension nc;
+ private boolean jdkCA;
+ private boolean hasJdkCABeenChecked;
+
+ static {
+ CertPathHelperImpl.initialize();
+ }
/**
* Creates an instance of {@code TrustAnchor} with the specified
@@ -330,4 +337,18 @@ public class TrustAnchor {
sb.append(" Name Constraints: " + nc.toString() + "\n");
return sb.toString();
}
+
+ /**
+ * Returns true if anchor is a JDK CA (a root CA that is included by
+ * default in the cacerts keystore).
+ */
+ synchronized boolean isJdkCA() {
+ if (!hasJdkCABeenChecked) {
+ if (trustedCert != null) {
+ jdkCA = AnchorCertificates.contains(trustedCert);
+ }
+ hasJdkCABeenChecked = true;
+ }
+ return jdkCA;
+ }
}
diff --git a/src/java.base/share/classes/java/util/jar/JarFile.java b/src/java.base/share/classes/java/util/jar/JarFile.java
index 760925cb114..9628decf186 100644
--- a/src/java.base/share/classes/java/util/jar/JarFile.java
+++ b/src/java.base/share/classes/java/util/jar/JarFile.java
@@ -29,7 +29,6 @@ import jdk.internal.access.SharedSecrets;
import jdk.internal.access.JavaUtilZipFileAccess;
import sun.security.action.GetPropertyAction;
import sun.security.util.ManifestEntryVerifier;
-import sun.security.util.SignatureFileVerifier;
import java.io.ByteArrayInputStream;
import java.io.EOFException;
diff --git a/src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java b/src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java
index fb46e8b0fc3..8e03028ecd0 100644
--- a/src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java
+++ b/src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java
@@ -358,10 +358,14 @@ public class AnnotationParser {
result = parseConst(tag, buf, constPool);
}
- if (!(result instanceof ExceptionProxy) &&
- !memberType.isInstance(result))
+ if (result == null) {
+ result = new AnnotationTypeMismatchExceptionProxy(
+ memberType.getClass().getName());
+ } else if (!(result instanceof ExceptionProxy) &&
+ !memberType.isInstance(result)) {
result = new AnnotationTypeMismatchExceptionProxy(
result.getClass() + "[" + result + "]");
+ }
return result;
}
@@ -469,8 +473,10 @@ public class AnnotationParser {
String typeName = constPool.getUTF8At(typeNameIndex);
int constNameIndex = buf.getShort() & 0xFFFF;
String constName = constPool.getUTF8At(constNameIndex);
-
- if (!typeName.endsWith(";")) {
+ if (!enumType.isEnum()) {
+ return new AnnotationTypeMismatchExceptionProxy(
+ typeName + "." + constName);
+ } else if (!typeName.endsWith(";")) {
// support now-obsolete early jsr175-format class files.
if (!enumType.getName().equals(typeName))
return new AnnotationTypeMismatchExceptionProxy(
diff --git a/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java b/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java
index d84e7182216..08c6be29c28 100644
--- a/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java
+++ b/src/java.base/share/classes/sun/security/pkcs/SignerInfo.java
@@ -36,9 +36,11 @@ import java.security.cert.X509Certificate;
import java.security.*;
import java.security.spec.PSSParameterSpec;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
-import java.util.EnumSet;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import sun.security.provider.SHAKE256;
@@ -55,16 +57,8 @@ import sun.security.x509.KeyUsageExtension;
*/
public class SignerInfo implements DerEncoder {
- // Digest and Signature restrictions
- private static final Set<CryptoPrimitive> DIGEST_PRIMITIVE_SET =
- Collections.unmodifiableSet(EnumSet.of(CryptoPrimitive.MESSAGE_DIGEST));
-
- private static final Set<CryptoPrimitive> SIG_PRIMITIVE_SET =
- Collections.unmodifiableSet(EnumSet.of(CryptoPrimitive.SIGNATURE));
-
private static final DisabledAlgorithmConstraints JAR_DISABLED_CHECK =
- new DisabledAlgorithmConstraints(
- DisabledAlgorithmConstraints.PROPERTY_JAR_DISABLED_ALGS);
+ DisabledAlgorithmConstraints.jarConstraints();
BigInteger version;
X500Name issuerName;
@@ -79,6 +73,14 @@ public class SignerInfo implements DerEncoder {
PKCS9Attributes authenticatedAttributes;
PKCS9Attributes unauthenticatedAttributes;
+ /**
+ * A map containing the algorithms in this SignerInfo. This is used to
+ * avoid checking algorithms to see if they are disabled more than once.
+ * The key is the AlgorithmId of the algorithm, and the value is the name of
+ * the field or attribute.
+ */
+ private Map<AlgorithmId, String> algorithms = new HashMap<>();
+
public SignerInfo(X500Name issuerName,
BigInteger serial,
AlgorithmId digestAlgorithmId,
@@ -329,20 +331,15 @@ public class SignerInfo implements DerEncoder {
throws NoSuchAlgorithmException, SignatureException {
try {
+ Timestamp timestamp = getTimestamp();
ContentInfo content = block.getContentInfo();
if (data == null) {
data = content.getContentBytes();
}
- Timestamp timestamp = null;
- try {
- timestamp = getTimestamp();
- } catch (Exception ignore) {
- }
-
- ConstraintsParameters cparams =
- new ConstraintsParameters(timestamp);
+ String digestAlgName = digestAlgorithmId.getName();
+ algorithms.put(digestAlgorithmId, "SignerInfo digestAlgorithm field");
byte[] dataSigned;
@@ -368,19 +365,10 @@ public class SignerInfo implements DerEncoder {
if (messageDigest == null) // fail if there is no message digest
return null;
- String digestAlgname = digestAlgorithmId.getName();
-
- // check that digest algorithm is not restricted
- try {
- JAR_DISABLED_CHECK.permits(digestAlgname, cparams);
- } catch (CertPathValidatorException e) {
- throw new SignatureException(e.getMessage(), e);
- }
-
byte[] computedMessageDigest;
- if (digestAlgname.equals("SHAKE256")
- || digestAlgname.equals("SHAKE256-LEN")) {
- if (digestAlgname.equals("SHAKE256-LEN")) {
+ if (digestAlgName.equals("SHAKE256")
+ || digestAlgName.equals("SHAKE256-LEN")) {
+ if (digestAlgName.equals("SHAKE256-LEN")) {
int v = new DerValue(digestAlgorithmId
.getEncodedParams()).getInteger();
if (v != 512) {
@@ -392,15 +380,12 @@ public class SignerInfo implements DerEncoder {
md.update(data, 0, data.length);
computedMessageDigest = md.digest();
} else {
- MessageDigest md = MessageDigest.getInstance(digestAlgname);
+ MessageDigest md = MessageDigest.getInstance(digestAlgName);
computedMessageDigest = md.digest(data);
}
- if (messageDigest.length != computedMessageDigest.length)
+ if (!MessageDigest.isEqual(messageDigest, computedMessageDigest)) {
return null;
- for (int i = 0; i < messageDigest.length; i++) {
- if (messageDigest[i] != computedMessageDigest[i])
- return null;
}
// message digest attribute matched
@@ -414,16 +399,18 @@ public class SignerInfo implements DerEncoder {
// put together digest algorithm and encryption algorithm
// to form signing algorithm. See makeSigAlg for details.
- String algname = makeSigAlg(
+ String sigAlgName = makeSigAlg(
digestAlgorithmId,
digestEncryptionAlgorithmId,
authenticatedAttributes == null);
- // check that jar signature algorithm is not restricted
- try {
- JAR_DISABLED_CHECK.permits(algname, cparams);
- } catch (CertPathValidatorException e) {
- throw new SignatureException(e.getMessage(), e);
+ KnownOIDs oid = KnownOIDs.findMatch(sigAlgName);
+ if (oid != null) {
+ AlgorithmId sigAlgId =
+ new AlgorithmId(ObjectIdentifier.of(oid),
+ digestEncryptionAlgorithmId.getParameters());
+ algorithms.put(sigAlgId,
+ "SignerInfo digestEncryptionAlgorithm field");
}
X509Certificate cert = getCertificate(block);
@@ -432,14 +419,6 @@ public class SignerInfo implements DerEncoder {
}
PublicKey key = cert.getPublicKey();
- // check if the public key is restricted
- if (!JAR_DISABLED_CHECK.permits(SIG_PRIMITIVE_SET, key)) {
- throw new SignatureException("Public key check failed. " +
- "Disabled key used: " +
- KeyUtil.getKeySize(key) + " bit " +
- key.getAlgorithm());
- }
-
if (cert.hasUnsupportedCriticalExtension()) {
throw new SignatureException("Certificate has unsupported "
+ "critical extension(s)");
@@ -476,13 +455,13 @@ public class SignerInfo implements DerEncoder {
}
}
- Signature sig = Signature.getInstance(algname);
+ Signature sig = Signature.getInstance(sigAlgName);
AlgorithmParameters ap =
digestEncryptionAlgorithmId.getParameters();
try {
SignatureUtil.initVerifyWithParam(sig, key,
- SignatureUtil.getParamSpec(algname, ap));
+ SignatureUtil.getParamSpec(sigAlgName, ap));
} catch (ProviderException | InvalidAlgorithmParameterException |
InvalidKeyException e) {
throw new SignatureException(e.getMessage(), e);
@@ -492,9 +471,8 @@ public class SignerInfo implements DerEncoder {
if (sig.verify(encryptedDigest)) {
return this;
}
- } catch (IOException e) {
- throw new SignatureException("IO error verifying signature:\n" +
- e.getMessage());
+ } catch (IOException | CertificateException e) {
+ throw new SignatureException("Error verifying signature", e);
}
return null;
}
@@ -654,6 +632,9 @@ public class SignerInfo implements DerEncoder {
// Extract the signer (the Timestamping Authority)
// while verifying the content
SignerInfo[] tsa = tsToken.verify(encTsTokenInfo);
+ if (tsa == null || tsa.length == 0) {
+ throw new SignatureException("Unable to verify timestamp");
+ }
// Expect only one signer
ArrayList<X509Certificate> chain = tsa[0].getCertificateChain(tsToken);
CertificateFactory cf = CertificateFactory.getInstance("X.509");
@@ -662,6 +643,7 @@ public class SignerInfo implements DerEncoder {
TimestampToken tsTokenInfo = new TimestampToken(encTsTokenInfo);
// Check that the signature timestamp applies to this signature
verifyTimestamp(tsTokenInfo);
+ algorithms.putAll(tsa[0].algorithms);
// Create a timestamp object
timestamp = new Timestamp(tsTokenInfo.getDate(), tsaChain);
return timestamp;
@@ -674,18 +656,13 @@ public class SignerInfo implements DerEncoder {
*/
private void verifyTimestamp(TimestampToken token)
throws NoSuchAlgorithmException, SignatureException {
- String digestAlgname = token.getHashAlgorithm().getName();
- // check that algorithm is not restricted
- if (!JAR_DISABLED_CHECK.permits(DIGEST_PRIMITIVE_SET, digestAlgname,
- null)) {
- throw new SignatureException("Timestamp token digest check failed. " +
- "Disabled algorithm used: " + digestAlgname);
- }
- MessageDigest md =
- MessageDigest.getInstance(digestAlgname);
+ AlgorithmId digestAlgId = token.getHashAlgorithm();
+ algorithms.put(digestAlgId, "TimestampToken digestAlgorithm field");
+
+ MessageDigest md = MessageDigest.getInstance(digestAlgId.getName());
- if (!Arrays.equals(token.getHashedMessage(),
+ if (!MessageDigest.isEqual(token.getHashedMessage(),
md.digest(encryptedDigest))) {
throw new SignatureException("Signature timestamp (#" +
@@ -726,4 +703,35 @@ public class SignerInfo implements DerEncoder {
}
return out;
}
+
+ /**
+ * Verify all of the algorithms in the array of SignerInfos against the
+ * constraints in the jdk.jar.disabledAlgorithms security property.
+ *
+ * @param infos array of SignerInfos
+ * @param params constraint parameters
+ * @param name the name of the signer's PKCS7 file
+ * @return a set of algorithms that passed the checks and are not disabled
+ */
+ public static Set<String> verifyAlgorithms(SignerInfo[] infos,
+ JarConstraintsParameters params, String name) throws SignatureException {
+ Map<AlgorithmId, String> algorithms = new HashMap<>();
+ for (SignerInfo info : infos) {
+ algorithms.putAll(info.algorithms);
+ }
+
+ Set<String> enabledAlgorithms = new HashSet<>();
+ try {
+ for (Map.Entry<AlgorithmId, String> algorithm : algorithms.entrySet()) {
+ params.setExtendedExceptionMsg(name, algorithm.getValue());
+ AlgorithmId algId = algorithm.getKey();
+ JAR_DISABLED_CHECK.permits(algId.getName(),
+ algId.getParameters(), params);
+ enabledAlgorithms.add(algId.getName());
+ }
+ } catch (CertPathValidatorException e) {
+ throw new SignatureException(e);
+ }
+ return enabledAlgorithms;
+ }
}
diff --git a/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java b/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java
index 8282d51c425..56f26d69280 100644
--- a/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java
+++ b/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2017, 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
@@ -27,8 +27,6 @@ package sun.security.provider.certpath;
import java.security.AlgorithmConstraints;
import java.security.CryptoPrimitive;
-import java.security.Timestamp;
-import java.security.cert.CertPathValidator;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
@@ -53,14 +51,13 @@ import java.security.interfaces.DSAParams;
import java.security.interfaces.DSAPublicKey;
import java.security.spec.DSAPublicKeySpec;
-import sun.security.util.AnchorCertificates;
import sun.security.util.ConstraintsParameters;
import sun.security.util.Debug;
import sun.security.util.DisabledAlgorithmConstraints;
import sun.security.validator.Validator;
+import sun.security.x509.AlgorithmId;
import sun.security.x509.X509CertImpl;
import sun.security.x509.X509CRLImpl;
-import sun.security.x509.AlgorithmId;
/**
* A {@code PKIXCertPathChecker} implementation to check whether a
@@ -78,10 +75,10 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
private final AlgorithmConstraints constraints;
private final PublicKey trustedPubKey;
- private final Date pkixdate;
+ private final Date date;
private PublicKey prevPubKey;
- private final Timestamp jarTimestamp;
private final String variant;
+ private TrustAnchor anchor;
private static final Set<CryptoPrimitive> SIGNATURE_PRIMITIVE_SET =
Collections.unmodifiableSet(EnumSet.of(CryptoPrimitive.SIGNATURE));
@@ -94,95 +91,70 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
CryptoPrimitive.KEY_AGREEMENT));
private static final DisabledAlgorithmConstraints
- certPathDefaultConstraints = new DisabledAlgorithmConstraints(
- DisabledAlgorithmConstraints.PROPERTY_CERTPATH_DISABLED_ALGS);
-
- // If there is no "cacerts" keyword, then disable anchor checking
- private static final boolean publicCALimits =
- certPathDefaultConstraints.checkProperty("jdkCA");
-
- // If anchor checking enabled, this will be true if the trust anchor
- // has a match in the cacerts file
- private boolean trustedMatch = false;
+ certPathDefaultConstraints =
+ DisabledAlgorithmConstraints.certPathConstraints();
/**
- * Create a new {@code AlgorithmChecker} with the given algorithm
- * given {@code TrustAnchor} and {@code String} variant.
+ * Create a new {@code AlgorithmChecker} with the given
+ * {@code TrustAnchor} and {@code String} variant.
*
* @param anchor the trust anchor selected to validate the target
* certificate
- * @param variant is the Validator variants of the operation. A null value
+ * @param variant the Validator variant of the operation. A null value
* passed will set it to Validator.GENERIC.
*/
public AlgorithmChecker(TrustAnchor anchor, String variant) {
- this(anchor, certPathDefaultConstraints, null, null, variant);
+ this(anchor, certPathDefaultConstraints, null, variant);
}
/**
* Create a new {@code AlgorithmChecker} with the given
- * {@code AlgorithmConstraints}, {@code Timestamp}, and {@code String}
- * variant.
+ * {@code AlgorithmConstraints} and {@code String} variant.
*
* Note that this constructor can initialize a variation of situations where
- * the AlgorithmConstraints, Timestamp, or Variant maybe known.
+ * the AlgorithmConstraints or Variant maybe known.
*
* @param constraints the algorithm constraints (or null)
- * @param jarTimestamp Timestamp passed for JAR timestamp constraint
- * checking. Set to null if not applicable.
- * @param variant is the Validator variants of the operation. A null value
+ * @param variant the Validator variant of the operation. A null value
* passed will set it to Validator.GENERIC.
*/
- public AlgorithmChecker(AlgorithmConstraints constraints,
- Timestamp jarTimestamp, String variant) {
- this(null, constraints, null, jarTimestamp, variant);
+ public AlgorithmChecker(AlgorithmConstraints constraints, String variant) {
+ this(null, constraints, null, variant);
}
/**
* Create a new {@code AlgorithmChecker} with the
- * given {@code TrustAnchor}, {@code AlgorithmConstraints},
- * {@code Timestamp}, and {@code String} variant.
+ * given {@code TrustAnchor}, {@code AlgorithmConstraints}, {@code Date},
+ * and {@code String} variant.
*
* @param anchor the trust anchor selected to validate the target
* certificate
* @param constraints the algorithm constraints (or null)
- * @param pkixdate The date specified by the PKIXParameters date. If the
- * PKIXParameters is null, the current date is used. This
- * should be null when jar files are being checked.
- * @param jarTimestamp Timestamp passed for JAR timestamp constraint
- * checking. Set to null if not applicable.
- * @param variant is the Validator variants of the operation. A null value
+ * @param date the date specified by the PKIXParameters date, or the
+ * JAR timestamp if jar files are being validated and the
+ * JAR is timestamped. May be null if no timestamp or
+ * PKIXParameter date is set.
+ * @param variant the Validator variant of the operation. A null value
* passed will set it to Validator.GENERIC.
*/
public AlgorithmChecker(TrustAnchor anchor,
- AlgorithmConstraints constraints, Date pkixdate,
- Timestamp jarTimestamp, String variant) {
+ AlgorithmConstraints constraints, Date date, String variant) {
if (anchor != null) {
if (anchor.getTrustedCert() != null) {
this.trustedPubKey = anchor.getTrustedCert().getPublicKey();
- // Check for anchor certificate restrictions
- trustedMatch = checkFingerprint(anchor.getTrustedCert());
- if (trustedMatch && debug != null) {
- debug.println("trustedMatch = true");
- }
} else {
this.trustedPubKey = anchor.getCAPublicKey();
}
+ this.anchor = anchor;
} else {
this.trustedPubKey = null;
- if (debug != null) {
- debug.println("TrustAnchor is null, trustedMatch is false.");
- }
}
this.prevPubKey = this.trustedPubKey;
this.constraints = (constraints == null ? certPathDefaultConstraints :
constraints);
- // If we are checking jar files, set pkixdate the same as the timestamp
- // for certificate checking
- this.pkixdate = (jarTimestamp != null ? jarTimestamp.getTimestamp() :
- pkixdate);
- this.jarTimestamp = jarTimestamp;
+ this.date = date;
this.variant = (variant == null ? Validator.VAR_GENERIC : variant);
}
@@ -194,24 +166,11 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
* certificate
* @param pkixdate Date the constraints are checked against. The value is
* either the PKIXParameters date or null for the current date.
- * @param variant is the Validator variants of the operation. A null value
+ * @param variant the Validator variant of the operation. A null value
* passed will set it to Validator.GENERIC.
*/
public AlgorithmChecker(TrustAnchor anchor, Date pkixdate, String variant) {
- this(anchor, certPathDefaultConstraints, pkixdate, null, variant);
- }
-
- // Check this 'cert' for restrictions in the AnchorCertificates
- // trusted certificates list
- private static boolean checkFingerprint(X509Certificate cert) {
- if (!publicCALimits) {
- return false;
- }
-
- if (debug != null) {
- debug.println("AlgorithmChecker.contains: " + cert.getSigAlgName());
- }
- return AnchorCertificates.contains(cert);
+ this(anchor, certPathDefaultConstraints, pkixdate, variant);
}
@Override
@@ -318,18 +277,19 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
}
ConstraintsParameters cp =
- new ConstraintsParameters((X509Certificate)cert,
- trustedMatch, pkixdate, jarTimestamp, variant);
+ new CertPathConstraintsParameters(x509Cert, variant,
+ anchor, date);
// Check against local constraints if it is DisabledAlgorithmConstraints
if (constraints instanceof DisabledAlgorithmConstraints) {
- ((DisabledAlgorithmConstraints)constraints).permits(currSigAlg, cp);
+ ((DisabledAlgorithmConstraints)constraints).permits(currSigAlg,
+ currSigAlgParams, cp);
// DisabledAlgorithmsConstraints does not check primitives, so key
// additional key check.
} else {
// Perform the default constraints checking anyway.
- certPathDefaultConstraints.permits(currSigAlg, cp);
+ certPathDefaultConstraints.permits(currSigAlg, currSigAlgParams, cp);
// Call locally set constraints to check key with primitives.
if (!constraints.permits(primitives, currPubKey)) {
throw new CertPathValidatorException(
@@ -408,14 +368,10 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
// Don't bother to change the trustedPubKey.
if (anchor.getTrustedCert() != null) {
prevPubKey = anchor.getTrustedCert().getPublicKey();
- // Check for anchor certificate restrictions
- trustedMatch = checkFingerprint(anchor.getTrustedCert());
- if (trustedMatch && debug != null) {
- debug.println("trustedMatch = true");
- }
} else {
prevPubKey = anchor.getCAPublicKey();
}
+ this.anchor = anchor;
}
}
@@ -424,11 +380,12 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
*
* @param key the public key to verify the CRL signature
* @param crl the target CRL
- * @param variant is the Validator variants of the operation. A null value
+ * @param variant the Validator variant of the operation. A null value
* passed will set it to Validator.GENERIC.
+ * @param anchor the trust anchor selected to validate the CRL issuer
*/
- static void check(PublicKey key, X509CRL crl, String variant)
- throws CertPathValidatorException {
+ static void check(PublicKey key, X509CRL crl, String variant,
+ TrustAnchor anchor) throws CertPathValidatorException {
X509CRLImpl x509CRLImpl = null;
try {
@@ -438,7 +395,7 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
}
AlgorithmId algorithmId = x509CRLImpl.getSigAlgId();
- check(key, algorithmId, variant);
+ check(key, algorithmId, variant, anchor);
}
/**
@@ -446,16 +403,16 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
*
* @param key the public key to verify the CRL signature
* @param algorithmId signature algorithm Algorithm ID
- * @param variant is the Validator variants of the operation. A null value
- * passed will set it to Validator.GENERIC.
+ * @param variant the Validator variant of the operation. A null
+ * value passed will set it to Validator.GENERIC.
+ * @param anchor the trust anchor selected to validate the public key
*/
- static void check(PublicKey key, AlgorithmId algorithmId, String variant)
- throws CertPathValidatorException {
- String sigAlgName = algorithmId.getName();
- AlgorithmParameters sigAlgParams = algorithmId.getParameters();
+ static void check(PublicKey key, AlgorithmId algorithmId, String variant,
+ TrustAnchor anchor) throws CertPathValidatorException {
- certPathDefaultConstraints.permits(new ConstraintsParameters(
- sigAlgName, sigAlgParams, key, variant));
+ certPathDefaultConstraints.permits(algorithmId.getName(),
+ algorithmId.getParameters(),
+ new CertPathConstraintsParameters(key, variant, anchor));
}
}
diff --git a/src/java.base/share/classes/sun/security/provider/certpath/CertPathConstraintsParameters.java b/src/java.base/share/classes/sun/security/provider/certpath/CertPathConstraintsParameters.java
new file mode 100644
index 00000000000..597c1f7935c
--- /dev/null
+++ b/src/java.base/share/classes/sun/security/provider/certpath/CertPathConstraintsParameters.java
@@ -0,0 +1,125 @@
+/*
+ * 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.
+ */
+
+package sun.security.provider.certpath;
+
+import java.security.Key;
+import java.security.cert.TrustAnchor;
+import java.security.cert.X509Certificate;
+import java.util.Date;
+import java.util.Set;
+
+import sun.security.util.ConstraintsParameters;
+import sun.security.validator.Validator;
+
+/**
+ * This class contains parameters for checking certificates against
+ * constraints specified in the jdk.certpath.disabledAlgorithms security
+ * property.
+ */
+class CertPathConstraintsParameters implements ConstraintsParameters {
+ // The public key of the certificate
+ private final Key key;
+ // The certificate's trust anchor which will be checked against the
+ // jdkCA constraint, if specified.
+ private final TrustAnchor anchor;
+ // The PKIXParameter validity date or the timestamp of the signed JAR
+ // file, if this chain is associated with a timestamped signed JAR.
+ private final Date date;
+ // The variant or usage of this certificate
+ private final String variant;
+ // The certificate being checked (may be null if a CRL or OCSPResponse is
+ // being checked)
+ private final X509Certificate cert;
+
+ public CertPathConstraintsParameters(X509Certificate cert,
+ String variant, TrustAnchor anchor, Date date) {
+ this(cert.getPublicKey(), variant, anchor, date, cert);
+ }
+
+ public CertPathConstraintsParameters(Key key, String variant,
+ TrustAnchor anchor) {
+ this(key, variant, anchor, null, null);
+ }
+
+ private CertPathConstraintsParameters(Key key, String variant,
+ TrustAnchor anchor, Date date, X509Certificate cert) {
+ this.key = key;
+ this.variant = (variant == null ? Validator.VAR_GENERIC : variant);
+ this.anchor = anchor;
+ this.date = date;
+ this.cert = cert;
+ }
+
+ @Override
+ public boolean anchorIsJdkCA() {
+ return CertPathHelper.isJdkCA(anchor);
+ }
+
+ @Override
+ public Set<Key> getKeys() {
+ return (key == null) ? Set.of() : Set.of(key);
+ }
+
+ @Override
+ public Date getDate() {
+ return date;
+ }
+
+ @Override
+ public String getVariant() {
+ return variant;
+ }
+
+ @Override
+ public String extendedExceptionMsg() {
+ return (cert == null ? "."
+ : " used with certificate: " +
+ cert.getSubjectX500Principal());
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("[\n");
+ sb.append("\n Variant: ").append(variant);
+ if (anchor != null) {
+ sb.append("\n Anchor: ").append(anchor);
+ }
+ if (cert != null) {
+ sb.append("\n Cert Issuer: ")
+ .append(cert.getIssuerX500Principal());
+ sb.append("\n Cert Subject: ")
+ .append(cert.getSubjectX500Principal());
+ }
+ if (key != null) {
+ sb.append("\n Key: ").append(key.getAlgorithm());
+ }
+ if (date != null) {
+ sb.append("\n Date: ").append(date);
+ }
+ sb.append("\n]");
+ return sb.toString();
+ }
+}
diff --git a/src/java.base/share/classes/sun/security/provider/certpath/CertPathHelper.java b/src/java.base/share/classes/sun/security/provider/certpath/CertPathHelper.java
index af6da8a2686..7c02007422d 100644
--- a/src/java.base/share/classes/sun/security/provider/certpath/CertPathHelper.java
+++ b/src/java.base/share/classes/sun/security/provider/certpath/CertPathHelper.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -28,13 +28,14 @@ package sun.security.provider.certpath;
import java.util.Date;
import java.util.Set;
+import java.security.cert.TrustAnchor;
import java.security.cert.X509CertSelector;
import java.security.cert.X509CRLSelector;
import sun.security.x509.GeneralNameInterface;
/**
- * Helper class that allows access to Sun specific known-public methods in the
+ * Helper class that allows access to JDK specific known-public methods in the
* java.security.cert package. It relies on a subclass in the
* java.security.cert packages that is initialized before any of these methods
* are called (achieved via static initializers).
@@ -59,6 +60,8 @@ public abstract class CertPathHelper {
protected abstract void implSetDateAndTime(X509CRLSelector sel, Date date, long skew);
+ protected abstract boolean implIsJdkCA(TrustAnchor anchor);
+
static void setPathToNames(X509CertSelector sel,
Set<GeneralNameInterface> names) {
instance.implSetPathToNames(sel, names);
@@ -67,4 +70,8 @@ public abstract class CertPathHelper {
public static void setDateAndTime(X509CRLSelector sel, Date date, long skew) {
instance.implSetDateAndTime(sel, date, skew);
}
+
+ public static boolean isJdkCA(TrustAnchor anchor) {
+ return (anchor == null) ? false : instance.implIsJdkCA(anchor);
+ }
}
diff --git a/src/java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java b/src/java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java
index ee8b5c74ae9..afdeca8f6d4 100644
--- a/src/java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java
+++ b/src/java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java
@@ -74,7 +74,7 @@ public class DistributionPointFetcher {
throws CertStoreException
{
return getCRLs(selector, signFlag, prevKey, null, provider, certStores,
- reasonsMask, trustAnchors, validity, variant);
+ reasonsMask, trustAnchors, validity, variant, null);
}
/**
* Return the X509CRLs matching this selector. The selector must be
@@ -91,8 +91,14 @@ public class DistributionPointFetcher {
Date validity)
throws CertStoreException
{
+ if (trustAnchors.isEmpty()) {
+ throw new CertStoreException(
+ "at least one TrustAnchor must be specified");
+ }
+ TrustAnchor anchor = trustAnchors.iterator().next();
return getCRLs(selector, signFlag, prevKey, null, provider, certStores,
- reasonsMask, trustAnchors, validity, Validator.VAR_GENERIC);
+ reasonsMask, trustAnchors, validity,
+ Validator.VAR_PLUGIN_CODE_SIGNING, anchor);
}
/**
@@ -108,7 +114,8 @@ public class DistributionPointFetcher {
boolean[] reasonsMask,
Set<TrustAnchor> trustAnchors,
Date validity,
- String variant)
+ String variant,
+ TrustAnchor anchor)
throws CertStoreException
{
X509Certificate cert = selector.getCertificateChecking();
@@ -137,7 +144,7 @@ public class DistributionPointFetcher {
DistributionPoint point = t.next();
Collection<X509CRL> crls = getCRLs(selector, certImpl,
point, reasonsMask, signFlag, prevKey, prevCert, provider,
- certStores, trustAnchors, validity, variant);
+ certStores, trustAnchors, validity, variant, anchor);
results.addAll(crls);
}
if (debug != null) {
@@ -162,7 +169,8 @@ public class DistributionPointFetcher {
X509CertImpl certImpl, DistributionPoint point, boolean[] reasonsMask,
boolean signFlag, PublicKey prevKey, X509Certificate prevCert,
String provider, List<CertStore> certStores,
- Set<TrustAnchor> trustAnchors, Date validity, String variant)
+ Set<TrustAnchor> trustAnchors, Date validity, String variant,
+ TrustAnchor anchor)
throws CertStoreException {
// check for full name
@@ -225,7 +233,7 @@ public class DistributionPointFetcher {
selector.setIssuerNames(null);
if (selector.match(crl) && verifyCRL(certImpl, point, crl,
reasonsMask, signFlag, prevKey, prevCert, provider,
- trustAnchors, certStores, validity, variant)) {
+ trustAnchors, certStores, validity, variant, anchor)) {
crls.add(crl);
}
} catch (IOException | CRLException e) {
@@ -335,7 +343,8 @@ public class DistributionPointFetcher {
X509CRL crl, boolean[] reasonsMask, boolean signFlag,
PublicKey prevKey, X509Certificate prevCert, String provider,
Set<TrustAnchor> trustAnchors, List<CertStore> certStores,
- Date validity, String variant) throws CRLException, IOException {
+ Date validity, String variant, TrustAnchor anchor)
+ throws CRLException, IOException {
if (debug != null) {
debug.println("DistributionPointFetcher.verifyCRL: " +
@@ -682,7 +691,7 @@ public class DistributionPointFetcher {
// check the crl signature algorithm
try {
- AlgorithmChecker.check(prevKey, crl, variant);
+ AlgorithmChecker.check(prevKey, crl, variant, anchor);
} catch (CertPathValidatorException cpve) {
if (debug != null) {
debug.println("CRL signature algorithm check failed: " + cpve);
diff --git a/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java b/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java
index 51f49b9d377..6d5f2c7bf82 100644
--- a/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java
+++ b/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java
@@ -123,7 +123,8 @@ public final class OCSP {
throws IOException, CertPathValidatorException
{
return check(cert, issuerCert, responderURI, responderCert, date,
- Collections.<Extension>emptyList(), Validator.VAR_GENERIC);
+ Collections.<Extension>emptyList(),
+ Validator.VAR_PLUGIN_CODE_SIGNING);
}
diff --git a/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java b/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java
index a431dd98bf9..8134e2592dd 100644
--- a/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java
+++ b/src/java.base/share/classes/sun/security/provider/certpath/OCSPResponse.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2021, 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
@@ -462,6 +462,7 @@ public final class OCSPResponse {
}
// Check whether the signer cert returned by the responder is trusted
+ boolean signedByTrustedResponder = false;
if (signerCert != null) {
// Check if the response is signed by the issuing CA
if (signerCert.getSubjectX500Principal().equals(
@@ -476,6 +477,7 @@ public final class OCSPResponse {
// Check if the response is signed by a trusted responder
} else if (signerCert.equals(responderCert)) {
+ signedByTrustedResponder = true;
if (debug != null) {
debug.println("OCSP response is signed by a Trusted " +
"Responder");
@@ -566,7 +568,10 @@ public final class OCSPResponse {
if (signerCert != null) {
// Check algorithm constraints specified in security property
// "jdk.certpath.disabledAlgorithms".
- AlgorithmChecker.check(signerCert.getPublicKey(), sigAlgId, variant);
+ AlgorithmChecker.check(signerCert.getPublicKey(), sigAlgId, variant,
+ signedByTrustedResponder
+ ? new TrustAnchor(responderCert, null)
+ : issuerInfo.getAnchor());
if (!verifySignature(signerCert)) {
throw new CertPathValidatorException(
diff --git a/src/java.base/share/classes/sun/security/provider/certpath/PKIX.java b/src/java.base/share/classes/sun/security/provider/certpath/PKIX.java
index 36e2e722a8b..26ab6592a16 100644
--- a/src/java.base/share/classes/sun/security/provider/certpath/PKIX.java
+++ b/src/java.base/share/classes/sun/security/provider/certpath/PKIX.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
@@ -33,6 +33,7 @@ import java.util.*;
import javax.security.auth.x500.X500Principal;
import sun.security.util.Debug;
+import sun.security.validator.Validator;
/**
* Common utility methods and classes used by the PKIX CertPathValidator and
@@ -87,7 +88,7 @@ class PKIX {
private Set<TrustAnchor> anchors;
private List<X509Certificate> certs;
private Timestamp timestamp;
- private String variant;
+ private String variant = Validator.VAR_GENERIC;
ValidatorParams(CertPath cp, PKIXParameters params)
throws InvalidAlgorithmParameterException
@@ -155,9 +156,17 @@ class PKIX {
}
Date date() {
if (!gotDate) {
- date = params.getDate();
- if (date == null)
- date = new Date();
+ // use timestamp if checking signed code that is
+ // timestamped, otherwise use date parameter
+ if (timestamp != null &&
+ (variant.equals(Validator.VAR_CODE_SIGNING) ||
+ variant.equals(Validator.VAR_PLUGIN_CODE_SIGNING))) {
+ date = timestamp.getTimestamp();
+ } else {
+ date = params.getDate();
+ if (date == null)
+ date = new Date();
+ }
gotDate = true;
}
return date;
@@ -198,10 +207,6 @@ class PKIX {
return params;
}
- Timestamp timestamp() {
- return timestamp;
- }
-
String variant() {
return variant;
}
diff --git a/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java b/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java
index 49cf2646f2e..fdacbf716df 100644
--- a/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java
+++ b/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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,6 @@ import java.util.concurrent.atomic.AtomicLong;
import jdk.internal.event.X509ValidationEvent;
import jdk.internal.event.EventHelper;
import sun.security.provider.certpath.PKIX.ValidatorParams;
-import sun.security.validator.Validator;
import sun.security.x509.X509CertImpl;
import sun.security.util.Debug;
@@ -178,7 +177,7 @@ public final class PKIXCertPathValidator extends CertPathValidatorSpi {
// add standard checkers that we will be using
certPathCheckers.add(untrustedChecker);
certPathCheckers.add(new AlgorithmChecker(anchor, null, params.date(),
- params.timestamp(), params.variant()));
+ params.variant()));
certPathCheckers.add(new KeyChecker(certPathLen,
params.targetCertConstraints()));
certPathCheckers.add(new ConstraintsChecker(certPathLen));
@@ -195,19 +194,7 @@ public final class PKIXCertPathValidator extends CertPathValidatorSpi {
rootNode);
certPathCheckers.add(pc);
- // the time that the certificate validity period should be
- // checked against
- Date timeToCheck = null;
- // use timestamp if checking signed code that is timestamped, otherwise
- // use date parameter from PKIXParameters
- if ((params.variant() == Validator.VAR_CODE_SIGNING ||
- params.variant() == Validator.VAR_PLUGIN_CODE_SIGNING) &&
- params.timestamp() != null) {
- timeToCheck = params.timestamp().getTimestamp();
- } else {
- timeToCheck = params.date();
- }
- BasicChecker bc = new BasicChecker(anchor, timeToCheck,
+ BasicChecker bc = new BasicChecker(anchor, params.date(),
params.sigProvider(), false);
certPathCheckers.add(bc);
diff --git a/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java b/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java
index b4e4388f17a..32e962c3dbd 100644
--- a/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java
+++ b/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java
@@ -585,7 +585,8 @@ class RevocationChecker extends PKIXRevocationChecker {
approvedCRLs.addAll(DistributionPointFetcher.getCRLs(
sel, signFlag, prevKey, prevCert,
params.sigProvider(), certStores,
- reasonsMask, anchors, null, params.variant()));
+ reasonsMask, anchors, null,
+ params.variant(), anchor));
}
} catch (CertStoreException e) {
if (e instanceof CertStoreTypeException) {
@@ -893,7 +894,7 @@ class RevocationChecker extends PKIXRevocationChecker {
if (DistributionPointFetcher.verifyCRL(
certImpl, point, crl, reasonsMask, signFlag,
prevKey, null, params.sigProvider(), anchors,
- certStores, params.date(), params.variant()))
+ certStores, params.date(), params.variant(), anchor))
{
results.add(crl);
}
diff --git a/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java b/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java
index 375fc1c2bfb..0f11956ed37 100644
--- a/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java
+++ b/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java
@@ -1558,7 +1558,7 @@ final class AbstractTrustManagerWrapper extends X509ExtendedTrustManager
// A forward checker, need to check from trust to target
if (checkedLength >= 0) {
AlgorithmChecker checker =
- new AlgorithmChecker(constraints, null,
+ new AlgorithmChecker(constraints,
(checkClientTrusted ? Validator.VAR_TLS_CLIENT :
Validator.VAR_TLS_SERVER));
checker.init(false);
diff --git a/src/java.base/share/classes/sun/security/ssl/X509KeyManagerImpl.java b/src/java.base/share/classes/sun/security/ssl/X509KeyManagerImpl.java
index 269efd31208..c5bc2052125 100644
--- a/src/java.base/share/classes/sun/security/ssl/X509KeyManagerImpl.java
+++ b/src/java.base/share/classes/sun/security/ssl/X509KeyManagerImpl.java
@@ -838,8 +838,7 @@ final class X509KeyManagerImpl extends X509ExtendedKeyManager
AlgorithmConstraints constraints, Certificate[] chain,
String variant) {
- AlgorithmChecker checker =
- new AlgorithmChecker(constraints, null, variant);
+ AlgorithmChecker checker = new AlgorithmChecker(constraints, variant);
try {
checker.init(false);
} catch (CertPathValidatorException cpve) {
diff --git a/src/java.base/share/classes/sun/security/util/AnchorCertificates.java b/src/java.base/share/classes/sun/security/util/AnchorCertificates.java
index 2cb7b7e81a3..7187a8bf9b5 100644
--- a/src/java.base/share/classes/sun/security/util/AnchorCertificates.java
+++ b/src/java.base/share/classes/sun/security/util/AnchorCertificates.java
@@ -36,6 +36,7 @@ import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
+import javax.security.auth.x500.X500Principal;
import sun.security.x509.X509CertImpl;
/**
@@ -47,9 +48,10 @@ public class AnchorCertificates {
private static final Debug debug = Debug.getInstance("certpath");
private static final String HASH = "SHA-256";
private static Set<String> certs = Collections.emptySet();
+ private static Set<X500Principal> certIssuers = Collections.emptySet();
static {
- AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public Void run() {
File f = new File(FilePaths.cacerts());
@@ -59,15 +61,16 @@ public class AnchorCertificates {
try (FileInputStream fis = new FileInputStream(f)) {
cacerts.load(fis, null);
certs = new HashSet<>();
+ certIssuers = new HashSet<>();
Enumeration<String> list = cacerts.aliases();
- String alias;
while (list.hasMoreElements()) {
- alias = list.nextElement();
+ String alias = list.nextElement();
// Check if this cert is labeled a trust anchor.
if (alias.contains(" [jdk")) {
X509Certificate cert = (X509Certificate) cacerts
.getCertificate(alias);
certs.add(X509CertImpl.getFingerprint(HASH, cert));
+ certIssuers.add(cert.getSubjectX500Principal());
}
}
}
@@ -83,10 +86,10 @@ public class AnchorCertificates {
}
/**
- * Checks if a certificate is a trust anchor.
+ * Checks if a certificate is a JDK trust anchor.
*
* @param cert the certificate to check
- * @return true if the certificate is trusted.
+ * @return true if the certificate is a JDK trust anchor
*/
public static boolean contains(X509Certificate cert) {
String key = X509CertImpl.getFingerprint(HASH, cert);
@@ -98,5 +101,15 @@ public class AnchorCertificates {
return result;
}
+ /**
+ * Checks if a JDK trust anchor is the issuer of a certificate.
+ *
+ * @param cert the certificate to check
+ * @return true if the certificate is issued by a trust anchor
+ */
+ public static boolean issuerOf(X509Certificate cert) {
+ return certIssuers.contains(cert.getIssuerX500Principal());
+ }
+
private AnchorCertificates() {}
}
diff --git a/src/java.base/share/classes/sun/security/util/ConstraintsParameters.java b/src/java.base/share/classes/sun/security/util/ConstraintsParameters.java
index 1d13ed1841a..82ce9c97af2 100644
--- a/src/java.base/share/classes/sun/security/util/ConstraintsParameters.java
+++ b/src/java.base/share/classes/sun/security/util/ConstraintsParameters.java
@@ -25,167 +25,42 @@
package sun.security.util;
-import sun.security.validator.Validator;
-
-import java.security.AlgorithmParameters;
import java.security.Key;
-import java.security.Timestamp;
-import java.security.cert.X509Certificate;
-import java.security.interfaces.ECKey;
-import java.security.interfaces.XECKey;
-import java.security.spec.NamedParameterSpec;
import java.util.Date;
+import java.util.Set;
/**
- * This class contains parameters for checking against constraints that extend
- * past the publicly available parameters in java.security.AlgorithmConstraints.
- *
- * This is currently passed between PKIX, AlgorithmChecker,
- * and DisabledAlgorithmConstraints.
+ * This interface contains parameters for checking against constraints that
+ * extend past the publicly available parameters in
+ * java.security.AlgorithmConstraints.
*/
-public class ConstraintsParameters {
- /*
- * The below 3 values are used the same as the permit() methods
- * published in java.security.AlgorithmConstraints.
- */
- // Algorithm string to be checked against constraints
- private final String algorithm;
- // AlgorithmParameters to the algorithm being checked
- private final AlgorithmParameters algParams;
- // Key being checked against constraints
- private final Key key;
+public interface ConstraintsParameters {
- /*
- * New values that are checked against constraints that the current public
- * API does not support.
+ /**
+ * Returns true if a certificate chains back to a trusted JDK root CA.
*/
- // A certificate being passed to check against constraints.
- private final X509Certificate cert;
- // This is true if the trust anchor in the certificate chain matches a cert
- // in AnchorCertificates
- private final boolean trustedMatch;
- // PKIXParameter date
- private final Date pkixDate;
- // Timestamp of the signed JAR file
- private final Timestamp jarTimestamp;
- private final String variant;
- // Named Curve
- private final String[] curveStr;
- private static final String[] EMPTYLIST = new String[0];
-
- public ConstraintsParameters(X509Certificate c, boolean match,
- Date pkixdate, Timestamp jarTime, String variant) {
- cert = c;
- trustedMatch = match;
- pkixDate = pkixdate;
- jarTimestamp = jarTime;
- this.variant = (variant == null ? Validator.VAR_GENERIC : variant);
- algorithm = null;
- algParams = null;
- key = null;
- if (c != null) {
- curveStr = getNamedCurveFromKey(c.getPublicKey());
- } else {
- curveStr = EMPTYLIST;
- }
- }
-
- public ConstraintsParameters(String algorithm, AlgorithmParameters params,
- Key key, String variant) {
- this.algorithm = algorithm;
- algParams = params;
- this.key = key;
- curveStr = getNamedCurveFromKey(key);
- cert = null;
- trustedMatch = false;
- pkixDate = null;
- jarTimestamp = null;
- this.variant = (variant == null ? Validator.VAR_GENERIC : variant);
- }
-
-
- public ConstraintsParameters(X509Certificate c) {
- this(c, false, null, null,
- Validator.VAR_GENERIC);
- }
-
- public ConstraintsParameters(Timestamp jarTime) {
- this(null, false, null, jarTime, Validator.VAR_GENERIC);
- }
-
- public String getAlgorithm() {
- return algorithm;
- }
-
- public AlgorithmParameters getAlgParams() {
- return algParams;
- }
+ boolean anchorIsJdkCA();
- public Key getKey() {
- return key;
- }
-
- // Returns if the trust anchor has a match if anchor checking is enabled.
- public boolean isTrustedMatch() {
- return trustedMatch;
- }
-
- public X509Certificate getCertificate() {
- return cert;
- }
-
- public Date getPKIXParamDate() {
- return pkixDate;
- }
-
- public Timestamp getJARTimestamp() {
- return jarTimestamp;
- }
-
- public String getVariant() {
- return variant;
- }
-
- public String[] getNamedCurve() {
- return curveStr;
- }
+ /**
+ * Returns the set of keys that should be checked against the
+ * constraints, or an empty set if there are no keys to be checked.
+ */
+ Set<Key> getKeys();
- public static String[] getNamedCurveFromKey(Key key) {
- if (key instanceof ECKey) {
- NamedCurve nc = CurveDB.lookup(((ECKey)key).getParams());
- return (nc == null ? EMPTYLIST : nc.getNameAndAliases());
- } else if (key instanceof XECKey) {
- String[] s = {
- ((NamedParameterSpec)((XECKey)key).getParams()).getName()
- };
- return s;
- } else {
- return EMPTYLIST;
- }
- }
+ /**
+ * Returns the date that should be checked against the constraints, or
+ * null if not set.
+ */
+ Date getDate();
- public String toString() {
- StringBuilder s = new StringBuilder();
- s.append("Cert: ");
- if (cert != null) {
- s.append(cert.toString());
- s.append("\nSigAlgo: ");
- s.append(cert.getSigAlgName());
- } else {
- s.append("None");
- }
- s.append("\nAlgParams: ");
- if (getAlgParams() != null) {
- getAlgParams().toString();
- } else {
- s.append("None");
- }
- s.append("\nNamedCurves: ");
- for (String c : getNamedCurve()) {
- s.append(c + " ");
- }
- s.append("\nVariant: " + getVariant());
- return s.toString();
- }
+ /**
+ * Returns the Validator variant.
+ */
+ String getVariant();
+ /**
+ * Returns an extended message used in exceptions. See
+ * DisabledAlgorithmConstraints for usage.
+ */
+ String extendedExceptionMsg();
}
diff --git a/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java b/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
index 83a2fcc44ed..13a4dcf4e6e 100644
--- a/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
+++ b/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
@@ -27,12 +27,18 @@ package sun.security.util;
import sun.security.validator.Validator;
-import java.security.CryptoPrimitive;
import java.security.AlgorithmParameters;
+import java.security.CryptoPrimitive;
import java.security.Key;
import java.security.cert.CertPathValidatorException;
import java.security.cert.CertPathValidatorException.BasicReason;
-import java.security.cert.X509Certificate;
+import java.security.interfaces.ECKey;
+import java.security.interfaces.XECKey;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.InvalidParameterSpecException;
+import java.security.spec.MGF1ParameterSpec;
+import java.security.spec.NamedParameterSpec;
+import java.security.spec.PSSParameterSpec;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
@@ -79,9 +85,27 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
private static final String PROPERTY_DISABLED_EC_CURVES =
"jdk.disabled.namedCurves";
+ private static class CertPathHolder {
+ static final DisabledAlgorithmConstraints CONSTRAINTS =
+ new DisabledAlgorithmConstraints(PROPERTY_CERTPATH_DISABLED_ALGS);
+ }
+
+ private static class JarHolder {
+ static final DisabledAlgorithmConstraints CONSTRAINTS =
+ new DisabledAlgorithmConstraints(PROPERTY_JAR_DISABLED_ALGS);
+ }
+
private final List<String> disabledAlgorithms;
private final Constraints algorithmConstraints;
+ public static DisabledAlgorithmConstraints certPathConstraints() {
+ return CertPathHolder.CONSTRAINTS;
+ }
+
+ public static DisabledAlgorithmConstraints jarConstraints() {
+ return JarHolder.CONSTRAINTS;
+ }
+
/**
* Initialize algorithm constraints with the specified security property.
*
@@ -122,7 +146,7 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
disabledAlgorithms.addAll(ecindex,
getAlgorithms(PROPERTY_DISABLED_EC_CURVES));
}
- algorithmConstraints = new Constraints(disabledAlgorithms);
+ algorithmConstraints = new Constraints(propertyName, disabledAlgorithms);
}
/*
@@ -172,32 +196,54 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
return checkConstraints(primitives, algorithm, key, parameters);
}
- public final void permits(ConstraintsParameters cp)
- throws CertPathValidatorException {
- permits(cp.getAlgorithm(), cp);
+ public final void permits(String algorithm, AlgorithmParameters ap,
+ ConstraintsParameters cp) throws CertPathValidatorException {
+
+ permits(algorithm, cp);
+ if (ap != null) {
+ permits(ap, cp);
+ }
}
- public final void permits(String algorithm, Key key,
- AlgorithmParameters params, String variant)
- throws CertPathValidatorException {
- permits(algorithm, new ConstraintsParameters(algorithm, params, key,
- (variant == null) ? Validator.VAR_GENERIC : variant));
+ private void permits(AlgorithmParameters ap, ConstraintsParameters cp)
+ throws CertPathValidatorException {
+
+ switch (ap.getAlgorithm().toUpperCase(Locale.ENGLISH)) {
+ case "RSASSA-PSS":
+ permitsPSSParams(ap, cp);
+ break;
+ default:
+ // unknown algorithm, just ignore
+ }
}
- /*
- * Check if a x509Certificate object is permitted. Check if all
- * algorithms are allowed, certificate constraints, and the
- * public key against key constraints.
- *
- * Uses new style permit() which throws exceptions.
- */
+ private void permitsPSSParams(AlgorithmParameters ap,
+ ConstraintsParameters cp) throws CertPathValidatorException {
+
+ try {
+ PSSParameterSpec pssParams =
+ ap.getParameterSpec(PSSParameterSpec.class);
+ String digestAlg = pssParams.getDigestAlgorithm();
+ permits(digestAlg, cp);
+ AlgorithmParameterSpec mgfParams = pssParams.getMGFParameters();
+ if (mgfParams instanceof MGF1ParameterSpec) {
+ String mgfDigestAlg =
+ ((MGF1ParameterSpec)mgfParams).getDigestAlgorithm();
+ if (!mgfDigestAlg.equalsIgnoreCase(digestAlg)) {
+ permits(mgfDigestAlg, cp);
+ }
+ }
+ } catch (InvalidParameterSpecException ipse) {
+ // ignore
+ }
+ }
public final void permits(String algorithm, ConstraintsParameters cp)
throws CertPathValidatorException {
- // Check if named curves in the ConstraintParameters are disabled.
- if (cp.getNamedCurve() != null) {
- for (String curve : cp.getNamedCurve()) {
+ // Check if named curves in the key are disabled.
+ for (Key key : cp.getKeys()) {
+ for (String curve : getNamedCurveFromKey(key)) {
if (!checkAlgorithm(disabledAlgorithms, curve, decomposer)) {
throw new CertPathValidatorException(
"Algorithm constraints check failed on disabled " +
@@ -210,15 +256,17 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
algorithmConstraints.permits(algorithm, cp);
}
- // Check if a string is contained inside the property
- public boolean checkProperty(String param) {
- param = param.toLowerCase(Locale.ENGLISH);
- for (String block : disabledAlgorithms) {
- if (block.toLowerCase(Locale.ENGLISH).indexOf(param) >= 0) {
- return true;
- }
+ private static List<String> getNamedCurveFromKey(Key key) {
+ if (key instanceof ECKey) {
+ NamedCurve nc = CurveDB.lookup(((ECKey)key).getParams());
+ return (nc == null ? List.of()
+ : Arrays.asList(nc.getNameAndAliases()));
+ } else if (key instanceof XECKey) {
+ return List.of(
+ ((NamedParameterSpec)((XECKey)key).getParams()).getName());
+ } else {
+ return List.of();
}
- return false;
}
// Check algorithm constraints with key and algorithm
@@ -246,8 +294,8 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
return false;
}
- // If this is an elliptic curve, check disabled the named curve.
- for (String curve : ConstraintsParameters.getNamedCurveFromKey(key)) {
+ // If this is an elliptic curve, check if it is disabled
+ for (String curve : getNamedCurveFromKey(key)) {
if (!permits(primitives, curve, null)) {
return false;
}
@@ -284,7 +332,7 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
"denyAfter\\s+(\\d{4})-(\\d{2})-(\\d{2})");
}
- public Constraints(List<String> constraintArray) {
+ public Constraints(String propertyName, List<String> constraintArray) {
for (String constraintEntry : constraintArray) {
if (constraintEntry == null || constraintEntry.isEmpty()) {
continue;
@@ -399,7 +447,7 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
}
}
- // Get applicable constraints based off the signature algorithm
+ // Get applicable constraints based off the algorithm
private List<Constraint> getConstraints(String algorithm) {
return constraintsMap.get(algorithm.toUpperCase(Locale.ENGLISH));
}
@@ -443,13 +491,12 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
return true;
}
- // Check if constraints permit this cert.
public void permits(String algorithm, ConstraintsParameters cp)
throws CertPathValidatorException {
- X509Certificate cert = cp.getCertificate();
if (debug != null) {
- debug.println("Constraints.permits(): " + cp.toString());
+ debug.println("Constraints.permits(): " + algorithm + ", "
+ + cp.toString());
}
// Get all signature algorithms to check for constraints
@@ -459,13 +506,10 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
algorithms.add(algorithm);
}
- // Attempt to add the public key algorithm if cert provided
- if (cert != null) {
- algorithms.add(cert.getPublicKey().getAlgorithm());
- }
- if (cp.getKey() != null) {
- algorithms.add(cp.getKey().getAlgorithm());
+ for (Key key : cp.getKeys()) {
+ algorithms.add(key.getAlgorithm());
}
+
// Check all applicable constraints
for (String alg : algorithms) {
List<Constraint> list = getConstraints(alg);
@@ -556,7 +600,7 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
* {@code next()} with the same {@code ConstraintsParameters}
* parameter passed if multiple constraints need to be checked.
*
- * @param cp CertConstraintParameter containing certificate info
+ * @param cp ConstraintsParameter containing certificate info
* @throws CertPathValidatorException if constraint disallows.
*
*/
@@ -605,14 +649,6 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
boolean next(Key key) {
return nextConstraint != null && nextConstraint.permits(key);
}
-
- String extendedMsg(ConstraintsParameters cp) {
- return (cp.getCertificate() == null ? "." :
- " used with certificate: " +
- cp.getCertificate().getSubjectX500Principal() +
- (cp.getVariant() != Validator.VAR_GENERIC ?
- ". Usage was " + cp.getVariant() : "."));
- }
}
/*
@@ -636,14 +672,15 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
debug.println("jdkCAConstraints.permits(): " + algorithm);
}
- // Check chain has a trust anchor in cacerts
- if (cp.isTrustedMatch()) {
+ // Check if any certs chain back to at least one trust anchor in
+ // cacerts
+ if (cp.anchorIsJdkCA()) {
if (next(cp)) {
return;
}
throw new CertPathValidatorException(
"Algorithm constraints check failed on certificate " +
- "anchor limits. " + algorithm + extendedMsg(cp),
+ "anchor limits. " + algorithm + cp.extendedExceptionMsg(),
null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
}
}
@@ -708,15 +745,10 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
Date currentDate;
String errmsg;
- if (cp.getJARTimestamp() != null) {
- currentDate = cp.getJARTimestamp().getTimestamp();
- errmsg = "JAR Timestamp date: ";
- } else if (cp.getPKIXParamDate() != null) {
- currentDate = cp.getPKIXParamDate();
- errmsg = "PKIXParameter date: ";
+ if (cp.getDate() != null) {
+ currentDate = cp.getDate();
} else {
currentDate = new Date();
- errmsg = "Current date: ";
}
if (!denyAfterDate.after(currentDate)) {
@@ -726,8 +758,8 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
throw new CertPathValidatorException(
"denyAfter constraint check failed: " + algorithm +
" used with Constraint date: " +
- dateFormat.format(denyAfterDate) + "; " + errmsg +
- dateFormat.format(currentDate) + extendedMsg(cp),
+ dateFormat.format(denyAfterDate) + "; params date: " +
+ dateFormat.format(currentDate) + cp.extendedExceptionMsg(),
null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
}
}
@@ -764,19 +796,27 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
@Override
public void permits(ConstraintsParameters cp)
throws CertPathValidatorException {
+ String variant = cp.getVariant();
for (String usage : usages) {
- String v = null;
- if (usage.compareToIgnoreCase("TLSServer") == 0) {
- v = Validator.VAR_TLS_SERVER;
- } else if (usage.compareToIgnoreCase("TLSClient") == 0) {
- v = Validator.VAR_TLS_CLIENT;
- } else if (usage.compareToIgnoreCase("SignedJAR") == 0) {
- v = Validator.VAR_PLUGIN_CODE_SIGNING;
+ boolean match = false;
+ switch (usage.toLowerCase()) {
+ case "tlsserver":
+ match = variant.equals(Validator.VAR_TLS_SERVER);
+ break;
+ case "tlsclient":
+ match = variant.equals(Validator.VAR_TLS_CLIENT);
+ break;
+ case "signedjar":
+ match =
+ variant.equals(Validator.VAR_PLUGIN_CODE_SIGNING) ||
+ variant.equals(Validator.VAR_CODE_SIGNING) ||
+ variant.equals(Validator.VAR_TSA_SERVER);
+ break;
}
if (debug != null) {
- debug.println("Checking if usage constraint \"" + v +
+ debug.println("Checking if usage constraint \"" + usage +
"\" matches \"" + cp.getVariant() + "\"");
if (Debug.isVerbose()) {
// Because usage checking can come from many places
@@ -784,13 +824,13 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
(new Exception()).printStackTrace(debug.getPrintStream());
}
}
- if (cp.getVariant().compareTo(v) == 0) {
+ if (match) {
if (next(cp)) {
return;
}
throw new CertPathValidatorException("Usage constraint " +
usage + " check failed: " + algorithm +
- extendedMsg(cp),
+ cp.extendedExceptionMsg(),
null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
}
}
@@ -843,31 +883,25 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
}
/*
- * If we are passed a certificate, extract the public key and use it.
- *
- * Check if each constraint fails and check if there is a linked
- * constraint Any permitted constraint will exit the linked list
- * to allow the operation.
+ * For each key, check if each constraint fails and check if there is
+ * a linked constraint. Any permitted constraint will exit the linked
+ * list to allow the operation.
*/
@Override
public void permits(ConstraintsParameters cp)
throws CertPathValidatorException {
- Key key = null;
- if (cp.getKey() != null) {
- key = cp.getKey();
- } else if (cp.getCertificate() != null) {
- key = cp.getCertificate().getPublicKey();
- }
- if (key != null && !permitsImpl(key)) {
- if (nextConstraint != null) {
- nextConstraint.permits(cp);
- return;
- }
- throw new CertPathValidatorException(
- "Algorithm constraints check failed on keysize limits. " +
- algorithm + " " + KeyUtil.getKeySize(key) + "bit key" +
- extendedMsg(cp),
+ for (Key key : cp.getKeys()) {
+ if (!permitsImpl(key)) {
+ if (nextConstraint != null) {
+ nextConstraint.permits(cp);
+ continue;
+ }
+ throw new CertPathValidatorException(
+ "Algorithm constraints check failed on keysize limits: " +
+ algorithm + " " + KeyUtil.getKeySize(key) + " bit key" +
+ cp.extendedExceptionMsg(),
null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
+ }
}
}
@@ -944,7 +978,7 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
throws CertPathValidatorException {
throw new CertPathValidatorException(
"Algorithm constraints check failed on disabled " +
- "algorithm: " + algorithm + extendedMsg(cp),
+ "algorithm: " + algorithm + cp.extendedExceptionMsg(),
null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
}
diff --git a/src/java.base/share/classes/sun/security/util/JarConstraintsParameters.java b/src/java.base/share/classes/sun/security/util/JarConstraintsParameters.java
new file mode 100644
index 00000000000..81fe0eaa835
--- /dev/null
+++ b/src/java.base/share/classes/sun/security/util/JarConstraintsParameters.java
@@ -0,0 +1,188 @@
+/*
+ * 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.
+ */
+
+package sun.security.util;
+
+import java.security.CodeSigner;
+import java.security.Key;
+import java.security.Timestamp;
+import java.security.cert.CertPath;
+import java.security.cert.X509Certificate;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import sun.security.util.AnchorCertificates;
+import sun.security.util.ConstraintsParameters;
+import sun.security.validator.Validator;
+
+/**
+ * This class contains parameters for checking signed JARs against
+ * constraints specified in the jdk.jar.disabledAlgorithms security
+ * property.
+ */
+public class JarConstraintsParameters implements ConstraintsParameters {
+
+ // true if chain is anchored by a JDK root CA
+ private boolean anchorIsJdkCA;
+ private boolean anchorIsJdkCASet;
+ // The timestamp of the signed JAR file, if timestamped
+ private Date timestamp;
+ // The keys of the signers
+ private final Set<Key> keys;
+ // The certs in the signers' chains that are issued by the trust anchor
+ private final Set<X509Certificate> certsIssuedByAnchor;
+ // The extended exception message
+ private String message;
+
+ /**
+ * Create a JarConstraintsParameters.
+ *
+ * @param signers the CodeSigners that signed the JAR
+ */
+ public JarConstraintsParameters(CodeSigner[] signers) {
+ this.keys = new HashSet<>();
+ this.certsIssuedByAnchor = new HashSet<>();
+ Date latestTimestamp = null;
+ boolean skipTimestamp = false;
+
+ // Iterate over the signers and extract the keys, the latest
+ // timestamp, and the last certificate of each chain which can be
+ // used for checking if the signer's certificate chains back to a
+ // JDK root CA
+ for (CodeSigner signer : signers) {
+ init(signer.getSignerCertPath());
+ Timestamp timestamp = signer.getTimestamp();
+ if (timestamp == null) {
+ // this means one of the signers doesn't have a timestamp
+ // and the JAR should be treated as if it isn't timestamped
+ latestTimestamp = null;
+ skipTimestamp = true;
+ } else {
+ // add the key and last cert of TSA too
+ init(timestamp.getSignerCertPath());
+ if (!skipTimestamp) {
+ Date timestampDate = timestamp.getTimestamp();
+ if (latestTimestamp == null) {
+ latestTimestamp = timestampDate;
+ } else {
+ if (latestTimestamp.before(timestampDate)) {
+ latestTimestamp = timestampDate;
+ }
+ }
+ }
+ }
+ }
+ this.timestamp = latestTimestamp;
+ }
+
+ // extract last certificate and key from chain
+ private void init(CertPath cp) {
+ @SuppressWarnings("unchecked")
+ List<X509Certificate> chain =
+ (List<X509Certificate>)cp.getCertificates();
+ if (!chain.isEmpty()) {
+ this.certsIssuedByAnchor.add(chain.get(chain.size() - 1));
+ this.keys.add(chain.get(0).getPublicKey());
+ }
+ }
+
+ @Override
+ public String getVariant() {
+ return Validator.VAR_GENERIC;
+ }
+
+ /**
+ * Since loading the cacerts keystore can be an expensive operation,
+ * this is only performed if this method is called during a "jdkCA"
+ * constraints check of a disabled algorithm, and the result is cached.
+ *
+ * @return true if at least one of the certificates are issued by a
+ * JDK root CA
+ */
+ @Override
+ public boolean anchorIsJdkCA() {
+ if (anchorIsJdkCASet) {
+ return anchorIsJdkCA;
+ }
+ for (X509Certificate cert : certsIssuedByAnchor) {
+ if (AnchorCertificates.issuerOf(cert)) {
+ anchorIsJdkCA = true;
+ break;
+ }
+ }
+ anchorIsJdkCASet = true;
+ return anchorIsJdkCA;
+ }
+
+ @Override
+ public Date getDate() {
+ return timestamp;
+ }
+
+ @Override
+ public Set<Key> getKeys() {
+ return keys;
+ }
+
+ /**
+ * Sets the extended error message. Note: this should be used
+ * carefully as it is specific to the attribute/entry/file being checked.
+ *
+ * @param file the name of the signature related file being verified
+ * @param target the attribute containing the algorithm that is being
+ * checked
+ */
+ public void setExtendedExceptionMsg(String file, String target) {
+ message = " used" + (target != null ? " with " + target : "") +
+ " in " + file + " file.";
+ }
+
+ @Override
+ public String extendedExceptionMsg() {
+ return message;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("[\n");
+ sb.append("\n Variant: ").append(getVariant());
+ sb.append("\n Certs Issued by Anchor:");
+ for (X509Certificate cert : certsIssuedByAnchor) {
+ sb.append("\n Cert Issuer: ")
+ .append(cert.getIssuerX500Principal());
+ sb.append("\n Cert Subject: ")
+ .append(cert.getSubjectX500Principal());
+ }
+ for (Key key : keys) {
+ sb.append("\n Key: ").append(key.getAlgorithm());
+ }
+ if (timestamp != null) {
+ sb.append("\n Timestamp: ").append(timestamp);
+ }
+ sb.append("\n]");
+ return sb.toString();
+ }
+}
diff --git a/src/java.base/share/classes/sun/security/util/ManifestEntryVerifier.java b/src/java.base/share/classes/sun/security/util/ManifestEntryVerifier.java
index d5dd2b4beb6..062190aeddf 100644
--- a/src/java.base/share/classes/sun/security/util/ManifestEntryVerifier.java
+++ b/src/java.base/share/classes/sun/security/util/ManifestEntryVerifier.java
@@ -27,13 +27,12 @@ package sun.security.util;
import java.security.*;
import java.io.*;
-import java.security.CodeSigner;
import java.util.*;
import java.util.jar.*;
-import java.util.Base64;
-
import sun.security.jca.Providers;
+import sun.security.util.DisabledAlgorithmConstraints;
+import sun.security.util.JarConstraintsParameters;
/**
* This class is used to verify each entry in a jar file with its
@@ -202,12 +201,29 @@ public class ManifestEntryVerifier {
throw new SecurityException("digest missing for " + name);
}
- if (signers != null)
+ if (signers != null) {
return signers;
+ }
+
+ JarConstraintsParameters params =
+ getParams(verifiedSigners, sigFileSigners);
for (int i=0; i < digests.size(); i++) {
- MessageDigest digest = digests.get(i);
+ MessageDigest digest = digests.get(i);
+ if (params != null) {
+ try {
+ params.setExtendedExceptionMsg(JarFile.MANIFEST_NAME,
+ name + " entry");
+ DisabledAlgorithmConstraints.jarConstraints()
+ .permits(digest.getAlgorithm(), params);
+ } catch (GeneralSecurityException e) {
+ if (debug != null) {
+ debug.println("Digest algorithm is restricted: " + e);
+ }
+ return null;
+ }
+ }
byte [] manHash = manifestHashes.get(i);
byte [] theHash = digest.digest();
@@ -231,4 +247,37 @@ public class ManifestEntryVerifier {
}
return signers;
}
+
+ /**
+ * Get constraints parameters for JAR. The constraints should be
+ * checked against all code signers. Returns the parameters,
+ * or null if the signers for this entry have already been checked.
+ */
+ private JarConstraintsParameters getParams(
+ Map<String, CodeSigner[]> verifiedSigners,
+ Map<String, CodeSigner[]> sigFileSigners) {
+
+ // verifiedSigners is usually preloaded with the Manifest's signers.
+ // If verifiedSigners contains the Manifest, then it will have all of
+ // the signers of the JAR. But if it doesn't then we need to fallback
+ // and check verifiedSigners to see if the signers of this entry have
+ // been checked already.
+ if (verifiedSigners.containsKey(JarFile.MANIFEST_NAME)) {
+ if (verifiedSigners.size() > 1) {
+ // this means we already checked it previously
+ return null;
+ } else {
+ return new JarConstraintsParameters(
+ verifiedSigners.get(JarFile.MANIFEST_NAME));
+ }
+ } else {
+ CodeSigner[] signers = sigFileSigners.get(name);
+ if (verifiedSigners.containsValue(signers)) {
+ return null;
+ } else {
+ return new JarConstraintsParameters(signers);
+ }
+ }
+ }
}
+
diff --git a/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java b/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java
index af3d5877b5e..531a0c4c3e0 100644
--- a/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java
+++ b/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java
@@ -33,7 +33,6 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.SignatureException;
-import java.security.Timestamp;
import java.security.cert.CertPath;
import java.security.cert.X509Certificate;
import java.security.cert.CertificateException;
@@ -47,6 +46,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
import java.util.jar.Attributes;
import java.util.jar.JarException;
import java.util.jar.JarFile;
@@ -61,16 +61,6 @@ public class SignatureFileVerifier {
/* Are we debugging ? */
private static final Debug debug = Debug.getInstance("jar");
- /**
- * Holder class to delay initialization of DisabledAlgorithmConstraints
- * until needed.
- */
- private static class ConfigurationHolder {
- static final DisabledAlgorithmConstraints JAR_DISABLED_CHECK =
- new DisabledAlgorithmConstraints(
- DisabledAlgorithmConstraints.PROPERTY_JAR_DISABLED_ALGS);
- }
-
private ArrayList<CodeSigner[]> signerCache;
private static final String ATTR_DIGEST =
@@ -99,13 +89,13 @@ public class SignatureFileVerifier {
/* for generating certpath objects */
private CertificateFactory certificateFactory = null;
- /** Algorithms that have been checked if they are weak. */
- private Map<String, Boolean> permittedAlgs= new HashMap<>();
-
- /** TSA timestamp of signed jar. The newest timestamp is used. If there
- * was no TSA timestamp used when signed, current time is used ("null").
+ /** Algorithms that have been previously checked against disabled
+ * constraints.
*/
- private Timestamp timestamp = null;
+ private Map<String, Boolean> permittedAlgs = new HashMap<>();
+
+ /** ConstraintsParameters for checking disabled algorithms */
+ private JarConstraintsParameters params;
/**
* Create the named SignatureFileVerifier.
@@ -320,32 +310,23 @@ public class SignatureFileVerifier {
name);
}
-
CodeSigner[] newSigners = getSigners(infos, block);
// make sure we have something to do all this work for...
- if (newSigners == null)
+ if (newSigners == null) {
return;
+ }
- /*
- * Look for the latest timestamp in the signature block. If an entry
- * has no timestamp, use current time (aka null).
- */
- for (CodeSigner s: newSigners) {
- if (debug != null) {
- debug.println("Gathering timestamp for: " + s.toString());
- }
- if (s.getTimestamp() == null) {
- timestamp = null;
- break;
- } else if (timestamp == null) {
- timestamp = s.getTimestamp();
- } else {
- if (timestamp.getTimestamp().before(
- s.getTimestamp().getTimestamp())) {
- timestamp = s.getTimestamp();
- }
- }
+ // check if any of the algorithms used to verify the SignerInfos
+ // are disabled
+ params = new JarConstraintsParameters(newSigners);
+ Set<String> notDisabledAlgorithms =
+ SignerInfo.verifyAlgorithms(infos, params, name + " PKCS7");
+
+ // add the SignerInfo algorithms that are ok to the permittedAlgs map
+ // so they are not checked again
+ for (String algorithm : notDisabledAlgorithms) {
+ permittedAlgs.put(algorithm, Boolean.TRUE);
}
Iterator<Map.Entry<String,Attributes>> entries =
@@ -396,13 +377,14 @@ public class SignatureFileVerifier {
* store the result. If the algorithm is in the map use that result.
* False is returned for weak algorithm, true for good algorithms.
*/
- boolean permittedCheck(String key, String algorithm) {
+ private boolean permittedCheck(String key, String algorithm) {
Boolean permitted = permittedAlgs.get(algorithm);
if (permitted == null) {
try {
- ConfigurationHolder.JAR_DISABLED_CHECK.permits(algorithm,
- new ConstraintsParameters(timestamp));
- } catch(GeneralSecurityException e) {
+ params.setExtendedExceptionMsg(name + ".SF", key + " attribute");
+ DisabledAlgorithmConstraints
+ .jarConstraints().permits(algorithm, params);
+ } catch (GeneralSecurityException e) {
permittedAlgs.put(algorithm, Boolean.FALSE);
permittedAlgs.put(key.toUpperCase(), Boolean.FALSE);
if (debug != null) {
diff --git a/src/java.base/share/classes/sun/security/validator/PKIXValidator.java b/src/java.base/share/classes/sun/security/validator/PKIXValidator.java
index 925b010afe9..465666a0d99 100644
--- a/src/java.base/share/classes/sun/security/validator/PKIXValidator.java
+++ b/src/java.base/share/classes/sun/security/validator/PKIXValidator.java
@@ -224,7 +224,7 @@ public final class PKIXValidator extends Validator {
// add new algorithm constraints checker
if (constraints != null) {
pkixParameters.addCertPathChecker(
- new AlgorithmChecker(constraints, null, variant));
+ new AlgorithmChecker(constraints, variant));
}
// attach it to the PKIXBuilderParameters.
diff --git a/src/java.base/share/classes/sun/security/validator/SimpleValidator.java b/src/java.base/share/classes/sun/security/validator/SimpleValidator.java
index 501ea510f9b..b7f72f8bdeb 100644
--- a/src/java.base/share/classes/sun/security/validator/SimpleValidator.java
+++ b/src/java.base/share/classes/sun/security/validator/SimpleValidator.java
@@ -167,7 +167,7 @@ public final class SimpleValidator extends Validator {
AlgorithmChecker appAlgChecker = null;
if (constraints != null) {
appAlgChecker = new AlgorithmChecker(anchor, constraints, null,
- null, variant);
+ variant);
}
// verify top down, starting at the certificate issued by
diff --git a/src/java.base/share/classes/sun/security/x509/AlgorithmId.java b/src/java.base/share/classes/sun/security/x509/AlgorithmId.java
index f9d65b0fa21..f5100671775 100644
--- a/src/java.base/share/classes/sun/security/x509/AlgorithmId.java
+++ b/src/java.base/share/classes/sun/security/x509/AlgorithmId.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2021, 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
@@ -80,6 +80,7 @@ public class AlgorithmId implements Serializable, DerEncoder {
@SuppressWarnings("serial") // Not statically typed as Serializable
protected DerValue params;
+ private transient byte[] encodedParams;
/**
* Constructs an algorithm ID which will be initialized
@@ -108,6 +109,17 @@ public class AlgorithmId implements Serializable, DerEncoder {
algid = oid;
algParams = algparams;
constructedFromDer = false;
+ if (algParams != null) {
+ try {
+ encodedParams = algParams.getEncoded();
+ } catch (IOException ioe) {
+ // It should be safe to ignore this.
+ // This exception can occur if AlgorithmParameters was not
+ // initialized (which should not occur), or if it was
+ // initialized with bogus parameters, which should have
+ // been detected when init was called.
+ }
+ }
}
/**
@@ -121,6 +133,7 @@ public class AlgorithmId implements Serializable, DerEncoder {
this.algid = oid;
this.params = params;
if (this.params != null) {
+ encodedParams = params.toByteArray();
decodeParams();
}
}
@@ -139,7 +152,7 @@ public class AlgorithmId implements Serializable, DerEncoder {
}
// Decode (parse) the parameters
- algParams.init(params.toByteArray());
+ algParams.init(encodedParams.clone());
}
/**
@@ -158,6 +171,7 @@ public class AlgorithmId implements Serializable, DerEncoder {
*
* @exception IOException on encoding error.
*/
+ @Override
public void derEncode (OutputStream out) throws IOException {
DerOutputStream bytes = new DerOutputStream();
DerOutputStream tmp = new DerOutputStream();
@@ -166,7 +180,12 @@ public class AlgorithmId implements Serializable, DerEncoder {
// Setup params from algParams since no DER encoding is given
if (constructedFromDer == false) {
if (algParams != null) {
- params = new DerValue(algParams.getEncoded());
+ if (encodedParams == null) {
+ // call getEncoded again in case algParams were initialized
+ // after being passed in to ctor.
+ encodedParams = algParams.getEncoded();
+ }
+ params = new DerValue(encodedParams);
} else {
params = null;
}
@@ -269,7 +288,7 @@ public class AlgorithmId implements Serializable, DerEncoder {
if (params != null) {
try {
AlgorithmId digestParams =
- AlgorithmId.parse(new DerValue(params.toByteArray()));
+ AlgorithmId.parse(new DerValue(encodedParams));
String digestAlg = digestParams.getName();
return digestAlg.replace("-", "") + "withECDSA";
} catch (IOException e) {
@@ -297,6 +316,10 @@ public class AlgorithmId implements Serializable, DerEncoder {
* Returns the DER encoded parameter, which can then be
* used to initialize java.security.AlgorithmParameters.
*
+ * Note that this* method should always return a new array as it is called
+ * directly by the JDK implementation of X509Certificate.getSigAlgParams()
+ * and X509CRL.getSigAlgParams().
+ *
* Note: for ecdsa-with-SHA2 plus hash algorithm (Ex: SHA-256), this method
* returns null because {@link #getName()} has already returned the "full"
* signature algorithm (Ex: SHA256withECDSA).
@@ -304,10 +327,10 @@ public class AlgorithmId implements Serializable, DerEncoder {
* @return DER encoded parameters, or null not present.
*/
public byte[] getEncodedParams() throws IOException {
- return (params == null ||
+ return (encodedParams == null ||
algid.toString().equals(KnownOIDs.SpecifiedSHA2withECDSA.value()))
? null
- : params.toByteArray();
+ : encodedParams.clone();
}
/**
@@ -315,8 +338,8 @@ public class AlgorithmId implements Serializable, DerEncoder {
* with the same parameters.
*/
public boolean equals(AlgorithmId other) {
- boolean paramsEqual = Objects.equals(other.params, params);
- return (algid.equals((Object)other.algid) && paramsEqual);
+ return algid.equals((Object)other.algid) &&
+ Arrays.equals(encodedParams, other.encodedParams);
}
/**
@@ -326,6 +349,7 @@ public class AlgorithmId implements Serializable, DerEncoder {
*
* @param other preferably an AlgorithmId, else an ObjectIdentifier
*/
+ @Override
public boolean equals(Object other) {
if (this == other) {
return true;
@@ -352,11 +376,11 @@ public class AlgorithmId implements Serializable, DerEncoder {
*
* @return a hashcode for this AlgorithmId.
*/
+ @Override
public int hashCode() {
- StringBuilder sbuf = new StringBuilder();
- sbuf.append(algid.toString());
- sbuf.append(paramsToString());
- return sbuf.toString().hashCode();
+ int hashCode = algid.hashCode();
+ hashCode = 31 * hashCode + Arrays.hashCode(encodedParams);
+ return hashCode;
}
/**
@@ -364,10 +388,10 @@ public class AlgorithmId implements Serializable, DerEncoder {
* This may be redefined by subclasses which parse those parameters.
*/
protected String paramsToString() {
- if (params == null) {
+ if (encodedParams == null) {
return "";
} else if (algParams != null) {
- return algParams.toString();
+ return ", " + algParams.toString();
} else {
return ", params unparsed";
}
@@ -376,6 +400,7 @@ public class AlgorithmId implements Serializable, DerEncoder {
/**
* Returns a string describing the algorithm and its parameters.
*/
+ @Override
public String toString() {
return getName() + paramsToString();
}
diff --git a/src/java.base/share/conf/security/java.security b/src/java.base/share/conf/security/java.security
index a6bb9e142d2..3e976d14fbf 100644
--- a/src/java.base/share/conf/security/java.security
+++ b/src/java.base/share/conf/security/java.security
@@ -1326,3 +1326,26 @@ jdk.io.permissionsUseCanonicalPath=false
#
# jdk.tls.alpnCharset=UTF-8
jdk.tls.alpnCharset=ISO_8859_1
+
+#
+# JNDI Object Factories Filter
+#
+# This filter is used by the JNDI runtime to control the set of object factory classes
+# which will be allowed to instantiate objects from object references returned by
+# naming/directory systems. The factory class named by the reference instance will be
+# matched against this filter. The filter property supports pattern-based filter syntax
+# with the same format as jdk.serialFilter.
+#
+# Each pattern is matched against the factory class name to allow or disallow it's
+# instantiation. The access to a factory class is allowed unless the filter returns
+# REJECTED.
+#
+# Note: This property is currently used by the JDK Reference implementation.
+# It is not guaranteed to be examined and used by other implementations.
+#
+# If the system property jdk.jndi.object.factoriesFilter is also specified, it supersedes
+# the security property value defined here. The default value of the property is "*".
+#
+# The default pattern value allows any object factory class specified by the reference
+# instance to recreate the referenced object.
+#jdk.jndi.object.factoriesFilter=*
diff --git a/src/java.base/share/man/java.1 b/src/java.base/share/man/java.1
index 070ba40d8e0..4f846951135 100644
--- a/src/java.base/share/man/java.1
+++ b/src/java.base/share/man/java.1
@@ -1,4 +1,4 @@
-.\" Copyright (c) 1994, 2020, Oracle and/or its affiliates. All rights reserved.
+.\" Copyright (c) 1994, 2021, 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
@@ -1310,7 +1310,7 @@ By default this option is disabled.
.RS
.RE
.TP
-.B \f[CB]\-XX:FlightRecorderOptions=\f[R]\f[I]parameter\f[R]\f[CB]=\f[R]\f[I]value\f[R] (or)\f[CB]\-XX:FlightRecorderOptions:\f[R]\f[I]parameter\f[R]\f[CB]=\f[R]\f[I]value\f[R]
+.B \f[CB]\-XX:FlightRecorderOptions:\f[R]\f[I]parameter\f[R]\f[CB]=\f[R]\f[I]value\f[R] (or)\f[CB]\-XX:FlightRecorderOptions:\f[R]\f[I]parameter\f[R]\f[CB]=\f[R]\f[I]value\f[R]
Sets the parameters that control the behavior of JFR.
.RS
.PP
@@ -1635,7 +1635,7 @@ By default, this option is disabled.
.RS
.RE
.TP
-.B \f[CB]\-XX:StartFlightRecording=\f[R]\f[I]parameter\f[R]\f[CB]=\f[R]\f[I]value\f[R]
+.B \f[CB]\-XX:StartFlightRecording:\f[R]\f[I]parameter\f[R]\f[CB]=\f[R]\f[I]value\f[R]
Starts a JFR recording for the Java application.
This option is equivalent to the \f[CB]JFR.start\f[R] diagnostic command
that starts a recording during runtime.
diff --git a/src/java.base/windows/classes/java/lang/ProcessImpl.java b/src/java.base/windows/classes/java/lang/ProcessImpl.java
index a5bab7db6ae..4a38238fd67 100644
--- a/src/java.base/windows/classes/java/lang/ProcessImpl.java
+++ b/src/java.base/windows/classes/java/lang/ProcessImpl.java
@@ -219,9 +219,9 @@ final class ProcessImpl extends Process {
private static final char ESCAPE_VERIFICATION[][] = {
// We guarantee the only command file execution for implicit [cmd.exe] run.
// http://technet.microsoft.com/en-us/library/bb490954.aspx
- {' ', '\t', '<', '>', '&', '|', '^'},
- {' ', '\t', '<', '>'},
- {' ', '\t', '<', '>'},
+ {' ', '\t', '\"', '<', '>', '&', '|', '^'},
+ {' ', '\t', '\"', '<', '>'},
+ {' ', '\t', '\"', '<', '>'},
{' ', '\t'}
};
@@ -281,18 +281,27 @@ final class ProcessImpl extends Process {
}
/**
- * Return the argument without quotes (1st and last) if present, else the arg.
+ * Return the argument without quotes (1st and last) if properly quoted, else the arg.
+ * A properly quoted string has first and last characters as quote and
+ * the last quote is not escaped.
* @param str a string
- * @return the string without 1st and last quotes
+ * @return the string without quotes
*/
private static String unQuote(String str) {
- int len = str.length();
- return (len >= 2 && str.charAt(0) == DOUBLEQUOTE && str.charAt(len - 1) == DOUBLEQUOTE)
- ? str.substring(1, len - 1)
- : str;
+ if (!str.startsWith("\"") || !str.endsWith("\"") || str.length() < 2)
+ return str; // no beginning or ending quote, or too short not quoted
+
+ if (str.endsWith("\\\"")) {
+ return str; // not properly quoted, treat as unquoted
+ }
+ // Strip leading and trailing quotes
+ return str.substring(1, str.length() - 1);
}
private static boolean needsEscaping(int verificationType, String arg) {
+ if (arg.isEmpty())
+ return true; // Empty string is to be quoted
+
// Switch off MS heuristic for internal ["].
// Please, use the explicit [cmd.exe] call
// if you need the internal ["].
diff --git a/src/java.naming/share/classes/com/sun/jndi/ldap/Obj.java b/src/java.naming/share/classes/com/sun/jndi/ldap/Obj.java
index 728ea0d8ecd..8ea0a5d7dee 100644
--- a/src/java.naming/share/classes/com/sun/jndi/ldap/Obj.java
+++ b/src/java.naming/share/classes/com/sun/jndi/ldap/Obj.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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,9 @@ final class Obj {
String[] codebases = getCodebases(attrs.get(JAVA_ATTRIBUTES[CODEBASE]));
try {
if ((attr = attrs.get(JAVA_ATTRIBUTES[SERIALIZED_DATA])) != null) {
+ if (!VersionHelper.isSerialDataAllowed()) {
+ throw new NamingException("Object deserialization is not allowed");
+ }
ClassLoader cl = helper.getURLClassLoader(codebases);
return deserializeObject((byte[])attr.get(), cl);
} else if ((attr = attrs.get(JAVA_ATTRIBUTES[REMOTE_LOC])) != null) {
diff --git a/src/java.naming/share/classes/com/sun/jndi/ldap/VersionHelper.java b/src/java.naming/share/classes/com/sun/jndi/ldap/VersionHelper.java
index e96f2552a7a..48cc50f4aaf 100644
--- a/src/java.naming/share/classes/com/sun/jndi/ldap/VersionHelper.java
+++ b/src/java.naming/share/classes/com/sun/jndi/ldap/VersionHelper.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -43,21 +43,52 @@ public final class VersionHelper {
*/
private static final boolean trustURLCodebase;
+ /**
+ * Determines whether objects may be deserialized from the content of
+ * 'javaSerializedData' attribute.
+ */
+ private static final boolean trustSerialData;
+
static {
// System property to control whether classes may be loaded from an
// arbitrary URL code base
- PrivilegedAction<String> act =
- () -> System.getProperty("com.sun.jndi.ldap.object.trustURLCodebase", "false");
- String trust = AccessController.doPrivileged(act);
+ String trust = getPrivilegedProperty(
+ "com.sun.jndi.ldap.object.trustURLCodebase", "false");
trustURLCodebase = "true".equalsIgnoreCase(trust);
+
+ // System property to control whether classes is allowed to be loaded from
+ // 'javaSerializedData' attribute
+ String trustSerialDataSp = getPrivilegedProperty(
+ "com.sun.jndi.ldap.object.trustSerialData", "true");
+ trustSerialData = "true".equalsIgnoreCase(trustSerialDataSp);
}
- private VersionHelper() { }
+ private static String getPrivilegedProperty(String propertyName, String defaultVal) {
+ PrivilegedAction<String> action = () -> System.getProperty(propertyName, defaultVal);
+ if (System.getSecurityManager() == null) {
+ return action.run();
+ } else {
+ return AccessController.doPrivileged(action);
+ }
+ }
+
+ private VersionHelper() {
+ }
static VersionHelper getVersionHelper() {
return helper;
}
+ /**
+ * Returns true if deserialization of objects from 'javaSerializedData'
+ * LDAP attribute is allowed.
+ *
+ * @return true if deserialization is allowed; false - otherwise
+ */
+ public static boolean isSerialDataAllowed() {
+ return trustSerialData;
+ }
+
ClassLoader getURLClassLoader(String[] url) throws MalformedURLException {
ClassLoader parent = getContextClassLoader();
/*
diff --git a/src/java.naming/share/classes/com/sun/naming/internal/ObjectFactoriesFilter.java b/src/java.naming/share/classes/com/sun/naming/internal/ObjectFactoriesFilter.java
new file mode 100644
index 00000000000..bc25b2bbc53
--- /dev/null
+++ b/src/java.naming/share/classes/com/sun/naming/internal/ObjectFactoriesFilter.java
@@ -0,0 +1,114 @@
+/*
+ * 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.
+ */
+
+package com.sun.naming.internal;
+
+import sun.security.util.SecurityProperties;
+
+import javax.naming.Reference;
+import java.io.ObjectInputFilter;
+import java.io.ObjectInputFilter.FilterInfo;
+import java.io.ObjectInputFilter.Status;
+
+/**
+ * This class implements the filter that validates object factories classes instantiated
+ * during {@link Reference} lookups.
+ * There is one system-wide filter instance per VM that can be set via
+ * the {@code "jdk.jndi.object.factoriesFilter"} system property value, or via
+ * setting the property in the security properties file. The system property value supersedes
+ * the security property value. If none of the properties are specified the default
+ * "*" value is used.
+ * The filter is implemented as {@link ObjectInputFilter} with capabilities limited to the
+ * validation of a factory's class types only ({@linkplain FilterInfo#serialClass()}).
+ * Array length, number of object references, depth, and stream size filtering capabilities are
+ * not supported by the filter.
+ */
+public final class ObjectFactoriesFilter {
+
+ /**
+ * Checks if serial filter configured with {@code "jdk.jndi.object.factoriesFilter"}
+ * system property value allows instantiation of the specified objects factory class.
+ * If the filter result is not {@linkplain Status#REJECTED REJECTED}, the filter will
+ * allow the instantiation of objects factory class.
+ *
+ * @param factoryClass objects factory class
+ * @return true - if the factory is allowed to be instantiated; false - otherwise
+ */
+ public static boolean canInstantiateObjectsFactory(Class<?> factoryClass) {
+ return checkInput(() -> factoryClass);
+ }
+
+ private static boolean checkInput(FactoryInfo factoryInfo) {
+ Status result = GLOBAL.checkInput(factoryInfo);
+ return result != Status.REJECTED;
+ }
+
+ // FilterInfo to check if objects factory class is allowed by the system-wide
+ // filter. Array length, number of object references, depth, and stream size
+ // capabilities are ignored.
+ @FunctionalInterface
+ private interface FactoryInfo extends FilterInfo {
+ @Override
+ default long arrayLength() {
+ return -1;
+ }
+
+ @Override
+ default long depth() {
+ return 1;
+ }
+
+ @Override
+ default long references() {
+ return 0;
+ }
+
+ @Override
+ default long streamBytes() {
+ return 0;
+ }
+ }
+
+ // Prevent instantiation of the factories filter class
+ private ObjectFactoriesFilter() {
+ throw new InternalError("Not instantiable");
+ }
+
+ // System property name that contains the patterns to filter object factory names
+ private static final String FACTORIES_FILTER_PROPNAME = "jdk.jndi.object.factoriesFilter";
+
+ // Default system property value that allows the load of any object factory classes
+ private static final String DEFAULT_SP_VALUE = "*";
+
+ // System wide object factories filter constructed from the system property
+ private static final ObjectInputFilter GLOBAL =
+ ObjectInputFilter.Config.createFilter(getFilterPropertyValue());
+
+ // Get security or system property value
+ private static String getFilterPropertyValue() {
+ String propVal = SecurityProperties.privilegedGetOverridable(FACTORIES_FILTER_PROPNAME);
+ return propVal != null ? propVal : DEFAULT_SP_VALUE;
+ }
+}
diff --git a/src/java.naming/share/classes/com/sun/naming/internal/VersionHelper.java b/src/java.naming/share/classes/com/sun/naming/internal/VersionHelper.java
index 95106351352..3b14a655354 100644
--- a/src/java.naming/share/classes/com/sun/naming/internal/VersionHelper.java
+++ b/src/java.naming/share/classes/com/sun/naming/internal/VersionHelper.java
@@ -96,6 +96,10 @@ public final class VersionHelper {
return loadClass(className, getContextClassLoader());
}
+ public Class<?> loadClassWithoutInit(String className) throws ClassNotFoundException {
+ return loadClass(className, false, getContextClassLoader());
+ }
+
/**
* @param className A non-null fully qualified class name.
* @param codebase A non-null, space-separated list of URL strings.
@@ -118,12 +122,17 @@ public final class VersionHelper {
* This internal method is used with Thread Context Class Loader (TCCL),
* please don't expose this method as public.
*/
- Class<?> loadClass(String className, ClassLoader cl)
+ Class<?> loadClass(String className, boolean initialize, ClassLoader cl)
throws ClassNotFoundException {
- Class<?> cls = Class.forName(className, true, cl);
+ Class<?> cls = Class.forName(className, initialize, cl);
return cls;
}
+ Class<?> loadClass(String className, ClassLoader cl)
+ throws ClassNotFoundException {
+ return loadClass(className, true, cl);
+ }
+
/*
* Returns a JNDI property from the system properties. Returns
* null if the property is not set, or if there is no permission
diff --git a/src/java.naming/share/classes/javax/naming/spi/NamingManager.java b/src/java.naming/share/classes/javax/naming/spi/NamingManager.java
index 9a6501b7a96..aac1498e09e 100644
--- a/src/java.naming/share/classes/javax/naming/spi/NamingManager.java
+++ b/src/java.naming/share/classes/javax/naming/spi/NamingManager.java
@@ -31,6 +31,8 @@ import java.security.PrivilegedAction;
import java.util.*;
import javax.naming.*;
+
+import com.sun.naming.internal.ObjectFactoriesFilter;
import com.sun.naming.internal.VersionHelper;
import com.sun.naming.internal.ResourceManager;
import com.sun.naming.internal.FactoryEnumeration;
@@ -147,7 +149,11 @@ public class NamingManager {
// Try to use current class loader
try {
- clas = helper.loadClass(factoryName);
+ clas = helper.loadClassWithoutInit(factoryName);
+ // Validate factory's class with the objects factory serial filter
+ if (!ObjectFactoriesFilter.canInstantiateObjectsFactory(clas)) {
+ return null;
+ }
} catch (ClassNotFoundException e) {
// ignore and continue
// e.printStackTrace();
@@ -160,6 +166,11 @@ public class NamingManager {
(codebase = ref.getFactoryClassLocation()) != null) {
try {
clas = helper.loadClass(factoryName, codebase);
+ // Validate factory's class with the objects factory serial filter
+ if (clas == null ||
+ !ObjectFactoriesFilter.canInstantiateObjectsFactory(clas)) {
+ return null;
+ }
} catch (ClassNotFoundException e) {
}
}
diff --git a/src/java.naming/share/classes/module-info.java b/src/java.naming/share/classes/module-info.java
index 4b89b55d3a3..f7d0ace806d 100644
--- a/src/java.naming/share/classes/module-info.java
+++ b/src/java.naming/share/classes/module-info.java
@@ -29,11 +29,11 @@
* Common standard JNDI environment properties that may be supported
* by JNDI providers are defined and documented in
* {@link javax.naming.Context}. Specific JNDI provider implementations
- * may also support other environment properties, which are specific
+ * may also support other environment or system properties, which are specific
* to their implementation.
*
* @implNote
- * The following implementation specific properties are supported by the
+ * The following implementation specific environment properties are supported by the
* default LDAP Naming Service Provider implementation in the JDK:
* <ul>
* <li>{@code com.sun.jndi.ldap.connect.timeout}:
@@ -74,7 +74,36 @@
* channel binding information to the server.
* </li>
* </ul>
- *
+ * <p>The following implementation specific system properties are supported by the
+ * default LDAP Naming Service Provider implementation in the JDK:
+ * <ul>
+ * <li>{@systemProperty com.sun.jndi.ldap.object.trustSerialData}:
+ * <br>The value of this system property is the string representation of a boolean value
+ * which allows to control the deserialization of java objects from the 'javaSerializedData'
+ * LDAP attribute. To prevent the deserialization of java objects from the 'javaSerializedData'
+ * attribute, the system property value can be set to 'false'.
+ * <br>If the property is not specified then the deserialization of java objects
+ * from the 'javaSerializedData' attribute is allowed.
+ * </li>
+ * <li>{@systemProperty jdk.jndi.object.factoriesFilter}:
+ * <br>The value of this system property defines a filter used by
+ * the JNDI runtime implementation to control the set of object factory classes which will
+ * be allowed to instantiate objects from object references returned by naming/directory systems.
+ * The factory class named by the reference instance will be matched against this filter.
+ * The filter property supports pattern-based filter syntax with the same format as
+ * {@link java.io.ObjectInputFilter.Config#createFilter(String) jdk.serialFilter}.
+ * This property can also be specified as a {@linkplain java.security.Security security property}.
+ * This property is also supported by the <a href="{@docRoot}/jdk.naming.rmi/module-summary.html">default JNDI
+ * RMI Provider</a>.
+ * <br>The default value allows any object factory class specified by the reference
+ * instance to recreate the referenced object.
+ * </li>
+ * </ul>
+ * <p>Other providers may define additional properties in their module description:
+ * <ul>
+ * <li><a href="{@docRoot}/jdk.naming.dns/module-summary.html">DNS Naming Provider</a></li>
+ * <li><a href="{@docRoot}/jdk.naming.rmi/module-summary.html">RMI Naming Provider</a></li>
+ * </ul>
* @provides javax.naming.ldap.spi.LdapDnsProvider
*
* @uses javax.naming.ldap.spi.LdapDnsProvider
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java b/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java
index d0a47316970..f44d73ba25b 100644
--- a/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java
@@ -121,6 +121,7 @@ class Http2Connection {
static private final int MAX_CLIENT_STREAM_ID = Integer.MAX_VALUE; // 2147483647
static private final int MAX_SERVER_STREAM_ID = Integer.MAX_VALUE - 1; // 2147483646
+ static private final int BUFFER = 8; // added as an upper bound
/**
* Flag set when no more streams to be opened on this connection.
@@ -1111,8 +1112,10 @@ class Http2Connection {
* and CONTINUATION frames from the list and return the List<Http2Frame>.
*/
private List<HeaderFrame> encodeHeaders(OutgoingHeaders<Stream<?>> frame) {
+ // max value of frame size is clamped by default frame size to avoid OOM
+ int bufferSize = Math.min(Math.max(getMaxSendFrameSize(), 1024), DEFAULT_FRAME_SIZE);
List<ByteBuffer> buffers = encodeHeadersImpl(
- getMaxSendFrameSize(),
+ bufferSize,
frame.getAttachment().getRequestPseudoHeaders(),
frame.getUserHeaders(),
frame.getSystemHeaders());
@@ -1135,9 +1138,9 @@ class Http2Connection {
// by the sendLock. / (see sendFrame())
// private final ByteBufferPool headerEncodingPool = new ByteBufferPool();
- private ByteBuffer getHeaderBuffer(int maxFrameSize) {
- ByteBuffer buf = ByteBuffer.allocate(maxFrameSize);
- buf.limit(maxFrameSize);
+ private ByteBuffer getHeaderBuffer(int size) {
+ ByteBuffer buf = ByteBuffer.allocate(size);
+ buf.limit(size);
return buf;
}
@@ -1152,8 +1155,8 @@ class Http2Connection {
* header field names MUST be converted to lowercase prior to their
* encoding in HTTP/2...
*/
- private List<ByteBuffer> encodeHeadersImpl(int maxFrameSize, HttpHeaders... headers) {
- ByteBuffer buffer = getHeaderBuffer(maxFrameSize);
+ private List<ByteBuffer> encodeHeadersImpl(int bufferSize, HttpHeaders... headers) {
+ ByteBuffer buffer = getHeaderBuffer(bufferSize);
List<ByteBuffer> buffers = new ArrayList<>();
for(HttpHeaders header : headers) {
for (Map.Entry<String, List<String>> e : header.map().entrySet()) {
@@ -1164,7 +1167,7 @@ class Http2Connection {
while (!hpackOut.encode(buffer)) {
buffer.flip();
buffers.add(buffer);
- buffer = getHeaderBuffer(maxFrameSize);
+ buffer = getHeaderBuffer(bufferSize);
}
}
}
@@ -1174,6 +1177,7 @@ class Http2Connection {
return buffers;
}
+
private List<ByteBuffer> encodeHeaders(OutgoingHeaders<Stream<?>> oh, Stream<?> stream) {
oh.streamid(stream.streamid);
if (Log.headers()) {
diff --git a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/MarkUnsafeAccessTest.java b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/MarkUnsafeAccessTest.java
index e6c76cdbc9c..5262add28ec 100644
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/MarkUnsafeAccessTest.java
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/MarkUnsafeAccessTest.java
@@ -115,6 +115,8 @@ public class MarkUnsafeAccessTest extends GraalCompilerTest {
testMappedByteBuffer(MappedByteBuffer::get);
}
+ // TODO Re-enable this test once JDK-8259360 got fixed.
+ /*
@Test
public void testCompiled() throws IOException {
Assume.assumeFalse("Crashes on AArch64 (GR-8351)", System.getProperty("os.arch").equalsIgnoreCase("aarch64"));
@@ -136,6 +138,7 @@ public class MarkUnsafeAccessTest extends GraalCompilerTest {
}
});
}
+ */
private static final int BLOCK_SIZE = 512;
private static final int BLOCK_COUNT = 16;
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java
index 369657e8411..3fe9449d2a6 100644
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java
@@ -373,7 +373,7 @@ public final class PlatformRecording implements AutoCloseable {
public void setMaxSize(long maxSize) {
synchronized (recorder) {
if (getState() == RecordingState.CLOSED) {
- throw new IllegalStateException("Can't set max age when recording is closed");
+ throw new IllegalStateException("Can't set max size when recording is closed");
}
this.maxSize = maxSize;
trimToSize();
diff --git a/src/jdk.management.jfr/share/classes/jdk/management/jfr/RemoteRecordingStream.java b/src/jdk.management.jfr/share/classes/jdk/management/jfr/RemoteRecordingStream.java
index dce30cc9a4c..d234bfe6631 100644
--- a/src/jdk.management.jfr/share/classes/jdk/management/jfr/RemoteRecordingStream.java
+++ b/src/jdk.management.jfr/share/classes/jdk/management/jfr/RemoteRecordingStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021, 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,7 +65,6 @@ import jdk.jfr.internal.management.EventByteStream;
* usage on a remote host and print the events to standard out.
*
* <pre>
- * {
* {@literal
* String host = "com.example";
* int port = 4711;
@@ -83,7 +82,7 @@ import jdk.jfr.internal.management.EventByteStream;
* rs.onEvent("jdk.GCPhasePause", System.out::println);
* rs.start();
* }
- * }
+ * }
* </pre>
*
* @since 16
diff --git a/src/jdk.naming.rmi/share/classes/module-info.java b/src/jdk.naming.rmi/share/classes/module-info.java
index 92c37e646b9..ffeddc3f397 100644
--- a/src/jdk.naming.rmi/share/classes/module-info.java
+++ b/src/jdk.naming.rmi/share/classes/module-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2015, 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
@@ -26,6 +26,24 @@
/**
* Provides the implementation of the RMI Java Naming provider.
*
+ * @implNote
+ * The following implementation specific system properties are supported by the
+ * default RMI Naming Service Provider implementation in the JDK:
+ * <ul>
+ * <li>{@systemProperty jdk.jndi.object.factoriesFilter}:
+ * <br>The value of this system property defines a filter used by
+ * the JNDI runtime implementation to control the set of object factory classes which will
+ * be allowed to instantiate objects from object references returned by naming/directory systems.
+ * The factory class named by the reference instance will be matched against this filter.
+ * The filter property supports pattern-based filter syntax with the same format as
+ * {@link java.io.ObjectInputFilter.Config#createFilter(String) jdk.serialFilter}.
+ * This property can also be specified as a {@linkplain java.security.Security security property}.
+ * This property is also supported by the <a href="{@docRoot}/java.naming/module-summary.html">default
+ * LDAP Naming Service Provider</a>.
+ * <br>The default value allows any object factory class specified by the reference
+ * instance to recreate the referenced object.
+ * </li>
+ * </ul>
* @provides javax.naming.spi.InitialContextFactory
* @moduleGraph
* @since 9
diff --git a/src/utils/IdealGraphVisualizer/Data/src/main/java/com/sun/hotspot/igv/data/serialization/Parser.java b/src/utils/IdealGraphVisualizer/Data/src/main/java/com/sun/hotspot/igv/data/serialization/Parser.java
index b2832cb399b..2c8d669d08a 100644
--- a/src/utils/IdealGraphVisualizer/Data/src/main/java/com/sun/hotspot/igv/data/serialization/Parser.java
+++ b/src/utils/IdealGraphVisualizer/Data/src/main/java/com/sun/hotspot/igv/data/serialization/Parser.java
@@ -34,6 +34,7 @@ import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
import javax.swing.SwingUtilities;
import javax.xml.parsers.ParserConfigurationException;
@@ -529,6 +530,8 @@ public class Parser implements GraphParser {
}
try {
XMLReader reader = createReader();
+ // To enforce using English for non-English users, we must use Locale.ROOT rather than Locale.ENGLISH
+ reader.setProperty("http://apache.org/xml/properties/locale", Locale.ROOT);
reader.setContentHandler(new XMLParser(xmlDocument, monitor));
reader.parse(new InputSource(Channels.newInputStream(channel)));
} catch (SAXException ex) {
diff --git a/src/utils/IdealGraphVisualizer/Data/src/test/java/com/sun/hotspot/igv/data/serialization/ParserTest.java b/src/utils/IdealGraphVisualizer/Data/src/test/java/com/sun/hotspot/igv/data/serialization/ParserTest.java
index c6b36d07c6d..10ff3966fab 100644
--- a/src/utils/IdealGraphVisualizer/Data/src/test/java/com/sun/hotspot/igv/data/serialization/ParserTest.java
+++ b/src/utils/IdealGraphVisualizer/Data/src/test/java/com/sun/hotspot/igv/data/serialization/ParserTest.java
@@ -222,4 +222,10 @@ public class ParserTest {
testBoth(new GraphDocument(), "<graphDocument></graphDocument>");
}
+ @Test
+ public void testParseIncompleteXML() {
+ // Exception should be swallowed, see catch clause in GraphParser.parse.
+ testBoth(new GraphDocument(), "<graphDocument>");
+ }
+
}
diff --git a/src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/DiagramViewModel.java b/src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/DiagramViewModel.java
index cccca711113..618705550a0 100644
--- a/src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/DiagramViewModel.java
+++ b/src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/DiagramViewModel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2021, 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
@@ -206,6 +206,11 @@ public class DiagramViewModel extends RangeSliderModel implements ChangedListene
@Override
public void changed(Group source) {
assert source == group;
+ if (group.getGraphs().isEmpty()) {
+ // If the group has been emptied, all corresponding graph views
+ // will be closed, so do nothing.
+ return;
+ }
filterGraphs();
setSelectedNodes(selectedNodes);
}
diff --git a/src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/EditorTopComponent.java b/src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/EditorTopComponent.java
index 9a858385f27..a379593dcaa 100644
--- a/src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/EditorTopComponent.java
+++ b/src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/EditorTopComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2021, 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,6 +25,8 @@ package com.sun.hotspot.igv.view;
import com.sun.hotspot.igv.data.ChangedEvent;
import com.sun.hotspot.igv.data.ChangedListener;
+import com.sun.hotspot.igv.data.GraphDocument;
+import com.sun.hotspot.igv.data.Group;
import com.sun.hotspot.igv.data.InputNode;
import com.sun.hotspot.igv.data.Properties;
import com.sun.hotspot.igv.data.Properties.PropertyMatcher;
@@ -225,6 +227,12 @@ public final class EditorTopComponent extends TopComponent implements PropertyCh
}
});
+ Group group = getDiagram().getGraph().getGroup();
+ group.getChangedEvent().addListener(g -> closeOnRemovedOrEmptyGroup());
+ if (group.getParent() instanceof GraphDocument) {
+ final GraphDocument doc = (GraphDocument) group.getParent();
+ doc.getChangedEvent().addListener(d -> closeOnRemovedOrEmptyGroup());
+ }
toolBar.add(NextDiagramAction.get(NextDiagramAction.class));
toolBar.add(PrevDiagramAction.get(PrevDiagramAction.class));
@@ -449,6 +457,14 @@ public final class EditorTopComponent extends TopComponent implements PropertyCh
return PREFERRED_ID;
}
+ private void closeOnRemovedOrEmptyGroup() {
+ Group group = getDiagram().getGraph().getGroup();
+ if (!group.getParent().getElements().contains(group) ||
+ group.getGraphs().isEmpty()) {
+ close();
+ }
+ }
+
private ChangedListener<DiagramViewModel> diagramChangedListener = new ChangedListener<DiagramViewModel>() {
@Override
diff --git a/src/utils/LogCompilation/src/test/java/com/sun/hotspot/tools/compiler/TestLogCompilation.java b/src/utils/LogCompilation/src/test/java/com/sun/hotspot/tools/compiler/TestLogCompilation.java
index fd8762ff7a6..53463c42533 100644
--- a/src/utils/LogCompilation/src/test/java/com/sun/hotspot/tools/compiler/TestLogCompilation.java
+++ b/src/utils/LogCompilation/src/test/java/com/sun/hotspot/tools/compiler/TestLogCompilation.java
@@ -83,7 +83,7 @@ public class TestLogCompilation {
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+LogCompilation",
"-XX:LogFile=target/jfr.log",
- "-XX:StartFlightRecording=dumponexit=true,filename=rwrecording.jfr"
+ "-XX:StartFlightRecording:dumponexit=true,filename=rwrecording.jfr"
};
static final String allSetupArgs[][] = {
diff --git a/test/hotspot/gtest/metaspace/test_metaspaceUtils.cpp b/test/hotspot/gtest/metaspace/test_metaspaceUtils.cpp
index 66f46aabf38..d987ccf1895 100644
--- a/test/hotspot/gtest/metaspace/test_metaspaceUtils.cpp
+++ b/test/hotspot/gtest/metaspace/test_metaspaceUtils.cpp
@@ -73,3 +73,18 @@ TEST_VM(MetaspaceUtils, committed_compressed_class_pointers) {
EXPECT_LE(committed_class, committed);
}
+TEST_VM(MetaspaceUtils, non_compressed_class_pointers) {
+ if (UseCompressedClassPointers) {
+ return;
+ }
+
+ size_t committed_class = MetaspaceUtils::committed_bytes(Metaspace::ClassType);
+ EXPECT_EQ(committed_class, 0UL);
+
+ size_t used_class = MetaspaceUtils::used_bytes(Metaspace::ClassType);
+ EXPECT_EQ(used_class, 0UL);
+
+ size_t reserved_class = MetaspaceUtils::reserved_bytes(Metaspace::ClassType);
+ EXPECT_EQ(reserved_class, 0UL);
+}
+
diff --git a/test/hotspot/jtreg/compiler/exceptions/TestSpilling.java b/test/hotspot/jtreg/compiler/exceptions/TestSpilling.java
new file mode 100644
index 00000000000..572e2384d56
--- /dev/null
+++ b/test/hotspot/jtreg/compiler/exceptions/TestSpilling.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2021, 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 compiler.exceptions;
+
+/**
+ * @test
+ * @bug 8263227
+ * @summary Tests that users of return values from exception-throwing method
+ * calls are not duplicated in the call's exception path. The second
+ * run with a variable seed is added for test robustness.
+ * @library /test/lib /
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions
+ * -Xbatch -XX:+StressGCM -XX:StressSeed=0
+ * -XX:+VerifyRegisterAllocator
+ * -XX:CompileCommand=dontinline,java.lang.Integer::*
+ * compiler.exceptions.TestSpilling
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions
+ * -Xbatch -XX:+StressGCM
+ * -XX:+VerifyRegisterAllocator
+ * -XX:CompileCommand=dontinline,java.lang.Integer::*
+ * compiler.exceptions.TestSpilling
+ */
+
+public class TestSpilling {
+
+ public static void test() {
+ int a = Integer.valueOf(42).intValue();
+ // After global code motion, the logic below should only be placed in
+ // the fall-through path of java.lang.Integer::intValue(). Otherwise,
+ // live range splitting might create uses without reaching definitions
+ // if 'a' is spilled.
+ int b = (((a & 0x0000F000)) + 1);
+ int c = a / b + ((a % b > 0) ? 1 : 0);
+ }
+
+ public static void main(String[] args) {
+ for (int i = 0; i < 10_000; i++) {
+ test();
+ }
+ }
+
+}
diff --git a/test/hotspot/jtreg/gc/TestFullGCCount.java b/test/hotspot/jtreg/gc/TestFullGCCount.java
index 541ddd3dd2b..4557fb95c7b 100644
--- a/test/hotspot/jtreg/gc/TestFullGCCount.java
+++ b/test/hotspot/jtreg/gc/TestFullGCCount.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2021, 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
@@ -28,7 +28,8 @@ package gc;
* @bug 7072527
* @summary JMM GC counters overcount in some cases
* @comment Shenandoah has "ExplicitGCInvokesConcurrent" on by default
- * @requires !(vm.gc == "Shenandoah" & vm.opt.ExplicitGCInvokesConcurrent != false)
+ * @requires !(vm.gc == "Shenandoah" & vm.opt.ExplicitGCInvokesConcurrent != false)
+ * @requires vm.gc != "Z"
* @modules java.management
* @run main/othervm -Xlog:gc gc.TestFullGCCount
*/
diff --git a/test/hotspot/jtreg/gc/g1/TestG1SkipCompaction.java b/test/hotspot/jtreg/gc/g1/TestG1SkipCompaction.java
index 7eee42f621d..f5fadcbb880 100644
--- a/test/hotspot/jtreg/gc/g1/TestG1SkipCompaction.java
+++ b/test/hotspot/jtreg/gc/g1/TestG1SkipCompaction.java
@@ -48,7 +48,7 @@ public class TestG1SkipCompaction {
"-XX:MarkSweepDeadRatio=3",
"-Xmx8m",
"-Xms8M",
- "-Xlog:gc+phases=debug",
+ "-Xlog:gc+phases=trace",
"-XX:G1HeapRegionSize=1m",
GCTest.class.getName()
};
@@ -61,9 +61,8 @@ public class TestG1SkipCompaction {
Matcher m = r.matcher(output.getStdout());
if (!m.find()) {
- throw new RuntimeException("Could not find any no moving region output");
+ throw new RuntimeException("Could not find any not compacted regions in the logs");
}
-
}
public static void main(String[] args) throws Exception {
diff --git a/test/hotspot/jtreg/gc/z/TestGarbageCollectorMXBean.java b/test/hotspot/jtreg/gc/z/TestGarbageCollectorMXBean.java
index 96dc8cc77c0..e29d75b009c 100644
--- a/test/hotspot/jtreg/gc/z/TestGarbageCollectorMXBean.java
+++ b/test/hotspot/jtreg/gc/z/TestGarbageCollectorMXBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021, 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
@@ -53,6 +53,7 @@ public class TestGarbageCollectorMXBean {
final long initialCapacity = Long.parseLong(args[0]) * M;
final long maxCapacity = Long.parseLong(args[1]) * M;
final AtomicInteger cycles = new AtomicInteger();
+ final AtomicInteger pauses = new AtomicInteger();
final AtomicInteger errors = new AtomicInteger();
final NotificationListener listener = (Notification notification, Object ignored) -> {
@@ -85,38 +86,65 @@ public class TestGarbageCollectorMXBean {
log(" MemoryUsageAfterGC: " + memoryUsageAfterGC);
log("");
- if (name.equals("ZGC")) {
+ if (name.equals("ZGC Cycles")) {
cycles.incrementAndGet();
+
+ if (!action.equals("end of GC cycle")) {
+ log("ERROR: Action");
+ errors.incrementAndGet();
+ }
+
+ if (memoryUsageBeforeGC.getInit() != initialCapacity) {
+ log("ERROR: MemoryUsageBeforeGC.init");
+ errors.incrementAndGet();
+ }
+
+ if (memoryUsageBeforeGC.getUsed() > initialCapacity) {
+ log("ERROR: MemoryUsageBeforeGC.used");
+ errors.incrementAndGet();
+ }
+
+ if (memoryUsageBeforeGC.getCommitted() != initialCapacity) {
+ log("ERROR: MemoryUsageBeforeGC.committed");
+ errors.incrementAndGet();
+ }
+
+ if (memoryUsageBeforeGC.getMax() != maxCapacity) {
+ log("ERROR: MemoryUsageBeforeGC.max");
+ errors.incrementAndGet();
+ }
+ } else if (name.equals("ZGC Pauses")) {
+ pauses.incrementAndGet();
+
+ if (!action.equals("end of GC pause")) {
+ log("ERROR: Action");
+ errors.incrementAndGet();
+ }
+
+ if (memoryUsageBeforeGC.getInit() != 0) {
+ log("ERROR: MemoryUsageBeforeGC.init");
+ errors.incrementAndGet();
+ }
+
+ if (memoryUsageBeforeGC.getUsed() != 0) {
+ log("ERROR: MemoryUsageBeforeGC.used");
+ errors.incrementAndGet();
+ }
+
+ if (memoryUsageBeforeGC.getCommitted() != 0) {
+ log("ERROR: MemoryUsageBeforeGC.committed");
+ errors.incrementAndGet();
+ }
+
+ if (memoryUsageBeforeGC.getMax() != 0) {
+ log("ERROR: MemoryUsageBeforeGC.max");
+ errors.incrementAndGet();
+ }
} else {
log("ERROR: Name");
errors.incrementAndGet();
}
- if (!action.equals("end of major GC")) {
- log("ERROR: Action");
- errors.incrementAndGet();
- }
-
- if (memoryUsageBeforeGC.getInit() != initialCapacity) {
- log("ERROR: MemoryUsageBeforeGC.init");
- errors.incrementAndGet();
- }
-
- if (memoryUsageBeforeGC.getUsed() > initialCapacity) {
- log("ERROR: MemoryUsageBeforeGC.used");
- errors.incrementAndGet();
- }
-
- if (memoryUsageBeforeGC.getCommitted() != initialCapacity) {
- log("ERROR: MemoryUsageBeforeGC.committed");
- errors.incrementAndGet();
- }
-
- if (memoryUsageBeforeGC.getMax() != maxCapacity) {
- log("ERROR: MemoryUsageBeforeGC.max");
- errors.incrementAndGet();
- }
-
if (!cause.equals("System.gc()")) {
log("ERROR: Cause");
errors.incrementAndGet();
@@ -143,6 +171,7 @@ public class TestGarbageCollectorMXBean {
}
final int minCycles = 5;
+ final int minPauses = minCycles * 3;
// Run GCs
for (int i = 0; i < minCycles; i++) {
@@ -162,10 +191,13 @@ public class TestGarbageCollectorMXBean {
}
final int actualCycles = cycles.get();
+ final int actualPauses = pauses.get();
final int actualErrors = errors.get();
log(" minCycles: " + minCycles);
+ log(" minPauses: " + minPauses);
log("actualCycles: " + actualCycles);
+ log("actualPauses: " + actualPauses);
log("actualErrors: " + actualErrors);
// Verify number of cycle events
@@ -173,6 +205,11 @@ public class TestGarbageCollectorMXBean {
throw new Exception("Unexpected cycles");
}
+ // Verify number of pause events
+ if (actualPauses < minPauses) {
+ throw new Exception("Unexpected pauses");
+ }
+
// Verify number of errors
if (actualErrors != 0) {
throw new Exception("Unexpected errors");
diff --git a/test/hotspot/jtreg/gc/z/TestMemoryManagerMXBean.java b/test/hotspot/jtreg/gc/z/TestMemoryManagerMXBean.java
index ffa36803bbd..a5c5c1367e7 100644
--- a/test/hotspot/jtreg/gc/z/TestMemoryManagerMXBean.java
+++ b/test/hotspot/jtreg/gc/z/TestMemoryManagerMXBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021, 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,8 +39,10 @@ public class TestMemoryManagerMXBean {
}
public static void main(String[] args) throws Exception {
- int zgcMemoryManagers = 0;
- int zgcMemoryPools = 0;
+ int zgcCyclesMemoryManagers = 0;
+ int zgcPausesMemoryManagers = 0;
+ int zgcCyclesMemoryPools = 0;
+ int zgcPausesMemoryPools = 0;
for (final var memoryManager : ManagementFactory.getMemoryManagerMXBeans()) {
final var memoryManagerName = memoryManager.getName();
@@ -48,8 +50,10 @@ public class TestMemoryManagerMXBean {
System.out.println("MemoryManager: " + memoryManagerName);
- if (memoryManagerName.equals("ZGC")) {
- zgcMemoryManagers++;
+ if (memoryManagerName.equals("ZGC Cycles")) {
+ zgcCyclesMemoryManagers++;
+ } else if (memoryManagerName.equals("ZGC Pauses")) {
+ zgcPausesMemoryManagers++;
}
for (final var memoryPoolName : memoryManager.getMemoryPoolNames()) {
@@ -58,21 +62,29 @@ public class TestMemoryManagerMXBean {
System.out.println(" MemoryPool: " + memoryPoolName);
if (memoryPoolName.equals("ZHeap")) {
- zgcMemoryPools++;
+ if (memoryManagerName.equals("ZGC Cycles")) {
+ zgcCyclesMemoryPools++;
+ } else if (memoryManagerName.equals("ZGC Pauses")) {
+ zgcPausesMemoryPools++;
+ }
}
}
+ }
- if (zgcMemoryManagers != zgcMemoryPools) {
- throw new Exception("MemoryManagers/MemoryPools mismatch");
- }
+ if (zgcCyclesMemoryManagers != 1) {
+ throw new Exception("Unexpected number of cycle MemoryManagers");
+ }
+
+ if (zgcPausesMemoryManagers != 1) {
+ throw new Exception("Unexpected number of pause MemoryManagers");
}
- if (zgcMemoryManagers != 1) {
- throw new Exception("All MemoryManagers not found");
+ if (zgcCyclesMemoryPools != 1) {
+ throw new Exception("Unexpected number of cycle MemoryPools");
}
- if (zgcMemoryPools != 1) {
- throw new Exception("All MemoryPools not found");
+ if (zgcPausesMemoryPools != 1) {
+ throw new Exception("Unexpected number of pause MemoryPools");
}
}
}
diff --git a/test/hotspot/jtreg/gtest/MetaspaceUtilsGtests.java b/test/hotspot/jtreg/gtest/MetaspaceUtilsGtests.java
new file mode 100644
index 00000000000..7a9b1c8dfb3
--- /dev/null
+++ b/test/hotspot/jtreg/gtest/MetaspaceUtilsGtests.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2021 THL A29 Limited, a Tencent company. 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.
+ *
+ */
+
+/*
+ * Note: This runs the metaspace utils related parts of gtest in configurations which
+ * are not tested explicitly in the standard gtests.
+ *
+ */
+
+/* @test
+ * @bug 8264008
+ * @summary Run metaspace utils related gtests with compressed class pointers off
+ * @requires vm.bits == 64
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ * java.xml
+ * @requires vm.flagless
+ * @run main/native GTestWrapper --gtest_filter=MetaspaceUtils* -XX:-UseCompressedClassPointers
+ */
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/CDSandJFR.java b/test/hotspot/jtreg/runtime/cds/appcds/CDSandJFR.java
index 2bd7fddcba0..065786686fa 100644
--- a/test/hotspot/jtreg/runtime/cds/appcds/CDSandJFR.java
+++ b/test/hotspot/jtreg/runtime/cds/appcds/CDSandJFR.java
@@ -64,20 +64,20 @@ public class CDSandJFR {
TestCommon.checkDump(output, "Skipping jdk/jfr/Event: JFR event class");
output = TestCommon.exec(appJar,
- "-XX:StartFlightRecording=dumponexit=true",
+ "-XX:StartFlightRecording:dumponexit=true",
"Hello");
TestCommon.checkExec(output, "Hello World");
TestCommon.checkExec(TestCommon.exec(appJar,
- "-XX:FlightRecorderOptions=retransform=true",
+ "-XX:FlightRecorderOptions:retransform=true",
"GetFlightRecorder"));
TestCommon.checkExec(TestCommon.exec(appJar,
- "-XX:FlightRecorderOptions=retransform=false",
+ "-XX:FlightRecorderOptions:retransform=false",
"GetFlightRecorder"));
// Test dumping with flight recorder enabled.
output = TestCommon.testDump(appJar, TestCommon.list(classes),
- "-XX:StartFlightRecording=dumponexit=true");
+ "-XX:StartFlightRecording:dumponexit=true");
TestCommon.checkDump(output, "warning: JFR will be disabled during CDS dumping");
}
}
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java b/test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java
index 0595633dfc2..24b957b31bf 100644
--- a/test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java
+++ b/test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java
@@ -417,7 +417,7 @@ public class TestCommon extends CDSTestUtils {
if (RUN_WITH_JFR) {
boolean usesJFR = false;
for (String s : cmd) {
- if (s.startsWith("-XX:StartFlightRecording=") || s.startsWith("-XX:FlightRecorderOptions")) {
+ if (s.startsWith("-XX:StartFlightRecording") || s.startsWith("-XX:FlightRecorderOptions")) {
System.out.println("JFR option might have been specified. Don't interfere: " + s);
usesJFR = true;
break;
@@ -425,7 +425,7 @@ public class TestCommon extends CDSTestUtils {
}
if (!usesJFR) {
System.out.println("JFR option not specified. Enabling JFR ...");
- cmd.add(0, "-XX:StartFlightRecording=dumponexit=true");
+ cmd.add(0, "-XX:StartFlightRecording:dumponexit=true");
System.out.println(cmd);
}
}
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestWithProfiler.java b/test/hotspot/jtreg/runtime/cds/appcds/TestWithProfiler.java
index a3e72d65779..9bde3137f32 100644
--- a/test/hotspot/jtreg/runtime/cds/appcds/TestWithProfiler.java
+++ b/test/hotspot/jtreg/runtime/cds/appcds/TestWithProfiler.java
@@ -49,7 +49,7 @@ public class TestWithProfiler {
output = TestCommon.exec(appJar,
"-XX:+UnlockDiagnosticVMOptions",
"-Xint",
- "-XX:StartFlightRecording=duration=15s,filename=myrecording.jfr,settings=profile,dumponexit=true",
+ "-XX:StartFlightRecording:duration=15s,filename=myrecording.jfr,settings=profile,dumponexit=true",
"TestWithProfilerHelper");
TestCommon.checkExec(output);
}
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/customLoader/HelloCustom_JFR.java b/test/hotspot/jtreg/runtime/cds/appcds/customLoader/HelloCustom_JFR.java
index 2b713236c08..e51c0d8cd68 100644
--- a/test/hotspot/jtreg/runtime/cds/appcds/customLoader/HelloCustom_JFR.java
+++ b/test/hotspot/jtreg/runtime/cds/appcds/customLoader/HelloCustom_JFR.java
@@ -24,7 +24,7 @@
/*
* @test
- * @summary Same as HelloCustom, but add -XX:StartFlightRecording=dumponexit=true to the runtime
+ * @summary Same as HelloCustom, but add -XX:StartFlightRecording:dumponexit=true to the runtime
* options. This makes sure that the shared classes are compatible with both
* JFR and JVMTI ClassFileLoadHook.
* @requires vm.hasJFR
@@ -47,6 +47,6 @@ import sun.hotspot.WhiteBox;
public class HelloCustom_JFR {
public static void main(String[] args) throws Exception {
- HelloCustom.run("-XX:StartFlightRecording=dumponexit=true", "-Xlog:cds+jvmti=debug");
+ HelloCustom.run("-XX:StartFlightRecording:dumponexit=true", "-Xlog:cds+jvmti=debug");
}
}
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/ModulePathAndCP_JFR.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/ModulePathAndCP_JFR.java
index d5edcc84f5a..e626efb61c8 100644
--- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/ModulePathAndCP_JFR.java
+++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/ModulePathAndCP_JFR.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2021, 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
@@ -27,14 +27,14 @@
* @requires vm.hasJFR & vm.cds
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
* @run driver/timeout=480 ModulePathAndCP_JFR
- * @summary Same as ModulePathAndCP, but add -XX:StartFlightRecording=dumponexit=true to the runtime
+ * @summary Same as ModulePathAndCP, but add -XX:StartFlightRecording:dumponexit=true to the runtime
* options. This makes sure that the shared classes are compatible with both
* JFR and JVMTI ClassFileLoadHook.
*/
public class ModulePathAndCP_JFR {
public static void main(String... args) throws Exception {
- ModulePathAndCP.run("-XX:StartFlightRecording=dumponexit=true", "-Xlog:cds+jvmti=debug,jfr+startup=off");
+ ModulePathAndCP.run("-XX:StartFlightRecording:dumponexit=true", "-Xlog:cds+jvmti=debug,jfr+startup=off");
}
}
diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/FlagCombo.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/FlagCombo.java
index 1b0bb52ea39..886a46f1c17 100644
--- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/FlagCombo.java
+++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/FlagCombo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2021, 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
@@ -55,7 +55,7 @@ public class FlagCombo {
if (args.length == 0) {
SharedStringsUtils.runWithArchiveAuto("HelloString",
- "-XX:StartFlightRecording=dumponexit=true");
+ "-XX:StartFlightRecording:dumponexit=true");
}
SharedStringsUtils.runWithArchive("HelloString", "-XX:+UnlockDiagnosticVMOptions",
diff --git a/test/hotspot/jtreg/testlibrary_tests/ctw/CtwTest.java b/test/hotspot/jtreg/testlibrary_tests/ctw/CtwTest.java
index ca0577ff8e8..ec22510bf8d 100644
--- a/test/hotspot/jtreg/testlibrary_tests/ctw/CtwTest.java
+++ b/test/hotspot/jtreg/testlibrary_tests/ctw/CtwTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2021, 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
@@ -96,9 +96,11 @@ public abstract class CtwTest {
String[] cmd = Arrays.copyOf(CTW_COMMAND, CTW_COMMAND.length + args.length - 1);
System.arraycopy(args, 1, cmd, CTW_COMMAND.length, args.length - 1);
if (Platform.isWindows()) {
- // '*' has to be escaped on windows
+ // arguments with '*' has to be quoted on windows
for (int i = 0; i < cmd.length; ++i) {
- cmd[i] = cmd[i].replace("*", "\"*\"");
+ if (cmd[i].charAt(0) != '"' && cmd[i].indexOf('*') >= 0) {
+ cmd[i] = '"' + cmd[i] + '"';
+ }
}
}
ProcessBuilder pb = ProcessTools.createTestJvm(cmd);
diff --git a/test/jdk/com/sun/jdi/JdbOptions.java b/test/jdk/com/sun/jdi/JdbOptions.java
index 114aa3ddd50..a4e3bfd356f 100644
--- a/test/jdk/com/sun/jdi/JdbOptions.java
+++ b/test/jdk/com/sun/jdi/JdbOptions.java
@@ -120,19 +120,19 @@ public class JdbOptions {
test("-connect",
"com.sun.jdi.CommandLineLaunch:vmexec=java,options=\"-client\" \"-XX:+PrintVMOptions\""
+ " -XX:+IgnoreUnrecognizedVMOptions"
- + " \"-XX:StartFlightRecording=dumponexit=true,maxsize=500M\" \"-XX:FlightRecorderOptions=repository=jfrrep\""
+ + " \"-XX:StartFlightRecording:dumponexit=true,maxsize=500M\" \"-XX:FlightRecorderOptions:repository=jfrrep\""
+ ",main=" + targ + " " + outFilename)
- .expectedArg("-XX:StartFlightRecording=dumponexit=true,maxsize=500M")
- .expectedArg("-XX:FlightRecorderOptions=repository=jfrrep");
+ .expectedArg("-XX:StartFlightRecording:dumponexit=true,maxsize=500M")
+ .expectedArg("-XX:FlightRecorderOptions:repository=jfrrep");
// 'options' contains commas - values are quoted (single quotes)
test("-connect",
"com.sun.jdi.CommandLineLaunch:vmexec=java,options='-client' '-XX:+PrintVMOptions'"
+ " -XX:+IgnoreUnrecognizedVMOptions"
- + " '-XX:StartFlightRecording=dumponexit=true,maxsize=500M' '-XX:FlightRecorderOptions=repository=jfrrep'"
+ + " '-XX:StartFlightRecording:dumponexit=true,maxsize=500M' '-XX:FlightRecorderOptions:repository=jfrrep'"
+ ",main=" + targ + " " + outFilename)
- .expectedArg("-XX:StartFlightRecording=dumponexit=true,maxsize=500M")
- .expectedArg("-XX:FlightRecorderOptions=repository=jfrrep");
+ .expectedArg("-XX:StartFlightRecording:dumponexit=true,maxsize=500M")
+ .expectedArg("-XX:FlightRecorderOptions:repository=jfrrep");
// java options are specified in 2 ways, with and without spaces
// options are quoted by using single and double quotes.
@@ -141,15 +141,15 @@ public class JdbOptions {
"-connect",
"com.sun.jdi.CommandLineLaunch:vmexec=java,options=-Dprop3=val3 '-Dprop4=val 4'"
+ " -XX:+IgnoreUnrecognizedVMOptions"
- + " \"-XX:StartFlightRecording=dumponexit=true,maxsize=500M\""
- + " '-XX:FlightRecorderOptions=repository=jfrrep'"
+ + " \"-XX:StartFlightRecording:dumponexit=true,maxsize=500M\""
+ + " '-XX:FlightRecorderOptions:repository=jfrrep'"
+ ",main=" + targ + " " + outFilename + " prop1 prop2 prop3 prop4")
.expectedProp("prop1", "val1")
.expectedProp("prop2", "val 2")
.expectedProp("prop3", "val3")
.expectedProp("prop4", "val 4")
- .expectedArg("-XX:StartFlightRecording=dumponexit=true,maxsize=500M")
- .expectedArg("-XX:FlightRecorderOptions=repository=jfrrep");
+ .expectedArg("-XX:StartFlightRecording:dumponexit=true,maxsize=500M")
+ .expectedArg("-XX:FlightRecorderOptions:repository=jfrrep");
}
diff --git a/test/jdk/java/io/Serializable/serialFilter/GlobalFilterTest.java b/test/jdk/java/io/Serializable/serialFilter/GlobalFilterTest.java
index 6ebf35726d0..140a6fce0ca 100644
--- a/test/jdk/java/io/Serializable/serialFilter/GlobalFilterTest.java
+++ b/test/jdk/java/io/Serializable/serialFilter/GlobalFilterTest.java
@@ -60,7 +60,7 @@ import org.testng.annotations.DataProvider;
* @build GlobalFilterTest SerialFilterTest
* @requires vm.hasJFR
* @run testng/othervm/policy=security.policy
- * -XX:StartFlightRecording=name=DeserializationEvent,dumponexit=true
+ * -XX:StartFlightRecording:name=DeserializationEvent,dumponexit=true
* -Djava.security.properties=${test.src}/java.security-extra1
* -Djava.security.debug=properties GlobalFilterTest
*/
diff --git a/test/jdk/java/lang/String/StringRepeat.java b/test/jdk/java/lang/String/StringRepeat.java
index f268117d445..491bfe9f86f 100644
--- a/test/jdk/java/lang/String/StringRepeat.java
+++ b/test/jdk/java/lang/String/StringRepeat.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,24 +24,36 @@
/*
* @test
* @summary This exercises String#repeat patterns and limits.
- * @run main/othervm -Xmx2g StringRepeat
+ * @run main/othervm StringRepeat
+ */
+
+/*
+ * @test
+ * @summary This exercises String#repeat patterns with 16 * 1024 * 1024 repeats.
+ * @requires os.maxMemory >= 2G
+ * @run main/othervm -Xmx2g StringRepeat 16777216
*/
import java.nio.CharBuffer;
public class StringRepeat {
- public static void main(String... arg) {
+ public static void main(String... args) {
+ if (args.length > 0) {
+ REPEATS = new int[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ REPEATS[i] = Integer.parseInt(args[i]);
+ }
+ }
test1();
test2();
}
/*
- * Varitions of repeat count.
+ * Default varitions of repeat count.
*/
static int[] REPEATS = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 32, 64, 128, 256, 512, 1024, 64 * 1024, 1024 * 1024,
- 16 * 1024 * 1024
+ 32, 64, 128, 256, 512, 1024, 64 * 1024, 1024 * 1024
};
/*
diff --git a/test/jdk/java/lang/annotation/AnnotationTypeMismatchException/AnnotationTypeMismatchTest.java b/test/jdk/java/lang/annotation/AnnotationTypeMismatchException/AnnotationTypeMismatchTest.java
new file mode 100644
index 00000000000..3393575a2b0
--- /dev/null
+++ b/test/jdk/java/lang/annotation/AnnotationTypeMismatchException/AnnotationTypeMismatchTest.java
@@ -0,0 +1,87 @@
+/*
+ * 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 8228988
+ * @summary An annotation-typed property of an annotation that is represented as an
+ * incompatible property of another type should yield an AnnotationTypeMismatchException.
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * @run main AnnotationTypeMismatchTest
+ */
+
+import jdk.internal.org.objectweb.asm.AnnotationVisitor;
+import jdk.internal.org.objectweb.asm.ClassWriter;
+import jdk.internal.org.objectweb.asm.Opcodes;
+import jdk.internal.org.objectweb.asm.Type;
+
+import java.lang.annotation.AnnotationTypeMismatchException;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+public class AnnotationTypeMismatchTest {
+
+ public static void main(String[] args) throws Exception {
+ /*
+ * @AnAnnotation(value = AnEnum.VALUE) // would now be: value = @Value
+ * class Carrier { }
+ */
+ ClassWriter writer = new ClassWriter(0);
+ writer.visit(Opcodes.V1_8, 0, "sample/Carrier", null, Type.getInternalName(Object.class), null);
+ AnnotationVisitor v = writer.visitAnnotation(Type.getDescriptor(AnAnnotation.class), true);
+ v.visitEnum("value", Type.getDescriptor(AnEnum.class), "VALUE");
+ writer.visitEnd();
+ byte[] b = writer.toByteArray();
+ ByteArrayClassLoader cl = new ByteArrayClassLoader(AnnotationTypeMismatchTest.class.getClassLoader());
+ cl.init(b);
+ AnAnnotation sample = cl.loadClass("sample.Carrier").getAnnotation(AnAnnotation.class);
+ try {
+ Value value = sample.value();
+ throw new IllegalStateException("Found value: " + value);
+ } catch (AnnotationTypeMismatchException e) {
+ // correct
+ }
+ }
+
+ public enum AnEnum {
+ VALUE
+ }
+
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface AnAnnotation {
+ Value value() default @Value;
+ }
+
+ public @interface Value { }
+
+ public static class ByteArrayClassLoader extends ClassLoader {
+
+ public ByteArrayClassLoader(ClassLoader parent) {
+ super(parent);
+ }
+
+ public void init(byte[] b) {
+ defineClass("sample.Carrier", b, 0, b.length);
+ }
+ }
+}
diff --git a/test/jdk/java/lang/annotation/AnnotationTypeMismatchException/EnumTypeMismatchTest.java b/test/jdk/java/lang/annotation/AnnotationTypeMismatchException/EnumTypeMismatchTest.java
new file mode 100644
index 00000000000..48f0e6c8cb8
--- /dev/null
+++ b/test/jdk/java/lang/annotation/AnnotationTypeMismatchException/EnumTypeMismatchTest.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 8228988
+ * @summary An enumeration-typed property of an annotation that is represented as an
+ * incompatible property of another type should yield an AnnotationTypeMismatchException.
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * @run main EnumTypeMismatchTest
+ */
+
+import jdk.internal.org.objectweb.asm.AnnotationVisitor;
+import jdk.internal.org.objectweb.asm.ClassWriter;
+import jdk.internal.org.objectweb.asm.Opcodes;
+import jdk.internal.org.objectweb.asm.Type;
+
+import java.lang.annotation.AnnotationTypeMismatchException;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+public class EnumTypeMismatchTest {
+
+ public static void main(String[] args) throws Exception {
+ /*
+ * @AnAnnotation(value = @AnAnnotation) // would now be: value = AnEnum.VALUE
+ * class Carrier { }
+ */
+ ClassWriter writer = new ClassWriter(0);
+ writer.visit(Opcodes.V1_8, 0, "sample/Carrier", null, Type.getInternalName(Object.class), null);
+ AnnotationVisitor v = writer.visitAnnotation(Type.getDescriptor(AnAnnotation.class), true);
+ v.visitAnnotation("value", Type.getDescriptor(AnAnnotation.class)).visitEnd();
+ writer.visitEnd();
+ byte[] b = writer.toByteArray();
+ ByteArrayClassLoader cl = new ByteArrayClassLoader(EnumTypeMismatchTest.class.getClassLoader());
+ cl.init(b);
+ AnAnnotation sample = cl.loadClass("sample.Carrier").getAnnotation(AnAnnotation.class);
+ try {
+ AnEnum value = sample.value();
+ throw new IllegalStateException("Found value: " + value);
+ } catch (AnnotationTypeMismatchException e) {
+ // correct
+ }
+ }
+
+ public enum AnEnum {
+ VALUE
+ }
+
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface AnAnnotation {
+ AnEnum value() default AnEnum.VALUE;
+ }
+
+ public static class ByteArrayClassLoader extends ClassLoader {
+
+ public ByteArrayClassLoader(ClassLoader parent) {
+ super(parent);
+ }
+
+ void init(byte[] b) {
+ defineClass("sample.Carrier", b, 0, b.length);
+ }
+ }
+}
diff --git a/test/jdk/java/lang/management/MemoryMXBean/MemoryTest.java b/test/jdk/java/lang/management/MemoryMXBean/MemoryTest.java
index 036f225ffc3..d60b2e46593 100644
--- a/test/jdk/java/lang/management/MemoryMXBean/MemoryTest.java
+++ b/test/jdk/java/lang/management/MemoryMXBean/MemoryTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@
* @author Mandy Chung
*
* @modules jdk.management
- * @run main MemoryTest 1 1
+ * @run main MemoryTest 2 1
*/
/*
diff --git a/test/jdk/java/security/cert/X509Certificate/GetSigAlgParams.java b/test/jdk/java/security/cert/X509Certificate/GetSigAlgParams.java
new file mode 100644
index 00000000000..6d7a8345617
--- /dev/null
+++ b/test/jdk/java/security/cert/X509Certificate/GetSigAlgParams.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2021, 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 8259428
+ * @summary Verify X509Certificate.getSigAlgParams() returns new array each
+ * time it is called
+ * @modules java.base/sun.security.tools.keytool java.base/sun.security.x509
+ */
+
+import java.security.cert.X509Certificate;
+import sun.security.tools.keytool.CertAndKeyGen;
+import sun.security.x509.X500Name;
+
+public class GetSigAlgParams {
+
+ public static void main(String[] args) throws Exception {
+
+ CertAndKeyGen cakg = new CertAndKeyGen("RSASSA-PSS", "RSASSA-PSS");
+ cakg.generate(1024);
+ X509Certificate c = cakg.getSelfCertificate(new X500Name("CN=Me"), 100);
+ if (c.getSigAlgParams() == c.getSigAlgParams()) {
+ throw new Exception("Encoded params are the same byte array");
+ }
+ }
+}
diff --git a/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetEncoded.java b/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetEncoded.java
new file mode 100644
index 00000000000..d1f1d1c9042
--- /dev/null
+++ b/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetEncoded.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2021, 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 8261779
+ * @summary Check that EncryptedPrivateKeyInfo.getEncoded() calls
+ * AlgorithmParameters.getEncoded() when first called
+ */
+
+import java.io.IOException;
+import java.security.AlgorithmParameters;
+import java.security.AlgorithmParametersSpi;
+import java.security.Provider;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.ECGenParameterSpec;
+import java.security.spec.InvalidParameterSpecException;
+import java.util.Arrays;
+import javax.crypto.EncryptedPrivateKeyInfo;
+
+public class GetEncoded {
+
+ public static void main(String[] argv) throws Exception {
+
+ AlgorithmParameters params =
+ AlgorithmParameters.getInstance("EC", new MyProvider());
+ EncryptedPrivateKeyInfo epki =
+ new EncryptedPrivateKeyInfo(params, new byte[] {1, 2, 3, 4});
+ try {
+ epki.getEncoded();
+ throw new Exception("Should have thrown IOException");
+ } catch (IOException ioe) {
+ // test passed, expected exception
+ }
+
+ AlgorithmParameters ap1 = AlgorithmParameters.getInstance("EC");
+ EncryptedPrivateKeyInfo epki1 =
+ new EncryptedPrivateKeyInfo(ap1, new byte[] {1, 2, 3, 4});
+ ap1.init(new ECGenParameterSpec("secp256r1"));
+
+ EncryptedPrivateKeyInfo epki2 =
+ new EncryptedPrivateKeyInfo(epki1.getEncoded());
+
+ AlgorithmParameters ap2 = epki2.getAlgParameters();
+ if (ap2 == null || !Arrays.equals(ap1.getEncoded(), ap2.getEncoded())) {
+ throw new Exception("AlgorithmParameters are not equal");
+ }
+ }
+
+ public static class MyProvider extends Provider {
+
+ MyProvider() {
+ super("MyProvider", "0.0", "My Provider");
+ put("AlgorithmParameters.EC", UnsupportedParameters.class.getName());
+ }
+ }
+
+ public static class UnsupportedParameters extends AlgorithmParametersSpi {
+
+ protected void engineInit(AlgorithmParameterSpec paramSpec)
+ throws InvalidParameterSpecException {
+ throw new InvalidParameterSpecException("Not supported");
+ }
+ protected void engineInit(byte[] params) throws IOException {
+ throw new IOException("Not supported");
+ }
+ protected void engineInit(byte[] params, String format) throws IOException {
+ throw new IOException("Not supported");
+ }
+ protected <T extends AlgorithmParameterSpec> T engineGetParameterSpec(
+ Class<T> paramSpec) throws InvalidParameterSpecException {
+ throw new InvalidParameterSpecException("Not supported");
+ }
+ protected byte[] engineGetEncoded() throws IOException {
+ throw new IOException("Not supported");
+ }
+ protected byte[] engineGetEncoded(String format) throws IOException {
+ throw new IOException("Not supported");
+ }
+ protected String engineToString() {
+ return null;
+ }
+ }
+}
diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestRegisteredFalseAndRunning.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestRegisteredFalseAndRunning.java
index 65d604a65f6..95bfbf527e1 100644
--- a/test/jdk/jdk/jfr/api/metadata/annotations/TestRegisteredFalseAndRunning.java
+++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestRegisteredFalseAndRunning.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2021, 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 @@ import jdk.jfr.Registered;
* @requires vm.hasJFR
* @library /test/lib
* @run main/othervm jdk.jfr.api.metadata.annotations.TestRegisteredFalseAndRunning
- * @run main/othervm -XX:FlightRecorderOptions=retransform=false jdk.jfr.api.metadata.annotations.TestRegisteredFalseAndRunning
+ * @run main/othervm -XX:FlightRecorderOptions:retransform=false jdk.jfr.api.metadata.annotations.TestRegisteredFalseAndRunning
*/
public class TestRegisteredFalseAndRunning {
@Registered(false)
diff --git a/test/jdk/jdk/jfr/event/gc/stacktrace/TestMetaspaceSerialGCAllocationPendingStackTrace.java b/test/jdk/jdk/jfr/event/gc/stacktrace/TestMetaspaceSerialGCAllocationPendingStackTrace.java
index fcf43d40209..83aa4fb522e 100644
--- a/test/jdk/jdk/jfr/event/gc/stacktrace/TestMetaspaceSerialGCAllocationPendingStackTrace.java
+++ b/test/jdk/jdk/jfr/event/gc/stacktrace/TestMetaspaceSerialGCAllocationPendingStackTrace.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2021, 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 @@ package jdk.jfr.event.gc.stacktrace;
*
* @requires vm.gc == "null" | vm.gc == "Serial"
* @library /test/lib /test/jdk
- * @run main/othervm -XX:+UseSerialGC -Xlog:gc* -XX:MaxMetaspaceSize=64M -XX:+FlightRecorder jdk.jfr.event.gc.stacktrace.TestMetaspaceSerialGCAllocationPendingStackTrace
+ * @run main/othervm -XX:+UseSerialGC -Xlog:gc* -XX:MaxMetaspaceSize=64M jdk.jfr.event.gc.stacktrace.TestMetaspaceSerialGCAllocationPendingStackTrace
*/
public class TestMetaspaceSerialGCAllocationPendingStackTrace {
diff --git a/test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelMarkSweepAllocationPendingStackTrace.java b/test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelMarkSweepAllocationPendingStackTrace.java
index 364ebdc65ef..5ab67d2561a 100644
--- a/test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelMarkSweepAllocationPendingStackTrace.java
+++ b/test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelMarkSweepAllocationPendingStackTrace.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2021, 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 @@ package jdk.jfr.event.gc.stacktrace;
*
* @requires vm.gc == "null" | vm.gc == "Parallel"
* @library /test/lib /test/jdk
- * @run main/othervm -XX:MaxNewSize=10M -Xmx64M -XX:+UseParallelGC -Xlog:gc* -XX:+FlightRecorder jdk.jfr.event.gc.stacktrace.TestParallelMarkSweepAllocationPendingStackTrace
+ * @run main/othervm -XX:MaxNewSize=10M -Xmx64M -XX:+UseParallelGC -Xlog:gc* jdk.jfr.event.gc.stacktrace.TestParallelMarkSweepAllocationPendingStackTrace
*/
public class TestParallelMarkSweepAllocationPendingStackTrace {
diff --git a/test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelScavengeAllocationPendingStackTrace.java b/test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelScavengeAllocationPendingStackTrace.java
index 6d686b8510a..08ec7ffd05c 100644
--- a/test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelScavengeAllocationPendingStackTrace.java
+++ b/test/jdk/jdk/jfr/event/gc/stacktrace/TestParallelScavengeAllocationPendingStackTrace.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2021, 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 @@ package jdk.jfr.event.gc.stacktrace;
*
* @requires vm.gc == "null" | vm.gc == "Parallel"
* @library /test/lib /test/jdk
- * @run main/othervm -XX:+UseParallelGC -Xlog:gc* -XX:+FlightRecorder jdk.jfr.event.gc.stacktrace.TestParallelScavengeAllocationPendingStackTrace
+ * @run main/othervm -XX:+UseParallelGC -Xlog:gc* jdk.jfr.event.gc.stacktrace.TestParallelScavengeAllocationPendingStackTrace
*/
public class TestParallelScavengeAllocationPendingStackTrace {
diff --git a/test/jdk/jdk/jfr/event/runtime/TestSafepointEvents.java b/test/jdk/jdk/jfr/event/runtime/TestSafepointEvents.java
index de2daa5ff2f..b8915ae5036 100644
--- a/test/jdk/jdk/jfr/event/runtime/TestSafepointEvents.java
+++ b/test/jdk/jdk/jfr/event/runtime/TestSafepointEvents.java
@@ -44,7 +44,7 @@ import sun.hotspot.WhiteBox;
* @build sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:.
- * -XX:+FlightRecorder -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* jdk.jfr.event.runtime.TestSafepointEvents
*/
public class TestSafepointEvents {
diff --git a/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java b/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java
index b2ea45206af..543cde82380 100644
--- a/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java
+++ b/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2021, 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
@@ -93,7 +93,7 @@ public class TestShutdownEvent {
"-Xlog:jfr=debug",
"-XX:-CreateCoredumpOnCrash",
"--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
- "-XX:StartFlightRecording=filename=./dumped.jfr,dumponexit=true,settings=default",
+ "-XX:StartFlightRecording:filename=./dumped.jfr,dumponexit=true,settings=default",
"jdk.jfr.event.runtime.TestShutdownEvent$TestMain",
String.valueOf(subTestIndex));
OutputAnalyzer output = ProcessTools.executeProcess(pb);
diff --git a/test/jdk/jdk/jfr/event/runtime/TestThrowableInstrumentation.java b/test/jdk/jdk/jfr/event/runtime/TestThrowableInstrumentation.java
index 344c59680fb..078224b573a 100644
--- a/test/jdk/jdk/jfr/event/runtime/TestThrowableInstrumentation.java
+++ b/test/jdk/jdk/jfr/event/runtime/TestThrowableInstrumentation.java
@@ -39,7 +39,7 @@ import jdk.test.lib.Platform;
* @build sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
- * -Xbatch -XX:StartFlightRecording=dumponexit=true jdk.jfr.event.runtime.TestThrowableInstrumentation
+ * -Xbatch -XX:StartFlightRecording:dumponexit=true jdk.jfr.event.runtime.TestThrowableInstrumentation
*/
public class TestThrowableInstrumentation {
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdStartPathToGCRoots.java b/test/jdk/jdk/jfr/jcmd/TestJcmdStartPathToGCRoots.java
index ce998e5344b..31a458c2f8f 100644
--- a/test/jdk/jdk/jfr/jcmd/TestJcmdStartPathToGCRoots.java
+++ b/test/jdk/jdk/jfr/jcmd/TestJcmdStartPathToGCRoots.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -44,15 +44,15 @@ public class TestJcmdStartPathToGCRoots {
public static void main(String[] args) throws Exception {
JcmdHelper.jcmd("JFR.start", "path-to-gc-roots=true");
- assertCutoff("infinity", "Expected cutoff to be '0 ns' wuth -XX:StartFlightRecording=path-to-gc-roots=true");
+ assertCutoff("infinity", "Expected cutoff to be '0 ns' wuth -XX:StartFlightRecording:path-to-gc-roots=true");
closeRecording();
JcmdHelper.jcmd("JFR.start", "path-to-gc-roots=false");
- assertCutoff("0 ns", "Expected cutoff to be '0 ns' with -XX:StartFlightRecording=path-to-gc-roots=false");
+ assertCutoff("0 ns", "Expected cutoff to be '0 ns' with -XX:StartFlightRecording:path-to-gc-roots=false");
closeRecording();
JcmdHelper.jcmd("JFR.start");
- assertCutoff("0 ns", "Expected cutoff to be '0 ns' with -XX:StartFlightRecording=");
+ assertCutoff("0 ns", "Expected cutoff to be '0 ns' with -XX:StartFlightRecording:");
closeRecording();
}
diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdStartWithOptions.java b/test/jdk/jdk/jfr/jcmd/TestJcmdStartWithOptions.java
index 4687940f6a0..fe8db5f773a 100644
--- a/test/jdk/jdk/jfr/jcmd/TestJcmdStartWithOptions.java
+++ b/test/jdk/jdk/jfr/jcmd/TestJcmdStartWithOptions.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2021, 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
@@ -36,7 +36,7 @@ import jdk.test.lib.process.OutputAnalyzer;
* @key jfr
* @requires vm.hasJFR
* @library /test/lib /test/jdk
- * @run main/othervm -XX:+FlightRecorder -XX:FlightRecorderOptions=maxchunksize=2097152 jdk.jfr.jcmd.TestJcmdStartWithOptions
+ * @run main/othervm -XX:FlightRecorderOptions:maxchunksize=2097152 jdk.jfr.jcmd.TestJcmdStartWithOptions
*/
public class TestJcmdStartWithOptions {
diff --git a/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java b/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java
index cfcf31778fe..3869509b242 100644
--- a/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java
+++ b/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2021, 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
@@ -112,7 +112,7 @@ public class TestDumpOnCrash {
"-Xmx64m",
"-XX:-CreateCoredumpOnCrash",
"--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
- "-XX:StartFlightRecording=" + flightRecordingOptions,
+ "-XX:StartFlightRecording:" + flightRecordingOptions,
crasher.getName(),
signal)
.start();
diff --git a/test/jdk/jdk/jfr/jvm/TestJfrJavaBase.java b/test/jdk/jdk/jfr/jvm/TestJfrJavaBase.java
index 0d4eb3a2439..e6a3b2662ac 100644
--- a/test/jdk/jdk/jfr/jvm/TestJfrJavaBase.java
+++ b/test/jdk/jdk/jfr/jvm/TestJfrJavaBase.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2021, 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
@@ -55,7 +55,7 @@ public class TestJfrJavaBase {
TestJfrJavaBase.class.getName(), "runtest"));
output.shouldHaveExitValue(0);
} else {
- output = ProcessTools.executeTestJava("-XX:StartFlightRecording=dumponexit=true",
+ output = ProcessTools.executeTestJava("-XX:StartFlightRecording:dumponexit=true",
"--limit-modules", "java.base", "-version");
checkOutput(output);
output.shouldHaveExitValue(1);
diff --git a/test/jdk/jdk/jfr/jvm/TestLogOutput.java b/test/jdk/jdk/jfr/jvm/TestLogOutput.java
index 0bf2e8ad7b8..18527abb90b 100644
--- a/test/jdk/jdk/jfr/jvm/TestLogOutput.java
+++ b/test/jdk/jdk/jfr/jvm/TestLogOutput.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2021, 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 @@ import java.util.List;
* @summary Sanity test jfr logging output
* @requires vm.hasJFR
* @library /test/lib
- * @run main/othervm -Xlog:disable -Xlog:jfr*=trace:file=jfr_trace.txt -XX:StartFlightRecording=duration=1s,filename=recording.jfr jdk.jfr.jvm.TestLogOutput
+ * @run main/othervm -Xlog:disable -Xlog:jfr*=trace:file=jfr_trace.txt -XX:StartFlightRecording:duration=1s,filename=recording.jfr jdk.jfr.jvm.TestLogOutput
*/
public class TestLogOutput {
public static void main(String[] args) throws Exception {
diff --git a/test/jdk/jdk/jfr/startupargs/TestBadOptionValues.java b/test/jdk/jdk/jfr/startupargs/TestBadOptionValues.java
index 0720e977678..9f6eed30bb1 100644
--- a/test/jdk/jdk/jfr/startupargs/TestBadOptionValues.java
+++ b/test/jdk/jdk/jfr/startupargs/TestBadOptionValues.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2021, 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,8 +41,8 @@ import jdk.test.lib.process.ProcessTools;
*/
public class TestBadOptionValues {
- private static final String START_FLIGHT_RECORDING = "-XX:StartFlightRecording=";
- private static final String FLIGHT_RECORDER_OPTIONS = "-XX:FlightRecorderOptions=";
+ private static final String START_FLIGHT_RECORDING = "-XX:StartFlightRecording:";
+ private static final String FLIGHT_RECORDER_OPTIONS = "-XX:FlightRecorderOptions:";
private static void test(String prepend, String expectedOutput, String... options) throws Exception {
ProcessBuilder pb;
diff --git a/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java b/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java
index c526be051a7..454bbb631ad 100644
--- a/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java
+++ b/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -52,27 +52,27 @@ public class TestDumpOnExit {
// Test without security manager and a file name relative to current directory
testDumponExit(() -> dumpPath,
"-Xlog:jfr=trace",
- "-XX:StartFlightRecording=filename=./dumped.jfr,dumponexit=true,settings=profile",
+ "-XX:StartFlightRecording:filename=./dumped.jfr,dumponexit=true,settings=profile",
"jdk.jfr.startupargs.TestDumpOnExit$TestMain"
);
// Test a memory recording without a security manager
testDumponExit(() -> findJFRFileInCurrentDirectory(),
"-Xlog:jfr=trace",
- "-XX:StartFlightRecording=dumponexit=true,disk=false",
+ "-XX:StartFlightRecording:dumponexit=true,disk=false",
"jdk.jfr.startupargs.TestDumpOnExit$TestMain"
);
// Test with security manager and a file name relative to current directory
testDumponExit(() -> dumpPath,
"-Xlog:jfr=trace",
- "-XX:StartFlightRecording=filename=./dumped.jfr,dumponexit=true,settings=profile",
+ "-XX:StartFlightRecording:filename=./dumped.jfr,dumponexit=true,settings=profile",
"-Djava.security.manager",
"jdk.jfr.startupargs.TestDumpOnExit$TestMain"
);
// Test with security manager but without a name
testDumponExit(() -> findJFRFileInCurrentDirectory(),
"-Xlog:jfr=trace",
- "-XX:StartFlightRecording=dumponexit=true,settings=profile",
+ "-XX:StartFlightRecording:dumponexit=true,settings=profile",
"-Djava.security.manager",
"jdk.jfr.startupargs.TestDumpOnExit$TestMain"
);
diff --git a/test/jdk/jdk/jfr/startupargs/TestFlushInterval.java b/test/jdk/jdk/jfr/startupargs/TestFlushInterval.java
index c3482e44489..83c4d07c23b 100644
--- a/test/jdk/jdk/jfr/startupargs/TestFlushInterval.java
+++ b/test/jdk/jdk/jfr/startupargs/TestFlushInterval.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2021, 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
@@ -37,7 +37,7 @@ import jdk.jfr.internal.PrivateAccess;
* @requires vm.hasJFR
* @library /test/lib /test/jdk
* @modules jdk.jfr/jdk.jfr.internal
- * @run main/othervm -XX:StartFlightRecording=flush-interval=2s jdk.jfr.startupargs.TestFlushInterval
+ * @run main/othervm -XX:StartFlightRecording:flush-interval=2s jdk.jfr.startupargs.TestFlushInterval
*/
public class TestFlushInterval {
diff --git a/test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java b/test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java
index 3a17887b224..9dbdc85898d 100644
--- a/test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java
+++ b/test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2021, 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
@@ -325,7 +325,7 @@ public class TestMemoryOptions {
}
public String getTestString() {
- String optionString = "-XX:FlightRecorderOptions=";
+ String optionString = "-XX:FlightRecorderOptions:";
for (Option o : optionList) {
String optionParamString = o.getOptionParamString();
if (optionParamString == null) {
@@ -334,7 +334,7 @@ public class TestMemoryOptions {
optionString = optionString.concat(optionParamString);
optionString = optionString.concat(",");
}
- if (optionString.equals("-XX:FlightRecorderOptions=")) {
+ if (optionString.equals("-XX:FlightRecorderOptions:")) {
return null;
}
// strip last ","
diff --git a/test/jdk/jdk/jfr/startupargs/TestOldObjectQueueSize.java b/test/jdk/jdk/jfr/startupargs/TestOldObjectQueueSize.java
index 974ca7f12a8..0613906afac 100644
--- a/test/jdk/jdk/jfr/startupargs/TestOldObjectQueueSize.java
+++ b/test/jdk/jdk/jfr/startupargs/TestOldObjectQueueSize.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2021, 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,15 +34,15 @@ import jdk.test.lib.jfr.Events;
/**
* @test
- * @summary Test -XX:FlightRecorderOptions=old-object-queue-size
+ * @summary Test -XX:FlightRecorderOptions:old-object-queue-size
* @requires vm.hasJFR
* @modules jdk.jfr/jdk.jfr.internal.test
* @library /test/lib
* @key jfr
*
- * @run main/othervm -XX:TLABSize=2k -XX:FlightRecorderOptions=old-object-queue-size=0 jdk.jfr.startupargs.TestOldObjectQueueSize off
- * @run main/othervm -XX:TLABSize=2k -Xlog:gc+tlab=trace -XX:FlightRecorderOptions=old-object-queue-size=10000 jdk.jfr.startupargs.TestOldObjectQueueSize many
- * @run main/othervm -XX:TLABSize=2k -Xlog:gc+tlab=trace -XX:FlightRecorderOptions=old-object-queue-size=1000000 jdk.jfr.startupargs.TestOldObjectQueueSize many
+ * @run main/othervm -XX:TLABSize=2k -XX:FlightRecorderOptions:old-object-queue-size=0 jdk.jfr.startupargs.TestOldObjectQueueSize off
+ * @run main/othervm -XX:TLABSize=2k -Xlog:gc+tlab=trace -XX:FlightRecorderOptions:old-object-queue-size=10000 jdk.jfr.startupargs.TestOldObjectQueueSize many
+ * @run main/othervm -XX:TLABSize=2k -Xlog:gc+tlab=trace -XX:FlightRecorderOptions:old-object-queue-size=1000000 jdk.jfr.startupargs.TestOldObjectQueueSize many
*/
public class TestOldObjectQueueSize {
diff --git a/test/jdk/jdk/jfr/startupargs/TestRepositoryPath.java b/test/jdk/jdk/jfr/startupargs/TestRepositoryPath.java
index 95bcbe5090b..a5052b42d6d 100644
--- a/test/jdk/jdk/jfr/startupargs/TestRepositoryPath.java
+++ b/test/jdk/jdk/jfr/startupargs/TestRepositoryPath.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2021, 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 @@ import jdk.test.lib.Asserts;
* @key jfr
* @requires vm.hasJFR
* @library /test/lib /test/jdk
- * @run main/othervm -XX:StartFlightRecording=name=TestStartRecording,settings=profile -XX:FlightRecorderOptions=repository=./repo jdk.jfr.startupargs.TestRepositoryPath
+ * @run main/othervm -XX:StartFlightRecording:name=TestStartRecording,settings=profile -XX:FlightRecorderOptions:repository=./repo jdk.jfr.startupargs.TestRepositoryPath
*/
public class TestRepositoryPath {
diff --git a/test/jdk/jdk/jfr/startupargs/TestRepositoryPathLong.java b/test/jdk/jdk/jfr/startupargs/TestRepositoryPathLong.java
index 94adb290977..4dda1ab23d2 100644
--- a/test/jdk/jdk/jfr/startupargs/TestRepositoryPathLong.java
+++ b/test/jdk/jdk/jfr/startupargs/TestRepositoryPathLong.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2021, 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 @@ import jdk.test.lib.Asserts;
* @key jfr
* @requires vm.hasJFR
* @library /test/lib /test/jdk
- * @run main/othervm -XX:StartFlightRecording=name=myrec,settings=profile -XX:FlightRecorderOptions=repository=./subdirectory/subdirectory1/subdirectory2/subdirectory3/subdirectory4/subdirectory5/subdirectory6/subdirectory7/subdirectory8/subdirectory9/subdirectory10/subdirectory11/subdirectory12/subdirectory13/subdirectory14/subdirectory15 jdk.jfr.startupargs.TestRepositoryPathLong
+ * @run main/othervm -XX:StartFlightRecording:name=myrec,settings=profile -XX:FlightRecorderOptions:repository=./subdirectory/subdirectory1/subdirectory2/subdirectory3/subdirectory4/subdirectory5/subdirectory6/subdirectory7/subdirectory8/subdirectory9/subdirectory10/subdirectory11/subdirectory12/subdirectory13/subdirectory14/subdirectory15 jdk.jfr.startupargs.TestRepositoryPathLong
*/
public class TestRepositoryPathLong {
diff --git a/test/jdk/jdk/jfr/startupargs/TestRetransform.java b/test/jdk/jdk/jfr/startupargs/TestRetransform.java
index ad5793361d0..6e516afe7eb 100644
--- a/test/jdk/jdk/jfr/startupargs/TestRetransform.java
+++ b/test/jdk/jdk/jfr/startupargs/TestRetransform.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2021, 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,8 +35,8 @@ import jdk.test.lib.jfr.SimpleEvent;
* @key jfr
* @requires vm.hasJFR
* @library /test/lib
- * @run main/othervm -XX:FlightRecorderOptions=retransform=false jdk.jfr.startupargs.TestRetransform
- * @run main/othervm -XX:FlightRecorderOptions=retransform=true jdk.jfr.startupargs.TestRetransform
+ * @run main/othervm -XX:FlightRecorderOptions:retransform=false jdk.jfr.startupargs.TestRetransform
+ * @run main/othervm -XX:FlightRecorderOptions:retransform=true jdk.jfr.startupargs.TestRetransform
*/
public class TestRetransform {
private static class TestEvent extends Event {
diff --git a/test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java b/test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java
index 4d7a390b502..a427cfc1af4 100644
--- a/test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java
+++ b/test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2021, 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
@@ -91,7 +91,7 @@ public class TestRetransformUsingLog {
private static void startApp(boolean recording, boolean retransform, Consumer<OutputAnalyzer> verifier) throws Exception {
List<String> args = new ArrayList<>();
args.add("-Xlog:jfr+system");
- args.add("-XX:FlightRecorderOptions=retransform=" + retransform);
+ args.add("-XX:FlightRecorderOptions:retransform=" + retransform);
if (recording) {
args.add("-XX:StartFlightRecording");
}
diff --git a/test/jdk/jdk/jfr/startupargs/TestStartDelay.java b/test/jdk/jdk/jfr/startupargs/TestStartDelay.java
index cd1521dc179..7036e373a41 100644
--- a/test/jdk/jdk/jfr/startupargs/TestStartDelay.java
+++ b/test/jdk/jdk/jfr/startupargs/TestStartDelay.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2021, 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
@@ -37,7 +37,7 @@ import jdk.test.lib.jfr.CommonHelper;
* @key jfr
* @requires vm.hasJFR
* @library /test/lib /test/jdk
- * @run main/othervm -XX:StartFlightRecording=name=TestStartDelay,delay=5000s jdk.jfr.startupargs.TestStartDelay
+ * @run main/othervm -XX:StartFlightRecording:name=TestStartDelay,delay=5000s jdk.jfr.startupargs.TestStartDelay
*/
public class TestStartDelay {
diff --git a/test/jdk/jdk/jfr/startupargs/TestStartDelayRunning.java b/test/jdk/jdk/jfr/startupargs/TestStartDelayRunning.java
index 11898ca41e8..b74714b9bdd 100644
--- a/test/jdk/jdk/jfr/startupargs/TestStartDelayRunning.java
+++ b/test/jdk/jdk/jfr/startupargs/TestStartDelayRunning.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2021, 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
@@ -36,7 +36,7 @@ import jdk.test.lib.jfr.CommonHelper;
* @key jfr
* @requires vm.hasJFR
* @library /test/lib /test/jdk
- * @run main/othervm -XX:StartFlightRecording=name=TestStartDelay,delay=1s jdk.jfr.startupargs.TestStartDelayRunning
+ * @run main/othervm -XX:StartFlightRecording:name=TestStartDelay,delay=1s jdk.jfr.startupargs.TestStartDelayRunning
*/
public class TestStartDelayRunning {
diff --git a/test/jdk/jdk/jfr/startupargs/TestStartDuration.java b/test/jdk/jdk/jfr/startupargs/TestStartDuration.java
index 5bbb7b1443a..195f2362648 100644
--- a/test/jdk/jdk/jfr/startupargs/TestStartDuration.java
+++ b/test/jdk/jdk/jfr/startupargs/TestStartDuration.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2021, 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,7 +54,7 @@ public class TestStartDuration {
private static void testDurationInRange(String duration, Duration durationString, boolean wait) throws Exception {
ProcessBuilder pb = ProcessTools.createTestJvm(
- "-XX:StartFlightRecording=name=TestStartDuration,duration=" + duration, TestValues.class.getName(),
+ "-XX:StartFlightRecording:name=TestStartDuration,duration=" + duration, TestValues.class.getName(),
durationString.toString(), wait ? "wait" : "");
OutputAnalyzer out = ProcessTools.executeProcess(pb);
@@ -64,7 +64,7 @@ public class TestStartDuration {
private static void testDurationJavaVersion(String duration, boolean inRange) throws Exception {
ProcessBuilder pb = ProcessTools.createTestJvm(
- "-XX:StartFlightRecording=name=TestStartDuration,duration=" + duration, "-version");
+ "-XX:StartFlightRecording:name=TestStartDuration,duration=" + duration, "-version");
OutputAnalyzer out = ProcessTools.executeProcess(pb);
if (inRange) {
diff --git a/test/jdk/jdk/jfr/startupargs/TestStartMaxAgeSize.java b/test/jdk/jdk/jfr/startupargs/TestStartMaxAgeSize.java
index 7a053f10aec..95a6b436ddb 100644
--- a/test/jdk/jdk/jfr/startupargs/TestStartMaxAgeSize.java
+++ b/test/jdk/jdk/jfr/startupargs/TestStartMaxAgeSize.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2021, 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
@@ -36,7 +36,7 @@ import jdk.test.lib.jfr.CommonHelper;
* @key jfr
* @requires vm.hasJFR
* @library /test/lib /test/jdk
- * @run main/othervm -XX:StartFlightRecording=name=TestStartMaxAgeSize,maxage=10s,maxsize=1000000 jdk.jfr.startupargs.TestStartMaxAgeSize
+ * @run main/othervm -XX:StartFlightRecording:name=TestStartMaxAgeSize,maxage=10s,maxsize=1000000 jdk.jfr.startupargs.TestStartMaxAgeSize
*/
public class TestStartMaxAgeSize {
diff --git a/test/jdk/jdk/jfr/startupargs/TestStartName.java b/test/jdk/jdk/jfr/startupargs/TestStartName.java
index 9ce9410f763..ddcff1eecd5 100644
--- a/test/jdk/jdk/jfr/startupargs/TestStartName.java
+++ b/test/jdk/jdk/jfr/startupargs/TestStartName.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@ public class TestStartName {
private static void testName(String recordingName, boolean validName) throws Exception {
ProcessBuilder pb = ProcessTools.createTestJvm(
- "-XX:StartFlightRecording=name=" + recordingName, TestName.class.getName(), recordingName);
+ "-XX:StartFlightRecording:name=" + recordingName, TestName.class.getName(), recordingName);
OutputAnalyzer out = ProcessTools.executeProcess(pb);
if (validName) {
diff --git a/test/jdk/jdk/jfr/startupargs/TestStartNoSettings.java b/test/jdk/jdk/jfr/startupargs/TestStartNoSettings.java
index cf48ee84899..ac5f5efa5c1 100644
--- a/test/jdk/jdk/jfr/startupargs/TestStartNoSettings.java
+++ b/test/jdk/jdk/jfr/startupargs/TestStartNoSettings.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2021, 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
@@ -36,7 +36,7 @@ import jdk.jfr.Recording;
* @requires vm.hasJFR
* @library /test/lib
* @run main/othervm jdk.jfr.startupargs.TestStartNoSettings
- * -XX:StartFlightRecording=settings=none
+ * -XX:StartFlightRecording:settings=none
*/
public class TestStartNoSettings {
@@ -61,7 +61,7 @@ public class TestStartNoSettings {
}
if (!userEnabled) {
- throw new Exception("Expected 'UserEvent' to be enabled with -XX:StartFlightRecording=settings=none");
+ throw new Exception("Expected 'UserEvent' to be enabled with -XX:StartFlightRecording:settings=none");
}
}
}
diff --git a/test/jdk/jdk/jfr/startupargs/TestStartRecording.java b/test/jdk/jdk/jfr/startupargs/TestStartRecording.java
index 2f0cd665bcf..7eb24cc8fa6 100644
--- a/test/jdk/jdk/jfr/startupargs/TestStartRecording.java
+++ b/test/jdk/jdk/jfr/startupargs/TestStartRecording.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2021, 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
@@ -36,7 +36,7 @@ import jdk.test.lib.process.OutputAnalyzer;
* @key jfr
* @requires vm.hasJFR
* @library /test/lib /test/jdk
- * @run main/othervm -XX:StartFlightRecording=name=TestStartRecording,settings=profile jdk.jfr.startupargs.TestStartRecording
+ * @run main/othervm -XX:StartFlightRecording:name=TestStartRecording,settings=profile jdk.jfr.startupargs.TestStartRecording
*/
public class TestStartRecording {
diff --git a/test/jdk/sun/security/pkcs/pkcs8/PKCS8Test.java b/test/jdk/sun/security/pkcs/pkcs8/PKCS8Test.java
index fbe09e5e307..0c715ca8581 100644
--- a/test/jdk/sun/security/pkcs/pkcs8/PKCS8Test.java
+++ b/test/jdk/sun/security/pkcs/pkcs8/PKCS8Test.java
@@ -50,7 +50,7 @@ import sun.security.util.DerValue;
public class PKCS8Test {
static final String FORMAT = "PKCS#8";
- static final String EXPECTED_ALG_ID_CHRS = "DSA\n" +
+ static final String EXPECTED_ALG_ID_CHRS = "DSA, \n" +
"\tp: 02\n\tq: 03\n\tg: 04\n";
static final String ALGORITHM = "DSA";
@@ -79,10 +79,10 @@ public class PKCS8Test {
PKCS8Key decodedKey = (PKCS8Key)PKCS8Key.parseKey(
new DerValue(encodedKey));
- Assert.assertEquals(ALGORITHM, decodedKey.getAlgorithm());
- Assert.assertEquals(FORMAT, decodedKey.getFormat());
- Assert.assertEquals(EXPECTED_ALG_ID_CHRS,
- decodedKey.getAlgorithmId().toString());
+ Assert.assertEquals(decodedKey.getAlgorithm(), ALGORITHM);
+ Assert.assertEquals(decodedKey.getFormat(), FORMAT);
+ Assert.assertEquals(decodedKey.getAlgorithmId().toString(),
+ EXPECTED_ALG_ID_CHRS);
byte[] encodedOutput = decodedKey.getEncoded();
Assert.assertTrue(Arrays.equals(encodedOutput, EXPECTED),
diff --git a/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java b/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java
index 9bfab8494f9..0063db82e0e 100644
--- a/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java
+++ b/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java
@@ -318,7 +318,7 @@ public class TimestampCheck {
sign("tsdisabled", "-digestalg", "MD5",
"-sigalg", "MD5withRSA", "-tsadigestalg", "MD5")
.shouldHaveExitValue(68)
- .shouldContain("The timestamp is invalid. Without a valid timestamp")
+ .shouldContain("TSA certificate chain is invalid")
.shouldMatch("MD5.*-digestalg.*is disabled")
.shouldMatch("MD5.*-tsadigestalg.*is disabled")
.shouldMatch("MD5withRSA.*-sigalg.*is disabled");
@@ -326,7 +326,6 @@ public class TimestampCheck {
signVerbose("tsdisabled", "unsigned.jar", "tsdisabled2.jar", "signer")
.shouldHaveExitValue(64)
- .shouldContain("The timestamp is invalid. Without a valid timestamp")
.shouldContain("TSA certificate chain is invalid");
// Disabled timestamp is an error and jar treated unsigned
@@ -658,7 +657,7 @@ public class TimestampCheck {
.shouldMatch("Timestamp signature algorithm: .*key.*(disabled)");
verify(file, "-J-Djava.security.debug=jar")
.shouldHaveExitValue(16)
- .shouldMatch("SignatureException:.*disabled");
+ .shouldMatch("SignatureException:.*keysize");
// For 8171319: keytool should print out warnings when reading or
// generating cert/cert req using disabled algorithms.
diff --git a/test/jdk/sun/security/x509/AlgorithmId/AlgorithmIdEqualsHashCode.java b/test/jdk/sun/security/x509/AlgorithmId/AlgorithmIdEqualsHashCode.java
index f9387f626c7..ff91e3dff81 100644
--- a/test/jdk/sun/security/x509/AlgorithmId/AlgorithmIdEqualsHashCode.java
+++ b/test/jdk/sun/security/x509/AlgorithmId/AlgorithmIdEqualsHashCode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,13 +24,17 @@
/*
* @test
* @author Gary Ellison
- * @bug 4170635
+ * @bug 4170635 8258247
* @summary Verify equals()/hashCode() contract honored
- * @modules java.base/sun.security.x509
+ * @modules java.base/sun.security.x509 java.base/sun.security.util
*/
import java.io.*;
+import java.security.AlgorithmParameters;
+import java.security.spec.MGF1ParameterSpec;
+import java.security.spec.PSSParameterSpec;
+import sun.security.util.DerValue;
import sun.security.x509.*;
public class AlgorithmIdEqualsHashCode {
@@ -41,7 +45,6 @@ public class AlgorithmIdEqualsHashCode {
AlgorithmId ai2 = AlgorithmId.get("DH");
AlgorithmId ai3 = AlgorithmId.get("DH");
-
// supposedly transitivity is broken
// System.out.println(ai1.equals(ai2));
// System.out.println(ai2.equals(ai3));
@@ -57,5 +60,42 @@ public class AlgorithmIdEqualsHashCode {
else
throw new Exception("Failed equals()/hashCode() contract");
+ // check that AlgorithmIds with same name but different params
+ // are not equal
+ AlgorithmParameters algParams1 =
+ AlgorithmParameters.getInstance("RSASSA-PSS");
+ AlgorithmParameters algParams2 =
+ AlgorithmParameters.getInstance("RSASSA-PSS");
+ algParams1.init(new PSSParameterSpec("SHA-1", "MGF1",
+ MGF1ParameterSpec.SHA1, 20, PSSParameterSpec.TRAILER_FIELD_BC));
+ algParams2.init(new PSSParameterSpec("SHA-256", "MGF1",
+ MGF1ParameterSpec.SHA1, 20, PSSParameterSpec.TRAILER_FIELD_BC));
+ ai1 = new AlgorithmId(AlgorithmId.RSASSA_PSS_oid, algParams1);
+ ai2 = new AlgorithmId(AlgorithmId.RSASSA_PSS_oid, algParams2);
+ if (ai1.equals(ai2)) {
+ throw new Exception("Failed equals() contract");
+ } else {
+ System.out.println("PASSED equals() test");
+ }
+
+ // check that two AlgorithmIds created with the same parameters but
+ // one with DER encoded parameters and the other with
+ // AlgorithmParameters are equal
+ byte[] encoded = ai1.encode();
+ ai3 = AlgorithmId.parse(new DerValue(encoded));
+ if (!ai1.equals(ai3)) {
+ throw new Exception("Failed equals() contract");
+ } else {
+ System.out.println("PASSED equals() test");
+ }
+
+ // check that two AlgorithmIds created with different parameters but
+ // one with DER encoded parameters and the other with
+ // AlgorithmParameters are not equal
+ if (ai2.equals(ai3)) {
+ throw new Exception("Failed equals() contract");
+ } else {
+ System.out.println("PASSED equals() test");
+ }
}
}