1787 lines
72 KiB
Diff
1787 lines
72 KiB
Diff
|
|
From b3dd0f06b1d27afc1bf547605c856952e4392a08 Mon Sep 17 00:00:00 2001
|
||
|
|
Date: Thu, 18 Jan 2024 14:57:37 +0800
|
||
|
|
Subject: [PATCH] puyuan: jdk17.0.9 patch
|
||
|
|
|
||
|
|
---
|
||
|
|
src/hotspot/cpu/x86/x86_32.ad | 24 +--
|
||
|
|
src/hotspot/share/classfile/stringTable.hpp | 8 +-
|
||
|
|
.../share/gc/shenandoah/shenandoahFullGC.cpp | 3 +
|
||
|
|
src/hotspot/share/opto/compile.cpp | 2 +-
|
||
|
|
src/hotspot/share/runtime/arguments.cpp | 1 -
|
||
|
|
.../share/classes/java/util/zip/ZipFile.java | 18 ++-
|
||
|
|
.../classes/sun/security/pkcs/PKCS7.java | 4 +-
|
||
|
|
.../classes/java/io/WinNTFileSystem.java | 31 ++++
|
||
|
|
.../PLATFORM_API_WinOS_DirectSound.cpp | 26 +++-
|
||
|
|
.../javax/xml/stream/XMLStreamException.java | 2 +-
|
||
|
|
.../TestArrayAllocatorMallocLimit.java | 4 +-
|
||
|
|
.../CommandLine/UnrecognizedProperty.java | 45 ++++++
|
||
|
|
.../ExceptionCauseTest.java | 62 ++++++++
|
||
|
|
test/jdk/java/io/File/GetAbsolutePath.java | 114 ++++++++------
|
||
|
|
test/jdk/java/io/File/GetCanonicalPath.java | 82 ++++++++--
|
||
|
|
test/jdk/java/io/File/IsAbsolute.java | 58 +++----
|
||
|
|
test/jdk/java/io/File/WindowsPrefixes.java | 97 ++++++++++++
|
||
|
|
.../Lines/OpenLineAfterScreenLock.java | 144 ++++++++++++++++++
|
||
|
|
.../pkcs11/MessageDigest/TestCloning.java | 25 ++-
|
||
|
|
test/jdk/sun/security/pkcs11/PSSUtil.java | 84 ++++++++++
|
||
|
|
.../Signature/KeyAndParamCheckForPSS.java | 104 +++++++------
|
||
|
|
.../pkcs11/Signature/SignatureTestPSS.java | 110 ++++++-------
|
||
|
|
.../x509/X509CRLImpl/UnexpectedNPE.java | 63 +++-----
|
||
|
|
23 files changed, 842 insertions(+), 269 deletions(-)
|
||
|
|
create mode 100644 test/hotspot/jtreg/runtime/CommandLine/UnrecognizedProperty.java
|
||
|
|
create mode 100644 test/jaxp/javax/xml/jaxp/unittest/stream/XMLStreamExceptionTest/ExceptionCauseTest.java
|
||
|
|
create mode 100644 test/jdk/java/io/File/WindowsPrefixes.java
|
||
|
|
create mode 100644 test/jdk/javax/sound/sampled/Lines/OpenLineAfterScreenLock.java
|
||
|
|
create mode 100644 test/jdk/sun/security/pkcs11/PSSUtil.java
|
||
|
|
|
||
|
|
diff --git a/src/hotspot/cpu/x86/x86_32.ad b/src/hotspot/cpu/x86/x86_32.ad
|
||
|
|
index 01005c730..e7ab73b77 100644
|
||
|
|
--- a/src/hotspot/cpu/x86/x86_32.ad
|
||
|
|
+++ b/src/hotspot/cpu/x86/x86_32.ad
|
||
|
|
@@ -13150,7 +13150,7 @@ instruct cmovPP_reg_LTGE(cmpOp cmp, flagsReg_long_LTGE flags, eRegP dst, eRegP s
|
||
|
|
|
||
|
|
// Compare 2 longs and CMOVE doubles
|
||
|
|
instruct cmovDDPR_reg_LTGE(cmpOp cmp, flagsReg_long_LTGE flags, regDPR dst, regDPR src) %{
|
||
|
|
- predicate( UseSSE<=1 && _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::lt || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ge );
|
||
|
|
+ predicate( UseSSE<=1 && ( _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::lt || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ge ) );
|
||
|
|
match(Set dst (CMoveD (Binary cmp flags) (Binary dst src)));
|
||
|
|
ins_cost(200);
|
||
|
|
expand %{
|
||
|
|
@@ -13160,7 +13160,7 @@ instruct cmovDDPR_reg_LTGE(cmpOp cmp, flagsReg_long_LTGE flags, regDPR dst, regD
|
||
|
|
|
||
|
|
// Compare 2 longs and CMOVE doubles
|
||
|
|
instruct cmovDD_reg_LTGE(cmpOp cmp, flagsReg_long_LTGE flags, regD dst, regD src) %{
|
||
|
|
- predicate( UseSSE>=2 && _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::lt || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ge );
|
||
|
|
+ predicate( UseSSE>=2 && ( _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::lt || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ge ) );
|
||
|
|
match(Set dst (CMoveD (Binary cmp flags) (Binary dst src)));
|
||
|
|
ins_cost(200);
|
||
|
|
expand %{
|
||
|
|
@@ -13169,7 +13169,7 @@ instruct cmovDD_reg_LTGE(cmpOp cmp, flagsReg_long_LTGE flags, regD dst, regD src
|
||
|
|
%}
|
||
|
|
|
||
|
|
instruct cmovFFPR_reg_LTGE(cmpOp cmp, flagsReg_long_LTGE flags, regFPR dst, regFPR src) %{
|
||
|
|
- predicate( UseSSE==0 && _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::lt || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ge );
|
||
|
|
+ predicate( UseSSE==0 && ( _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::lt || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ge ) );
|
||
|
|
match(Set dst (CMoveF (Binary cmp flags) (Binary dst src)));
|
||
|
|
ins_cost(200);
|
||
|
|
expand %{
|
||
|
|
@@ -13178,7 +13178,7 @@ instruct cmovFFPR_reg_LTGE(cmpOp cmp, flagsReg_long_LTGE flags, regFPR dst, regF
|
||
|
|
%}
|
||
|
|
|
||
|
|
instruct cmovFF_reg_LTGE(cmpOp cmp, flagsReg_long_LTGE flags, regF dst, regF src) %{
|
||
|
|
- predicate( UseSSE>=1 && _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::lt || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ge );
|
||
|
|
+ predicate( UseSSE>=1 && ( _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::lt || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ge ) );
|
||
|
|
match(Set dst (CMoveF (Binary cmp flags) (Binary dst src)));
|
||
|
|
ins_cost(200);
|
||
|
|
expand %{
|
||
|
|
@@ -13313,7 +13313,7 @@ instruct cmovPP_reg_EQNE(cmpOp cmp, flagsReg_long_EQNE flags, eRegP dst, eRegP s
|
||
|
|
|
||
|
|
// Compare 2 longs and CMOVE doubles
|
||
|
|
instruct cmovDDPR_reg_EQNE(cmpOp cmp, flagsReg_long_EQNE flags, regDPR dst, regDPR src) %{
|
||
|
|
- predicate( UseSSE<=1 && _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::eq || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ne );
|
||
|
|
+ predicate( UseSSE<=1 && ( _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::eq || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ne ) );
|
||
|
|
match(Set dst (CMoveD (Binary cmp flags) (Binary dst src)));
|
||
|
|
ins_cost(200);
|
||
|
|
expand %{
|
||
|
|
@@ -13323,7 +13323,7 @@ instruct cmovDDPR_reg_EQNE(cmpOp cmp, flagsReg_long_EQNE flags, regDPR dst, regD
|
||
|
|
|
||
|
|
// Compare 2 longs and CMOVE doubles
|
||
|
|
instruct cmovDD_reg_EQNE(cmpOp cmp, flagsReg_long_EQNE flags, regD dst, regD src) %{
|
||
|
|
- predicate( UseSSE>=2 && _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::eq || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ne );
|
||
|
|
+ predicate( UseSSE>=2 && ( _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::eq || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ne ) );
|
||
|
|
match(Set dst (CMoveD (Binary cmp flags) (Binary dst src)));
|
||
|
|
ins_cost(200);
|
||
|
|
expand %{
|
||
|
|
@@ -13332,7 +13332,7 @@ instruct cmovDD_reg_EQNE(cmpOp cmp, flagsReg_long_EQNE flags, regD dst, regD src
|
||
|
|
%}
|
||
|
|
|
||
|
|
instruct cmovFFPR_reg_EQNE(cmpOp cmp, flagsReg_long_EQNE flags, regFPR dst, regFPR src) %{
|
||
|
|
- predicate( UseSSE==0 && _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::eq || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ne );
|
||
|
|
+ predicate( UseSSE==0 && ( _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::eq || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ne ) );
|
||
|
|
match(Set dst (CMoveF (Binary cmp flags) (Binary dst src)));
|
||
|
|
ins_cost(200);
|
||
|
|
expand %{
|
||
|
|
@@ -13341,7 +13341,7 @@ instruct cmovFFPR_reg_EQNE(cmpOp cmp, flagsReg_long_EQNE flags, regFPR dst, regF
|
||
|
|
%}
|
||
|
|
|
||
|
|
instruct cmovFF_reg_EQNE(cmpOp cmp, flagsReg_long_EQNE flags, regF dst, regF src) %{
|
||
|
|
- predicate( UseSSE>=1 && _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::eq || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ne );
|
||
|
|
+ predicate( UseSSE>=1 && ( _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::eq || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ne ) );
|
||
|
|
match(Set dst (CMoveF (Binary cmp flags) (Binary dst src)));
|
||
|
|
ins_cost(200);
|
||
|
|
expand %{
|
||
|
|
@@ -13508,7 +13508,7 @@ instruct cmovPP_reg_LEGT(cmpOp_commute cmp, flagsReg_long_LEGT flags, eRegP dst,
|
||
|
|
|
||
|
|
// Compare 2 longs and CMOVE doubles
|
||
|
|
instruct cmovDDPR_reg_LEGT(cmpOp_commute cmp, flagsReg_long_LEGT flags, regDPR dst, regDPR src) %{
|
||
|
|
- predicate( UseSSE<=1 && _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::le || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::gt );
|
||
|
|
+ predicate( UseSSE<=1 && ( _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::le || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::gt ) );
|
||
|
|
match(Set dst (CMoveD (Binary cmp flags) (Binary dst src)));
|
||
|
|
ins_cost(200);
|
||
|
|
expand %{
|
||
|
|
@@ -13518,7 +13518,7 @@ instruct cmovDDPR_reg_LEGT(cmpOp_commute cmp, flagsReg_long_LEGT flags, regDPR d
|
||
|
|
|
||
|
|
// Compare 2 longs and CMOVE doubles
|
||
|
|
instruct cmovDD_reg_LEGT(cmpOp_commute cmp, flagsReg_long_LEGT flags, regD dst, regD src) %{
|
||
|
|
- predicate( UseSSE>=2 && _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::le || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::gt );
|
||
|
|
+ predicate( UseSSE>=2 && ( _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::le || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::gt ) );
|
||
|
|
match(Set dst (CMoveD (Binary cmp flags) (Binary dst src)));
|
||
|
|
ins_cost(200);
|
||
|
|
expand %{
|
||
|
|
@@ -13527,7 +13527,7 @@ instruct cmovDD_reg_LEGT(cmpOp_commute cmp, flagsReg_long_LEGT flags, regD dst,
|
||
|
|
%}
|
||
|
|
|
||
|
|
instruct cmovFFPR_reg_LEGT(cmpOp_commute cmp, flagsReg_long_LEGT flags, regFPR dst, regFPR src) %{
|
||
|
|
- predicate( UseSSE==0 && _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::le || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::gt );
|
||
|
|
+ predicate( UseSSE==0 && ( _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::le || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::gt ) );
|
||
|
|
match(Set dst (CMoveF (Binary cmp flags) (Binary dst src)));
|
||
|
|
ins_cost(200);
|
||
|
|
expand %{
|
||
|
|
@@ -13537,7 +13537,7 @@ instruct cmovFFPR_reg_LEGT(cmpOp_commute cmp, flagsReg_long_LEGT flags, regFPR d
|
||
|
|
|
||
|
|
|
||
|
|
instruct cmovFF_reg_LEGT(cmpOp_commute cmp, flagsReg_long_LEGT flags, regF dst, regF src) %{
|
||
|
|
- predicate( UseSSE>=1 && _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::le || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::gt );
|
||
|
|
+ predicate( UseSSE>=1 && ( _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::le || _kids[0]->_kids[0]->_leaf->as_Bool()->_test._test == BoolTest::gt ) );
|
||
|
|
match(Set dst (CMoveF (Binary cmp flags) (Binary dst src)));
|
||
|
|
ins_cost(200);
|
||
|
|
expand %{
|
||
|
|
diff --git a/src/hotspot/share/classfile/stringTable.hpp b/src/hotspot/share/classfile/stringTable.hpp
|
||
|
|
index 6c6ded24c..823aa6975 100644
|
||
|
|
--- a/src/hotspot/share/classfile/stringTable.hpp
|
||
|
|
+++ b/src/hotspot/share/classfile/stringTable.hpp
|
||
|
|
@@ -25,7 +25,7 @@
|
||
|
|
#ifndef SHARE_CLASSFILE_STRINGTABLE_HPP
|
||
|
|
#define SHARE_CLASSFILE_STRINGTABLE_HPP
|
||
|
|
|
||
|
|
-#include "memory/allocation.hpp"
|
||
|
|
+#include "memory/allStatic.hpp"
|
||
|
|
#include "memory/padded.hpp"
|
||
|
|
#include "oops/oop.hpp"
|
||
|
|
#include "oops/weakHandle.hpp"
|
||
|
|
@@ -36,15 +36,11 @@ class DumpedInternedStrings;
|
||
|
|
class JavaThread;
|
||
|
|
class SerializeClosure;
|
||
|
|
|
||
|
|
-class StringTable;
|
||
|
|
class StringTableConfig;
|
||
|
|
-class StringTableCreateEntry;
|
||
|
|
|
||
|
|
-class StringTable : public CHeapObj<mtSymbol>{
|
||
|
|
+class StringTable : AllStatic {
|
||
|
|
friend class VMStructs;
|
||
|
|
- friend class Symbol;
|
||
|
|
friend class StringTableConfig;
|
||
|
|
- friend class StringTableCreateEntry;
|
||
|
|
|
||
|
|
static volatile bool _has_work;
|
||
|
|
|
||
|
|
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp
|
||
|
|
index 26c31356f..5e0b3ebdb 100644
|
||
|
|
--- a/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp
|
||
|
|
+++ b/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp
|
||
|
|
@@ -908,6 +908,9 @@ public:
|
||
|
|
// Make empty regions that have been allocated into regular
|
||
|
|
if (r->is_empty() && live > 0) {
|
||
|
|
r->make_regular_bypass();
|
||
|
|
+ if (ZapUnusedHeapArea) {
|
||
|
|
+ SpaceMangler::mangle_region(MemRegion(r->top(), r->end()));
|
||
|
|
+ }
|
||
|
|
}
|
||
|
|
|
||
|
|
// Reclaim regular regions that became empty
|
||
|
|
diff --git a/src/hotspot/share/opto/compile.cpp b/src/hotspot/share/opto/compile.cpp
|
||
|
|
index 4b22284f9..56471d69a 100644
|
||
|
|
--- a/src/hotspot/share/opto/compile.cpp
|
||
|
|
+++ b/src/hotspot/share/opto/compile.cpp
|
||
|
|
@@ -775,7 +775,7 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci,
|
||
|
|
// If any phase is randomized for stress testing, seed random number
|
||
|
|
// generation and log the seed for repeatability.
|
||
|
|
if (StressLCM || StressGCM || StressIGVN || StressCCP) {
|
||
|
|
- if (FLAG_IS_DEFAULT(StressSeed) || (FLAG_IS_ERGO(StressSeed) && RepeatCompilation)) {
|
||
|
|
+ if (FLAG_IS_DEFAULT(StressSeed) || (FLAG_IS_ERGO(StressSeed) && directive->RepeatCompilationOption)) {
|
||
|
|
_stress_seed = static_cast<uint>(Ticks::now().nanoseconds());
|
||
|
|
FLAG_SET_ERGO(StressSeed, _stress_seed);
|
||
|
|
} else {
|
||
|
|
diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp
|
||
|
|
index 5683e4fe0..60f639795 100644
|
||
|
|
--- a/src/hotspot/share/runtime/arguments.cpp
|
||
|
|
+++ b/src/hotspot/share/runtime/arguments.cpp
|
||
|
|
@@ -339,7 +339,6 @@ static bool matches_property_suffix(const char* option, const char* property, si
|
||
|
|
// any of the reserved module properties.
|
||
|
|
// property should be passed without the leading "-D".
|
||
|
|
bool Arguments::is_internal_module_property(const char* property) {
|
||
|
|
- assert((strncmp(property, "-D", 2) != 0), "Unexpected leading -D");
|
||
|
|
if (strncmp(property, MODULE_PROPERTY_PREFIX, MODULE_PROPERTY_PREFIX_LEN) == 0) {
|
||
|
|
const char* property_suffix = property + MODULE_PROPERTY_PREFIX_LEN;
|
||
|
|
if (matches_property_suffix(property_suffix, ADDEXPORTS, ADDEXPORTS_LEN) ||
|
||
|
|
diff --git a/src/java.base/share/classes/java/util/zip/ZipFile.java b/src/java.base/share/classes/java/util/zip/ZipFile.java
|
||
|
|
index d47a1d260..7e16e6a67 100644
|
||
|
|
--- a/src/java.base/share/classes/java/util/zip/ZipFile.java
|
||
|
|
+++ b/src/java.base/share/classes/java/util/zip/ZipFile.java
|
||
|
|
@@ -95,8 +95,9 @@ import static java.util.zip.ZipUtils.*;
|
||
|
|
* @since 1.1
|
||
|
|
*/
|
||
|
|
public class ZipFile implements ZipConstants, Closeable {
|
||
|
|
-
|
||
|
|
- private final String name; // zip file name
|
||
|
|
+
|
||
|
|
+ private final String filePath; // zip file path
|
||
|
|
+ private final String fileName; // name of the file
|
||
|
|
private volatile boolean closeRequested;
|
||
|
|
|
||
|
|
// The "resource" used by this zip file that needs to be
|
||
|
|
@@ -246,7 +247,8 @@ public class ZipFile implements ZipConstants, Closeable {
|
||
|
|
}
|
||
|
|
Objects.requireNonNull(charset, "charset");
|
||
|
|
|
||
|
|
- this.name = name;
|
||
|
|
+ this.filePath = name;
|
||
|
|
+ this.fileName = file.getName();
|
||
|
|
long t0 = System.nanoTime();
|
||
|
|
|
||
|
|
this.res = new CleanableResource(this, ZipCoder.get(charset), file, mode);
|
||
|
|
@@ -477,8 +479,16 @@ public class ZipFile implements ZipConstants, Closeable {
|
||
|
|
* @return the path name of the ZIP file
|
||
|
|
*/
|
||
|
|
public String getName() {
|
||
|
|
- return name;
|
||
|
|
+ return filePath;
|
||
|
|
}
|
||
|
|
+
|
||
|
|
+ /**
|
||
|
|
+ * {@return a string identifying this {@code ZipFile}, for debugging}
|
||
|
|
+ */
|
||
|
|
+ @Override
|
||
|
|
+ public String toString() {
|
||
|
|
+ return this.fileName+ "@" + Integer.toHexString(System.identityHashCode(this));
|
||
|
|
+ }
|
||
|
|
|
||
|
|
private class ZipEntryIterator<T extends ZipEntry>
|
||
|
|
implements Enumeration<T>, Iterator<T> {
|
||
|
|
diff --git a/src/java.base/share/classes/sun/security/pkcs/PKCS7.java b/src/java.base/share/classes/sun/security/pkcs/PKCS7.java
|
||
|
|
index f7df9934f..44df67ec0 100644
|
||
|
|
--- a/src/java.base/share/classes/sun/security/pkcs/PKCS7.java
|
||
|
|
+++ b/src/java.base/share/classes/sun/security/pkcs/PKCS7.java
|
||
|
|
@@ -153,7 +153,9 @@ public class PKCS7 {
|
||
|
|
ContentInfo block = new ContentInfo(derin, oldStyle);
|
||
|
|
contentType = block.contentType;
|
||
|
|
DerValue content = block.getContent();
|
||
|
|
-
|
||
|
|
+ if (content == null) {
|
||
|
|
+ throw new ParsingException("content is null");
|
||
|
|
+ }
|
||
|
|
if (contentType.equals(ContentInfo.SIGNED_DATA_OID)) {
|
||
|
|
parseSignedData(content);
|
||
|
|
} else if (contentType.equals(ContentInfo.OLD_SIGNED_DATA_OID)) {
|
||
|
|
diff --git a/src/java.base/windows/classes/java/io/WinNTFileSystem.java b/src/java.base/windows/classes/java/io/WinNTFileSystem.java
|
||
|
|
index 0fabd6f2b..d910beb44 100644
|
||
|
|
--- a/src/java.base/windows/classes/java/io/WinNTFileSystem.java
|
||
|
|
+++ b/src/java.base/windows/classes/java/io/WinNTFileSystem.java
|
||
|
|
@@ -41,6 +41,8 @@ import sun.security.action.GetPropertyAction;
|
||
|
|
*/
|
||
|
|
class WinNTFileSystem extends FileSystem {
|
||
|
|
|
||
|
|
+ private static final String LONG_PATH_PREFIX = "\\\\?\\";
|
||
|
|
+
|
||
|
|
private final char slash;
|
||
|
|
private final char altSlash;
|
||
|
|
private final char semicolon;
|
||
|
|
@@ -59,6 +61,23 @@ class WinNTFileSystem extends FileSystem {
|
||
|
|
ENABLE_ADS = true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
+ // Strip a long path or UNC prefix and return the result.
|
||
|
|
+ // If there is no such prefix, return the parameter passed in.
|
||
|
|
+ private static String stripLongOrUNCPrefix(String path) {
|
||
|
|
+ // if a prefix is present, remove it
|
||
|
|
+ if (path.startsWith(LONG_PATH_PREFIX)) {
|
||
|
|
+ if (path.startsWith("UNC\\", 4)) {
|
||
|
|
+ path = "\\\\" + path.substring(8);
|
||
|
|
+ } else {
|
||
|
|
+ path = path.substring(4);
|
||
|
|
+ // if only "UNC" remains, a trailing "\\" was likely removed
|
||
|
|
+ if (path.equals("UNC")) {
|
||
|
|
+ path = "\\\\";
|
||
|
|
+ }
|
||
|
|
+ }
|
||
|
|
+ }
|
||
|
|
+ return path;
|
||
|
|
+ }
|
||
|
|
|
||
|
|
public WinNTFileSystem() {
|
||
|
|
Properties props = GetPropertyAction.privilegedGetProperties();
|
||
|
|
@@ -100,6 +119,7 @@ class WinNTFileSystem extends FileSystem {
|
||
|
|
This way we iterate through the whole pathname string only once. */
|
||
|
|
@Override
|
||
|
|
public String normalize(String path) {
|
||
|
|
+ path = stripLongOrUNCPrefix(path);
|
||
|
|
int n = path.length();
|
||
|
|
char slash = this.slash;
|
||
|
|
char altSlash = this.altSlash;
|
||
|
|
@@ -225,6 +245,8 @@ class WinNTFileSystem extends FileSystem {
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public int prefixLength(String path) {
|
||
|
|
+ assert !path.startsWith(LONG_PATH_PREFIX);
|
||
|
|
+
|
||
|
|
char slash = this.slash;
|
||
|
|
int n = path.length();
|
||
|
|
if (n == 0) return 0;
|
||
|
|
@@ -244,6 +266,8 @@ class WinNTFileSystem extends FileSystem {
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public String resolve(String parent, String child) {
|
||
|
|
+ assert !child.startsWith(LONG_PATH_PREFIX);
|
||
|
|
+
|
||
|
|
int pn = parent.length();
|
||
|
|
if (pn == 0) return child;
|
||
|
|
int cn = child.length();
|
||
|
|
@@ -315,6 +339,9 @@ class WinNTFileSystem extends FileSystem {
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public boolean isAbsolute(File f) {
|
||
|
|
+ String path = f.getPath();
|
||
|
|
+ assert !path.startsWith(LONG_PATH_PREFIX);
|
||
|
|
+
|
||
|
|
int pl = f.getPrefixLength();
|
||
|
|
return (((pl == 2) && (f.getPath().charAt(0) == slash))
|
||
|
|
|| (pl == 3));
|
||
|
|
@@ -353,6 +380,8 @@ class WinNTFileSystem extends FileSystem {
|
||
|
|
@Override
|
||
|
|
public String resolve(File f) {
|
||
|
|
String path = f.getPath();
|
||
|
|
+ assert !path.startsWith(LONG_PATH_PREFIX);
|
||
|
|
+
|
||
|
|
int pl = f.getPrefixLength();
|
||
|
|
if ((pl == 2) && (path.charAt(0) == slash))
|
||
|
|
return path; /* UNC */
|
||
|
|
@@ -440,6 +469,8 @@ class WinNTFileSystem extends FileSystem {
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public String canonicalize(String path) throws IOException {
|
||
|
|
+ assert !path.startsWith(LONG_PATH_PREFIX);
|
||
|
|
+
|
||
|
|
// If path is a drive letter only then skip canonicalization
|
||
|
|
int len = path.length();
|
||
|
|
if ((len == 2) &&
|
||
|
|
diff --git a/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_DirectSound.cpp b/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_DirectSound.cpp
|
||
|
|
index ea188e934..8585eda01 100644
|
||
|
|
--- a/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_DirectSound.cpp
|
||
|
|
+++ b/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_DirectSound.cpp
|
||
|
|
@@ -1,5 +1,5 @@
|
||
|
|
/*
|
||
|
|
- * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
+ * Copyright (c) 2003, 2023, 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
|
||
|
|
@@ -184,6 +184,12 @@ INT32 DAUDIO_GetDirectAudioDeviceCount() {
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
+ HRESULT hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE);
|
||
|
|
+ if (FAILED(hr) && hr != RPC_E_CHANGED_MODE) {
|
||
|
|
+ DS_unlockCache();
|
||
|
|
+ return 0;
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
if (g_lastCacheRefreshTime == 0
|
||
|
|
|| (UINT64) timeGetTime() > (UINT64) (g_lastCacheRefreshTime + WAIT_BETWEEN_CACHE_REFRESH_MILLIS)) {
|
||
|
|
/* first, initialize any old cache items */
|
||
|
|
@@ -224,6 +230,11 @@ INT32 DAUDIO_GetDirectAudioDeviceCount() {
|
||
|
|
|
||
|
|
g_lastCacheRefreshTime = (UINT64) timeGetTime();
|
||
|
|
}
|
||
|
|
+
|
||
|
|
+ if (hr != RPC_E_CHANGED_MODE) {
|
||
|
|
+ ::CoUninitialize();
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
DS_unlockCache();
|
||
|
|
/*TRACE1("DirectSound: %d installed devices\n", g_mixerCount);*/
|
||
|
|
return g_mixerCount;
|
||
|
|
@@ -258,6 +269,13 @@ INT32 DAUDIO_GetDirectAudioDeviceDescription(INT32 mixerIndex, DirectAudioDevice
|
||
|
|
DS_unlockCache();
|
||
|
|
return FALSE;
|
||
|
|
}
|
||
|
|
+
|
||
|
|
+ HRESULT hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE);
|
||
|
|
+ if (FAILED(hr) && hr != RPC_E_CHANGED_MODE) {
|
||
|
|
+ DS_unlockCache();
|
||
|
|
+ return 0;
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
desc->maxSimulLines = 0;
|
||
|
|
if (g_audioDeviceCache[desc->deviceID].isSource) {
|
||
|
|
DirectSoundEnumerateW((LPDSENUMCALLBACKW) DS_GetDescEnum, desc);
|
||
|
|
@@ -267,6 +285,10 @@ INT32 DAUDIO_GetDirectAudioDeviceDescription(INT32 mixerIndex, DirectAudioDevice
|
||
|
|
strncpy(desc->description, "DirectSound Capture", DAUDIO_STRING_LENGTH);
|
||
|
|
}
|
||
|
|
|
||
|
|
+ if (hr != RPC_E_CHANGED_MODE) {
|
||
|
|
+ ::CoUninitialize();
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
/*desc->vendor;
|
||
|
|
desc->version;*/
|
||
|
|
|
||
|
|
@@ -357,7 +379,7 @@ typedef struct {
|
||
|
|
} DS_Info;
|
||
|
|
|
||
|
|
|
||
|
|
-LPCSTR TranslateDSError(HRESULT hr) {
|
||
|
|
+LPSTR TranslateDSError(HRESULT hr) {
|
||
|
|
switch(hr) {
|
||
|
|
case DSERR_ALLOCATED:
|
||
|
|
return "DSERR_ALLOCATED";
|
||
|
|
diff --git a/src/java.xml/share/classes/javax/xml/stream/XMLStreamException.java b/src/java.xml/share/classes/javax/xml/stream/XMLStreamException.java
|
||
|
|
index 5a229ed1e..ec9734d7c 100644
|
||
|
|
--- a/src/java.xml/share/classes/javax/xml/stream/XMLStreamException.java
|
||
|
|
+++ b/src/java.xml/share/classes/javax/xml/stream/XMLStreamException.java
|
||
|
|
@@ -94,7 +94,7 @@ public class XMLStreamException extends Exception {
|
||
|
|
public XMLStreamException(String msg, Location location, Throwable th) {
|
||
|
|
super("ParseError at [row,col]:["+location.getLineNumber()+","+
|
||
|
|
location.getColumnNumber()+"]\n"+
|
||
|
|
- "Message: "+msg);
|
||
|
|
+ "Message: "+msg, th);
|
||
|
|
nested = th;
|
||
|
|
this.location = location;
|
||
|
|
}
|
||
|
|
diff --git a/test/hotspot/jtreg/gc/arguments/TestArrayAllocatorMallocLimit.java b/test/hotspot/jtreg/gc/arguments/TestArrayAllocatorMallocLimit.java
|
||
|
|
index ca4d2d5d7..b66a43d85 100644
|
||
|
|
--- a/test/hotspot/jtreg/gc/arguments/TestArrayAllocatorMallocLimit.java
|
||
|
|
+++ b/test/hotspot/jtreg/gc/arguments/TestArrayAllocatorMallocLimit.java
|
||
|
|
@@ -1,5 +1,5 @@
|
||
|
|
/*
|
||
|
|
- * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
+ * Copyright (c) 2014, 2023, 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,7 +52,7 @@ public class TestArrayAllocatorMallocLimit {
|
||
|
|
private static final String printFlagsFinalPattern = " *size_t *" + flagName + " *:?= *(\\d+) *\\{experimental\\} *";
|
||
|
|
|
||
|
|
public static void testDefaultValue() throws Exception {
|
||
|
|
- ProcessBuilder pb = GCArguments.createJavaProcessBuilder(
|
||
|
|
+ ProcessBuilder pb = GCArguments.createTestJvm(
|
||
|
|
"-XX:+UnlockExperimentalVMOptions", "-XX:+PrintFlagsFinal", "-version");
|
||
|
|
|
||
|
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||
|
|
diff --git a/test/hotspot/jtreg/runtime/CommandLine/UnrecognizedProperty.java b/test/hotspot/jtreg/runtime/CommandLine/UnrecognizedProperty.java
|
||
|
|
new file mode 100644
|
||
|
|
index 000000000..78ec54bbc
|
||
|
|
--- /dev/null
|
||
|
|
+++ b/test/hotspot/jtreg/runtime/CommandLine/UnrecognizedProperty.java
|
||
|
|
@@ -0,0 +1,45 @@
|
||
|
|
+/*
|
||
|
|
+ * Copyright (c) 2023, 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 8321479
|
||
|
|
+ * @summary VM should not crash with property "-D-D"
|
||
|
|
+ * @requires vm.flagless
|
||
|
|
+ * @library /test/lib
|
||
|
|
+ * @run driver UnrecognizedProperty
|
||
|
|
+ */
|
||
|
|
+
|
||
|
|
+import jdk.test.lib.process.ProcessTools;
|
||
|
|
+import jdk.test.lib.process.OutputAnalyzer;
|
||
|
|
+
|
||
|
|
+public class UnrecognizedProperty {
|
||
|
|
+ public static void main(String[] args) throws Exception {
|
||
|
|
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
||
|
|
+ "-D-D");
|
||
|
|
+
|
||
|
|
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||
|
|
+ output.shouldContain("Usage: java");
|
||
|
|
+ output.shouldHaveExitValue(1);
|
||
|
|
+ }
|
||
|
|
+}
|
||
|
|
\ No newline at end of file
|
||
|
|
diff --git a/test/jaxp/javax/xml/jaxp/unittest/stream/XMLStreamExceptionTest/ExceptionCauseTest.java b/test/jaxp/javax/xml/jaxp/unittest/stream/XMLStreamExceptionTest/ExceptionCauseTest.java
|
||
|
|
new file mode 100644
|
||
|
|
index 000000000..e32527621
|
||
|
|
--- /dev/null
|
||
|
|
+++ b/test/jaxp/javax/xml/jaxp/unittest/stream/XMLStreamExceptionTest/ExceptionCauseTest.java
|
||
|
|
@@ -0,0 +1,62 @@
|
||
|
|
+/*
|
||
|
|
+ * Copyright (c) 2023, 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 stream.XMLStreamExceptionTest;
|
||
|
|
+
|
||
|
|
+import java.io.IOException;
|
||
|
|
+
|
||
|
|
+import javax.xml.stream.Location;
|
||
|
|
+import javax.xml.stream.XMLStreamException;
|
||
|
|
+
|
||
|
|
+import org.testng.Assert;
|
||
|
|
+import org.testng.annotations.Listeners;
|
||
|
|
+import org.testng.annotations.Test;
|
||
|
|
+
|
||
|
|
+/*
|
||
|
|
+ * @test
|
||
|
|
+ * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
||
|
|
+ * @run testng/othervm -DrunSecMngr=true -Djava.security.manager=allow stream.XMLStreamExceptionTest.ExceptionCauseTest
|
||
|
|
+ * @run testng/othervm stream.XMLStreamExceptionTest.ExceptionCauseTest
|
||
|
|
+ * @summary Test XMLStreamException constructor initializes chained exception
|
||
|
|
+ */
|
||
|
|
+@Listeners({jaxp.library.BasePolicy.class})
|
||
|
|
+public class ExceptionCauseTest {
|
||
|
|
+
|
||
|
|
+ @Test
|
||
|
|
+ public void testExceptionCause() {
|
||
|
|
+
|
||
|
|
+ // Create exception with cause
|
||
|
|
+ Throwable cause = new Throwable("cause");
|
||
|
|
+ Location location = new Location() {
|
||
|
|
+ public int getLineNumber() { return 0; }
|
||
|
|
+ public int getColumnNumber() { return 0; }
|
||
|
|
+ public int getCharacterOffset() { return 0; }
|
||
|
|
+ public String getPublicId() { return null; }
|
||
|
|
+ public String getSystemId() { return null; }
|
||
|
|
+ };
|
||
|
|
+ XMLStreamException e = new XMLStreamException("message", location, cause);
|
||
|
|
+
|
||
|
|
+ // Verify cause
|
||
|
|
+ Assert.assertSame(e.getCause(), cause, "XMLStreamException has the wrong cause");
|
||
|
|
+ }
|
||
|
|
+}
|
||
|
|
diff --git a/test/jdk/java/io/File/GetAbsolutePath.java b/test/jdk/java/io/File/GetAbsolutePath.java
|
||
|
|
index 1f69d0b6e..ad2e1cc79 100644
|
||
|
|
--- a/test/jdk/java/io/File/GetAbsolutePath.java
|
||
|
|
+++ b/test/jdk/java/io/File/GetAbsolutePath.java
|
||
|
|
@@ -1,5 +1,5 @@
|
||
|
|
/*
|
||
|
|
- * Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
+ * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||
|
|
*
|
||
|
|
* This code is free software; you can redistribute it and/or modify it
|
||
|
|
@@ -22,74 +22,92 @@
|
||
|
|
*/
|
||
|
|
|
||
|
|
/* @test
|
||
|
|
- @bug 4131169 4109131
|
||
|
|
- @summary Basic test for getAbsolutePath method
|
||
|
|
+ * @bug 4131169 4109131 8287843
|
||
|
|
+ * @summary Basic test for getAbsolutePath method
|
||
|
|
+ * @run junit GetAbsolutePath
|
||
|
|
*/
|
||
|
|
|
||
|
|
-import java.io.*;
|
||
|
|
+import java.io.File;
|
||
|
|
+import java.io.IOException;
|
||
|
|
+import java.util.stream.Stream;
|
||
|
|
|
||
|
|
+import org.junit.jupiter.api.BeforeAll;
|
||
|
|
+import org.junit.jupiter.api.Test;
|
||
|
|
+import org.junit.jupiter.api.condition.EnabledOnOs;
|
||
|
|
+import org.junit.jupiter.api.condition.OS;
|
||
|
|
+import org.junit.jupiter.params.provider.Arguments;
|
||
|
|
+import org.junit.jupiter.params.ParameterizedTest;
|
||
|
|
+import org.junit.jupiter.params.provider.MethodSource;
|
||
|
|
+import static org.junit.jupiter.api.Assertions.*;
|
||
|
|
|
||
|
|
public class GetAbsolutePath {
|
||
|
|
|
||
|
|
- private static boolean ignoreCase = false;
|
||
|
|
+ private static final String USER_DIR = System.getProperty("user.dir");
|
||
|
|
|
||
|
|
- private static void ck(String path, String ans) throws Exception {
|
||
|
|
- File f = new File(path);
|
||
|
|
- String p = f.getAbsolutePath();
|
||
|
|
- if ((ignoreCase && p.equalsIgnoreCase(ans)) || p.equals(ans))
|
||
|
|
- System.err.println(path + " ==> " + p);
|
||
|
|
- else
|
||
|
|
- throw new Exception(path + ": expected " + ans + ", got " + p);
|
||
|
|
+ private static char driveLetter() {
|
||
|
|
+ assert System.getProperty("os.name").startsWith("Windows");
|
||
|
|
+
|
||
|
|
+ if ((USER_DIR.length() > 2) && (USER_DIR.charAt(1) == ':')
|
||
|
|
+ && (USER_DIR.charAt(2) == '\\'))
|
||
|
|
+ return USER_DIR.charAt(0);
|
||
|
|
+
|
||
|
|
+ throw new RuntimeException("Current directory has no drive");
|
||
|
|
}
|
||
|
|
|
||
|
|
- private static void testWin32() throws Exception {
|
||
|
|
- String wd = System.getProperty("user.dir");
|
||
|
|
- char d;
|
||
|
|
- if ((wd.length() > 2) && (wd.charAt(1) == ':')
|
||
|
|
- && (wd.charAt(2) == '\\'))
|
||
|
|
- d = wd.charAt(0);
|
||
|
|
- else
|
||
|
|
- throw new Exception("Current directory has no drive");
|
||
|
|
- ck("/foo/bar", d + ":\\foo\\bar");
|
||
|
|
- ck("\\foo\\bar", d + ":\\foo\\bar");
|
||
|
|
- ck("c:\\foo\\bar", "c:\\foo\\bar");
|
||
|
|
- ck("c:/foo/bar", "c:\\foo\\bar");
|
||
|
|
- ck("\\\\foo\\bar", "\\\\foo\\bar");
|
||
|
|
+ private static Stream<Arguments> windowsSource() {
|
||
|
|
+ char drive = driveLetter();
|
||
|
|
+ return Stream.of(Arguments.of("/foo/bar", drive + ":\\foo\\bar"),
|
||
|
|
+ Arguments.of("\\foo\\bar", drive + ":\\foo\\bar"),
|
||
|
|
+ Arguments.of("c:\\foo\\bar", "c:\\foo\\bar"),
|
||
|
|
+ Arguments.of("c:/foo/bar", "c:\\foo\\bar"),
|
||
|
|
+ Arguments.of("\\\\foo\\bar", "\\\\foo\\bar"),
|
||
|
|
+ Arguments.of("", USER_DIR), // empty path
|
||
|
|
+ Arguments.of("\\\\?\\foo", USER_DIR + "\\foo"),
|
||
|
|
+ Arguments.of("\\\\?\\C:\\Users\\x", "C:\\Users\\x"),
|
||
|
|
+ Arguments.of("\\\\?\\" + drive + ":", USER_DIR),
|
||
|
|
+ Arguments.of("\\\\?\\" + drive + ":bar", USER_DIR + "\\bar"));
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ @EnabledOnOs(OS.WINDOWS)
|
||
|
|
+ @ParameterizedTest
|
||
|
|
+ @MethodSource("windowsSource")
|
||
|
|
+ public void windows(String path, String absolute) throws IOException {
|
||
|
|
+ File file = new File(path);
|
||
|
|
+ assertEquals(0, absolute.compareToIgnoreCase(file.getAbsolutePath()));
|
||
|
|
+ }
|
||
|
|
|
||
|
|
- /* Tricky directory-relative case */
|
||
|
|
- d = Character.toLowerCase(d);
|
||
|
|
+ @EnabledOnOs(OS.WINDOWS)
|
||
|
|
+ @Test
|
||
|
|
+ public void windowsDriveRelative() throws IOException {
|
||
|
|
+ // Tricky directory-relative case
|
||
|
|
+ char d = Character.toLowerCase(driveLetter());
|
||
|
|
char z = 0;
|
||
|
|
if (d != 'c') z = 'c';
|
||
|
|
else if (d != 'd') z = 'd';
|
||
|
|
if (z != 0) {
|
||
|
|
File f = new File(z + ":.");
|
||
|
|
if (f.exists()) {
|
||
|
|
- String zwd = f.getCanonicalPath();
|
||
|
|
- ck(z + ":foo", zwd + "\\foo");
|
||
|
|
+ String zUSER_DIR = f.getCanonicalPath();
|
||
|
|
+ File path = new File(z + ":foo");
|
||
|
|
+ String p = path.getAbsolutePath();
|
||
|
|
+ String ans = zUSER_DIR + "\\foo";
|
||
|
|
+ assertEquals(0, p.compareToIgnoreCase(ans));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
-
|
||
|
|
- /* Empty path */
|
||
|
|
- ck("", wd);
|
||
|
|
}
|
||
|
|
|
||
|
|
- private static void testUnix() throws Exception {
|
||
|
|
- String wd = System.getProperty("user.dir");
|
||
|
|
- ck("foo", wd + "/foo");
|
||
|
|
- ck("foo/bar", wd + "/foo/bar");
|
||
|
|
- ck("/foo", "/foo");
|
||
|
|
- ck("/foo/bar", "/foo/bar");
|
||
|
|
-
|
||
|
|
- /* Empty path */
|
||
|
|
- ck("", wd);
|
||
|
|
+ private static Stream<Arguments> unixSource() {
|
||
|
|
+ return Stream.of(Arguments.of("foo", USER_DIR + "/foo"),
|
||
|
|
+ Arguments.of("foo/bar", USER_DIR + "/foo/bar"),
|
||
|
|
+ Arguments.of("/foo", "/foo"),
|
||
|
|
+ Arguments.of("/foo/bar", "/foo/bar"),
|
||
|
|
+ Arguments.of("", USER_DIR));
|
||
|
|
}
|
||
|
|
|
||
|
|
- public static void main(String[] args) throws Exception {
|
||
|
|
- if (File.separatorChar == '\\') {
|
||
|
|
- ignoreCase = true;
|
||
|
|
- testWin32();
|
||
|
|
- }
|
||
|
|
- if (File.separatorChar == '/') testUnix();
|
||
|
|
+ @EnabledOnOs({OS.LINUX, OS.MAC})
|
||
|
|
+ @ParameterizedTest
|
||
|
|
+ @MethodSource("unixSource")
|
||
|
|
+ public void unix(String path, String absolute) throws IOException {
|
||
|
|
+ assertEquals(absolute, new File(path).getAbsolutePath());
|
||
|
|
}
|
||
|
|
-
|
||
|
|
}
|
||
|
|
diff --git a/test/jdk/java/io/File/GetCanonicalPath.java b/test/jdk/java/io/File/GetCanonicalPath.java
|
||
|
|
index dfd0fa5ca..0abf25244 100644
|
||
|
|
--- a/test/jdk/java/io/File/GetCanonicalPath.java
|
||
|
|
+++ b/test/jdk/java/io/File/GetCanonicalPath.java
|
||
|
|
@@ -1,5 +1,5 @@
|
||
|
|
/*
|
||
|
|
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
+ * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||
|
|
*
|
||
|
|
* This code is free software; you can redistribute it and/or modify it
|
||
|
|
@@ -22,21 +22,81 @@
|
||
|
|
*/
|
||
|
|
|
||
|
|
/* @test
|
||
|
|
- @bug 4899022
|
||
|
|
- @summary Look for erroneous representation of drive letter
|
||
|
|
+ * @bug 4899022
|
||
|
|
+ * @requires (os.family == "windows")
|
||
|
|
+ * @summary Look for erroneous representation of drive letter
|
||
|
|
+ * @run junit GetCanonicalPath
|
||
|
|
*/
|
||
|
|
|
||
|
|
-import java.io.*;
|
||
|
|
+import java.io.File;
|
||
|
|
+import java.io.IOException;
|
||
|
|
+import java.util.ArrayList;
|
||
|
|
+import java.util.List;
|
||
|
|
+import java.util.stream.Stream;
|
||
|
|
+
|
||
|
|
+import org.junit.jupiter.api.Test;
|
||
|
|
+import org.junit.jupiter.params.ParameterizedTest;
|
||
|
|
+import org.junit.jupiter.params.provider.Arguments;
|
||
|
|
+import org.junit.jupiter.params.provider.MethodSource;
|
||
|
|
+import org.junit.jupiter.params.provider.ValueSource;
|
||
|
|
+
|
||
|
|
+import static org.junit.jupiter.api.Assertions.*;
|
||
|
|
|
||
|
|
public class GetCanonicalPath {
|
||
|
|
- public static void main(String[] args) throws Exception {
|
||
|
|
- if (File.separatorChar == '\\') {
|
||
|
|
- testDriveLetter();
|
||
|
|
- }
|
||
|
|
+ private static Stream<Arguments> pathProvider() {
|
||
|
|
+ List<Arguments> list = new ArrayList<Arguments>();
|
||
|
|
+
|
||
|
|
+ File dir = new File(System.getProperty("user.dir", "."));
|
||
|
|
+ char drive = dir.getPath().charAt(0);
|
||
|
|
+
|
||
|
|
+ String pathname = drive + ":\\";
|
||
|
|
+ list.add(Arguments.of(pathname, pathname));
|
||
|
|
+
|
||
|
|
+ list.add(Arguments.of(drive + ":", dir.toString()));
|
||
|
|
+
|
||
|
|
+ String name = "foo";
|
||
|
|
+ pathname = "\\\\?\\" + name;
|
||
|
|
+ list.add(Arguments.of(pathname, new File(dir, name).toString()));
|
||
|
|
+ pathname = "\\\\?\\" + drive + ":" + name;
|
||
|
|
+ list.add(Arguments.of(pathname, new File(dir, name).toString()));
|
||
|
|
+
|
||
|
|
+ pathname = "foo\\bar\\gus";
|
||
|
|
+ list.add(Arguments.of(pathname, new File(dir, pathname).toString()));
|
||
|
|
+
|
||
|
|
+ pathname = drive + ":\\foo\\bar\\gus";
|
||
|
|
+ list.add(Arguments.of(pathname, pathname));
|
||
|
|
+
|
||
|
|
+ pathname = "\\\\server\\share\\foo\\bar\\gus";
|
||
|
|
+ list.add(Arguments.of(pathname, pathname));
|
||
|
|
+
|
||
|
|
+ pathname = "\\\\localhost\\" + drive + "$\\Users\\file.dat";
|
||
|
|
+ list.add(Arguments.of(pathname, pathname));
|
||
|
|
+
|
||
|
|
+ list.add(Arguments.of("\\\\?\\" + drive + ":\\Users\\file.dat",
|
||
|
|
+ drive + ":\\Users\\file.dat"));
|
||
|
|
+ list.add(Arguments.of("\\\\?\\UNC\\localhost\\" + drive + "$\\Users\\file.dat",
|
||
|
|
+ "\\\\localhost\\" + drive + "$\\Users\\file.dat"));
|
||
|
|
+
|
||
|
|
+ return list.stream();
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ @ParameterizedTest
|
||
|
|
+ @ValueSource(strings = {"\\\\?", "\\\\?\\UNC", "\\\\?\\UNC\\"})
|
||
|
|
+ void badPaths(String pathname) {
|
||
|
|
+ assertThrows(IOException.class, () -> new File(pathname).getCanonicalPath());
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ @ParameterizedTest
|
||
|
|
+ @MethodSource("pathProvider")
|
||
|
|
+ void goodPaths(String pathname, String expected) throws IOException {
|
||
|
|
+ File file = new File(pathname);
|
||
|
|
+ String canonicalPath = file.getCanonicalPath();
|
||
|
|
+ assertEquals(expected, canonicalPath);
|
||
|
|
}
|
||
|
|
- private static void testDriveLetter() throws Exception {
|
||
|
|
+
|
||
|
|
+ @Test
|
||
|
|
+ void driveLetter() throws IOException {
|
||
|
|
String path = new File("c:/").getCanonicalPath();
|
||
|
|
- if (path.length() > 3)
|
||
|
|
- throw new RuntimeException("Drive letter incorrectly represented");
|
||
|
|
+ assertFalse(path.length() > 3, "Drive letter incorrectly represented");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
diff --git a/test/jdk/java/io/File/IsAbsolute.java b/test/jdk/java/io/File/IsAbsolute.java
|
||
|
|
index 581d7bebf..cdeda917c 100644
|
||
|
|
--- a/test/jdk/java/io/File/IsAbsolute.java
|
||
|
|
+++ b/test/jdk/java/io/File/IsAbsolute.java
|
||
|
|
@@ -1,5 +1,5 @@
|
||
|
|
/*
|
||
|
|
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||
|
|
*
|
||
|
|
* This code is free software; you can redistribute it and/or modify it
|
||
|
|
@@ -22,42 +22,46 @@
|
||
|
|
*/
|
||
|
|
|
||
|
|
/* @test
|
||
|
|
- @bug 4022397
|
||
|
|
- @summary General test for isAbsolute
|
||
|
|
+ * @bug 4022397 8287843
|
||
|
|
+ * @summary General test for isAbsolute
|
||
|
|
+ * @run junit IsAbsolute
|
||
|
|
*/
|
||
|
|
|
||
|
|
-import java.io.*;
|
||
|
|
+import java.io.File;
|
||
|
|
+import java.io.IOException;
|
||
|
|
|
||
|
|
+import org.junit.jupiter.api.condition.EnabledOnOs;
|
||
|
|
+import org.junit.jupiter.api.condition.OS;
|
||
|
|
+import org.junit.jupiter.params.ParameterizedTest;
|
||
|
|
+import org.junit.jupiter.params.provider.ValueSource;
|
||
|
|
+import static org.junit.jupiter.api.Assertions.*;
|
||
|
|
|
||
|
|
public class IsAbsolute {
|
||
|
|
-
|
||
|
|
- private static void ck(String path, boolean ans) throws Exception {
|
||
|
|
- File f = new File(path);
|
||
|
|
- boolean x = f.isAbsolute();
|
||
|
|
- if (x != ans)
|
||
|
|
- throw new Exception(path + ": expected " + ans + ", got " + x);
|
||
|
|
- System.err.println(path + " ==> " + x);
|
||
|
|
+ @EnabledOnOs(OS.WINDOWS)
|
||
|
|
+ @ParameterizedTest
|
||
|
|
+ @ValueSource(strings = {"c:\\foo\\bar", "c:/foo/bar", "\\\\foo\\bar"})
|
||
|
|
+ public void windowsAbsolute(String path) throws IOException {
|
||
|
|
+ assertTrue(new File(path).isAbsolute());
|
||
|
|
}
|
||
|
|
|
||
|
|
- private static void testWin32() throws Exception {
|
||
|
|
- ck("/foo/bar", false);
|
||
|
|
- ck("\\foo\\bar", false);
|
||
|
|
- ck("c:\\foo\\bar", true);
|
||
|
|
- ck("c:/foo/bar", true);
|
||
|
|
- ck("c:foo\\bar", false);
|
||
|
|
- ck("\\\\foo\\bar", true);
|
||
|
|
+ @EnabledOnOs(OS.WINDOWS)
|
||
|
|
+ @ParameterizedTest
|
||
|
|
+ @ValueSource(strings = {"/foo/bar", "\\foo\\bar", "c:foo\\bar"})
|
||
|
|
+ public void windowsNotAbsolute(String path) throws IOException {
|
||
|
|
+ assertFalse(new File(path).isAbsolute());
|
||
|
|
}
|
||
|
|
|
||
|
|
- private static void testUnix() throws Exception {
|
||
|
|
- ck("foo", false);
|
||
|
|
- ck("foo/bar", false);
|
||
|
|
- ck("/foo", true);
|
||
|
|
- ck("/foo/bar", true);
|
||
|
|
+ @EnabledOnOs({OS.LINUX, OS.MAC})
|
||
|
|
+ @ParameterizedTest
|
||
|
|
+ @ValueSource(strings = {"/foo", "/foo/bar"})
|
||
|
|
+ public void unixAbsolute(String path) throws IOException {
|
||
|
|
+ assertTrue(new File(path).isAbsolute());
|
||
|
|
}
|
||
|
|
|
||
|
|
- public static void main(String[] args) throws Exception {
|
||
|
|
- if (File.separatorChar == '\\') testWin32();
|
||
|
|
- if (File.separatorChar == '/') testUnix();
|
||
|
|
+ @EnabledOnOs({OS.LINUX, OS.MAC})
|
||
|
|
+ @ParameterizedTest
|
||
|
|
+ @ValueSource(strings = {"foo", "foo/bar"})
|
||
|
|
+ public void unixNotAbsolute(String path) throws IOException {
|
||
|
|
+ assertFalse(new File(path).isAbsolute());
|
||
|
|
}
|
||
|
|
-
|
||
|
|
}
|
||
|
|
diff --git a/test/jdk/java/io/File/WindowsPrefixes.java b/test/jdk/java/io/File/WindowsPrefixes.java
|
||
|
|
new file mode 100644
|
||
|
|
index 000000000..0997f1f45
|
||
|
|
--- /dev/null
|
||
|
|
+++ b/test/jdk/java/io/File/WindowsPrefixes.java
|
||
|
|
@@ -0,0 +1,97 @@
|
||
|
|
+/*
|
||
|
|
+ * Copyright (c) 1998, 2023, 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 8287843
|
||
|
|
+ * @summary Basic test for Windows path prefixes
|
||
|
|
+ * @requires (os.family == "windows")
|
||
|
|
+ * @run junit WindowsPrefixes
|
||
|
|
+ */
|
||
|
|
+
|
||
|
|
+import java.io.File;
|
||
|
|
+import java.io.IOException;
|
||
|
|
+import java.util.stream.Stream;
|
||
|
|
+
|
||
|
|
+import org.junit.jupiter.api.BeforeAll;
|
||
|
|
+import org.junit.jupiter.api.Test;
|
||
|
|
+import org.junit.jupiter.api.condition.EnabledOnOs;
|
||
|
|
+import org.junit.jupiter.api.condition.OS;
|
||
|
|
+import org.junit.jupiter.params.provider.Arguments;
|
||
|
|
+import org.junit.jupiter.params.ParameterizedTest;
|
||
|
|
+import org.junit.jupiter.params.provider.MethodSource;
|
||
|
|
+import static org.junit.jupiter.api.Assertions.*;
|
||
|
|
+
|
||
|
|
+public class WindowsPrefixes {
|
||
|
|
+
|
||
|
|
+ private static Stream<Arguments> paths() {
|
||
|
|
+ return Stream.of(Arguments.of(""),
|
||
|
|
+ Arguments.of("C:\\"),
|
||
|
|
+ Arguments.of("C:"),
|
||
|
|
+ Arguments.of("\\foo"),
|
||
|
|
+ Arguments.of("foo"),
|
||
|
|
+ Arguments.of("foo\\bar"),
|
||
|
|
+ Arguments.of("C:\\foo"),
|
||
|
|
+ Arguments.of("C:foo"),
|
||
|
|
+ Arguments.of("C:\\foo\\bar"));
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ @ParameterizedTest
|
||
|
|
+ @MethodSource("paths")
|
||
|
|
+ public void getAbsolutePath(String path) throws IOException {
|
||
|
|
+ File file = new File(path);
|
||
|
|
+ File that = new File("\\\\?\\" + path);
|
||
|
|
+ assertEquals(file.getAbsolutePath(), that.getAbsolutePath());
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ @ParameterizedTest
|
||
|
|
+ @MethodSource("paths")
|
||
|
|
+ public void getCanonicalPath(String path) throws IOException {
|
||
|
|
+ File file = new File(path);
|
||
|
|
+ File that = new File("\\\\?\\" + path);
|
||
|
|
+ assertEquals(file.getCanonicalPath(), that.getCanonicalPath());
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ @ParameterizedTest
|
||
|
|
+ @MethodSource("paths")
|
||
|
|
+ public void getName(String path) throws IOException {
|
||
|
|
+ File file = new File(path);
|
||
|
|
+ File that = new File("\\\\?\\" + path);
|
||
|
|
+ assertEquals(file.getName(), that.getName());
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ @ParameterizedTest
|
||
|
|
+ @MethodSource("paths")
|
||
|
|
+ public void getParent(String path) throws IOException {
|
||
|
|
+ File file = new File(path);
|
||
|
|
+ File that = new File("\\\\?\\" + path);
|
||
|
|
+ assertEquals(file.getParent(), that.getParent());
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ @ParameterizedTest
|
||
|
|
+ @MethodSource("paths")
|
||
|
|
+ public void isAbsolute(String path) throws IOException {
|
||
|
|
+ File file = new File(path);
|
||
|
|
+ File that = new File("\\\\?\\" + path);
|
||
|
|
+ assertEquals(file.isAbsolute(), that.isAbsolute());
|
||
|
|
+ }
|
||
|
|
+}
|
||
|
|
diff --git a/test/jdk/javax/sound/sampled/Lines/OpenLineAfterScreenLock.java b/test/jdk/javax/sound/sampled/Lines/OpenLineAfterScreenLock.java
|
||
|
|
new file mode 100644
|
||
|
|
index 000000000..c9bb4c4ee
|
||
|
|
--- /dev/null
|
||
|
|
+++ b/test/jdk/javax/sound/sampled/Lines/OpenLineAfterScreenLock.java
|
||
|
|
@@ -0,0 +1,144 @@
|
||
|
|
+/*
|
||
|
|
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||
|
|
+ *
|
||
|
|
+ * This code is free software; you can redistribute it and/or modify it
|
||
|
|
+ * under the terms of the GNU General Public License version 2 only, as
|
||
|
|
+ * published by the Free Software Foundation.
|
||
|
|
+ *
|
||
|
|
+ * This code is distributed in the hope that it will be useful, but WITHOUT
|
||
|
|
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||
|
|
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||
|
|
+ * version 2 for more details (a copy is included in the LICENSE file that
|
||
|
|
+ * accompanied this code).
|
||
|
|
+ *
|
||
|
|
+ * You should have received a copy of the GNU General Public License version
|
||
|
|
+ * 2 along with this work; if not, write to the Free Software Foundation,
|
||
|
|
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||
|
|
+ *
|
||
|
|
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||
|
|
+ * or visit www.oracle.com if you need additional information or have any
|
||
|
|
+ * questions.
|
||
|
|
+ */
|
||
|
|
+
|
||
|
|
+import java.awt.BorderLayout;
|
||
|
|
+import java.awt.event.WindowAdapter;
|
||
|
|
+import java.awt.event.WindowEvent;
|
||
|
|
+import java.util.Arrays;
|
||
|
|
+import java.util.concurrent.CountDownLatch;
|
||
|
|
+import java.util.concurrent.TimeUnit;
|
||
|
|
+
|
||
|
|
+import javax.sound.sampled.AudioSystem;
|
||
|
|
+import javax.sound.sampled.Line;
|
||
|
|
+import javax.sound.sampled.LineUnavailableException;
|
||
|
|
+import javax.sound.sampled.Mixer;
|
||
|
|
+import javax.sound.sampled.TargetDataLine;
|
||
|
|
+import javax.swing.JButton;
|
||
|
|
+import javax.swing.JFileChooser;
|
||
|
|
+import javax.swing.JFrame;
|
||
|
|
+import javax.swing.JScrollPane;
|
||
|
|
+import javax.swing.JTextArea;
|
||
|
|
+
|
||
|
|
+import static javax.swing.SwingUtilities.invokeAndWait;
|
||
|
|
+
|
||
|
|
+/*
|
||
|
|
+ * @test
|
||
|
|
+ * @bug 8301846
|
||
|
|
+ * @requires (os.family == "windows")
|
||
|
|
+ * @summary Sound recording fails after screen lock and unlock.
|
||
|
|
+ * @run main/manual OpenLineAfterScreenLock
|
||
|
|
+ */
|
||
|
|
+public class OpenLineAfterScreenLock {
|
||
|
|
+
|
||
|
|
+ private static final String INSTRUCTIONS = String.join(System.lineSeparator(),
|
||
|
|
+ "This test verifies it can record sound from the first sound capture device after",
|
||
|
|
+ "locking and unlocking the screen. The first part of the test has already completed.",
|
||
|
|
+ "",
|
||
|
|
+ "Lock the screen and unlock it. Then click Continue to complete the test.",
|
||
|
|
+ "",
|
||
|
|
+ "The test will finish automatically."
|
||
|
|
+ );
|
||
|
|
+
|
||
|
|
+ private static final CountDownLatch latch = new CountDownLatch(1);
|
||
|
|
+
|
||
|
|
+ private static JFrame frame;
|
||
|
|
+
|
||
|
|
+ public static void main(String[] args) throws Exception {
|
||
|
|
+ try {
|
||
|
|
+ runTest();
|
||
|
|
+
|
||
|
|
+ // Creating JFileChooser initializes COM
|
||
|
|
+ // which affects ability to open audio lines
|
||
|
|
+ new JFileChooser();
|
||
|
|
+
|
||
|
|
+ invokeAndWait(OpenLineAfterScreenLock::createInstructionsUI);
|
||
|
|
+ if (!latch.await(2, TimeUnit.MINUTES)) {
|
||
|
|
+ throw new RuntimeException("Test failed: Test timed out!!");
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ runTest();
|
||
|
|
+ } finally {
|
||
|
|
+ invokeAndWait(() -> {
|
||
|
|
+ if (frame != null) {
|
||
|
|
+ frame.dispose();
|
||
|
|
+ }
|
||
|
|
+ });
|
||
|
|
+ }
|
||
|
|
+ System.out.println("Test Passed");
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ private static void runTest() {
|
||
|
|
+ try {
|
||
|
|
+ Mixer mixer = getMixer();
|
||
|
|
+ TargetDataLine line =
|
||
|
|
+ (TargetDataLine) mixer.getLine(mixer.getTargetLineInfo()[0]);
|
||
|
|
+ line.open();
|
||
|
|
+ line.close();
|
||
|
|
+ } catch (LineUnavailableException e) {
|
||
|
|
+ throw new RuntimeException("Test failed: Line unavailable", e);
|
||
|
|
+ }
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ private static Mixer getMixer() {
|
||
|
|
+ return Arrays.stream(AudioSystem.getMixerInfo())
|
||
|
|
+ .map(AudioSystem::getMixer)
|
||
|
|
+ .filter(OpenLineAfterScreenLock::isRecordingDevice)
|
||
|
|
+ .skip(1) // Skip the primary driver and choose one directly
|
||
|
|
+ .findAny()
|
||
|
|
+ .orElseThrow();
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ private static boolean isRecordingDevice(Mixer mixer) {
|
||
|
|
+ Line.Info[] lineInfos = mixer.getTargetLineInfo();
|
||
|
|
+ return lineInfos.length > 0
|
||
|
|
+ && lineInfos[0].getLineClass() == TargetDataLine.class;
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ private static void createInstructionsUI() {
|
||
|
|
+ frame = new JFrame("Instructions for OpenLineAfterScreenLock");
|
||
|
|
+
|
||
|
|
+ JTextArea textArea = new JTextArea(INSTRUCTIONS);
|
||
|
|
+ textArea.setEditable(false);
|
||
|
|
+
|
||
|
|
+ JScrollPane pane = new JScrollPane(textArea);
|
||
|
|
+ frame.getContentPane().add(pane, BorderLayout.NORTH);
|
||
|
|
+
|
||
|
|
+ JButton button = new JButton("Continue");
|
||
|
|
+ button.addActionListener(e -> latch.countDown());
|
||
|
|
+ frame.getContentPane().add(button, BorderLayout.PAGE_END);
|
||
|
|
+
|
||
|
|
+ frame.pack();
|
||
|
|
+ frame.setLocationRelativeTo(null);
|
||
|
|
+
|
||
|
|
+ frame.addWindowListener(new CloseWindowHandler());
|
||
|
|
+ frame.setVisible(true);
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ private static class CloseWindowHandler extends WindowAdapter {
|
||
|
|
+ @Override
|
||
|
|
+ public void windowClosing(WindowEvent e) {
|
||
|
|
+ latch.countDown();
|
||
|
|
+ throw new RuntimeException("Test window closed abruptly");
|
||
|
|
+ }
|
||
|
|
+ }
|
||
|
|
+}
|
||
|
|
diff --git a/test/jdk/sun/security/pkcs11/MessageDigest/TestCloning.java b/test/jdk/sun/security/pkcs11/MessageDigest/TestCloning.java
|
||
|
|
index c37f6d332..58635671f 100644
|
||
|
|
--- a/test/jdk/sun/security/pkcs11/MessageDigest/TestCloning.java
|
||
|
|
+++ b/test/jdk/sun/security/pkcs11/MessageDigest/TestCloning.java
|
||
|
|
@@ -1,5 +1,5 @@
|
||
|
|
/*
|
||
|
|
- * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
+ * Copyright (c) 2012, 2023, 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,6 +39,8 @@ import java.util.Arrays;
|
||
|
|
import java.util.Random;
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
+import jtreg.SkippedException;
|
||
|
|
+
|
||
|
|
public class TestCloning extends PKCS11Test {
|
||
|
|
|
||
|
|
public static void main(String[] args) throws Exception {
|
||
|
|
@@ -57,15 +59,31 @@ public class TestCloning extends PKCS11Test {
|
||
|
|
r.nextBytes(data1);
|
||
|
|
r.nextBytes(data2);
|
||
|
|
System.out.println("Testing against provider " + p.getName());
|
||
|
|
+
|
||
|
|
+ boolean skipTest = true;
|
||
|
|
+
|
||
|
|
for (String alg : ALGS) {
|
||
|
|
- System.out.println("Testing " + alg);
|
||
|
|
+ System.out.println("Digest algo: " + alg);
|
||
|
|
MessageDigest md = MessageDigest.getInstance(alg, p);
|
||
|
|
- md = testCloning(md, p);
|
||
|
|
+ try {
|
||
|
|
+ md = testCloning(md, p);;
|
||
|
|
+ } catch (CloneNotSupportedException cnse) {
|
||
|
|
+ // skip test if clone isn't supported
|
||
|
|
+ System.out.println("=> Clone not supported; skip!");
|
||
|
|
+ continue;
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ // start testing below
|
||
|
|
+ skipTest = false;
|
||
|
|
+
|
||
|
|
// repeat the test again after generating digest once
|
||
|
|
for (int j = 0; j < 10; j++) {
|
||
|
|
md = testCloning(md, p);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
+ if (skipTest) {
|
||
|
|
+ throw new SkippedException("Test Skipped!");
|
||
|
|
+ }
|
||
|
|
}
|
||
|
|
|
||
|
|
private static MessageDigest testCloning(MessageDigest mdObj, Provider p)
|
||
|
|
@@ -125,4 +143,3 @@ public class TestCloning extends PKCS11Test {
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
-
|
||
|
|
diff --git a/test/jdk/sun/security/pkcs11/PSSUtil.java b/test/jdk/sun/security/pkcs11/PSSUtil.java
|
||
|
|
new file mode 100644
|
||
|
|
index 000000000..d1848804f
|
||
|
|
--- /dev/null
|
||
|
|
+++ b/test/jdk/sun/security/pkcs11/PSSUtil.java
|
||
|
|
@@ -0,0 +1,84 @@
|
||
|
|
+/*
|
||
|
|
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||
|
|
+ *
|
||
|
|
+ * This code is free software; you can redistribute it and/or modify it
|
||
|
|
+ * under the terms of the GNU General Public License version 2 only, as
|
||
|
|
+ * published by the Free Software Foundation.
|
||
|
|
+ *
|
||
|
|
+ * This code is distributed in the hope that it will be useful, but WITHOUT
|
||
|
|
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||
|
|
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||
|
|
+ * version 2 for more details (a copy is included in the LICENSE file that
|
||
|
|
+ * accompanied this code).
|
||
|
|
+ *
|
||
|
|
+ * You should have received a copy of the GNU General Public License version
|
||
|
|
+ * 2 along with this work; if not, write to the Free Software Foundation,
|
||
|
|
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||
|
|
+ *
|
||
|
|
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||
|
|
+ * or visit www.oracle.com if you need additional information or have any
|
||
|
|
+ * questions.
|
||
|
|
+ */
|
||
|
|
+import java.security.KeyPair;
|
||
|
|
+import java.security.KeyPairGenerator;
|
||
|
|
+import java.security.MessageDigest;
|
||
|
|
+import java.security.NoSuchAlgorithmException;
|
||
|
|
+import java.security.Provider;
|
||
|
|
+import java.security.Signature;
|
||
|
|
+
|
||
|
|
+public class PSSUtil {
|
||
|
|
+
|
||
|
|
+ /**
|
||
|
|
+ * ALGORITHM name, fixed as RSA for PKCS11
|
||
|
|
+ */
|
||
|
|
+ private static final String KEYALG = "RSA";
|
||
|
|
+ private static final String SIGALG = "RSASSA-PSS";
|
||
|
|
+
|
||
|
|
+ public static enum AlgoSupport {
|
||
|
|
+ NO, MAYBE, YES
|
||
|
|
+ };
|
||
|
|
+
|
||
|
|
+ public static boolean isSignatureSupported(Provider p) {
|
||
|
|
+ try {
|
||
|
|
+ Signature.getInstance(SIGALG, p);
|
||
|
|
+ return true;
|
||
|
|
+ } catch (NoSuchAlgorithmException e) {
|
||
|
|
+ System.out.println("Skip testing " + SIGALG +
|
||
|
|
+ " due to no support");
|
||
|
|
+ return false;
|
||
|
|
+ }
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ public static AlgoSupport isHashSupported(Provider p, String... hashAlgs) {
|
||
|
|
+
|
||
|
|
+ AlgoSupport status = AlgoSupport.YES;
|
||
|
|
+ for (String h : hashAlgs) {
|
||
|
|
+ String sigAlg = (h.startsWith("SHA3-") ?
|
||
|
|
+ h : h.replace("-", "")) + "with" + SIGALG;
|
||
|
|
+ try {
|
||
|
|
+ Signature.getInstance(sigAlg, p);
|
||
|
|
+ // Yes, proceed to check next hash algorithm
|
||
|
|
+ continue;
|
||
|
|
+ } catch (NoSuchAlgorithmException e) {
|
||
|
|
+ // continue trying other checks
|
||
|
|
+ }
|
||
|
|
+ try {
|
||
|
|
+ MessageDigest.getInstance(h, p);
|
||
|
|
+ status = AlgoSupport.MAYBE;
|
||
|
|
+ } catch (NoSuchAlgorithmException e) {
|
||
|
|
+ // if not supported as a standalone digest algo, chance of it
|
||
|
|
+ // being supported by PSS is very very low
|
||
|
|
+ return AlgoSupport.NO;
|
||
|
|
+ }
|
||
|
|
+ }
|
||
|
|
+ return status;
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ public static KeyPair generateKeys(Provider p, int size)
|
||
|
|
+ throws NoSuchAlgorithmException {
|
||
|
|
+ KeyPairGenerator kpg = KeyPairGenerator.getInstance(KEYALG, p);
|
||
|
|
+ kpg.initialize(size);
|
||
|
|
+ return kpg.generateKeyPair();
|
||
|
|
+ }
|
||
|
|
+}
|
||
|
|
diff --git a/test/jdk/sun/security/pkcs11/Signature/KeyAndParamCheckForPSS.java b/test/jdk/sun/security/pkcs11/Signature/KeyAndParamCheckForPSS.java
|
||
|
|
index f1c0492b5..adf7a0890 100644
|
||
|
|
--- a/test/jdk/sun/security/pkcs11/Signature/KeyAndParamCheckForPSS.java
|
||
|
|
+++ b/test/jdk/sun/security/pkcs11/Signature/KeyAndParamCheckForPSS.java
|
||
|
|
@@ -1,5 +1,5 @@
|
||
|
|
/*
|
||
|
|
- * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
+ * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||
|
|
*
|
||
|
|
* This code is free software; you can redistribute it and/or modify it
|
||
|
|
@@ -24,6 +24,8 @@ import java.security.*;
|
||
|
|
import java.security.interfaces.*;
|
||
|
|
import java.security.spec.*;
|
||
|
|
|
||
|
|
+import jtreg.SkippedException;
|
||
|
|
+
|
||
|
|
/**
|
||
|
|
* @test
|
||
|
|
* @bug 8080462 8226651 8242332
|
||
|
|
@@ -35,25 +37,19 @@ import java.security.spec.*;
|
||
|
|
*/
|
||
|
|
public class KeyAndParamCheckForPSS extends PKCS11Test {
|
||
|
|
|
||
|
|
- /**
|
||
|
|
- * ALGORITHM name, fixed as RSA for PKCS11
|
||
|
|
- */
|
||
|
|
- private static final String KEYALG = "RSA";
|
||
|
|
private static final String SIGALG = "RSASSA-PSS";
|
||
|
|
|
||
|
|
public static void main(String[] args) throws Exception {
|
||
|
|
main(new KeyAndParamCheckForPSS(), args);
|
||
|
|
}
|
||
|
|
|
||
|
|
+ private static boolean skipTest = true;
|
||
|
|
+
|
||
|
|
@Override
|
||
|
|
public void main(Provider p) throws Exception {
|
||
|
|
- Signature sig;
|
||
|
|
- try {
|
||
|
|
- sig = Signature.getInstance(SIGALG, p);
|
||
|
|
- } catch (NoSuchAlgorithmException e) {
|
||
|
|
- System.out.println("Skip testing RSASSA-PSS" +
|
||
|
|
- " due to no support");
|
||
|
|
- return;
|
||
|
|
+ if (!PSSUtil.isSignatureSupported(p)) {
|
||
|
|
+ throw new SkippedException("Skip due to no support for " +
|
||
|
|
+ SIGALG);
|
||
|
|
}
|
||
|
|
|
||
|
|
// NOTE: key length >= (digest length + 2) in bytes
|
||
|
|
@@ -76,27 +72,26 @@ public class KeyAndParamCheckForPSS extends PKCS11Test {
|
||
|
|
runTest(p, 1040, "SHA3-512", "SHA3-256");
|
||
|
|
runTest(p, 1040, "SHA3-512", "SHA3-384");
|
||
|
|
runTest(p, 1040, "SHA3-512", "SHA3-512");
|
||
|
|
+
|
||
|
|
+ if (skipTest) {
|
||
|
|
+ throw new SkippedException("Test Skipped");
|
||
|
|
+ }
|
||
|
|
}
|
||
|
|
|
||
|
|
- private void runTest(Provider p, int keySize, String hashAlg,
|
||
|
|
+ private static void runTest(Provider p, int keySize, String hashAlg,
|
||
|
|
String mgfHashAlg) throws Exception {
|
||
|
|
|
||
|
|
- // skip further test if this provider does not support hashAlg or
|
||
|
|
- // mgfHashAlg
|
||
|
|
- try {
|
||
|
|
- MessageDigest.getInstance(hashAlg, p);
|
||
|
|
- MessageDigest.getInstance(mgfHashAlg, p);
|
||
|
|
- } catch (NoSuchAlgorithmException nsae) {
|
||
|
|
- System.out.println("No support for " + hashAlg + ", skip");
|
||
|
|
+ System.out.println("Testing " + hashAlg + " and MGF1" + mgfHashAlg);
|
||
|
|
+ PSSUtil.AlgoSupport s = PSSUtil.isHashSupported(p, hashAlg, mgfHashAlg);
|
||
|
|
+ if (s == PSSUtil.AlgoSupport.NO) {
|
||
|
|
+ System.out.println("=> Skip; no support");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
- System.out.println("Testing [" + keySize + " " + hashAlg + "]");
|
||
|
|
+ Signature sig = Signature.getInstance(SIGALG, p);
|
||
|
|
|
||
|
|
// create a key pair with the supplied size
|
||
|
|
- KeyPairGenerator kpg = KeyPairGenerator.getInstance(KEYALG, p);
|
||
|
|
- kpg.initialize(keySize);
|
||
|
|
- KeyPair kp = kpg.generateKeyPair();
|
||
|
|
+ KeyPair kp = PSSUtil.generateKeys(p, keySize);
|
||
|
|
|
||
|
|
int bigSaltLen = keySize/8 - 14;
|
||
|
|
AlgorithmParameterSpec paramsBad = new PSSParameterSpec(hashAlg,
|
||
|
|
@@ -108,58 +103,71 @@ public class KeyAndParamCheckForPSS extends PKCS11Test {
|
||
|
|
PublicKey pub = kp.getPublic();
|
||
|
|
|
||
|
|
// test#1 - setParameter then initSign
|
||
|
|
- Signature sig = Signature.getInstance("RSASSA-PSS", p);
|
||
|
|
- sig.setParameter(paramsBad);
|
||
|
|
+ sig = Signature.getInstance(SIGALG, p);
|
||
|
|
+ try {
|
||
|
|
+ sig.setParameter(paramsGood);
|
||
|
|
+ sig.initSign(priv);
|
||
|
|
+ // algorithm support confirmed
|
||
|
|
+ skipTest = false;
|
||
|
|
+ } catch (Exception ex) {
|
||
|
|
+ if (s == PSSUtil.AlgoSupport.MAYBE) {
|
||
|
|
+ // confirmed to be unsupported; skip the rest of the test
|
||
|
|
+ System.out.println("=> Skip; no PSS support");
|
||
|
|
+ return;
|
||
|
|
+ } else {
|
||
|
|
+ throw new RuntimeException("Unexpected Exception", ex);
|
||
|
|
+ }
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ sig = Signature.getInstance(SIGALG, p);
|
||
|
|
try {
|
||
|
|
+ sig.setParameter(paramsBad);
|
||
|
|
sig.initSign(priv);
|
||
|
|
throw new RuntimeException("Expected IKE not thrown");
|
||
|
|
} catch (InvalidKeyException ike) {
|
||
|
|
- System.out.println("test#1: got expected IKE");
|
||
|
|
+ // expected
|
||
|
|
}
|
||
|
|
|
||
|
|
+ // test#2 - setParameter then initVerify
|
||
|
|
+ sig = Signature.getInstance(SIGALG, p);
|
||
|
|
sig.setParameter(paramsGood);
|
||
|
|
- sig.initSign(priv);
|
||
|
|
- System.out.println("test#1: pass");
|
||
|
|
+ sig.initVerify(pub);
|
||
|
|
|
||
|
|
- // test#2 - setParameter then initVerify
|
||
|
|
- sig = Signature.getInstance("RSASSA-PSS", p);
|
||
|
|
- sig.setParameter(paramsBad);
|
||
|
|
+ sig = Signature.getInstance(SIGALG, p);
|
||
|
|
try {
|
||
|
|
+ sig.setParameter(paramsBad);
|
||
|
|
sig.initVerify(pub);
|
||
|
|
throw new RuntimeException("Expected IKE not thrown");
|
||
|
|
} catch (InvalidKeyException ike) {
|
||
|
|
- System.out.println("test#2: got expected IKE");
|
||
|
|
+ // expected
|
||
|
|
}
|
||
|
|
|
||
|
|
- sig.setParameter(paramsGood);
|
||
|
|
- sig.initVerify(pub);
|
||
|
|
-
|
||
|
|
- System.out.println("test#2: pass");
|
||
|
|
-
|
||
|
|
// test#3 - initSign, then setParameter
|
||
|
|
- sig = Signature.getInstance("RSASSA-PSS", p);
|
||
|
|
+ sig = Signature.getInstance(SIGALG, p);
|
||
|
|
sig.initSign(priv);
|
||
|
|
+ sig.setParameter(paramsGood);
|
||
|
|
+
|
||
|
|
+ sig = Signature.getInstance(SIGALG, p);
|
||
|
|
try {
|
||
|
|
+ sig.initSign(priv);
|
||
|
|
sig.setParameter(paramsBad);
|
||
|
|
throw new RuntimeException("Expected IAPE not thrown");
|
||
|
|
} catch (InvalidAlgorithmParameterException iape) {
|
||
|
|
- System.out.println("test#3: got expected IAPE");
|
||
|
|
+ // expected
|
||
|
|
}
|
||
|
|
|
||
|
|
- sig.setParameter(paramsGood);
|
||
|
|
- System.out.println("test#3: pass");
|
||
|
|
-
|
||
|
|
// test#4 - initVerify, then setParameter
|
||
|
|
- sig = Signature.getInstance("RSASSA-PSS", p);
|
||
|
|
+ sig = Signature.getInstance(SIGALG, p);
|
||
|
|
+ sig.setParameter(paramsGood);
|
||
|
|
sig.initVerify(pub);
|
||
|
|
+
|
||
|
|
+ sig = Signature.getInstance(SIGALG, p);
|
||
|
|
try {
|
||
|
|
+ sig.initVerify(pub);
|
||
|
|
sig.setParameter(paramsBad);
|
||
|
|
throw new RuntimeException("Expected IAPE not thrown");
|
||
|
|
} catch (InvalidAlgorithmParameterException iape) {
|
||
|
|
- System.out.println("test#4: got expected IAPE");
|
||
|
|
+ // expected
|
||
|
|
}
|
||
|
|
-
|
||
|
|
- sig.setParameter(paramsGood);
|
||
|
|
- System.out.println("test#4: pass");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
diff --git a/test/jdk/sun/security/pkcs11/Signature/SignatureTestPSS.java b/test/jdk/sun/security/pkcs11/Signature/SignatureTestPSS.java
|
||
|
|
index 4c1f7284b..c87554a51 100644
|
||
|
|
--- a/test/jdk/sun/security/pkcs11/Signature/SignatureTestPSS.java
|
||
|
|
+++ b/test/jdk/sun/security/pkcs11/Signature/SignatureTestPSS.java
|
||
|
|
@@ -1,5 +1,5 @@
|
||
|
|
/*
|
||
|
|
- * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
+ * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||
|
|
*
|
||
|
|
* This code is free software; you can redistribute it and/or modify it
|
||
|
|
@@ -24,6 +24,7 @@ import java.security.*;
|
||
|
|
import java.security.interfaces.*;
|
||
|
|
import java.security.spec.*;
|
||
|
|
import java.util.stream.IntStream;
|
||
|
|
+import jtreg.SkippedException;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @test
|
||
|
|
@@ -35,8 +36,6 @@ import java.util.stream.IntStream;
|
||
|
|
*/
|
||
|
|
public class SignatureTestPSS extends PKCS11Test {
|
||
|
|
|
||
|
|
- // PKCS11 does not support RSASSA-PSS keys yet
|
||
|
|
- private static final String KEYALG = "RSA";
|
||
|
|
private static final String SIGALG = "RSASSA-PSS";
|
||
|
|
|
||
|
|
private static final int[] KEYSIZES = { 2048, 3072 };
|
||
|
|
@@ -44,7 +43,7 @@ public class SignatureTestPSS extends PKCS11Test {
|
||
|
|
"SHA-224", "SHA-256", "SHA-384" , "SHA-512",
|
||
|
|
"SHA3-224", "SHA3-256", "SHA3-384" , "SHA3-512",
|
||
|
|
};
|
||
|
|
- private Provider prov;
|
||
|
|
+ private static final byte[] DATA = generateData(100);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* How much times signature updated.
|
||
|
|
@@ -56,88 +55,72 @@ public class SignatureTestPSS extends PKCS11Test {
|
||
|
|
*/
|
||
|
|
private static final int UPDATE_TIMES_HUNDRED = 100;
|
||
|
|
|
||
|
|
+ private static boolean skipTest = true;
|
||
|
|
+
|
||
|
|
public static void main(String[] args) throws Exception {
|
||
|
|
main(new SignatureTestPSS(), args);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void main(Provider p) throws Exception {
|
||
|
|
- Signature sig;
|
||
|
|
- try {
|
||
|
|
- sig = Signature.getInstance(SIGALG, p);
|
||
|
|
- } catch (NoSuchAlgorithmException e) {
|
||
|
|
- System.out.println("Skip testing RSASSA-PSS" +
|
||
|
|
- " due to no support");
|
||
|
|
- return;
|
||
|
|
+ if (!PSSUtil.isSignatureSupported(p)) {
|
||
|
|
+ throw new SkippedException("Skip due to no support for " + SIGALG);
|
||
|
|
}
|
||
|
|
- this.prov = p;
|
||
|
|
- for (int i : KEYSIZES) {
|
||
|
|
- runTest(i);
|
||
|
|
- }
|
||
|
|
- }
|
||
|
|
|
||
|
|
- private void runTest(int keySize) throws Exception {
|
||
|
|
- byte[] data = new byte[100];
|
||
|
|
- IntStream.range(0, data.length).forEach(j -> {
|
||
|
|
- data[j] = (byte) j;
|
||
|
|
- });
|
||
|
|
- System.out.println("[KEYSIZE = " + keySize + "]");
|
||
|
|
-
|
||
|
|
- // create a key pair
|
||
|
|
- KeyPair kpair = generateKeys(KEYALG, keySize);
|
||
|
|
- test(DIGESTS, kpair.getPrivate(), kpair.getPublic(), data);
|
||
|
|
- }
|
||
|
|
-
|
||
|
|
- private void test(String[] digestAlgs, PrivateKey privKey,
|
||
|
|
- PublicKey pubKey, byte[] data) throws RuntimeException {
|
||
|
|
- // For signature algorithm, create and verify a signature
|
||
|
|
- for (String hash : digestAlgs) {
|
||
|
|
- for (String mgfHash : digestAlgs) {
|
||
|
|
- try {
|
||
|
|
- checkSignature(data, pubKey, privKey, hash, mgfHash);
|
||
|
|
- } catch (NoSuchAlgorithmException | InvalidKeyException |
|
||
|
|
- SignatureException | NoSuchProviderException ex) {
|
||
|
|
- throw new RuntimeException(ex);
|
||
|
|
- } catch (InvalidAlgorithmParameterException ex2) {
|
||
|
|
- System.out.println("Skip test due to " + ex2);
|
||
|
|
+ for (int kSize : KEYSIZES) {
|
||
|
|
+ System.out.println("[KEYSIZE = " + kSize + "]");
|
||
|
|
+ KeyPair kp = PSSUtil.generateKeys(p, kSize);
|
||
|
|
+ PrivateKey privKey = kp.getPrivate();
|
||
|
|
+ PublicKey pubKey = kp.getPublic();
|
||
|
|
+ for (String hash : DIGESTS) {
|
||
|
|
+ for (String mgfHash : DIGESTS) {
|
||
|
|
+ System.out.println(" [Hash = " + hash +
|
||
|
|
+ ", MGF1 Hash = " + mgfHash + "]");
|
||
|
|
+ PSSUtil.AlgoSupport s =
|
||
|
|
+ PSSUtil.isHashSupported(p, hash, mgfHash);
|
||
|
|
+ if (s == PSSUtil.AlgoSupport.NO) {
|
||
|
|
+ System.out.println(" => Skip; no support");
|
||
|
|
+ continue;
|
||
|
|
+ }
|
||
|
|
+ checkSignature(p, DATA, pubKey, privKey, hash, mgfHash, s);
|
||
|
|
}
|
||
|
|
- }
|
||
|
|
- };
|
||
|
|
- }
|
||
|
|
+ };
|
||
|
|
+ }
|
||
|
|
|
||
|
|
- private KeyPair generateKeys(String keyalg, int size)
|
||
|
|
- throws NoSuchAlgorithmException {
|
||
|
|
- KeyPairGenerator kpg = KeyPairGenerator.getInstance(keyalg, prov);
|
||
|
|
- kpg.initialize(size);
|
||
|
|
- return kpg.generateKeyPair();
|
||
|
|
+ // start testing below
|
||
|
|
+ if (skipTest) {
|
||
|
|
+ throw new SkippedException("Test Skipped");
|
||
|
|
+ }
|
||
|
|
}
|
||
|
|
|
||
|
|
- private void checkSignature(byte[] data, PublicKey pub,
|
||
|
|
- PrivateKey priv, String hash, String mgfHash)
|
||
|
|
+ private static void checkSignature(Provider p, byte[] data, PublicKey pub,
|
||
|
|
+ PrivateKey priv, String hash, String mgfHash, PSSUtil.AlgoSupport s)
|
||
|
|
throws NoSuchAlgorithmException, InvalidKeyException,
|
||
|
|
SignatureException, NoSuchProviderException,
|
||
|
|
InvalidAlgorithmParameterException {
|
||
|
|
|
||
|
|
- String testName = hash + " and MGF1_" + mgfHash;
|
||
|
|
// only test RSASSA-PSS signature against the supplied hash/mgfHash
|
||
|
|
// if they are supported; otherwise PKCS11 library will throw
|
||
|
|
// CKR_MECHANISM_PARAM_INVALID at Signature.initXXX calls
|
||
|
|
+ Signature sig = Signature.getInstance(SIGALG, p);
|
||
|
|
+ AlgorithmParameterSpec params = new PSSParameterSpec(
|
||
|
|
+ hash, "MGF1", new MGF1ParameterSpec(mgfHash), 0, 1);
|
||
|
|
+ sig.initSign(priv);
|
||
|
|
+
|
||
|
|
try {
|
||
|
|
- MessageDigest md = MessageDigest.getInstance(hash, prov);
|
||
|
|
- if (!hash.equalsIgnoreCase(mgfHash)) {
|
||
|
|
- md = MessageDigest.getInstance(mgfHash, prov);
|
||
|
|
+ sig.setParameter(params);
|
||
|
|
+ } catch (InvalidAlgorithmParameterException iape) {
|
||
|
|
+ if (s == PSSUtil.AlgoSupport.MAYBE) {
|
||
|
|
+ // confirmed to be unsupported; skip the rest of the test
|
||
|
|
+ System.out.println(" => Skip; no PSS support");
|
||
|
|
+ return;
|
||
|
|
+ } else {
|
||
|
|
+ throw new RuntimeException("Unexpected Exception", iape);
|
||
|
|
}
|
||
|
|
- } catch (NoSuchAlgorithmException nsae) {
|
||
|
|
- System.out.println("Skip testing " + hash + "/" + mgfHash);
|
||
|
|
- return;
|
||
|
|
}
|
||
|
|
+ // start testing below
|
||
|
|
+ skipTest = false;
|
||
|
|
|
||
|
|
- System.out.println("Testing against " + testName);
|
||
|
|
- Signature sig = Signature.getInstance(SIGALG, prov);
|
||
|
|
- AlgorithmParameterSpec params = new PSSParameterSpec(
|
||
|
|
- hash, "MGF1", new MGF1ParameterSpec(mgfHash), 0, 1);
|
||
|
|
- sig.setParameter(params);
|
||
|
|
- sig.initSign(priv);
|
||
|
|
for (int i = 0; i < UPDATE_TIMES_HUNDRED; i++) {
|
||
|
|
sig.update(data);
|
||
|
|
}
|
||
|
|
@@ -163,5 +146,6 @@ public class SignatureTestPSS extends PKCS11Test {
|
||
|
|
if (sig.verify(signedData)) {
|
||
|
|
throw new RuntimeException("Failed to detect bad signature");
|
||
|
|
}
|
||
|
|
+ System.out.println(" => Passed");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
diff --git a/test/jdk/sun/security/x509/X509CRLImpl/UnexpectedNPE.java b/test/jdk/sun/security/x509/X509CRLImpl/UnexpectedNPE.java
|
||
|
|
index 8c14c48ee..fb85353ee 100644
|
||
|
|
--- a/test/jdk/sun/security/x509/X509CRLImpl/UnexpectedNPE.java
|
||
|
|
+++ b/test/jdk/sun/security/x509/X509CRLImpl/UnexpectedNPE.java
|
||
|
|
@@ -1,5 +1,5 @@
|
||
|
|
/*
|
||
|
|
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
+ * Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||
|
|
*
|
||
|
|
* This code is free software; you can redistribute it and/or modify it
|
||
|
|
@@ -23,56 +23,43 @@
|
||
|
|
|
||
|
|
/*
|
||
|
|
* @test
|
||
|
|
- * @bug 5052433
|
||
|
|
- * @summary NullPointerException for generateCRL and generateCRLs methods.
|
||
|
|
+ * @bug 5052433 8315042
|
||
|
|
+ * @summary Verify that generateCRL and generateCRLs methods do not throw
|
||
|
|
+ * NullPointerException. They should throw CRLException instead.
|
||
|
|
+ * @library /test/lib
|
||
|
|
*/
|
||
|
|
import java.security.NoSuchProviderException;
|
||
|
|
import java.security.cert.*;
|
||
|
|
import java.io.ByteArrayInputStream;
|
||
|
|
+import java.util.Base64;
|
||
|
|
|
||
|
|
-public class UnexpectedNPE {
|
||
|
|
- CertificateFactory cf = null ;
|
||
|
|
+import jdk.test.lib.Utils;
|
||
|
|
|
||
|
|
- public UnexpectedNPE() {}
|
||
|
|
+public class UnexpectedNPE {
|
||
|
|
+ static CertificateFactory cf = null;
|
||
|
|
|
||
|
|
- public static void main( String[] av ) {
|
||
|
|
+ public static void main(String[] av ) throws CertificateException,
|
||
|
|
+ NoSuchProviderException {
|
||
|
|
byte[] encoded_1 = { 0x00, 0x00, 0x00, 0x00 };
|
||
|
|
byte[] encoded_2 = { 0x30, 0x01, 0x00, 0x00 };
|
||
|
|
byte[] encoded_3 = { 0x30, 0x01, 0x00 };
|
||
|
|
+ byte[] encoded_4 = Base64.getDecoder().decode(
|
||
|
|
+ "MAsGCSqGSMP7TQEHAjI1Bgn///////8wCwUyAQ==");
|
||
|
|
|
||
|
|
- UnexpectedNPE unpe = new UnexpectedNPE() ;
|
||
|
|
-
|
||
|
|
- if(!unpe.run(encoded_1)) {
|
||
|
|
- throw new SecurityException("CRLException has not been thrown");
|
||
|
|
- }
|
||
|
|
+ cf = CertificateFactory.getInstance("X.509", "SUN");
|
||
|
|
|
||
|
|
- if(!unpe.run(encoded_2)) {
|
||
|
|
- throw new SecurityException("CRLException has not been thrown");
|
||
|
|
- }
|
||
|
|
-
|
||
|
|
- if(!unpe.run(encoded_2)) {
|
||
|
|
- throw new SecurityException("CRLException has not been thrown");
|
||
|
|
- }
|
||
|
|
+ run(encoded_1);
|
||
|
|
+ run(encoded_2);
|
||
|
|
+ run(encoded_3);
|
||
|
|
+ run(encoded_4);
|
||
|
|
}
|
||
|
|
|
||
|
|
- private boolean run(byte[] buf) {
|
||
|
|
- if (cf == null) {
|
||
|
|
- try {
|
||
|
|
- cf = CertificateFactory.getInstance("X.509", "SUN");
|
||
|
|
- } catch (CertificateException e) {
|
||
|
|
- throw new SecurityException("Cannot get CertificateFactory");
|
||
|
|
- } catch (NoSuchProviderException npe) {
|
||
|
|
- throw new SecurityException("Cannot get CertificateFactory");
|
||
|
|
- }
|
||
|
|
- }
|
||
|
|
- try {
|
||
|
|
- cf.generateCRL(new ByteArrayInputStream(buf));
|
||
|
|
- } catch (CRLException ce) {
|
||
|
|
- System.out.println("NPE checking passed");
|
||
|
|
- return true;
|
||
|
|
- }
|
||
|
|
-
|
||
|
|
- System.out.println("CRLException has not been thrown");
|
||
|
|
- return false;
|
||
|
|
+ private static void run(byte[] buf) {
|
||
|
|
+ Utils.runAndCheckException(
|
||
|
|
+ () -> cf.generateCRL(new ByteArrayInputStream(buf)),
|
||
|
|
+ CRLException.class);
|
||
|
|
+ Utils.runAndCheckException(
|
||
|
|
+ () -> cf.generateCRLs(new ByteArrayInputStream(buf)),
|
||
|
|
+ CRLException.class);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
--
|
||
|
|
2.43.0.windows.1
|
||
|
|
|