+id="toc-editing-this-document">Editing This Document
TL;DR (Instructions for the
@@ -341,7 +341,7 @@
Branch Protection
build can be run on both machines with and without support for branch
protection in hardware. Branch Protection is only supported for Linux
targets.
-
Building on 32-bit arm
+
Building on 32-bit ARM
This is not recommended. Instead, see the section on Cross-compiling.
Operating System
@@ -698,7 +698,7 @@
Boot JDK Requirements
locations on most platforms, this heuristics has a high likelihood to
fail. If the boot JDK is not automatically detected, or the wrong JDK is
picked, use --with-boot-jdk to point to the JDK to use.
-
Cross-compiling means using one platform (the build
platform) to generate output that can ran on another platform (the
target platform).
@@ -1399,7 +1399,7 @@
Verifying the Build
contain the newly built JDK, for your target system.
Copy these folders to your target system. Then you can run
e.g. images/jdk/bin/java -version.
-
Cross compiling the easy way
+
Cross-Compiling the Easy Way
Setting up a proper cross-compilation environment can be a lot of
work. Fortunately there are ways that more or less automate this
process. Here are two recommended methods, using the "devkits" that can
@@ -1409,7 +1409,7 @@
Cross compiling the easy way
solution only work for gcc.
The devkit method is regularly used for testing by Oracle, and the
debootstrap method is regularly used in GitHub Actions testing.
-
Using OpenJDK devkits
+
Using OpenJDK Devkits
The JDK build system provides out-of-the box support for creating and
using so called devkits. A devkit is basically a collection
of a cross-compiling toolchain and a sysroot environment which can
@@ -1660,8 +1660,8 @@
Using Debian debootstrap
-
Considerations for specific
-targets
+
Considerations for Specific
+Targets
Building for ARM32
A common cross-compilation target is the ARM CPU. When building for
ARM, it is recommended to set the ABI profile. A number of pre-defined
@@ -1772,7 +1772,7 @@
Precompiled Headers
circumstances, it can actually slow things down.
You can experiment by disabling pre-compiled headers using
--disable-precompiled-headers.
-
Icecc / icecream
+
Icecc / Icecream
icecc/icecream is a
simple way to setup a distributed compiler network. If you have multiple
machines available for building the JDK, you can drastically cut
@@ -1780,7 +1780,7 @@
Icecc / icecream
To use, setup an icecc network, and install icecc on the build
machine. Then run configure using
--enable-icecc.
-
Using the javac server
+
Using the javac Server
To speed up compilation of Java code, especially during incremental
compilations, the javac server is automatically enabled in the
configuration step by default. To explicitly enable or disable the javac
@@ -2456,7 +2456,7 @@
If you want to contribute changes to this document, edit
doc/building.md and then run
make update-build-docs to generate the same changes in
diff --git a/doc/building.md b/doc/building.md
index e33976413745a..611cfe15915c8 100644
--- a/doc/building.md
+++ b/doc/building.md
@@ -154,7 +154,7 @@ support (GCC 9.1.0+ or Clang 10+). The resulting build can be run on both
machines with and without support for branch protection in hardware. Branch
Protection is only supported for Linux targets.
-### Building on 32-bit arm
+### Building on 32-bit ARM
This is not recommended. Instead, see the section on [Cross-compiling](
#cross-compiling).
@@ -518,7 +518,7 @@ heuristics has a high likelihood to fail. If the boot JDK is not automatically
detected, or the wrong JDK is picked, use `--with-boot-jdk` to point to the JDK
to use.
-### Getting JDK binaries
+### Getting JDK Binaries
An overview of common ways to download and install prebuilt JDK binaries can be
found on https://openjdk.org/install. An alternative is to download the [Oracle
@@ -1026,7 +1026,7 @@ The default mode "auto" will try for `hardened` signing if the debug level is
If hardened isn't possible, then `debug` signing is chosen if it works. If
nothing works, the codesign build step is disabled.
-## Cross-compiling
+## Cross-Compiling
Cross-compiling means using one platform (the *build* platform) to generate
output that can ran on another platform (the *target* platform).
@@ -1213,7 +1213,7 @@ built JDK, for your *target* system.
Copy these folders to your *target* system. Then you can run e.g.
`images/jdk/bin/java -version`.
-### Cross compiling the easy way
+### Cross-Compiling the Easy Way
Setting up a proper cross-compilation environment can be a lot of work.
Fortunately there are ways that more or less automate this process. Here are
@@ -1225,7 +1225,7 @@ solution only work for gcc.
The devkit method is regularly used for testing by Oracle, and the debootstrap
method is regularly used in GitHub Actions testing.
-#### Using OpenJDK devkits
+#### Using OpenJDK Devkits
The JDK build system provides out-of-the box support for creating and using so
called devkits. A `devkit` is basically a collection of a cross-compiling
@@ -1388,7 +1388,7 @@ Architectures that are known to successfully cross-compile like this are:
| sh4 | sid | sh4 | sh4-linux-gnu | zero |
| riscv64 | sid | riscv64 | riscv64-linux-gnu | (all) |
-### Considerations for specific targets
+### Considerations for Specific Targets
#### Building for ARM32
@@ -1526,7 +1526,7 @@ things down.
You can experiment by disabling pre-compiled headers using
`--disable-precompiled-headers`.
-### Icecc / icecream
+### Icecc / Icecream
[icecc/icecream](https://github.com/icecc/icecream) is a simple way to setup a
distributed compiler network. If you have multiple machines available for
@@ -1536,7 +1536,7 @@ it.
To use, setup an icecc network, and install icecc on the build machine. Then
run `configure` using `--enable-icecc`.
-### Using the javac server
+### Using the javac Server
To speed up compilation of Java code, especially during incremental
compilations, the javac server is automatically enabled in the configuration
@@ -2274,7 +2274,7 @@ our rules and guidelines to be able to accept your contribution.
The official place to start is the [OpenJDK Developers’ Guide](
https://openjdk.org/guide/).
-## Editing this document
+## Editing This Document
If you want to contribute changes to this document, edit `doc/building.md` and
then run `make update-build-docs` to generate the same changes in
From c4aba875708f1701e8f1b6fa9676f42e235ec461 Mon Sep 17 00:00:00 2001
From: Vladimir Kozlov
Date: Tue, 21 Nov 2023 16:48:24 +0000
Subject: [PATCH 007/250] 8320272: Make method_entry_barrier address shared
Reviewed-by: dlong
---
src/hotspot/cpu/aarch64/c2_CodeStubs_aarch64.cpp | 2 +-
.../aarch64/gc/shared/barrierSetAssembler_aarch64.cpp | 2 +-
src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp | 2 +-
src/hotspot/cpu/aarch64/stubRoutines_aarch64.cpp | 1 -
src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp | 6 ------
.../cpu/arm/gc/shared/barrierSetAssembler_arm.cpp | 2 +-
src/hotspot/cpu/arm/stubGenerator_arm.cpp | 2 +-
src/hotspot/cpu/arm/stubRoutines_arm.cpp | 2 --
src/hotspot/cpu/arm/stubRoutines_arm.hpp | 2 --
.../cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp | 2 +-
src/hotspot/cpu/ppc/stubGenerator_ppc.cpp | 4 ++--
src/hotspot/cpu/ppc/stubRoutines_ppc.hpp | 4 ----
src/hotspot/cpu/ppc/stubRoutines_ppc_64.cpp | 5 -----
src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp | 9 ++++++---
.../cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp | 10 +++++++---
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp | 2 +-
src/hotspot/cpu/riscv/stubRoutines_riscv.cpp | 1 -
src/hotspot/cpu/riscv/stubRoutines_riscv.hpp | 6 ------
.../cpu/s390/gc/shared/barrierSetAssembler_s390.cpp | 2 +-
src/hotspot/cpu/s390/stubGenerator_s390.cpp | 4 ++--
src/hotspot/cpu/s390/stubRoutines_s390.cpp | 2 --
src/hotspot/cpu/s390/stubRoutines_s390.hpp | 4 ----
src/hotspot/cpu/x86/c2_CodeStubs_x86.cpp | 2 +-
.../cpu/x86/gc/shared/barrierSetAssembler_x86.cpp | 4 ++--
src/hotspot/cpu/x86/stubGenerator_x86_32.cpp | 2 +-
src/hotspot/cpu/x86/stubGenerator_x86_64.cpp | 2 +-
src/hotspot/cpu/x86/stubRoutines_x86.hpp | 2 --
src/hotspot/cpu/x86/stubRoutines_x86_32.cpp | 1 -
src/hotspot/cpu/x86/stubRoutines_x86_64.cpp | 1 -
src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp | 3 +--
src/hotspot/share/runtime/stubRoutines.cpp | 1 +
src/hotspot/share/runtime/stubRoutines.hpp | 4 ++++
32 files changed, 36 insertions(+), 62 deletions(-)
diff --git a/src/hotspot/cpu/aarch64/c2_CodeStubs_aarch64.cpp b/src/hotspot/cpu/aarch64/c2_CodeStubs_aarch64.cpp
index 69ea37fa45b34..dabafb9288b83 100644
--- a/src/hotspot/cpu/aarch64/c2_CodeStubs_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/c2_CodeStubs_aarch64.cpp
@@ -55,7 +55,7 @@ int C2EntryBarrierStub::max_size() const {
void C2EntryBarrierStub::emit(C2_MacroAssembler& masm) {
__ bind(entry());
- __ movptr(rscratch1, (uintptr_t) StubRoutines::aarch64::method_entry_barrier());
+ __ lea(rscratch1, RuntimeAddress(StubRoutines::method_entry_barrier()));
__ blr(rscratch1);
__ b(continuation());
diff --git a/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.cpp
index bfe29ddc8f716..070c685a07bb7 100644
--- a/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.cpp
@@ -358,7 +358,7 @@ void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm, Label* slo
__ br(condition, barrier_target);
if (slow_path == nullptr) {
- __ movptr(rscratch1, (uintptr_t) StubRoutines::aarch64::method_entry_barrier());
+ __ lea(rscratch1, RuntimeAddress(StubRoutines::method_entry_barrier()));
__ blr(rscratch1);
__ b(skip_barrier);
diff --git a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
index adf180d219cc0..97ca90ac76454 100644
--- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
@@ -8393,7 +8393,7 @@ class StubGenerator: public StubCodeGenerator {
BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
if (bs_nm != nullptr) {
- StubRoutines::aarch64::_method_entry_barrier = generate_method_entry_barrier();
+ StubRoutines::_method_entry_barrier = generate_method_entry_barrier();
}
StubRoutines::aarch64::_spin_wait = generate_spin_wait();
diff --git a/src/hotspot/cpu/aarch64/stubRoutines_aarch64.cpp b/src/hotspot/cpu/aarch64/stubRoutines_aarch64.cpp
index 3b6d3b5c40a28..80875a3b3cdcf 100644
--- a/src/hotspot/cpu/aarch64/stubRoutines_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/stubRoutines_aarch64.cpp
@@ -56,7 +56,6 @@ address StubRoutines::aarch64::_string_indexof_linear_ll = nullptr;
address StubRoutines::aarch64::_string_indexof_linear_uu = nullptr;
address StubRoutines::aarch64::_string_indexof_linear_ul = nullptr;
address StubRoutines::aarch64::_large_byte_array_inflate = nullptr;
-address StubRoutines::aarch64::_method_entry_barrier = nullptr;
static void empty_spin_wait() { }
address StubRoutines::aarch64::_spin_wait = CAST_FROM_FN_PTR(address, empty_spin_wait);
diff --git a/src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp b/src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp
index 2fcb35a1ae160..e6438908ce4c6 100644
--- a/src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp
+++ b/src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp
@@ -71,8 +71,6 @@ class aarch64 {
static address _string_indexof_linear_ul;
static address _large_byte_array_inflate;
- static address _method_entry_barrier;
-
static address _spin_wait;
static bool _completed;
@@ -179,10 +177,6 @@ class aarch64 {
return _large_byte_array_inflate;
}
- static address method_entry_barrier() {
- return _method_entry_barrier;
- }
-
static address spin_wait() {
return _spin_wait;
}
diff --git a/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.cpp b/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.cpp
index d6570283e60ac..9329876b808b2 100644
--- a/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.cpp
+++ b/src/hotspot/cpu/arm/gc/shared/barrierSetAssembler_arm.cpp
@@ -227,7 +227,7 @@ void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm) {
__ cmp(tmp0, tmp1);
__ b(skip, eq);
- __ mov_address(tmp0, StubRoutines::Arm::method_entry_barrier());
+ __ mov_address(tmp0, StubRoutines::method_entry_barrier());
__ call(tmp0);
__ b(skip);
diff --git a/src/hotspot/cpu/arm/stubGenerator_arm.cpp b/src/hotspot/cpu/arm/stubGenerator_arm.cpp
index 6e5484c98cbd4..7f9645f749ada 100644
--- a/src/hotspot/cpu/arm/stubGenerator_arm.cpp
+++ b/src/hotspot/cpu/arm/stubGenerator_arm.cpp
@@ -3188,7 +3188,7 @@ class StubGenerator: public StubCodeGenerator {
BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
if (bs_nm != nullptr) {
- StubRoutines::Arm::_method_entry_barrier = generate_method_entry_barrier();
+ StubRoutines::_method_entry_barrier = generate_method_entry_barrier();
}
}
diff --git a/src/hotspot/cpu/arm/stubRoutines_arm.cpp b/src/hotspot/cpu/arm/stubRoutines_arm.cpp
index ab4df1cd337fb..0cd174d8da673 100644
--- a/src/hotspot/cpu/arm/stubRoutines_arm.cpp
+++ b/src/hotspot/cpu/arm/stubRoutines_arm.cpp
@@ -33,5 +33,3 @@ address StubRoutines::Arm::_partial_subtype_check = nullptr;
address StubRoutines::_atomic_load_long_entry = nullptr;
address StubRoutines::_atomic_store_long_entry = nullptr;
-
-address StubRoutines::Arm::_method_entry_barrier = nullptr;
diff --git a/src/hotspot/cpu/arm/stubRoutines_arm.hpp b/src/hotspot/cpu/arm/stubRoutines_arm.hpp
index 46e66d5dcfee2..05c82881cd5f6 100644
--- a/src/hotspot/cpu/arm/stubRoutines_arm.hpp
+++ b/src/hotspot/cpu/arm/stubRoutines_arm.hpp
@@ -45,13 +45,11 @@ class Arm {
static address _idiv_irem_entry;
static address _partial_subtype_check;
- static address _method_entry_barrier;
public:
static address idiv_irem_entry() { return _idiv_irem_entry; }
static address partial_subtype_check() { return _partial_subtype_check; }
- static address method_entry_barrier() { return _method_entry_barrier; }
};
static bool returns_to_call_stub(address return_pc) {
diff --git a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp
index fbe37a0a35c35..f15e79534a2e5 100644
--- a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp
+++ b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp
@@ -188,7 +188,7 @@ void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm, Register t
__ block_comment("nmethod_entry_barrier (nmethod_entry_barrier) {");
// Load stub address using toc (fixed instruction size, unlike load_const_optimized)
- __ calculate_address_from_global_toc(tmp, StubRoutines::ppc::nmethod_entry_barrier(),
+ __ calculate_address_from_global_toc(tmp, StubRoutines::method_entry_barrier(),
true, true, false); // 2 instructions
__ mtctr(tmp);
diff --git a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp
index efcc8c897216d..e26f03f52d802 100644
--- a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp
+++ b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp
@@ -3558,7 +3558,7 @@ class StubGenerator: public StubCodeGenerator {
return start;
}
- address generate_nmethod_entry_barrier() {
+ address generate_method_entry_barrier() {
__ align(CodeEntryAlignment);
StubCodeMark mark(this, "StubRoutines", "nmethod_entry_barrier");
@@ -4806,7 +4806,7 @@ class StubGenerator: public StubCodeGenerator {
// nmethod entry barriers for concurrent class unloading
BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
if (bs_nm != nullptr) {
- StubRoutines::ppc::_nmethod_entry_barrier = generate_nmethod_entry_barrier();
+ StubRoutines::_method_entry_barrier = generate_method_entry_barrier();
}
// arraycopy stubs used by compilers
diff --git a/src/hotspot/cpu/ppc/stubRoutines_ppc.hpp b/src/hotspot/cpu/ppc/stubRoutines_ppc.hpp
index 1e1172c9ada43..4db0227e81b4e 100644
--- a/src/hotspot/cpu/ppc/stubRoutines_ppc.hpp
+++ b/src/hotspot/cpu/ppc/stubRoutines_ppc.hpp
@@ -53,11 +53,7 @@ class ppc {
friend class StubGenerator;
private:
- static address _nmethod_entry_barrier;
-
public:
- static address nmethod_entry_barrier();
-
static address generate_crc_constants(juint reverse_poly);
};
diff --git a/src/hotspot/cpu/ppc/stubRoutines_ppc_64.cpp b/src/hotspot/cpu/ppc/stubRoutines_ppc_64.cpp
index f2dc214456779..7df905b90682c 100644
--- a/src/hotspot/cpu/ppc/stubRoutines_ppc_64.cpp
+++ b/src/hotspot/cpu/ppc/stubRoutines_ppc_64.cpp
@@ -206,8 +206,3 @@ address StubRoutines::ppc::generate_crc_constants(juint reverse_poly) {
return consts;
}
-
-address StubRoutines::ppc::_nmethod_entry_barrier = nullptr;
-address StubRoutines::ppc::nmethod_entry_barrier() {
- return _nmethod_entry_barrier;
-}
diff --git a/src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp b/src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp
index e9556fe4dcf9f..d1c66ce1da76a 100644
--- a/src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp
+++ b/src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp
@@ -60,10 +60,13 @@ int C2EntryBarrierStub::max_size() const {
void C2EntryBarrierStub::emit(C2_MacroAssembler& masm) {
__ bind(entry());
+ RuntimeAddress target(StubRoutines::method_entry_barrier());
+ __ relocate(target.rspec(), [&] {
+ int32_t offset;
+ __ la_patchable(t0, target, offset);
+ __ jalr(ra, t0, offset);
+ });
- int32_t offset = 0;
- __ movptr(t0, StubRoutines::riscv::method_entry_barrier(), offset);
- __ jalr(ra, t0, offset);
__ j(continuation());
// make guard value 4-byte aligned so that it can be accessed by atomic instructions on RISC-V
diff --git a/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp
index ed045c37a6ffa..a4440890b0961 100644
--- a/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp
+++ b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp
@@ -308,9 +308,13 @@ void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm, Label* slo
Label skip_barrier;
__ beq(t0, t1, skip_barrier);
- int32_t offset = 0;
- __ movptr(t0, StubRoutines::riscv::method_entry_barrier(), offset);
- __ jalr(ra, t0, offset);
+ RuntimeAddress target(StubRoutines::method_entry_barrier());
+ __ relocate(target.rspec(), [&] {
+ int32_t offset;
+ __ la_patchable(t0, target, offset);
+ __ jalr(ra, t0, offset);
+ });
+
__ j(skip_barrier);
__ bind(local_guard);
diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp
index 057c4783edffa..e10357c4a5a50 100644
--- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp
+++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp
@@ -4813,7 +4813,7 @@ static const int64_t right_3_bits = right_n_bits(3);
BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
if (bs_nm != nullptr) {
- StubRoutines::riscv::_method_entry_barrier = generate_method_entry_barrier();
+ StubRoutines::_method_entry_barrier = generate_method_entry_barrier();
}
StubRoutines::_upcall_stub_exception_handler = generate_upcall_stub_exception_handler();
diff --git a/src/hotspot/cpu/riscv/stubRoutines_riscv.cpp b/src/hotspot/cpu/riscv/stubRoutines_riscv.cpp
index dd72044b0ce6b..39068a9a026ac 100644
--- a/src/hotspot/cpu/riscv/stubRoutines_riscv.cpp
+++ b/src/hotspot/cpu/riscv/stubRoutines_riscv.cpp
@@ -53,6 +53,5 @@ address StubRoutines::riscv::_string_indexof_linear_ll = nullptr;
address StubRoutines::riscv::_string_indexof_linear_uu = nullptr;
address StubRoutines::riscv::_string_indexof_linear_ul = nullptr;
address StubRoutines::riscv::_large_byte_array_inflate = nullptr;
-address StubRoutines::riscv::_method_entry_barrier = nullptr;
bool StubRoutines::riscv::_completed = false;
diff --git a/src/hotspot/cpu/riscv/stubRoutines_riscv.hpp b/src/hotspot/cpu/riscv/stubRoutines_riscv.hpp
index fde88f5e30b62..7c604e8c11cc2 100644
--- a/src/hotspot/cpu/riscv/stubRoutines_riscv.hpp
+++ b/src/hotspot/cpu/riscv/stubRoutines_riscv.hpp
@@ -70,8 +70,6 @@ class riscv {
static address _string_indexof_linear_ul;
static address _large_byte_array_inflate;
- static address _method_entry_barrier;
-
static bool _completed;
public:
@@ -148,10 +146,6 @@ class riscv {
return _large_byte_array_inflate;
}
- static address method_entry_barrier() {
- return _method_entry_barrier;
- }
-
static bool complete() {
return _completed;
}
diff --git a/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp b/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp
index 9613de903d9b3..480af074a4c1e 100644
--- a/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp
+++ b/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp
@@ -132,7 +132,7 @@ void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm) {
__ block_comment("nmethod_entry_barrier (nmethod_entry_barrier) {");
// Load jump addr:
- __ load_const(Z_R1_scratch, (uint64_t)StubRoutines::zarch::nmethod_entry_barrier()); // 2*6 bytes
+ __ load_const(Z_R1_scratch, (uint64_t)StubRoutines::method_entry_barrier()); // 2*6 bytes
// Load value from current java object:
__ z_lg(Z_R0_scratch, in_bytes(bs_nm->thread_disarmed_guard_value_offset()), Z_thread); // 6 bytes
diff --git a/src/hotspot/cpu/s390/stubGenerator_s390.cpp b/src/hotspot/cpu/s390/stubGenerator_s390.cpp
index 64d8d9fa978c8..db686158f2107 100644
--- a/src/hotspot/cpu/s390/stubGenerator_s390.cpp
+++ b/src/hotspot/cpu/s390/stubGenerator_s390.cpp
@@ -3015,7 +3015,7 @@ class StubGenerator: public StubCodeGenerator {
return start;
}
- address generate_nmethod_entry_barrier() {
+ address generate_method_entry_barrier() {
__ align(CodeEntryAlignment);
StubCodeMark mark(this, "StubRoutines", "nmethod_entry_barrier");
@@ -3187,7 +3187,7 @@ class StubGenerator: public StubCodeGenerator {
// nmethod entry barriers for concurrent class unloading
BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
if (bs_nm != nullptr) {
- StubRoutines::zarch::_nmethod_entry_barrier = generate_nmethod_entry_barrier();
+ StubRoutines::_method_entry_barrier = generate_method_entry_barrier();
}
StubRoutines::_upcall_stub_exception_handler = generate_upcall_stub_exception_handler();
diff --git a/src/hotspot/cpu/s390/stubRoutines_s390.cpp b/src/hotspot/cpu/s390/stubRoutines_s390.cpp
index 711de63fdeafc..2a60f71557c71 100644
--- a/src/hotspot/cpu/s390/stubRoutines_s390.cpp
+++ b/src/hotspot/cpu/s390/stubRoutines_s390.cpp
@@ -38,8 +38,6 @@ address StubRoutines::zarch::_partial_subtype_check = nullptr;
// Comapct string intrinsics: Translate table for string inflate intrinsic. Used by trot instruction.
address StubRoutines::zarch::_trot_table_addr = nullptr;
-address StubRoutines::zarch::_nmethod_entry_barrier = nullptr;
-
int StubRoutines::zarch::_atomic_memory_operation_lock = StubRoutines::zarch::unlocked;
#define __ masm->
diff --git a/src/hotspot/cpu/s390/stubRoutines_s390.hpp b/src/hotspot/cpu/s390/stubRoutines_s390.hpp
index 68e6b3f2b47a4..7116d441715ad 100644
--- a/src/hotspot/cpu/s390/stubRoutines_s390.hpp
+++ b/src/hotspot/cpu/s390/stubRoutines_s390.hpp
@@ -80,8 +80,6 @@ class zarch {
static address _trot_table_addr;
static jlong _trot_table[TROT_COLUMN_SIZE];
- static address _nmethod_entry_barrier;
-
public:
// Global lock for everyone who needs to use atomic_compare_and_exchange
// or atomic_increment -- should probably use more locks for more
@@ -102,8 +100,6 @@ class zarch {
// Comapct string intrinsics: Translate table for string inflate intrinsic. Used by trot instruction.
static void generate_load_trot_table_addr(MacroAssembler* masm, Register table);
-
- static address nmethod_entry_barrier() { return _nmethod_entry_barrier; }
};
#endif // CPU_S390_STUBROUTINES_S390_HPP
diff --git a/src/hotspot/cpu/x86/c2_CodeStubs_x86.cpp b/src/hotspot/cpu/x86/c2_CodeStubs_x86.cpp
index cd5e87b29ec4c..b9b4e8af02c5f 100644
--- a/src/hotspot/cpu/x86/c2_CodeStubs_x86.cpp
+++ b/src/hotspot/cpu/x86/c2_CodeStubs_x86.cpp
@@ -69,7 +69,7 @@ int C2EntryBarrierStub::max_size() const {
void C2EntryBarrierStub::emit(C2_MacroAssembler& masm) {
__ bind(entry());
- __ call(RuntimeAddress(StubRoutines::x86::method_entry_barrier()));
+ __ call(RuntimeAddress(StubRoutines::method_entry_barrier()));
__ jmp(continuation(), false /* maybe_short */);
}
diff --git a/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.cpp
index 6a7ac54f4734c..f09e1c9216206 100644
--- a/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.cpp
+++ b/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.cpp
@@ -402,7 +402,7 @@ void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm, Label* slo
} else {
Label done;
__ jccb(Assembler::equal, done);
- __ call(RuntimeAddress(StubRoutines::x86::method_entry_barrier()));
+ __ call(RuntimeAddress(StubRoutines::method_entry_barrier()));
__ bind(done);
}
}
@@ -423,7 +423,7 @@ void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm, Label*, La
__ cmpl_imm32(disarmed_addr, 0);
__ pop(tmp);
__ jcc(Assembler::equal, continuation);
- __ call(RuntimeAddress(StubRoutines::x86::method_entry_barrier()));
+ __ call(RuntimeAddress(StubRoutines::method_entry_barrier()));
__ bind(continuation);
}
#endif
diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_32.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_32.cpp
index d21233b258fb0..e6305ded69624 100644
--- a/src/hotspot/cpu/x86/stubGenerator_x86_32.cpp
+++ b/src/hotspot/cpu/x86/stubGenerator_x86_32.cpp
@@ -4218,7 +4218,7 @@ class StubGenerator: public StubCodeGenerator {
BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
if (bs_nm != nullptr) {
- StubRoutines::x86::_method_entry_barrier = generate_method_entry_barrier();
+ StubRoutines::_method_entry_barrier = generate_method_entry_barrier();
}
}
diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
index 894f225d3bc79..c73e0759b57f7 100644
--- a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
+++ b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
@@ -4052,7 +4052,7 @@ void StubGenerator::generate_final_stubs() {
BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
if (bs_nm != nullptr) {
- StubRoutines::x86::_method_entry_barrier = generate_method_entry_barrier();
+ StubRoutines::_method_entry_barrier = generate_method_entry_barrier();
}
if (UseVectorizedMismatchIntrinsic) {
diff --git a/src/hotspot/cpu/x86/stubRoutines_x86.hpp b/src/hotspot/cpu/x86/stubRoutines_x86.hpp
index 375cefd5e1df5..6c602324f3ef2 100644
--- a/src/hotspot/cpu/x86/stubRoutines_x86.hpp
+++ b/src/hotspot/cpu/x86/stubRoutines_x86.hpp
@@ -132,8 +132,6 @@ class x86 {
static address _verify_mxcsr_entry;
- static address _method_entry_barrier;
-
// masks and table for CRC32
static const uint64_t _crc_by128_masks[];
static const juint _crc_table[];
diff --git a/src/hotspot/cpu/x86/stubRoutines_x86_32.cpp b/src/hotspot/cpu/x86/stubRoutines_x86_32.cpp
index 0da5a3eca7db9..7916a3b36305a 100644
--- a/src/hotspot/cpu/x86/stubRoutines_x86_32.cpp
+++ b/src/hotspot/cpu/x86/stubRoutines_x86_32.cpp
@@ -32,7 +32,6 @@
// a description of how to extend it, see the stubRoutines.hpp file.
address StubRoutines::x86::_verify_fpu_cntrl_wrd_entry = nullptr;
-address StubRoutines::x86::_method_entry_barrier = nullptr;
address StubRoutines::x86::_d2i_wrapper = nullptr;
address StubRoutines::x86::_d2l_wrapper = nullptr;
diff --git a/src/hotspot/cpu/x86/stubRoutines_x86_64.cpp b/src/hotspot/cpu/x86/stubRoutines_x86_64.cpp
index 4287580e7f921..417b32eb4a64c 100644
--- a/src/hotspot/cpu/x86/stubRoutines_x86_64.cpp
+++ b/src/hotspot/cpu/x86/stubRoutines_x86_64.cpp
@@ -44,5 +44,4 @@ address StubRoutines::x86::_float_sign_mask = nullptr;
address StubRoutines::x86::_float_sign_flip = nullptr;
address StubRoutines::x86::_double_sign_mask = nullptr;
address StubRoutines::x86::_double_sign_flip = nullptr;
-address StubRoutines::x86::_method_entry_barrier = nullptr;
diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp
index e40e5ee856e8d..a3e2bd525ecf6 100644
--- a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp
+++ b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp
@@ -146,8 +146,7 @@ void CompilerToVM::Data::initialize(JVMCI_TRAPS) {
BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
if (bs_nm != nullptr) {
thread_disarmed_guard_value_offset = in_bytes(bs_nm->thread_disarmed_guard_value_offset());
- AMD64_ONLY(nmethod_entry_barrier = StubRoutines::x86::method_entry_barrier());
- AARCH64_ONLY(nmethod_entry_barrier = StubRoutines::aarch64::method_entry_barrier());
+ nmethod_entry_barrier = StubRoutines::method_entry_barrier();
BarrierSetAssembler* bs_asm = BarrierSet::barrier_set()->barrier_set_assembler();
AARCH64_ONLY(BarrierSetAssembler_nmethod_patching_type = (int) bs_asm->nmethod_patching_type());
AARCH64_ONLY(BarrierSetAssembler_patching_epoch_addr = bs_asm->patching_epoch_addr());
diff --git a/src/hotspot/share/runtime/stubRoutines.cpp b/src/hotspot/share/runtime/stubRoutines.cpp
index faeaedac55e1e..ff32240905de8 100644
--- a/src/hotspot/share/runtime/stubRoutines.cpp
+++ b/src/hotspot/share/runtime/stubRoutines.cpp
@@ -176,6 +176,7 @@ address StubRoutines::_hf2f = nullptr;
address StubRoutines::_vector_f_math[VectorSupport::NUM_VEC_SIZES][VectorSupport::NUM_SVML_OP] = {{nullptr}, {nullptr}};
address StubRoutines::_vector_d_math[VectorSupport::NUM_VEC_SIZES][VectorSupport::NUM_SVML_OP] = {{nullptr}, {nullptr}};
+address StubRoutines::_method_entry_barrier = nullptr;
address StubRoutines::_array_sort = nullptr;
address StubRoutines::_array_partition = nullptr;
diff --git a/src/hotspot/share/runtime/stubRoutines.hpp b/src/hotspot/share/runtime/stubRoutines.hpp
index 77d968263f75b..3000ed454a1e3 100644
--- a/src/hotspot/share/runtime/stubRoutines.hpp
+++ b/src/hotspot/share/runtime/stubRoutines.hpp
@@ -256,6 +256,8 @@ class StubRoutines: AllStatic {
static address _f2hf;
static address _hf2f;
+ static address _method_entry_barrier;
+
static address _cont_thaw;
static address _cont_returnBarrier;
static address _cont_returnBarrierExc;
@@ -460,6 +462,8 @@ class StubRoutines: AllStatic {
return ((hf2f_stub_t)_hf2f)(x);
}
+ static address method_entry_barrier() { return _method_entry_barrier; }
+
static address cont_thaw() { return _cont_thaw; }
static address cont_returnBarrier() { return _cont_returnBarrier; }
static address cont_returnBarrierExc(){return _cont_returnBarrierExc; }
From 61d81d6496a38e43a6039abc041b67626f06f5c9 Mon Sep 17 00:00:00 2001
From: Shaojin Wen
Date: Tue, 21 Nov 2023 17:00:18 +0000
Subject: [PATCH 008/250] 8317742: ISO Standard Date Format implementation
consistency on DateTimeFormatter and String.format
Reviewed-by: rriggs, naoto
---
.../share/classes/java/util/Formatter.java | 21 +++++-
.../java/util/Formatter/BasicDateTime.java | 64 ++++++++++++++++++-
2 files changed, 83 insertions(+), 2 deletions(-)
diff --git a/src/java.base/share/classes/java/util/Formatter.java b/src/java.base/share/classes/java/util/Formatter.java
index 5febf0d9153dc..9956ba18d693e 100644
--- a/src/java.base/share/classes/java/util/Formatter.java
+++ b/src/java.base/share/classes/java/util/Formatter.java
@@ -56,6 +56,7 @@
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZoneOffset;
+import java.time.chrono.IsoChronology;
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalQueries;
@@ -2050,6 +2051,11 @@ private static char getGroupingSeparator(Locale locale) {
return locale == null ? ',' : getDecimalFormatSymbols(locale).getGroupingSeparator();
}
+ // Use minus sign from cached DecimalFormatSymbols.
+ private static char getMinusSign(Locale locale) {
+ return locale == null ? '-' : getDecimalFormatSymbols(locale).getMinusSign();
+ }
+
private Appendable a;
private final Locale l;
private IOException lastException;
@@ -4490,7 +4496,20 @@ private Appendable print(Formatter fmt, StringBuilder sb, TemporalAccessor t, ch
}
case DateTime.ISO_STANDARD_DATE: { // 'F' (%Y-%m-%d)
char sep = '-';
- print(fmt, sb, t, DateTime.YEAR_4, l).append(sep);
+ ChronoField yearField;
+ if (t.query(TemporalQueries.chronology()) instanceof IsoChronology) {
+ yearField = ChronoField.YEAR;
+ } else {
+ yearField = ChronoField.YEAR_OF_ERA;
+ }
+ int year = t.get(yearField);
+ if (year < 0) {
+ sb.append(getMinusSign(l));
+ year = -year;
+ } else if (year > 9999) {
+ sb.append('+');
+ }
+ sb.append(localizedMagnitude(fmt, null, year, Flags.ZERO_PAD, 4, l)).append(sep);
print(fmt, sb, t, DateTime.MONTH, l).append(sep);
print(fmt, sb, t, DateTime.DAY_OF_MONTH_0, l);
break;
diff --git a/test/jdk/java/util/Formatter/BasicDateTime.java b/test/jdk/java/util/Formatter/BasicDateTime.java
index 4a65918b5b44f..936b695e77f7d 100644
--- a/test/jdk/java/util/Formatter/BasicDateTime.java
+++ b/test/jdk/java/util/Formatter/BasicDateTime.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2022, 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
@@ -34,6 +34,14 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DateFormatSymbols;
+import java.text.DecimalFormatSymbols;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
+import java.time.ZonedDateTime;
+import java.time.ZoneOffset;
+import java.time.chrono.*;
+import java.time.temporal.ChronoField;
import java.util.*;
import static java.util.Calendar.*;
@@ -450,5 +458,59 @@ public static void test() {
tryCatch("%%%", UnknownFormatConversionException.class);
// perhaps an IllegalFormatArgumentIndexException should be defined?
tryCatch("%<%", IllegalFormatFlagsException.class);
+
+ // %tF LocalDate
+ test("%tF", "2023-01-13", LocalDate.of(2023, 1, 13));
+ test("%tF", "2023-10-03", LocalDate.of(2023, 10, 3));
+ test("%tF", "0001-10-03", LocalDate.of(1, 10, 3));
+ test("%tF", "0012-10-03", LocalDate.of(12, 10, 3));
+ test("%tF", "0123-10-03", LocalDate.of(123, 10, 3));
+ test("%tF", "+12345-10-03", LocalDate.of(12345, 10, 3));
+ test("%tF", "+12345-10-03", LocalDateTime.of(12345, 10, 3, 0, 0, 0));
+ test("%tF", "+12345-10-03", OffsetDateTime.of(LocalDateTime.of(12345, 10, 3, 0, 0, 0), ZoneOffset.UTC));
+ test("%tF", "+12345-10-03", ZonedDateTime.of(LocalDateTime.of(12345, 10, 3, 0, 0, 0), ZoneOffset.UTC));
+ test("%tF", "-0001-10-03", LocalDate.of(-1, 10, 3));
+ test("%tF", "-0012-10-03", LocalDate.of(-12, 10, 3));
+ test("%tF", "-0123-10-03", LocalDate.of(-123, 10, 3));
+ test("%tF", "-1234-10-03", LocalDate.of(-1234, 10, 3));
+ test("%tF", "-12345-10-03", LocalDate.of(-12345, 10, 3));
+ test("%tF", "-12345-10-03", LocalDate.of(-12345, 10, 3));
+ test("%tF", "-12345-10-03", LocalDateTime.of(-12345, 10, 3, 0, 0, 0));
+ test("%tF", "-12345-10-03", OffsetDateTime.of(LocalDateTime.of(-12345, 10, 3, 0, 0, 0), ZoneOffset.UTC));
+ test("%tF", "-12345-10-03", ZonedDateTime.of(LocalDateTime.of(-12345, 10, 3, 0, 0, 0), ZoneOffset.UTC));
+
+ // check minusSign
+ int year = 2023, month = 1, dayOfMonth = 13;
+ String specifier = "%tF";
+ for (Locale locale : Locale.getAvailableLocales()) {
+ char minusSign = DecimalFormatSymbols.getInstance(locale).getMinusSign();
+ String str = new Formatter(new StringBuilder(), locale)
+ .format(specifier, LocalDate.of(year, month, dayOfMonth))
+ .toString();
+ test(locale, specifier, minusSign + str, LocalDate.of(-year, month, dayOfMonth));
+ }
+
+ // ja-JP-u-ca-japanese
+ ChronoLocalDate jpDate = Chronology
+ .ofLocale(Locale.forLanguageTag("ja-JP-u-ca-japanese"))
+ .dateNow();
+ test(Locale.JAPANESE,
+ "%tF",
+ String.format(
+ "%04d-%02d-%02d",
+ jpDate.get(ChronoField.YEAR_OF_ERA),
+ jpDate.get(ChronoField.MONTH_OF_YEAR),
+ jpDate.get(ChronoField.DAY_OF_MONTH)),
+ jpDate);
+
+ ChronoLocalDate jpDate1 = JapaneseChronology.INSTANCE.dateNow();
+ test(Locale.JAPANESE,
+ "%tF",
+ String.format(
+ "%04d-%02d-%02d",
+ jpDate1.get(ChronoField.YEAR_OF_ERA),
+ jpDate1.get(ChronoField.MONTH_OF_YEAR),
+ jpDate1.get(ChronoField.DAY_OF_MONTH)),
+ jpDate1);
}
}
From 1c0bd81a10f97c752818163a573d5983c7e481ac Mon Sep 17 00:00:00 2001
From: Weijun Wang
Date: Tue, 21 Nov 2023 17:46:11 +0000
Subject: [PATCH 009/250] 8319124: Update XML Security for Java to 3.0.3
Reviewed-by: mullan
---
.../apache/xml/internal/security/Init.java | 50 +--
.../security/algorithms/JCEMapper.java | 22 +-
.../algorithms/MessageDigestAlgorithm.java | 2 +
.../algorithms/SignatureAlgorithm.java | 8 +-
.../algorithms/SignatureAlgorithmSpi.java | 7 +-
.../implementations/ECDSAUtils.java | 7 +-
.../implementations/IntegrityHmac.java | 12 +
.../implementations/SignatureBaseRSA.java | 174 +++++++++-
.../implementations/SignatureDSA.java | 14 +
.../implementations/SignatureECDSA.java | 22 +-
.../implementations/SignatureEDDSA.java | 27 +-
.../internal/security/c14n/Canonicalizer.java | 2 +-
.../security/c14n/helper/AttrCompare.java | 6 +-
.../Canonicalizer11_OmitComments.java | 1 +
.../Canonicalizer11_WithComments.java | 1 +
.../Canonicalizer20010315.java | 4 +
.../Canonicalizer20010315Excl.java | 5 +
...Canonicalizer20010315ExclOmitComments.java | 1 +
...Canonicalizer20010315ExclWithComments.java | 1 +
.../Canonicalizer20010315OmitComments.java | 1 +
.../Canonicalizer20010315WithComments.java | 1 +
.../implementations/CanonicalizerBase.java | 8 +-
.../CanonicalizerPhysical.java | 4 +
.../implementations/NameSpaceSymbTable.java | 22 +-
.../exceptions/XMLSecurityException.java | 2 +
.../xml/internal/security/keys/KeyInfo.java | 1 +
.../keys/content/DEREncodedKeyValue.java | 1 +
.../keys/content/KeyInfoReference.java | 1 +
.../security/keys/content/KeyName.java | 1 +
.../security/keys/content/KeyValue.java | 1 +
.../security/keys/content/MgmtData.java | 1 +
.../security/keys/content/PGPData.java | 1 +
.../keys/content/RetrievalMethod.java | 1 +
.../security/keys/content/SPKIData.java | 1 +
.../security/keys/content/X509Data.java | 1 +
.../keys/content/keyvalues/DSAKeyValue.java | 2 +
.../keys/content/keyvalues/ECKeyValue.java | 11 +-
.../keys/content/keyvalues/RSAKeyValue.java | 2 +
.../keys/content/x509/XMLX509CRL.java | 1 +
.../keys/content/x509/XMLX509Certificate.java | 7 +-
.../keys/content/x509/XMLX509Digest.java | 1 +
.../content/x509/XMLX509IssuerSerial.java | 3 +
.../keys/content/x509/XMLX509SKI.java | 7 +-
.../keys/content/x509/XMLX509SubjectName.java | 3 +
.../keys/keyresolver/KeyResolver.java | 8 +-
.../implementations/PrivateKeyResolver.java | 2 +
.../implementations/RSAKeyValueResolver.java | 1 -
.../implementations/SecretKeyResolver.java | 2 +
.../implementations/SingleKeyResolver.java | 2 +
.../X509CertificateResolver.java | 4 +-
.../implementations/X509DigestResolver.java | 3 +-
.../implementations/X509SKIResolver.java | 9 +-
.../X509SubjectNameResolver.java | 15 +-
.../keys/storage/StorageResolver.java | 3 +
.../implementations/KeyStoreResolver.java | 4 +
.../SingleCertificateResolver.java | 4 +
.../internal/security/parser/XMLParser.java | 9 +
.../security/parser/XMLParserImpl.java | 6 +-
.../internal/security/signature/Manifest.java | 1 +
.../security/signature/ObjectContainer.java | 1 +
.../security/signature/Reference.java | 4 +
.../signature/SignatureProperties.java | 1 +
.../security/signature/SignatureProperty.java | 1 +
.../security/signature/SignedInfo.java | 3 +-
.../security/signature/XMLSignature.java | 1 +
.../security/signature/XMLSignatureInput.java | 1 +
.../reference/ReferenceSubTreeData.java | 5 +
.../xml/internal/security/utils/Base64.java | 44 +--
.../security/utils/DOMNamespaceContext.java | 3 +
.../security/utils/DigesterOutputStream.java | 5 +-
.../internal/security/utils/ElementProxy.java | 2 +-
.../security/utils/HelperNodeList.java | 2 +
.../internal/security/utils/JDKXPathAPI.java | 3 +
.../security/utils/JDKXPathFactory.java | 1 +
.../internal/security/utils/JavaUtils.java | 2 +-
.../utils/Signature11ElementProxy.java | 1 +
.../security/utils/SignatureElementProxy.java | 1 +
.../security/utils/SignerOutputStream.java | 3 +
.../utils/UnsyncByteArrayOutputStream.java | 3 +
.../xml/internal/security/utils/XMLUtils.java | 95 +++++-
.../implementations/ResolverDirectHTTP.java | 3 +-
.../implementations/ResolverFragment.java | 1 +
.../ResolverLocalFilesystem.java | 1 +
.../implementations/ResolverXPointer.java | 1 +
.../xml/crypto/dsig/SignatureMethod.java | 37 +++
.../dsig/internal/DigesterOutputStream.java | 1 +
.../xml/dsig/internal/MacOutputStream.java | 1 +
.../dom/AbstractDOMSignatureMethod.java | 6 +-
.../internal/dom/ApacheCanonicalizer.java | 14 +-
.../jcp/xml/dsig/internal/dom/ApacheData.java | 1 +
.../dsig/internal/dom/ApacheNodeSetData.java | 7 +-
.../internal/dom/ApacheOctetStreamData.java | 3 +
.../dsig/internal/dom/ApacheTransform.java | 28 +-
.../dom/DOMCanonicalXMLC14N11Method.java | 11 +-
.../dom/DOMCanonicalXMLC14NMethod.java | 12 +-
.../dom/DOMCanonicalizationMethod.java | 10 +-
.../dsig/internal/dom/DOMCryptoBinary.java | 3 +-
.../dsig/internal/dom/DOMDigestMethod.java | 19 +-
.../internal/dom/DOMEnvelopedTransform.java | 2 +
.../dsig/internal/dom/DOMExcC14NMethod.java | 22 +-
.../internal/dom/DOMHMACSignatureMethod.java | 38 ++-
.../jcp/xml/dsig/internal/dom/DOMKeyInfo.java | 3 +
.../dsig/internal/dom/DOMKeyInfoFactory.java | 14 +-
.../jcp/xml/dsig/internal/dom/DOMKeyName.java | 1 +
.../xml/dsig/internal/dom/DOMKeyValue.java | 2 +
.../xml/dsig/internal/dom/DOMManifest.java | 16 +-
.../jcp/xml/dsig/internal/dom/DOMPGPData.java | 13 +-
.../dom/DOMRSAPSSSignatureMethod.java | 34 +-
.../xml/dsig/internal/dom/DOMReference.java | 64 +++-
.../dsig/internal/dom/DOMRetrievalMethod.java | 5 +
.../dsig/internal/dom/DOMSignatureMethod.java | 308 ++++++++++++------
.../internal/dom/DOMSignatureProperties.java | 14 +-
.../internal/dom/DOMSignatureProperty.java | 15 +-
.../xml/dsig/internal/dom/DOMSignedInfo.java | 55 ++--
.../xml/dsig/internal/dom/DOMStructure.java | 6 +-
.../xml/dsig/internal/dom/DOMSubTreeData.java | 7 +-
.../xml/dsig/internal/dom/DOMTransform.java | 4 +
.../dsig/internal/dom/DOMURIDereferencer.java | 18 +-
.../xml/dsig/internal/dom/DOMX509Data.java | 7 +-
.../internal/dom/DOMX509IssuerSerial.java | 8 +-
.../xml/dsig/internal/dom/DOMXMLObject.java | 19 +-
.../dsig/internal/dom/DOMXMLSignature.java | 61 ++--
.../internal/dom/DOMXMLSignatureFactory.java | 64 +++-
.../dom/DOMXPathFilter2Transform.java | 3 +
.../dsig/internal/dom/DOMXPathTransform.java | 2 +
.../dsig/internal/dom/DOMXSLTTransform.java | 11 +-
.../org/jcp/xml/dsig/internal/dom/Utils.java | 6 +-
.../jcp/xml/dsig/internal/dom/XMLDSigRI.java | 18 +-
src/java.xml.crypto/share/legal/santuario.md | 2 +-
.../xml/crypto/dsig/GenerationTests.java | 48 ++-
130 files changed, 1337 insertions(+), 418 deletions(-)
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/Init.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/Init.java
index a35a4699d82a4..72153164340e4 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/Init.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/Init.java
@@ -57,17 +57,22 @@
*/
public class Init {
- /** The namespace for CONF file **/
+ /**
+ * The namespace for CONF file
+ **/
public static final String CONF_NS = "http://www.xmlsecurity.org/NS/#configuration";
private static final com.sun.org.slf4j.internal.Logger LOG =
- com.sun.org.slf4j.internal.LoggerFactory.getLogger(Init.class);
+ com.sun.org.slf4j.internal.LoggerFactory.getLogger(Init.class);
- /** Field alreadyInitialized */
+ /**
+ * Field alreadyInitialized
+ */
private static boolean alreadyInitialized = false;
/**
* Method isInitialized
+ *
* @return true if the library is already initialized.
*/
public static final synchronized boolean isInitialized() {
@@ -76,35 +81,28 @@ public static final synchronized boolean isInitialized() {
/**
* Method init
- *
*/
public static synchronized void init() {
if (alreadyInitialized) {
return;
}
+ PrivilegedAction action = () -> {
+ String cfile = System.getProperty("com.sun.org.apache.xml.internal.security.resource.config");
+ if (cfile == null) {
+ return null;
+ }
+ return getResourceAsStream(cfile, Init.class);
+ };
- @SuppressWarnings("removal")
- InputStream is = //NOPMD
- AccessController.doPrivileged(
- (PrivilegedAction)
- () -> {
- String cfile =
- System.getProperty("com.sun.org.apache.xml.internal.security.resource.config");
- if (cfile == null) {
- return null;
- }
- return getResourceAsStream(cfile, Init.class);
- }
- );
- if (is == null) {
- dynamicInit();
- } else {
- fileInit(is);
- try {
- is.close();
- } catch (IOException ex) {
- LOG.warn(ex.getMessage());
+ try (@SuppressWarnings("removal")
+ InputStream is = AccessController.doPrivileged(action)) {
+ if (is == null) {
+ dynamicInit();
+ } else {
+ fileInit(is);
}
+ } catch (IOException ex) {
+ LOG.warn(ex.getMessage(), ex);
}
alreadyInitialized = true;
@@ -412,9 +410,11 @@ private static List getResources(String resourceName, Class> callingClass
}
List ret = new ArrayList<>();
Enumeration urls = new Enumeration() {
+ @Override
public boolean hasMoreElements() {
return false;
}
+ @Override
public URL nextElement() {
return null;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java
index 5483f02f127d4..e4c1a30d52545 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java
@@ -40,7 +40,9 @@ public class JCEMapper {
private static Map algorithmsMap = new ConcurrentHashMap<>();
- private static String providerName;
+ private static String globalProviderName;
+
+ private static final ThreadLocal threadSpecificProviderName = new ThreadLocal<>();
/**
* Method register
@@ -344,7 +346,10 @@ private static Algorithm getAlgorithm(String algorithmURI) {
* @return the default providerId.
*/
public static String getProviderId() {
- return providerName;
+ if (threadSpecificProviderName.get() != null) {
+ return threadSpecificProviderName.get();
+ }
+ return globalProviderName;
}
/**
@@ -355,7 +360,18 @@ public static String getProviderId() {
*/
public static void setProviderId(String provider) {
JavaUtils.checkRegisterPermission();
- providerName = provider;
+ globalProviderName = provider;
+ }
+
+ /**
+ * Sets the default Provider for this thread to obtain the security algorithms
+ * @param threadSpecificProviderName the default providerId.
+ * @throws SecurityException if a security manager is installed and the
+ * caller does not have permission to register the JCE algorithm
+ */
+ public static void setThreadSpecificProviderName(String threadSpecificProviderName) {
+ JavaUtils.checkRegisterPermission();
+ JCEMapper.threadSpecificProviderName.set(threadSpecificProviderName);
}
/**
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java
index 6c3f500dbe81b..17351f0211e9e 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java
@@ -256,11 +256,13 @@ public void update(byte[] buf, int offset, int len) {
}
/** {@inheritDoc} */
+ @Override
public String getBaseNamespace() {
return Constants.SignatureSpecNS;
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_DIGESTMETHOD;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java
index 0c984d4e0300b..439eefb10dc73 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java
@@ -31,7 +31,11 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import com.sun.org.apache.xml.internal.security.algorithms.implementations.*;
+import com.sun.org.apache.xml.internal.security.algorithms.implementations.IntegrityHmac;
+import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureBaseRSA;
+import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureDSA;
+import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureECDSA;
+import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureEDDSA;
import com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
@@ -524,6 +528,7 @@ public static void registerDefaultAlgorithms() {
*
* @return URI of this element
*/
+ @Override
public String getBaseNamespace() {
return Constants.SignatureSpecNS;
}
@@ -533,6 +538,7 @@ public String getBaseNamespace() {
*
* @return Local name
*/
+ @Override
public String getBaseLocalName() {
return Constants._TAG_SIGNATUREMETHOD;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithmSpi.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithmSpi.java
index a049733c0ad1a..fde070f635452 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithmSpi.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithmSpi.java
@@ -22,7 +22,12 @@
*/
package com.sun.org.apache.xml.internal.security.algorithms;
-import java.security.*;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.SecureRandom;
+import java.security.Signature;
import java.security.spec.AlgorithmParameterSpec;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/ECDSAUtils.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/ECDSAUtils.java
index 510fab21584ec..73e02864bd926 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/ECDSAUtils.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/ECDSAUtils.java
@@ -28,7 +28,12 @@
import java.io.IOException;
import java.math.BigInteger;
import java.security.interfaces.ECPublicKey;
-import java.security.spec.*;
+import java.security.spec.ECField;
+import java.security.spec.ECFieldF2m;
+import java.security.spec.ECFieldFp;
+import java.security.spec.ECParameterSpec;
+import java.security.spec.ECPoint;
+import java.security.spec.EllipticCurve;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/IntegrityHmac.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/IntegrityHmac.java
index fdaf8643279c8..8f833756ff88c 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/IntegrityHmac.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/IntegrityHmac.java
@@ -90,6 +90,7 @@ public IntegrityHmac(Provider provider) throws XMLSignatureException {
* @param params
* @throws XMLSignatureException
*/
+ @Override
protected void engineSetParameter(AlgorithmParameterSpec params) throws XMLSignatureException {
throw new XMLSignatureException("empty", new Object[]{"Incorrect method call"});
}
@@ -102,6 +103,7 @@ protected void engineSetParameter(AlgorithmParameterSpec params) throws XMLSigna
* @return true if the signature is correct
* @throws XMLSignatureException
*/
+ @Override
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
try {
if (hmacOutputLength != null && hmacOutputLength.length < getDigestLength()) {
@@ -124,6 +126,7 @@ protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
* @param secretKey
* @throws XMLSignatureException
*/
+ @Override
protected void engineInitVerify(Key secretKey) throws XMLSignatureException {
if (!(secretKey instanceof SecretKey)) {
String supplied = null;
@@ -150,6 +153,7 @@ protected void engineInitVerify(Key secretKey) throws XMLSignatureException {
* @return the result of the {@link java.security.Signature#sign()} method
* @throws XMLSignatureException
*/
+ @Override
protected byte[] engineSign() throws XMLSignatureException {
try {
if (hmacOutputLength != null && hmacOutputLength.length < getDigestLength()) {
@@ -170,6 +174,7 @@ protected byte[] engineSign() throws XMLSignatureException {
* @param secretKey
* @throws XMLSignatureException
*/
+ @Override
protected void engineInitSign(Key secretKey) throws XMLSignatureException {
engineInitSign(secretKey, (AlgorithmParameterSpec)null);
}
@@ -181,6 +186,7 @@ protected void engineInitSign(Key secretKey) throws XMLSignatureException {
* @param algorithmParameterSpec
* @throws XMLSignatureException
*/
+ @Override
protected void engineInitSign(
Key secretKey, AlgorithmParameterSpec algorithmParameterSpec
) throws XMLSignatureException {
@@ -213,6 +219,7 @@ protected void engineInitSign(
* @param secureRandom
* @throws XMLSignatureException
*/
+ @Override
protected void engineInitSign(Key secretKey, SecureRandom secureRandom)
throws XMLSignatureException {
throw new XMLSignatureException("algorithms.CannotUseSecureRandomOnMAC");
@@ -225,6 +232,7 @@ protected void engineInitSign(Key secretKey, SecureRandom secureRandom)
* @param input
* @throws XMLSignatureException
*/
+ @Override
protected void engineUpdate(byte[] input) throws XMLSignatureException {
try {
this.macAlgorithm.update(input);
@@ -240,6 +248,7 @@ protected void engineUpdate(byte[] input) throws XMLSignatureException {
* @param input
* @throws XMLSignatureException
*/
+ @Override
protected void engineUpdate(byte input) throws XMLSignatureException {
try {
this.macAlgorithm.update(input);
@@ -257,6 +266,7 @@ protected void engineUpdate(byte input) throws XMLSignatureException {
* @param len
* @throws XMLSignatureException
*/
+ @Override
protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignatureException {
try {
this.macAlgorithm.update(buf, offset, len);
@@ -270,6 +280,7 @@ protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignature
* {@inheritDoc}
*
*/
+ @Override
protected String engineGetJCEAlgorithmString() {
return this.macAlgorithm.getAlgorithm();
}
@@ -279,6 +290,7 @@ protected String engineGetJCEAlgorithmString() {
*
* {@inheritDoc}
*/
+ @Override
protected String engineGetJCEProviderName() {
return this.macAlgorithm.getProvider().getName();
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureBaseRSA.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureBaseRSA.java
index 5186520729a6f..45dafc3ad3894 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureBaseRSA.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureBaseRSA.java
@@ -31,6 +31,8 @@
import java.security.Signature;
import java.security.SignatureException;
import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.MGF1ParameterSpec;
+import java.security.spec.PSSParameterSpec;
import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper;
import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithmSpi;
@@ -43,8 +45,6 @@
import org.w3c.dom.Text;
import javax.xml.crypto.dsig.DigestMethod;
-import java.security.spec.MGF1ParameterSpec;
-import java.security.spec.PSSParameterSpec;
public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
@@ -65,20 +65,25 @@ public SignatureBaseRSA() throws XMLSignatureException {
public SignatureBaseRSA(Provider provider) throws XMLSignatureException {
String algorithmID = JCEMapper.translateURItoJCEID(this.engineGetURI());
- LOG.debug("Created SignatureRSA using {}", algorithmID);
+ this.signatureAlgorithm = getSignature(provider, algorithmID);
+ LOG.debug("Created SignatureRSA using {0} and provider {1}",
+ algorithmID, signatureAlgorithm.getProvider());
+ }
+ Signature getSignature(Provider provider, String algorithmID)
+ throws XMLSignatureException {
try {
if (provider == null) {
String providerId = JCEMapper.getProviderId();
if (providerId == null) {
- this.signatureAlgorithm = Signature.getInstance(algorithmID);
+ return Signature.getInstance(algorithmID);
} else {
- this.signatureAlgorithm = Signature.getInstance(algorithmID, providerId);
+ return Signature.getInstance(algorithmID, providerId);
}
} else {
- this.signatureAlgorithm = Signature.getInstance(algorithmID, provider);
+ return Signature.getInstance(algorithmID, provider);
}
} catch (NoSuchAlgorithmException | NoSuchProviderException ex) {
@@ -88,6 +93,7 @@ public SignatureBaseRSA(Provider provider) throws XMLSignatureException {
}
/** {@inheritDoc} */
+ @Override
protected void engineSetParameter(AlgorithmParameterSpec params)
throws XMLSignatureException {
try {
@@ -98,6 +104,7 @@ protected void engineSetParameter(AlgorithmParameterSpec params)
}
/** {@inheritDoc} */
+ @Override
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
try {
return this.signatureAlgorithm.verify(signature);
@@ -107,11 +114,13 @@ protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
}
/** {@inheritDoc} */
+ @Override
protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
engineInitVerify(publicKey, this.signatureAlgorithm);
}
/** {@inheritDoc} */
+ @Override
protected byte[] engineSign() throws XMLSignatureException {
try {
return this.signatureAlgorithm.sign();
@@ -121,17 +130,20 @@ protected byte[] engineSign() throws XMLSignatureException {
}
/** {@inheritDoc} */
+ @Override
protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
throws XMLSignatureException {
engineInitSign(privateKey, secureRandom, this.signatureAlgorithm);
}
/** {@inheritDoc} */
+ @Override
protected void engineInitSign(Key privateKey) throws XMLSignatureException {
engineInitSign(privateKey, (SecureRandom)null);
}
/** {@inheritDoc} */
+ @Override
protected void engineUpdate(byte[] input) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(input);
@@ -141,6 +153,7 @@ protected void engineUpdate(byte[] input) throws XMLSignatureException {
}
/** {@inheritDoc} */
+ @Override
protected void engineUpdate(byte input) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(input);
@@ -150,6 +163,7 @@ protected void engineUpdate(byte input) throws XMLSignatureException {
}
/** {@inheritDoc} */
+ @Override
protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(buf, offset, len);
@@ -159,22 +173,26 @@ protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignature
}
/** {@inheritDoc} */
+ @Override
protected String engineGetJCEAlgorithmString() {
return this.signatureAlgorithm.getAlgorithm();
}
/** {@inheritDoc} */
+ @Override
protected String engineGetJCEProviderName() {
return this.signatureAlgorithm.getProvider().getName();
}
/** {@inheritDoc} */
+ @Override
protected void engineSetHMACOutputLength(int HMACOutputLength)
throws XMLSignatureException {
throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
}
/** {@inheritDoc} */
+ @Override
protected void engineInitSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
) throws XMLSignatureException {
@@ -356,10 +374,53 @@ public String engineGetURI() {
}
}
+ public abstract static class SignatureBaseRSAPSS extends SignatureBaseRSA {
+
+ public SignatureBaseRSAPSS() throws XMLSignatureException {
+ super();
+ }
+
+ public SignatureBaseRSAPSS(Provider provider) throws XMLSignatureException {
+ super(provider);
+ }
+
+ @Override
+ Signature getSignature(Provider provider, String algorithmID)
+ throws XMLSignatureException {
+ try {
+ Signature sig;
+ if (provider == null) {
+ String providerId = JCEMapper.getProviderId();
+ if (providerId == null) {
+ sig = Signature.getInstance("RSASSA-PSS");
+ } else {
+ sig = Signature.getInstance("RSASSA-PSS", providerId);
+ }
+ } else {
+ sig = Signature.getInstance("RSASSA-PSS", provider);
+ }
+ try {
+ sig.setParameter(getPSSParameterSpec());
+ } catch (InvalidAlgorithmParameterException e) {
+ throw new NoSuchAlgorithmException("Should not happen", e);
+ }
+ return sig;
+ } catch (NoSuchAlgorithmException | NoSuchProviderException e) {
+ return super.getSignature(provider, algorithmID);
+ }
+ }
+
+ abstract PSSParameterSpec getPSSParameterSpec();
+ }
+
/**
* Class SignatureRSASHA1MGF1
*/
- public static class SignatureRSASHA1MGF1 extends SignatureBaseRSA {
+ public static class SignatureRSASHA1MGF1 extends SignatureBaseRSAPSS {
+
+ private static final PSSParameterSpec SHA1_MGF1_PARAMS
+ = new PSSParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1,
+ 20, PSSParameterSpec.TRAILER_FIELD_BC);
/**
* Constructor SignatureRSASHA1MGF1
@@ -379,12 +440,21 @@ public SignatureRSASHA1MGF1(Provider provider) throws XMLSignatureException {
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1_MGF1;
}
+
+ @Override
+ public PSSParameterSpec getPSSParameterSpec() {
+ return SHA1_MGF1_PARAMS;
+ }
}
/**
* Class SignatureRSASHA224MGF1
*/
- public static class SignatureRSASHA224MGF1 extends SignatureBaseRSA {
+ public static class SignatureRSASHA224MGF1 extends SignatureBaseRSAPSS {
+
+ private static final PSSParameterSpec SHA224_MGF1_PARAMS
+ = new PSSParameterSpec("SHA-224", "MGF1", MGF1ParameterSpec.SHA224,
+ 28, PSSParameterSpec.TRAILER_FIELD_BC);
/**
* Constructor SignatureRSASHA224MGF1
@@ -404,12 +474,21 @@ public SignatureRSASHA224MGF1(Provider provider) throws XMLSignatureException {
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA224_MGF1;
}
+
+ @Override
+ public PSSParameterSpec getPSSParameterSpec() {
+ return SHA224_MGF1_PARAMS;
+ }
}
/**
* Class SignatureRSASHA256MGF1
*/
- public static class SignatureRSASHA256MGF1 extends SignatureBaseRSA {
+ public static class SignatureRSASHA256MGF1 extends SignatureBaseRSAPSS {
+
+ private static final PSSParameterSpec SHA256_MGF1_PARAMS
+ = new PSSParameterSpec("SHA-256", "MGF1", MGF1ParameterSpec.SHA256,
+ 32, PSSParameterSpec.TRAILER_FIELD_BC);
/**
* Constructor SignatureRSASHA256MGF1
@@ -429,12 +508,21 @@ public SignatureRSASHA256MGF1(Provider provider) throws XMLSignatureException {
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256_MGF1;
}
+
+ @Override
+ public PSSParameterSpec getPSSParameterSpec() {
+ return SHA256_MGF1_PARAMS;
+ }
}
/**
* Class SignatureRSASHA384MGF1
*/
- public static class SignatureRSASHA384MGF1 extends SignatureBaseRSA {
+ public static class SignatureRSASHA384MGF1 extends SignatureBaseRSAPSS {
+
+ private static final PSSParameterSpec SHA384_MGF1_PARAMS
+ = new PSSParameterSpec("SHA-384", "MGF1", MGF1ParameterSpec.SHA384,
+ 48, PSSParameterSpec.TRAILER_FIELD_BC);
/**
* Constructor SignatureRSASHA384MGF1
@@ -454,12 +542,21 @@ public SignatureRSASHA384MGF1(Provider provider) throws XMLSignatureException {
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384_MGF1;
}
+
+ @Override
+ public PSSParameterSpec getPSSParameterSpec() {
+ return SHA384_MGF1_PARAMS;
+ }
}
/**
* Class SignatureRSASHA512MGF1
*/
- public static class SignatureRSASHA512MGF1 extends SignatureBaseRSA {
+ public static class SignatureRSASHA512MGF1 extends SignatureBaseRSAPSS {
+
+ private static final PSSParameterSpec SHA512_MGF1_PARAMS
+ = new PSSParameterSpec("SHA-512", "MGF1", MGF1ParameterSpec.SHA512,
+ 64, PSSParameterSpec.TRAILER_FIELD_BC);
/**
* Constructor SignatureRSASHA512MGF1
@@ -479,12 +576,22 @@ public SignatureRSASHA512MGF1(Provider provider) throws XMLSignatureException {
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512_MGF1;
}
+
+ @Override
+ public PSSParameterSpec getPSSParameterSpec() {
+ return SHA512_MGF1_PARAMS;
+ }
}
/**
* Class SignatureRSA3_SHA224MGF1
*/
- public static class SignatureRSASHA3_224MGF1 extends SignatureBaseRSA {
+ public static class SignatureRSASHA3_224MGF1 extends SignatureBaseRSAPSS {
+
+ private static final PSSParameterSpec SHA3_224_MGF1_PARAMS
+ = new PSSParameterSpec("SHA3-224", "MGF1",
+ new MGF1ParameterSpec("SHA3-224"),
+ 28, PSSParameterSpec.TRAILER_FIELD_BC);
/**
* Constructor SignatureRSASHA3_224MGF1
@@ -504,12 +611,22 @@ public SignatureRSASHA3_224MGF1(Provider provider) throws XMLSignatureException
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA3_224_MGF1;
}
+
+ @Override
+ public PSSParameterSpec getPSSParameterSpec() {
+ return SHA3_224_MGF1_PARAMS;
+ }
}
/**
* Class SignatureRSA3_SHA256MGF1
*/
- public static class SignatureRSASHA3_256MGF1 extends SignatureBaseRSA {
+ public static class SignatureRSASHA3_256MGF1 extends SignatureBaseRSAPSS {
+
+ private static final PSSParameterSpec SHA3_256_MGF1_PARAMS
+ = new PSSParameterSpec("SHA3-256", "MGF1",
+ new MGF1ParameterSpec("SHA3-256"),
+ 32, PSSParameterSpec.TRAILER_FIELD_BC);
/**
* Constructor SignatureRSASHA3_256MGF1
@@ -529,12 +646,22 @@ public SignatureRSASHA3_256MGF1(Provider provider) throws XMLSignatureException
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA3_256_MGF1;
}
+
+ @Override
+ public PSSParameterSpec getPSSParameterSpec() {
+ return SHA3_256_MGF1_PARAMS;
+ }
}
/**
* Class SignatureRSA3_SHA384MGF1
*/
- public static class SignatureRSASHA3_384MGF1 extends SignatureBaseRSA {
+ public static class SignatureRSASHA3_384MGF1 extends SignatureBaseRSAPSS {
+
+ private static final PSSParameterSpec SHA3_384_MGF1_PARAMS
+ = new PSSParameterSpec("SHA3-384", "MGF1",
+ new MGF1ParameterSpec("SHA3-384"),
+ 48, PSSParameterSpec.TRAILER_FIELD_BC);
/**
* Constructor SignatureRSASHA3_384MGF1
@@ -554,12 +681,22 @@ public SignatureRSASHA3_384MGF1(Provider provider) throws XMLSignatureException
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA3_384_MGF1;
}
+
+ @Override
+ public PSSParameterSpec getPSSParameterSpec() {
+ return SHA3_384_MGF1_PARAMS;
+ }
}
/**
* Class SignatureRSASHA3_512MGF1
*/
- public static class SignatureRSASHA3_512MGF1 extends SignatureBaseRSA {
+ public static class SignatureRSASHA3_512MGF1 extends SignatureBaseRSAPSS {
+
+ private static final PSSParameterSpec SHA3_512_MGF1_PARAMS
+ = new PSSParameterSpec("SHA3-512", "MGF1",
+ new MGF1ParameterSpec("SHA3-512"),
+ 64, PSSParameterSpec.TRAILER_FIELD_BC);
/**
* Constructor SignatureRSASHA3_512MGF1
@@ -579,10 +716,15 @@ public SignatureRSASHA3_512MGF1(Provider provider) throws XMLSignatureException
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA3_512_MGF1;
}
+
+ @Override
+ public PSSParameterSpec getPSSParameterSpec() {
+ return SHA3_512_MGF1_PARAMS;
+ }
}
public static class SignatureRSASSAPSS extends SignatureBaseRSA {
- PSSParameterSpec pssParameterSpec;
+ private PSSParameterSpec pssParameterSpec;
public enum DigestAlgorithm {
SHA224("SHA-224", DigestMethod.SHA224, 28),
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureDSA.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureDSA.java
index 0f9f8463252a8..c2b0d05763df7 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureDSA.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureDSA.java
@@ -60,6 +60,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
*
* {@inheritDoc}
*/
+ @Override
protected String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_DSA;
}
@@ -100,6 +101,7 @@ public SignatureDSA(Provider provider) throws XMLSignatureException {
/**
* {@inheritDoc}
*/
+ @Override
protected void engineSetParameter(AlgorithmParameterSpec params)
throws XMLSignatureException {
try {
@@ -112,6 +114,7 @@ protected void engineSetParameter(AlgorithmParameterSpec params)
/**
* {@inheritDoc}
*/
+ @Override
protected boolean engineVerify(byte[] signature)
throws XMLSignatureException {
try {
@@ -130,6 +133,7 @@ protected boolean engineVerify(byte[] signature)
/**
* {@inheritDoc}
*/
+ @Override
protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
engineInitVerify(publicKey, this.signatureAlgorithm);
size = ((DSAKey)publicKey).getParams().getQ().bitLength();
@@ -138,6 +142,7 @@ protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
/**
* {@inheritDoc}
*/
+ @Override
protected byte[] engineSign() throws XMLSignatureException {
try {
byte[] jcebytes = this.signatureAlgorithm.sign();
@@ -151,6 +156,7 @@ protected byte[] engineSign() throws XMLSignatureException {
/**
* {@inheritDoc}
*/
+ @Override
protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
throws XMLSignatureException {
engineInitSign(privateKey, secureRandom, this.signatureAlgorithm);
@@ -160,6 +166,7 @@ protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
/**
* {@inheritDoc}
*/
+ @Override
protected void engineInitSign(Key privateKey) throws XMLSignatureException {
engineInitSign(privateKey, (SecureRandom)null);
}
@@ -167,6 +174,7 @@ protected void engineInitSign(Key privateKey) throws XMLSignatureException {
/**
* {@inheritDoc}
*/
+ @Override
protected void engineUpdate(byte[] input) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(input);
@@ -178,6 +186,7 @@ protected void engineUpdate(byte[] input) throws XMLSignatureException {
/**
* {@inheritDoc}
*/
+ @Override
protected void engineUpdate(byte input) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(input);
@@ -189,6 +198,7 @@ protected void engineUpdate(byte input) throws XMLSignatureException {
/**
* {@inheritDoc}
*/
+ @Override
protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(buf, offset, len);
@@ -202,6 +212,7 @@ protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignature
*
* {@inheritDoc}
*/
+ @Override
protected String engineGetJCEAlgorithmString() {
return this.signatureAlgorithm.getAlgorithm();
}
@@ -211,6 +222,7 @@ protected String engineGetJCEAlgorithmString() {
*
* {@inheritDoc}
*/
+ @Override
protected String engineGetJCEProviderName() {
return this.signatureAlgorithm.getProvider().getName();
}
@@ -221,6 +233,7 @@ protected String engineGetJCEProviderName() {
* @param HMACOutputLength
* @throws XMLSignatureException
*/
+ @Override
protected void engineSetHMACOutputLength(int HMACOutputLength) throws XMLSignatureException {
throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
}
@@ -232,6 +245,7 @@ protected void engineSetHMACOutputLength(int HMACOutputLength) throws XMLSignatu
* @param algorithmParameterSpec
* @throws XMLSignatureException
*/
+ @Override
protected void engineInitSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
) throws XMLSignatureException {
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureECDSA.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureECDSA.java
index 381ead9ec2efb..75a88b8eb1332 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureECDSA.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureECDSA.java
@@ -26,7 +26,14 @@
package com.sun.org.apache.xml.internal.security.algorithms.implementations;
import java.io.IOException;
-import java.security.*;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.Signature;
+import java.security.SignatureException;
import java.security.interfaces.ECPrivateKey;
import java.security.spec.AlgorithmParameterSpec;
@@ -118,6 +125,7 @@ public SignatureECDSA(Provider provider) throws XMLSignatureException {
}
/** {@inheritDoc} */
+ @Override
protected void engineSetParameter(AlgorithmParameterSpec params)
throws XMLSignatureException {
try {
@@ -128,6 +136,7 @@ protected void engineSetParameter(AlgorithmParameterSpec params)
}
/** {@inheritDoc} */
+ @Override
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
try {
byte[] jcebytes = SignatureECDSA.convertXMLDSIGtoASN1(signature);
@@ -143,11 +152,13 @@ protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
}
/** {@inheritDoc} */
+ @Override
protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
engineInitVerify(publicKey, signatureAlgorithm);
}
/** {@inheritDoc} */
+ @Override
protected byte[] engineSign() throws XMLSignatureException {
try {
byte[] jcebytes = this.signatureAlgorithm.sign();
@@ -158,6 +169,7 @@ protected byte[] engineSign() throws XMLSignatureException {
}
/** {@inheritDoc} */
+ @Override
protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
throws XMLSignatureException {
if (privateKey instanceof ECPrivateKey) {
@@ -169,11 +181,13 @@ protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
}
/** {@inheritDoc} */
+ @Override
protected void engineInitSign(Key privateKey) throws XMLSignatureException {
engineInitSign(privateKey, (SecureRandom)null);
}
/** {@inheritDoc} */
+ @Override
protected void engineUpdate(byte[] input) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(input);
@@ -183,6 +197,7 @@ protected void engineUpdate(byte[] input) throws XMLSignatureException {
}
/** {@inheritDoc} */
+ @Override
protected void engineUpdate(byte input) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(input);
@@ -192,6 +207,7 @@ protected void engineUpdate(byte input) throws XMLSignatureException {
}
/** {@inheritDoc} */
+ @Override
protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(buf, offset, len);
@@ -201,22 +217,26 @@ protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignature
}
/** {@inheritDoc} */
+ @Override
protected String engineGetJCEAlgorithmString() {
return this.signatureAlgorithm.getAlgorithm();
}
/** {@inheritDoc} */
+ @Override
protected String engineGetJCEProviderName() {
return this.signatureAlgorithm.getProvider().getName();
}
/** {@inheritDoc} */
+ @Override
protected void engineSetHMACOutputLength(int HMACOutputLength)
throws XMLSignatureException {
throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
}
/** {@inheritDoc} */
+ @Override
protected void engineInitSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
) throws XMLSignatureException {
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureEDDSA.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureEDDSA.java
index 03eb36e076c27..c297d96faeab5 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureEDDSA.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureEDDSA.java
@@ -22,16 +22,22 @@
*/
package com.sun.org.apache.xml.internal.security.algorithms.implementations;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.Signature;
+import java.security.SignatureException;
+import java.security.spec.AlgorithmParameterSpec;
+
import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper;
import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithmSpi;
import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
-import java.io.IOException;
-import java.security.*;
-import java.security.spec.AlgorithmParameterSpec;
-
/**
*
*/
@@ -77,6 +83,7 @@ public SignatureEDDSA(Provider provider) throws XMLSignatureException {
}
/** {@inheritDoc} */
+ @Override
protected void engineSetParameter(AlgorithmParameterSpec params)
throws XMLSignatureException {
try {
@@ -87,6 +94,7 @@ protected void engineSetParameter(AlgorithmParameterSpec params)
}
/** {@inheritDoc} */
+ @Override
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
try {
@@ -101,11 +109,13 @@ protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
}
/** {@inheritDoc} */
+ @Override
protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
engineInitVerify(publicKey, signatureAlgorithm);
}
/** {@inheritDoc} */
+ @Override
protected byte[] engineSign() throws XMLSignatureException {
try {
return this.signatureAlgorithm.sign();
@@ -115,6 +125,7 @@ protected byte[] engineSign() throws XMLSignatureException {
}
/** {@inheritDoc} */
+ @Override
protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
throws XMLSignatureException {
@@ -122,11 +133,13 @@ protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
}
/** {@inheritDoc} */
+ @Override
protected void engineInitSign(Key privateKey) throws XMLSignatureException {
engineInitSign(privateKey, (SecureRandom)null);
}
/** {@inheritDoc} */
+ @Override
protected void engineUpdate(byte[] input) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(input);
@@ -136,6 +149,7 @@ protected void engineUpdate(byte[] input) throws XMLSignatureException {
}
/** {@inheritDoc} */
+ @Override
protected void engineUpdate(byte input) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(input);
@@ -145,6 +159,7 @@ protected void engineUpdate(byte input) throws XMLSignatureException {
}
/** {@inheritDoc} */
+ @Override
protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(buf, offset, len);
@@ -154,22 +169,26 @@ protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignature
}
/** {@inheritDoc} */
+ @Override
protected String engineGetJCEAlgorithmString() {
return this.signatureAlgorithm.getAlgorithm();
}
/** {@inheritDoc} */
+ @Override
protected String engineGetJCEProviderName() {
return this.signatureAlgorithm.getProvider().getName();
}
/** {@inheritDoc} */
+ @Override
protected void engineSetHMACOutputLength(int HMACOutputLength)
throws XMLSignatureException {
throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
}
/** {@inheritDoc} */
+ @Override
protected void engineInitSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
) throws XMLSignatureException {
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java
index 71e2d976b5735..4e639339523e1 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java
@@ -122,7 +122,7 @@ private Canonicalizer(String algorithmURI) throws InvalidCanonicalizerException
* @return a Canonicalizer instance ready for the job
* @throws InvalidCanonicalizerException
*/
- public static final Canonicalizer getInstance(String algorithmURI)
+ public static Canonicalizer getInstance(String algorithmURI)
throws InvalidCanonicalizerException {
return new Canonicalizer(algorithmURI);
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/helper/AttrCompare.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/helper/AttrCompare.java
index 5ac239cd3a3b3..cbd541e63b055 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/helper/AttrCompare.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/helper/AttrCompare.java
@@ -22,11 +22,12 @@
*/
package com.sun.org.apache.xml.internal.security.c14n.helper;
-import com.sun.org.apache.xml.internal.security.utils.Constants;
-import org.w3c.dom.Attr;
import java.io.Serializable;
import java.util.Comparator;
+import com.sun.org.apache.xml.internal.security.utils.Constants;
+import org.w3c.dom.Attr;
+
/**
* Compares two attributes based on the C14n specification.
*
@@ -69,6 +70,7 @@ public class AttrCompare implements Comparator, Serializable {
* obj0 is less than, equal to, or greater than obj1
*
*/
+ @Override
public int compare(Attr attr0, Attr attr1) {
String namespaceURI0 = attr0.getNamespaceURI();
String namespaceURI1 = attr1.getNamespaceURI();
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11_OmitComments.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11_OmitComments.java
index 867faad7a8d5b..2f8254449f804 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11_OmitComments.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11_OmitComments.java
@@ -32,6 +32,7 @@ public Canonicalizer11_OmitComments() {
super(false, true);
}
+ @Override
public final String engineGetURI() {
return Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11_WithComments.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11_WithComments.java
index b4ded12429f47..181e559f5a172 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11_WithComments.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11_WithComments.java
@@ -32,6 +32,7 @@ public Canonicalizer11_WithComments() {
super(true, true);
}
+ @Override
public final String engineGetURI() {
return Canonicalizer.ALGO_ID_C14N11_WITH_COMMENTS;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java
index f0cd610b3209a..6b6fda395c9f4 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java
@@ -83,6 +83,7 @@ public Canonicalizer20010315(boolean includeComments, boolean c14n11) {
* @param writer OutputStream to write the canonicalization result
* @throws CanonicalizationException always
*/
+ @Override
public void engineCanonicalizeXPathNodeSet(Set xpathNodeSet, String inclusiveNamespaces, OutputStream writer)
throws CanonicalizationException {
@@ -98,6 +99,7 @@ public void engineCanonicalizeXPathNodeSet(Set xpathNodeSet, String inclus
* @param writer OutputStream to write the canonicalization result
* @throws CanonicalizationException
*/
+ @Override
public void engineCanonicalizeSubTree(Node rootNode, String inclusiveNamespaces, OutputStream writer)
throws CanonicalizationException {
@@ -113,6 +115,7 @@ public void engineCanonicalizeSubTree(Node rootNode, String inclusiveNamespaces,
* @param writer OutputStream to write the canonicalization result
* @throws CanonicalizationException
*/
+ @Override
public void engineCanonicalizeSubTree(
Node rootNode, String inclusiveNamespaces, boolean propagateDefaultNamespace, OutputStream writer)
throws CanonicalizationException {
@@ -297,6 +300,7 @@ protected void outputAttributes(Element element, NameSpaceSymbTable ns,
}
}
+ @Override
protected void circumventBugIfNeeded(XMLSignatureInput input)
throws XMLParserException, IOException {
if (!input.isNeedsToBeExpanded()) {
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java
index b7c543e583a42..44323692ee723 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java
@@ -82,6 +82,7 @@ public Canonicalizer20010315Excl(boolean includeComments) {
* @param writer OutputStream to write the canonicalization result
* @throws CanonicalizationException
*/
+ @Override
public void engineCanonicalizeSubTree(Node rootNode, OutputStream writer)
throws CanonicalizationException {
engineCanonicalizeSubTree(rootNode, "", null, writer);
@@ -95,6 +96,7 @@ public void engineCanonicalizeSubTree(Node rootNode, OutputStream writer)
* @param writer OutputStream to write the canonicalization result
* @throws CanonicalizationException
*/
+ @Override
public void engineCanonicalizeSubTree(
Node rootNode, String inclusiveNamespaces, OutputStream writer
) throws CanonicalizationException {
@@ -110,6 +112,7 @@ public void engineCanonicalizeSubTree(
* @param writer OutputStream to write the canonicalization result
* @throws CanonicalizationException
*/
+ @Override
public void engineCanonicalizeSubTree(
Node rootNode, String inclusiveNamespaces, boolean propagateDefaultNamespace, OutputStream writer
) throws CanonicalizationException {
@@ -155,6 +158,7 @@ public void engineCanonicalize(
* @param writer OutputStream to write the canonicalization result
* @throws CanonicalizationException
*/
+ @Override
public void engineCanonicalizeXPathNodeSet(
Set xpathNodeSet, String inclusiveNamespaces, OutputStream writer
) throws CanonicalizationException {
@@ -336,6 +340,7 @@ protected void outputAttributes(Element element, NameSpaceSymbTable ns,
}
}
+ @Override
protected void circumventBugIfNeeded(XMLSignatureInput input)
throws XMLParserException, IOException {
if (!input.isNeedsToBeExpanded() || inclusiveNSSet.isEmpty()) {
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315ExclOmitComments.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315ExclOmitComments.java
index df9f88a8386b1..ab6a65ccabc47 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315ExclOmitComments.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315ExclOmitComments.java
@@ -34,6 +34,7 @@ public Canonicalizer20010315ExclOmitComments() {
}
/** {@inheritDoc} */
+ @Override
public final String engineGetURI() {
return Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315ExclWithComments.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315ExclWithComments.java
index 6b80e68525ee8..054343005ff53 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315ExclWithComments.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315ExclWithComments.java
@@ -38,6 +38,7 @@ public Canonicalizer20010315ExclWithComments() {
}
/** {@inheritDoc} */
+ @Override
public final String engineGetURI() {
return Canonicalizer.ALGO_ID_C14N_EXCL_WITH_COMMENTS;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315OmitComments.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315OmitComments.java
index 6615436467fb5..46f44362d8c0f 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315OmitComments.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315OmitComments.java
@@ -37,6 +37,7 @@ public Canonicalizer20010315OmitComments() {
}
/** {@inheritDoc} */
+ @Override
public final String engineGetURI() {
return Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315WithComments.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315WithComments.java
index 23dd3496da561..54742c6b80e74 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315WithComments.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315WithComments.java
@@ -36,6 +36,7 @@ public Canonicalizer20010315WithComments() {
}
/** {@inheritDoc} */
+ @Override
public final String engineGetURI() {
return Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java
index d57a947dc0d4b..c1f499078fa63 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java
@@ -107,6 +107,7 @@ protected CanonicalizerBase(boolean includeComments) {
* @param writer OutputStream to write the canonicalization result
* @throws CanonicalizationException
*/
+ @Override
public void engineCanonicalizeSubTree(Node rootNode, OutputStream writer)
throws CanonicalizationException {
engineCanonicalizeSubTree(rootNode, (Node)null, writer);
@@ -119,6 +120,7 @@ public void engineCanonicalizeSubTree(Node rootNode, OutputStream writer)
* @param writer OutputStream to write the canonicalization result
* @throws CanonicalizationException
*/
+ @Override
public void engineCanonicalizeXPathNodeSet(Set xpathNodeSet, OutputStream writer)
throws CanonicalizationException {
this.xpathNodeSet = xpathNodeSet;
@@ -457,8 +459,7 @@ private void canonicalizeXPathNodeSet(Node currentNode, Node endnode, OutputStre
} while(true);
}
- protected int isVisibleDO(Node currentNode, int level)
- throws CanonicalizationException {
+ protected int isVisibleDO(Node currentNode, int level) throws CanonicalizationException {
if (nodeFilter != null) {
for (NodeFilter filter : nodeFilter) {
try {
@@ -477,8 +478,7 @@ protected int isVisibleDO(Node currentNode, int level)
return 1;
}
- protected int isVisibleInt(Node currentNode)
- throws CanonicalizationException {
+ protected int isVisibleInt(Node currentNode) throws CanonicalizationException {
if (nodeFilter != null) {
for (NodeFilter filter : nodeFilter) {
try {
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerPhysical.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerPhysical.java
index 66ad12029fc0d..c0756d5e09c4a 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerPhysical.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerPhysical.java
@@ -68,6 +68,7 @@ public CanonicalizerPhysical() {
* @param writer OutputStream to write the canonicalization result
* @throws CanonicalizationException always
*/
+ @Override
public void engineCanonicalizeXPathNodeSet(Set xpathNodeSet, String inclusiveNamespaces, OutputStream writer)
throws CanonicalizationException {
@@ -83,6 +84,7 @@ public void engineCanonicalizeXPathNodeSet(Set xpathNodeSet, String inclus
* @param writer OutputStream to write the canonicalization result
* @throws CanonicalizationException
*/
+ @Override
public void engineCanonicalizeSubTree(Node rootNode, String inclusiveNamespaces, OutputStream writer)
throws CanonicalizationException {
@@ -98,6 +100,7 @@ public void engineCanonicalizeSubTree(Node rootNode, String inclusiveNamespaces,
* @param writer OutputStream to write the canonicalization result
* @throws CanonicalizationException
*/
+ @Override
public void engineCanonicalizeSubTree(
Node rootNode, String inclusiveNamespaces, boolean propagateDefaultNamespace, OutputStream writer)
throws CanonicalizationException {
@@ -165,6 +168,7 @@ protected void handleParent(Element e, NameSpaceSymbTable ns) {
}
/** {@inheritDoc} */
+ @Override
public final String engineGetURI() {
return Canonicalizer.ALGO_ID_C14N_PHYSICAL;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/NameSpaceSymbTable.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/NameSpaceSymbTable.java
index 2ffe680595793..290ff35ea6103 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/NameSpaceSymbTable.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/NameSpaceSymbTable.java
@@ -26,7 +26,6 @@
import java.util.Collection;
import java.util.List;
-
import org.w3c.dom.Attr;
import org.w3c.dom.Node;
@@ -74,16 +73,16 @@ public NameSpaceSymbTable() {
* @param result the list where to fill the unrendered xmlns definitions.
**/
public void getUnrenderedNodes(Collection result) {
- for (NameSpaceSymbEntry n : symb.entrySet()) {
+ for (NameSpaceSymbEntry nsEntry : symb.entrySet()) {
//put them rendered?
- if (!n.rendered && n.n != null) {
- n = n.clone();
+ if (!nsEntry.rendered && nsEntry.n != null) {
+ nsEntry = nsEntry.clone();
needsClone();
- symb.put(n.prefix, n);
- n.lastrendered = n.uri;
- n.rendered = true;
+ symb.put(nsEntry.prefix, nsEntry);
+ nsEntry.lastrendered = nsEntry.uri;
+ nsEntry.rendered = true;
- result.add(n.n);
+ result.add(nsEntry.n);
}
}
}
@@ -311,6 +310,7 @@ class NameSpaceSymbEntry implements Cloneable {
}
/** {@inheritDoc} */
+ @Override
public NameSpaceSymbEntry clone() { //NOPMD
try {
return (NameSpaceSymbEntry)super.clone();
@@ -344,9 +344,9 @@ void put(String key, NameSpaceSymbEntry value) {
List entrySet() {
List a = new ArrayList<>();
- for (int i = 0;i < entries.length;i++) {
- if (entries[i] != null && entries[i].uri.length() != 0) {
- a.add(entries[i]);
+ for (NameSpaceSymbEntry nsEntry : entries) {
+ if (nsEntry != null && !nsEntry.uri.isEmpty()) {
+ a.add(nsEntry);
}
}
return a;
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/exceptions/XMLSecurityException.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/exceptions/XMLSecurityException.java
index 98764012ea789..18314073d512d 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/exceptions/XMLSecurityException.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/exceptions/XMLSecurityException.java
@@ -160,6 +160,7 @@ public String getMsgID() {
}
/** {@inheritDoc} */
+ @Override
public String toString() {
String s = this.getClass().getName();
String message = super.getLocalizedMessage();
@@ -181,6 +182,7 @@ public String toString() {
* Method printStackTrace
*
*/
+ @Override
public void printStackTrace() {
synchronized (System.err) {
super.printStackTrace(System.err);
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java
index 519df28b81413..62f25d1298daf 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java
@@ -1184,6 +1184,7 @@ public void addStorageResolver(StorageResolver storageResolver) {
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_KEYINFO;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/DEREncodedKeyValue.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/DEREncodedKeyValue.java
index 6a727b2c719c3..823a50366801f 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/DEREncodedKeyValue.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/DEREncodedKeyValue.java
@@ -98,6 +98,7 @@ public String getId() {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_DERENCODEDKEYVALUE;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyInfoReference.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyInfoReference.java
index 89e95dec431f8..66ef3e36c8430 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyInfoReference.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyInfoReference.java
@@ -95,6 +95,7 @@ public String getId() {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_KEYINFOREFERENCE;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyName.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyName.java
index c098cfa8d1ffb..45c18b63014ec 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyName.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyName.java
@@ -65,6 +65,7 @@ public String getKeyName() {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_KEYNAME;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyValue.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyValue.java
index d30f504cf29e9..ee999e6578351 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyValue.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyValue.java
@@ -160,6 +160,7 @@ public PublicKey getPublicKey() throws XMLSecurityException {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_KEYVALUE;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/MgmtData.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/MgmtData.java
index 53fcf0f89543f..affe29c32764b 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/MgmtData.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/MgmtData.java
@@ -66,6 +66,7 @@ public String getMgmtData() {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_MGMTDATA;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/PGPData.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/PGPData.java
index 27e2550f4ddd4..240bf48a03b6c 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/PGPData.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/PGPData.java
@@ -44,6 +44,7 @@ public PGPData(Element element, String baseURI) throws XMLSecurityException {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_PGPDATA;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/RetrievalMethod.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/RetrievalMethod.java
index 82a949d34d3ba..84054ddd74540 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/RetrievalMethod.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/RetrievalMethod.java
@@ -129,6 +129,7 @@ public Transforms getTransforms() throws XMLSecurityException {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_RETRIEVALMETHOD;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/SPKIData.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/SPKIData.java
index a352c056ef770..23eaf1c12572a 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/SPKIData.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/SPKIData.java
@@ -45,6 +45,7 @@ public SPKIData(Element element, String baseURI)
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_SPKIDATA;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/X509Data.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/X509Data.java
index 06aeae25fa737..c7640e4e4e166 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/X509Data.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/X509Data.java
@@ -528,6 +528,7 @@ public boolean containsUnknownElement() {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_X509DATA;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/DSAKeyValue.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/DSAKeyValue.java
index 95697892df834..9b2a2d258eaf3 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/DSAKeyValue.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/DSAKeyValue.java
@@ -97,6 +97,7 @@ public DSAKeyValue(Document doc, Key key) throws IllegalArgumentException {
}
/** {@inheritDoc} */
+ @Override
public PublicKey getPublicKey() throws XMLSecurityException {
try {
DSAPublicKeySpec pkspec =
@@ -123,6 +124,7 @@ public PublicKey getPublicKey() throws XMLSecurityException {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_DSAKEYVALUE;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/ECKeyValue.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/ECKeyValue.java
index 0517aa4f711ea..839d9e4285da3 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/ECKeyValue.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/ECKeyValue.java
@@ -40,16 +40,15 @@
import javax.xml.crypto.MarshalException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.I18n;
import com.sun.org.apache.xml.internal.security.utils.Signature11ElementProxy;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
public class ECKeyValue extends Signature11ElementProxy implements KeyValueContent {
@@ -161,6 +160,7 @@ public ECKeyValue(Document doc, Key key) throws IllegalArgumentException {
}
/** {@inheritDoc} */
+ @Override
public PublicKey getPublicKey() throws XMLSecurityException {
try {
ECParameterSpec ecParams = null;
@@ -210,6 +210,7 @@ public PublicKey getPublicKey() throws XMLSecurityException {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_ECKEYVALUE;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/RSAKeyValue.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/RSAKeyValue.java
index 5025dcd345f24..b691091e51867 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/RSAKeyValue.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/RSAKeyValue.java
@@ -93,6 +93,7 @@ public RSAKeyValue(Document doc, Key key) throws IllegalArgumentException {
}
/** {@inheritDoc} */
+ @Override
public PublicKey getPublicKey() throws XMLSecurityException {
try {
KeyFactory rsaFactory = KeyFactory.getInstance("RSA");
@@ -115,6 +116,7 @@ public PublicKey getPublicKey() throws XMLSecurityException {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_RSAKEYVALUE;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509CRL.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509CRL.java
index 5b50fa966cda6..2d0a13a85bb62 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509CRL.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509CRL.java
@@ -64,6 +64,7 @@ public byte[] getCRLBytes() throws XMLSecurityException {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_X509CRL;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509Certificate.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509Certificate.java
index 56844e472ff39..c50458f2bdc80 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509Certificate.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509Certificate.java
@@ -127,6 +127,7 @@ public PublicKey getPublicKey() throws XMLSecurityException, IOException {
}
/** {@inheritDoc} */
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof XMLX509Certificate)) {
return false;
@@ -139,12 +140,13 @@ public boolean equals(Object obj) {
}
}
+ @Override
public int hashCode() {
int result = 17;
try {
byte[] bytes = getCertificateBytes();
- for (int i = 0; i < bytes.length; i++) {
- result = 31 * result + bytes[i];
+ for (byte element : bytes) {
+ result = 31 * result + element;
}
} catch (XMLSecurityException e) {
LOG.debug(e.getMessage(), e);
@@ -153,6 +155,7 @@ public int hashCode() {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_X509CERTIFICATE;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509Digest.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509Digest.java
index 502a9a4dc82bd..7011016cfb699 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509Digest.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509Digest.java
@@ -132,6 +132,7 @@ public static byte[] getDigestBytesFromCert(X509Certificate cert, String algorit
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_X509DIGEST;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509IssuerSerial.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509IssuerSerial.java
index 0a186da2d9254..6e90ae6592cac 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509IssuerSerial.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509IssuerSerial.java
@@ -132,6 +132,7 @@ public String getIssuerName() {
}
/** {@inheritDoc} */
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof XMLX509IssuerSerial)) {
return false;
@@ -143,6 +144,7 @@ public boolean equals(Object obj) {
&& this.getIssuerName().equals(other.getIssuerName());
}
+ @Override
public int hashCode() {
int result = 17;
result = 31 * result + getSerialNumber().hashCode();
@@ -151,6 +153,7 @@ public int hashCode() {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_X509ISSUERSERIAL;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SKI.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SKI.java
index 197d417c00eba..451f955ea3c20 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SKI.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SKI.java
@@ -145,6 +145,7 @@ public static byte[] getSKIBytesFromCert(X509Certificate cert)
}
/** {@inheritDoc} */
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof XMLX509SKI)) {
return false;
@@ -159,12 +160,13 @@ public boolean equals(Object obj) {
}
}
+ @Override
public int hashCode() {
int result = 17;
try {
byte[] bytes = getSKIBytes();
- for (int i = 0; i < bytes.length; i++) {
- result = 31 * result + bytes[i];
+ for (byte element : bytes) {
+ result = 31 * result + element;
}
} catch (XMLSecurityException e) {
LOG.debug(e.getMessage(), e);
@@ -174,6 +176,7 @@ public int hashCode() {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_X509SKI;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SubjectName.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SubjectName.java
index 564c45e437adc..7b8008fef1225 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SubjectName.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SubjectName.java
@@ -80,6 +80,7 @@ public String getSubjectName() {
}
/** {@inheritDoc} */
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof XMLX509SubjectName)) {
return false;
@@ -92,6 +93,7 @@ public boolean equals(Object obj) {
return thisSubject.equals(otherSubject);
}
+ @Override
public int hashCode() {
int result = 17;
result = 31 * result + this.getSubjectName().hashCode();
@@ -99,6 +101,7 @@ public int hashCode() {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_X509SUBJECTNAME;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java
index 7445013e9cbcc..f0e0785efe6d5 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java
@@ -31,9 +31,6 @@
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.DEREncodedKeyValueResolver;
import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.DSAKeyValueResolver;
import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.ECKeyValueResolver;
@@ -47,6 +44,8 @@
import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.X509SubjectNameResolver;
import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver;
import com.sun.org.apache.xml.internal.security.utils.JavaUtils;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* KeyResolver is factory class for subclass of KeyResolverSpi that
@@ -295,10 +294,12 @@ public ResolverIterator(List list) {
it = res.iterator();
}
+ @Override
public boolean hasNext() {
return it.hasNext();
}
+ @Override
public KeyResolverSpi next() {
KeyResolverSpi resolver = it.next();
if (resolver == null) {
@@ -308,6 +309,7 @@ public KeyResolverSpi next() {
return resolver;
}
+ @Override
public void remove() {
throw new UnsupportedOperationException("Can't remove resolvers using the iterator");
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/PrivateKeyResolver.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/PrivateKeyResolver.java
index 20ecdbee0a5e9..a891104143fdd 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/PrivateKeyResolver.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/PrivateKeyResolver.java
@@ -32,7 +32,9 @@
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.Enumeration;
+
import javax.crypto.SecretKey;
+
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.keys.content.X509Data;
import com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509Certificate;
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RSAKeyValueResolver.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RSAKeyValueResolver.java
index 6c21cf0130ec9..3c44833379879 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RSAKeyValueResolver.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RSAKeyValueResolver.java
@@ -26,7 +26,6 @@
import java.security.PublicKey;
import java.security.cert.X509Certificate;
-
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.keys.content.keyvalues.RSAKeyValue;
import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverSpi;
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/SecretKeyResolver.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/SecretKeyResolver.java
index f8b6040234992..761ac9fd01215 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/SecretKeyResolver.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/SecretKeyResolver.java
@@ -27,7 +27,9 @@
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.cert.X509Certificate;
+
import javax.crypto.SecretKey;
+
import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverException;
import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverSpi;
import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver;
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/SingleKeyResolver.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/SingleKeyResolver.java
index 6d543808354f3..4e6223fad06b3 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/SingleKeyResolver.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/SingleKeyResolver.java
@@ -25,7 +25,9 @@
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.cert.X509Certificate;
+
import javax.crypto.SecretKey;
+
import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverException;
import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverSpi;
import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver;
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509CertificateResolver.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509CertificateResolver.java
index 0be1e5bf4f53e..7977a5538f29b 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509CertificateResolver.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509CertificateResolver.java
@@ -86,8 +86,8 @@ protected X509Certificate engineResolveX509Certificate(
}
// populate Object array
- for (int i = 0; i < els.length; i++) {
- XMLX509Certificate xmlCert = new XMLX509Certificate(els[i], baseURI);
+ for (Element el : els) {
+ XMLX509Certificate xmlCert = new XMLX509Certificate(el, baseURI);
X509Certificate cert = xmlCert.getX509Certificate();
if (cert != null) {
return cert;
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509DigestResolver.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509DigestResolver.java
index 9826ea3b9c8d7..047e7acbf5deb 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509DigestResolver.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509DigestResolver.java
@@ -134,8 +134,7 @@ private X509Certificate resolveCertificate(Element element, String baseURI, Stor
while (storageIterator.hasNext()) {
X509Certificate cert = (X509Certificate) storageIterator.next();
- for (int i = 0; i < x509Digests.length; i++) {
- XMLX509Digest keyInfoDigest = x509Digests[i];
+ for (XMLX509Digest keyInfoDigest : x509Digests) {
byte[] certDigestBytes = XMLX509Digest.getDigestBytesFromCert(cert, keyInfoDigest.getAlgorithm());
if (Arrays.equals(keyInfoDigest.getDigestBytes(), certDigestBytes)) {
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509SKIResolver.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509SKIResolver.java
index c2d8f9cef608f..09150a548f129 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509SKIResolver.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509SKIResolver.java
@@ -28,7 +28,6 @@
import java.security.cert.X509Certificate;
import java.util.Iterator;
-
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SKI;
import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverException;
@@ -95,20 +94,18 @@ protected X509Certificate engineResolveX509Certificate(
}
XMLX509SKI[] x509childObject = new XMLX509SKI[x509childNodes.length];
-
for (int i = 0; i < x509childNodes.length; i++) {
x509childObject[i] = new XMLX509SKI(x509childNodes[i], baseURI);
}
Iterator storageIterator = storage.getIterator();
while (storageIterator.hasNext()) {
- X509Certificate cert = (X509Certificate)storageIterator.next();
+ X509Certificate cert = (X509Certificate) storageIterator.next();
XMLX509SKI certSKI = new XMLX509SKI(element.getOwnerDocument(), cert);
- for (int i = 0; i < x509childObject.length; i++) {
- if (certSKI.equals(x509childObject[i])) {
+ for (XMLX509SKI childNodeSKI : x509childObject) {
+ if (certSKI.equals(childNodeSKI)) {
LOG.debug("Return PublicKey from {}", cert.getSubjectX500Principal().getName());
-
return cert;
}
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509SubjectNameResolver.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509SubjectNameResolver.java
index f90ff89671143..b2bd0770b1546 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509SubjectNameResolver.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509SubjectNameResolver.java
@@ -28,7 +28,6 @@
import java.security.cert.X509Certificate;
import java.util.Iterator;
-
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SubjectName;
import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverException;
@@ -101,18 +100,15 @@ protected X509Certificate engineResolveX509Certificate(
Iterator storageIterator = storage.getIterator();
while (storageIterator.hasNext()) {
- X509Certificate cert = (X509Certificate)storageIterator.next();
- XMLX509SubjectName certSN =
- new XMLX509SubjectName(element.getOwnerDocument(), cert);
-
+ X509Certificate cert = (X509Certificate) storageIterator.next();
+ XMLX509SubjectName certSN = new XMLX509SubjectName(element.getOwnerDocument(), cert);
LOG.debug("Found Certificate SN: {}", certSN.getSubjectName());
- for (int i = 0; i < x509childObject.length; i++) {
- LOG.debug("Found Element SN: {}", x509childObject[i].getSubjectName());
+ for (XMLX509SubjectName childSubject : x509childObject) {
+ LOG.debug("Found Element SN: {}", childSubject.getSubjectName());
- if (certSN.equals(x509childObject[i])) {
+ if (certSN.equals(childSubject)) {
LOG.debug("match !!! ");
-
return cert;
}
LOG.debug("no match...");
@@ -122,7 +118,6 @@ protected X509Certificate engineResolveX509Certificate(
return null;
} catch (XMLSecurityException ex) {
LOG.debug("XMLSecurityException", ex);
-
throw new KeyResolverException(ex);
}
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolver.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolver.java
index 2da744cad8c44..2b90e7901fdbe 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolver.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolver.java
@@ -133,6 +133,7 @@ public StorageResolverIterator(Iterator resolvers) {
}
/** {@inheritDoc} */
+ @Override
public boolean hasNext() {
if (currentResolver == null) {
return false;
@@ -147,6 +148,7 @@ public boolean hasNext() {
}
/** {@inheritDoc} */
+ @Override
public Certificate next() {
if (hasNext()) {
return currentResolver.next();
@@ -158,6 +160,7 @@ public Certificate next() {
/**
* Method remove
*/
+ @Override
public void remove() {
throw new UnsupportedOperationException("Can't remove keys from KeyStore");
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/KeyStoreResolver.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/KeyStoreResolver.java
index 6f7ff7deb92e4..cfe9c6e98a59a 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/KeyStoreResolver.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/KeyStoreResolver.java
@@ -64,6 +64,7 @@ public KeyStoreResolver(KeyStore keyStore) throws StorageResolverException {
}
/** {@inheritDoc} */
+ @Override
public Iterator getIterator() {
return new KeyStoreIterator(this.keyStore);
}
@@ -103,11 +104,13 @@ public KeyStoreIterator(KeyStore keyStore) {
}
/** {@inheritDoc} */
+ @Override
public boolean hasNext() {
return this.i < this.certs.size();
}
/** {@inheritDoc} */
+ @Override
public Certificate next() {
if (hasNext()) {
return this.certs.get(this.i++);
@@ -119,6 +122,7 @@ public Certificate next() {
/**
* Method remove
*/
+ @Override
public void remove() {
throw new UnsupportedOperationException("Can't remove keys from KeyStore");
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/SingleCertificateResolver.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/SingleCertificateResolver.java
index 2b57b3c4e2cba..9476cfdffe52b 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/SingleCertificateResolver.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/SingleCertificateResolver.java
@@ -46,6 +46,7 @@ public SingleCertificateResolver(X509Certificate x509cert) {
}
/** {@inheritDoc} */
+ @Override
public Iterator getIterator() {
return new InternalIterator(this.certificate);
}
@@ -71,11 +72,13 @@ public InternalIterator(X509Certificate x509cert) {
}
/** {@inheritDoc} */
+ @Override
public boolean hasNext() {
return !this.alreadyReturned;
}
/** {@inheritDoc} */
+ @Override
public Certificate next() {
if (this.alreadyReturned) {
throw new NoSuchElementException();
@@ -87,6 +90,7 @@ public Certificate next() {
/**
* Method remove
*/
+ @Override
public void remove() {
throw new UnsupportedOperationException("Can't remove keys from KeyStore");
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/parser/XMLParser.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/parser/XMLParser.java
index 0942b6b296f7c..24acfe33aa93b 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/parser/XMLParser.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/parser/XMLParser.java
@@ -31,6 +31,15 @@
*/
public interface XMLParser {
+ /**
+ * Parses a document from the input stream.
+ * Caller is responsible for closing the stream.
+ *
+ * @param inputStream
+ * @param disallowDocTypeDeclarations
+ * @return {@link Document}
+ * @throws XMLParserException
+ */
Document parse(InputStream inputStream, boolean disallowDocTypeDeclarations) throws XMLParserException;
}
\ No newline at end of file
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/parser/XMLParserImpl.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/parser/XMLParserImpl.java
index be28d2861a26e..91f4054dc896e 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/parser/XMLParserImpl.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/parser/XMLParserImpl.java
@@ -51,10 +51,10 @@ public class XMLParserImpl implements XMLParser {
(PrivilegedAction) () -> Integer.getInteger("com.sun.org.apache.xml.internal.security.parser.pool-size", 20));
private static final Map> DOCUMENT_BUILDERS =
- Collections.synchronizedMap(new WeakHashMap>());
+ Collections.synchronizedMap(new WeakHashMap<>());
private static final Map> DOCUMENT_BUILDERS_DISALLOW_DOCTYPE =
- Collections.synchronizedMap(new WeakHashMap>());
+ Collections.synchronizedMap(new WeakHashMap<>());
@Override
public Document parse(InputStream inputStream, boolean disallowDocTypeDeclarations) throws XMLParserException {
@@ -119,6 +119,7 @@ private static ClassLoader getContextClassLoader() {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
return AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
public ClassLoader run() {
return Thread.currentThread().getContextClassLoader();
}
@@ -132,6 +133,7 @@ private static ClassLoader getClassLoader(final Class> clazz) {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
return AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
public ClassLoader run() {
return clazz.getClassLoader();
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java
index 9d0ac02d75ec1..f63ac107fd09d 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java
@@ -575,6 +575,7 @@ public int getSignedContentLength() {
*
* {@inheritDoc}
*/
+ @Override
public String getBaseLocalName() {
return Constants._TAG_MANIFEST;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/ObjectContainer.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/ObjectContainer.java
index 5ab6c36164379..d1f049b5bc9e2 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/ObjectContainer.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/ObjectContainer.java
@@ -130,6 +130,7 @@ public Node appendChild(Node node) {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_OBJECT;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java
index 384436b7b4e1b..9636031b9a5f8 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java
@@ -193,10 +193,12 @@ protected Reference(
// Create DigestMethod Element without actually instantiating a MessageDigest Object
Algorithm digestAlgorithm = new Algorithm(getDocument(), messageDigestAlgorithm) {
+ @Override
public String getBaseNamespace() {
return Constants.SignatureSpecNS;
}
+ @Override
public String getBaseLocalName() {
return Constants._TAG_DIGESTMETHOD;
}
@@ -612,6 +614,7 @@ private void cacheDereferencedElement(XMLSignatureInput input) {
try {
final Set s = input.getNodeSet();
referenceData = new ReferenceNodeSetData() {
+ @Override
public Iterator iterator() {
return new Iterator() {
@@ -808,6 +811,7 @@ public boolean verify()
* Method getBaseLocalName
* {@inheritDoc}
*/
+ @Override
public String getBaseLocalName() {
return Constants._TAG_REFERENCE;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/SignatureProperties.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/SignatureProperties.java
index e409c99250010..8434b291c94d0 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/SignatureProperties.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/SignatureProperties.java
@@ -139,6 +139,7 @@ public void addSignatureProperty(SignatureProperty sp) {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_SIGNATUREPROPERTIES;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/SignatureProperty.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/SignatureProperty.java
index 1929f126a1434..bc9a7003c46a7 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/SignatureProperty.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/SignatureProperty.java
@@ -126,6 +126,7 @@ public Node appendChild(Node node) {
}
/** {@inheritDoc} */
+ @Override
public String getBaseLocalName() {
return Constants._TAG_SIGNATUREPROPERTY;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/SignedInfo.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/SignedInfo.java
index 6d4e4adf740df..90511f10fbc54 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/SignedInfo.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/SignedInfo.java
@@ -27,6 +27,7 @@
import java.io.OutputStream;
import java.security.Provider;
import java.security.spec.AlgorithmParameterSpec;
+
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
@@ -38,7 +39,6 @@
import com.sun.org.apache.xml.internal.security.transforms.params.InclusiveNamespaces;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
-
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -401,6 +401,7 @@ public SignatureAlgorithm getSignatureAlgorithm() {
* {@inheritDoc}
*
*/
+ @Override
public String getBaseLocalName() {
return Constants._TAG_SIGNEDINFO;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java
index dff41c30e5180..cfa545e5826c6 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java
@@ -1031,6 +1031,7 @@ public void setFollowNestedManifests(boolean followManifests) {
*
* @return Constants._TAG_SIGNATURE
*/
+ @Override
public String getBaseLocalName() {
return Constants._TAG_SIGNATURE;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java
index 165bc98721fb5..1f192e0553374 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java
@@ -391,6 +391,7 @@ public void setSourceURI(String sourceURI) {
* Method toString
* {@inheritDoc}
*/
+ @Override
public String toString() {
if (isNodeSet()) {
return "XMLSignatureInput/NodeSet/" + inputNodeSet.size()
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/reference/ReferenceSubTreeData.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/reference/ReferenceSubTreeData.java
index 215206015f871..14050f0715e3d 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/reference/ReferenceSubTreeData.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/signature/reference/ReferenceSubTreeData.java
@@ -30,6 +30,7 @@
import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException;
+
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -51,6 +52,7 @@ public ReferenceSubTreeData(Node root, boolean excludeComments) {
this.excludeComments = excludeComments;
}
+ @Override
public Iterator iterator() {
return new DelayedNodeIterator(root, excludeComments);
}
@@ -78,6 +80,7 @@ static class DelayedNodeIterator implements Iterator {
this.withComments = !excludeComments;
}
+ @Override
public boolean hasNext() {
if (nodeSet == null) {
nodeSet = dereferenceSameDocumentURI(root);
@@ -86,6 +89,7 @@ public boolean hasNext() {
return li.hasNext();
}
+ @Override
public Node next() {
if (nodeSet == null) {
nodeSet = dereferenceSameDocumentURI(root);
@@ -98,6 +102,7 @@ public Node next() {
}
}
+ @Override
public void remove() {
throw new UnsupportedOperationException();
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java
index 0534fff3844b9..2d5c019654996 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java
@@ -108,7 +108,7 @@ private Base64() {
* @param bitlen {@code int} the desired length in bits of the representation
* @return a byte array with {@code bitlen} bits of {@code big}
*/
- static final byte[] getBytes(BigInteger big, int bitlen) {
+ static byte[] getBytes(BigInteger big, int bitlen) {
//round bitlen
bitlen = ((bitlen + 7) >> 3) << 3;
@@ -148,7 +148,7 @@ static final byte[] getBytes(BigInteger big, int bitlen) {
* @param big
* @return String with Base64 encoding
*/
- public static final String encode(BigInteger big) {
+ public static String encode(BigInteger big) {
byte[] bytes = XMLUtils.getBytes(big, big.bitLength());
return XMLUtils.encodeToString(bytes);
}
@@ -164,7 +164,7 @@ public static final String encode(BigInteger big) {
* @param bitlen {@code int} the desired length in bits of the representation
* @return a byte array with {@code bitlen} bits of {@code big}
*/
- public static final byte[] encode(BigInteger big, int bitlen) {
+ public static byte[] encode(BigInteger big, int bitlen) {
//round bitlen
bitlen = ((bitlen + 7) >> 3) << 3;
@@ -205,7 +205,7 @@ public static final byte[] encode(BigInteger big, int bitlen) {
* @return the biginteger obtained from the node
* @throws Base64DecodingException
*/
- public static final BigInteger decodeBigIntegerFromElement(Element element)
+ public static BigInteger decodeBigIntegerFromElement(Element element)
throws Base64DecodingException {
return new BigInteger(1, Base64.decode(element));
}
@@ -216,7 +216,7 @@ public static final BigInteger decodeBigIntegerFromElement(Element element)
* @return a decoded BigInteger
* @throws Base64DecodingException
*/
- public static final BigInteger decodeBigIntegerFromText(Text text)
+ public static BigInteger decodeBigIntegerFromText(Text text)
throws Base64DecodingException {
return new BigInteger(1, Base64.decode(text.getData()));
}
@@ -228,7 +228,7 @@ public static final BigInteger decodeBigIntegerFromText(Text text)
* @param element
* @param biginteger
*/
- public static final void fillElementWithBigInteger(Element element, BigInteger biginteger) {
+ public static void fillElementWithBigInteger(Element element, BigInteger biginteger) {
String encodedInt = encode(biginteger);
@@ -253,7 +253,7 @@ public static final void fillElementWithBigInteger(Element element, BigInteger b
* $todo$ not tested yet
* @throws Base64DecodingException
*/
- public static final byte[] decode(Element element) throws Base64DecodingException {
+ public static byte[] decode(Element element) throws Base64DecodingException {
Node sibling = element.getFirstChild();
StringBuilder sb = new StringBuilder();
@@ -279,7 +279,7 @@ public static final byte[] decode(Element element) throws Base64DecodingExceptio
* @return an Element with the base64 encoded in the text.
*
*/
- public static final Element encodeToElement(Document doc, String localName, byte[] bytes) {
+ public static Element encodeToElement(Document doc, String localName, byte[] bytes) {
Element el = XMLUtils.createElementInSignatureSpace(doc, localName);
Text text = doc.createTextNode(encode(bytes));
@@ -296,7 +296,7 @@ public static final Element encodeToElement(Document doc, String localName, byte
* @throws Base64DecodingException
*
*/
- public static final byte[] decode(byte[] base64) throws Base64DecodingException {
+ public static byte[] decode(byte[] base64) throws Base64DecodingException {
return decodeInternal(base64, -1);
}
@@ -307,7 +307,7 @@ public static final byte[] decode(byte[] base64) throws Base64DecodingException
* @param binaryData {@code byte[]} to be base64 encoded
* @return the {@code String} with encoded data
*/
- public static final String encode(byte[] binaryData) {
+ public static String encode(byte[] binaryData) {
return XMLUtils.ignoreLineBreaks()
? encode(binaryData, Integer.MAX_VALUE)
: encode(binaryData, BASE64DEFAULTLENGTH);
@@ -323,7 +323,7 @@ public static final String encode(byte[] binaryData) {
* @throws IOException
* @throws Base64DecodingException
*/
- public static final byte[] decode(BufferedReader reader)
+ public static byte[] decode(BufferedReader reader)
throws IOException, Base64DecodingException {
byte[] retBytes = null;
@@ -342,11 +342,11 @@ public static final byte[] decode(BufferedReader reader)
return retBytes;
}
- protected static final boolean isWhiteSpace(byte octet) {
+ protected static boolean isWhiteSpace(byte octet) {
return octet == 0x20 || octet == 0xd || octet == 0xa || octet == 0x9;
}
- protected static final boolean isPad(byte octet) {
+ protected static boolean isPad(byte octet) {
return octet == PAD;
}
@@ -364,7 +364,7 @@ protected static final boolean isPad(byte octet) {
* @param length {@code int} length of wrapped lines; No wrapping if less than 4.
* @return a {@code String} with encoded data
*/
- public static final String encode(byte[] binaryData, int length) {
+ public static String encode(byte[] binaryData, int length) {
if (length < 4) {
length = Integer.MAX_VALUE;
}
@@ -474,7 +474,7 @@ public static final String encode(byte[] binaryData, int length) {
* @return byte array containing the decoded data
* @throws Base64DecodingException if there is a problem decoding the data
*/
- public static final byte[] decode(String encoded) throws Base64DecodingException {
+ public static byte[] decode(String encoded) throws Base64DecodingException {
if (encoded == null) {
return null;
}
@@ -483,7 +483,7 @@ public static final byte[] decode(String encoded) throws Base64DecodingException
return decodeInternal(bytes, len);
}
- protected static final int getBytesInternal(String s, byte[] result) {
+ protected static int getBytesInternal(String s, byte[] result) {
int length = s.length();
int newSize = 0;
@@ -496,7 +496,7 @@ protected static final int getBytesInternal(String s, byte[] result) {
return newSize;
}
- protected static final byte[] decodeInternal(byte[] base64Data, int len)
+ protected static byte[] decodeInternal(byte[] base64Data, int len)
throws Base64DecodingException {
// remove white spaces
if (len == -1) {
@@ -591,7 +591,7 @@ protected static final byte[] decodeInternal(byte[] base64Data, int len)
* @throws IOException
* @throws Base64DecodingException
*/
- public static final void decode(String base64Data, OutputStream os)
+ public static void decode(String base64Data, OutputStream os)
throws Base64DecodingException, IOException {
byte[] bytes = new byte[base64Data.length()];
int len = getBytesInternal(base64Data, bytes);
@@ -606,12 +606,12 @@ public static final void decode(String base64Data, OutputStream os)
* @throws IOException
* @throws Base64DecodingException
*/
- public static final void decode(byte[] base64Data, OutputStream os)
+ public static void decode(byte[] base64Data, OutputStream os)
throws Base64DecodingException, IOException {
decode(base64Data, os, -1);
}
- protected static final void decode(byte[] base64Data, OutputStream os, int len)
+ protected static void decode(byte[] base64Data, OutputStream os, int len)
throws Base64DecodingException, IOException {
// remove white spaces
if (len == -1) {
@@ -694,7 +694,7 @@ protected static final void decode(byte[] base64Data, OutputStream os, int len)
* @throws IOException
* @throws Base64DecodingException
*/
- public static final void decode(InputStream is, OutputStream os)
+ public static void decode(InputStream is, OutputStream os)
throws Base64DecodingException, IOException {
//byte[] decodedData = null;
byte b1 = 0, b2 = 0, b3 = 0, b4 = 0;
@@ -771,7 +771,7 @@ public static final void decode(InputStream is, OutputStream os)
* @param data the byte array of base64 data (with WS)
* @return the new length
*/
- protected static final int removeWhiteSpace(byte[] data) {
+ protected static int removeWhiteSpace(byte[] data) {
if (data == null) {
return 0;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/DOMNamespaceContext.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/DOMNamespaceContext.java
index 6a2f5d5af260e..0c2c5c8404398 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/DOMNamespaceContext.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/DOMNamespaceContext.java
@@ -84,6 +84,7 @@ public void setContext(Node context) {
this.context = context;
}
+ @Override
public String getNamespaceURI(String prefix) {
if (prefix == null) {
throw new IllegalArgumentException("prefix is null");
@@ -107,6 +108,7 @@ public String getNamespaceURI(String prefix) {
return NULL_NS_URI;
}
+ @Override
public String getPrefix(String namespaceURI) {
if (namespaceURI == null) {
throw new IllegalArgumentException("namespace URI is null");
@@ -140,6 +142,7 @@ public String getPrefix(String namespaceURI) {
/**
* Throws {@link UnsupportedOperationException}.
*/
+ @Override
public Iterator getPrefixes(String namespaceURI) {
throw new UnsupportedOperationException();
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/DigesterOutputStream.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/DigesterOutputStream.java
index 8f584c354f6cd..06840f74e41b8 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/DigesterOutputStream.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/DigesterOutputStream.java
@@ -43,16 +43,19 @@ public DigesterOutputStream(MessageDigestAlgorithm mda) {
}
/** {@inheritDoc} */
+ @Override
public void write(byte[] arg0) {
write(arg0, 0, arg0.length);
}
/** {@inheritDoc} */
- public void write(int arg0) {
+ @Override
+ public synchronized void write(int arg0) {
mda.update((byte)arg0);
}
/** {@inheritDoc} */
+ @Override
public void write(byte[] arg0, int arg1, int arg2) {
if (LOG.isDebugEnabled()) {
LOG.debug("Pre-digested input:");
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java
index c1d4c5d0367b8..6f061fc977244 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java
@@ -23,8 +23,8 @@
package com.sun.org.apache.xml.internal.security.utils;
import java.math.BigInteger;
-import java.util.concurrent.ConcurrentHashMap;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import org.w3c.dom.Attr;
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/HelperNodeList.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/HelperNodeList.java
index 65f9b8f93f9ba..b198861d0419a 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/HelperNodeList.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/HelperNodeList.java
@@ -57,6 +57,7 @@ public HelperNodeList(boolean allNodesMustHaveSameParent) {
* @param index
* @return node with index i
*/
+ @Override
public Node item(int index) {
return nodes.get(index);
}
@@ -66,6 +67,7 @@ public Node item(int index) {
*
* @return length of the list
*/
+ @Override
public int getLength() {
return nodes.size();
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/JDKXPathAPI.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/JDKXPathAPI.java
index e6b65e07a005f..ea5524e3b8bea 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/JDKXPathAPI.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/JDKXPathAPI.java
@@ -57,6 +57,7 @@ class JDKXPathAPI implements XPathAPI {
*
* @throws TransformerException
*/
+ @Override
public NodeList selectNodeList(
Node contextNode, Node xpathnode, String str, Node namespaceNode
) throws TransformerException {
@@ -92,6 +93,7 @@ public NodeList selectNodeList(
* @param str The XPath expression
* @param namespaceNode The node from which prefixes in the XPath will be resolved to namespaces.
*/
+ @Override
public boolean evaluate(Node contextNode, Node xpathnode, String str, Node namespaceNode)
throws TransformerException {
if (!str.equals(xpathStr) || xpathExpression == null) {
@@ -122,6 +124,7 @@ public boolean evaluate(Node contextNode, Node xpathnode, String str, Node names
/**
* Clear any context information from this object
*/
+ @Override
public void clear() {
xpathStr = null;
xpathExpression = null;
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/JDKXPathFactory.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/JDKXPathFactory.java
index 98c1872898a61..2659fc0ecd0bc 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/JDKXPathFactory.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/JDKXPathFactory.java
@@ -31,6 +31,7 @@ public class JDKXPathFactory extends XPathFactory {
/**
* Get a new XPathAPI instance
*/
+ @Override
public XPathAPI newXPathAPI() {
return new JDKXPathAPI();
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/JavaUtils.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/JavaUtils.java
index 4f5cb7d68a99b..647675ae61cbe 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/JavaUtils.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/JavaUtils.java
@@ -95,7 +95,7 @@ public static void writeBytesToFilename(String filename, byte[] bytes) {
/**
* This method reads all bytes from the given InputStream till EOF and
- * returns them as a byte array.
+ * returns them as a byte array. The method doesn't close the input stream.
*
* @param inputStream
* @return the bytes read from the stream
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Signature11ElementProxy.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Signature11ElementProxy.java
index 6a5981f61cb9f..086698cdad512 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Signature11ElementProxy.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/Signature11ElementProxy.java
@@ -69,6 +69,7 @@ public Signature11ElementProxy(Element element, String baseURI) throws XMLSecuri
}
/** {@inheritDoc} */
+ @Override
public String getBaseNamespace() {
return Constants.SignatureSpec11NS;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/SignatureElementProxy.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/SignatureElementProxy.java
index e10f09fa7e564..847ed4ecefbcf 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/SignatureElementProxy.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/SignatureElementProxy.java
@@ -63,6 +63,7 @@ public SignatureElementProxy(Element element, String baseURI) throws XMLSecurity
}
/** {@inheritDoc} */
+ @Override
public String getBaseNamespace() {
return Constants.SignatureSpecNS;
}
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/SignerOutputStream.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/SignerOutputStream.java
index beb0604f2e63b..04c255504ef80 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/SignerOutputStream.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/SignerOutputStream.java
@@ -44,6 +44,7 @@ public SignerOutputStream(SignatureAlgorithm sa) {
}
/** {@inheritDoc} */
+ @Override
public void write(byte[] arg0) {
try {
sa.update(arg0);
@@ -53,6 +54,7 @@ public void write(byte[] arg0) {
}
/** {@inheritDoc} */
+ @Override
public void write(int arg0) {
try {
sa.update((byte)arg0);
@@ -62,6 +64,7 @@ public void write(int arg0) {
}
/** {@inheritDoc} */
+ @Override
public void write(byte[] arg0, int arg1, int arg2) {
if (LOG.isDebugEnabled()) {
LOG.debug("Canonicalized SignedInfo:");
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java
index a0358ffbf770d..f0dc1432d5a9d 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java
@@ -44,6 +44,7 @@ public UnsyncByteArrayOutputStream() {
buf = new byte[INITIAL_SIZE];
}
+ @Override
public void write(byte[] arg0) {
if ((VM_ARRAY_INDEX_MAX_VALUE - pos) < arg0.length) {
throw new OutOfMemoryError("Required length exceeds implementation limit");
@@ -56,6 +57,7 @@ public void write(byte[] arg0) {
pos = newPos;
}
+ @Override
public void write(byte[] arg0, int arg1, int arg2) {
if ((VM_ARRAY_INDEX_MAX_VALUE - pos) < arg2) {
throw new OutOfMemoryError("Required length exceeds implementation limit");
@@ -68,6 +70,7 @@ public void write(byte[] arg0, int arg1, int arg2) {
pos = newPos;
}
+ @Override
public void write(int arg0) {
if (VM_ARRAY_INDEX_MAX_VALUE - pos == 0) {
throw new OutOfMemoryError("Required length exceeds implementation limit");
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java
index 446d640194e09..ca1eea1da44cb 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java
@@ -22,11 +22,15 @@
*/
package com.sun.org.apache.xml.internal.security.utils;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.math.BigInteger;
+import java.nio.file.Files;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
@@ -42,6 +46,8 @@
import com.sun.org.apache.xml.internal.security.parser.XMLParser;
import com.sun.org.apache.xml.internal.security.parser.XMLParserException;
import com.sun.org.apache.xml.internal.security.parser.XMLParserImpl;
+import com.sun.org.slf4j.internal.Logger;
+import com.sun.org.slf4j.internal.LoggerFactory;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -50,6 +56,8 @@
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
/**
* DOM and XML accessibility and comfort functions.
*
@@ -61,8 +69,7 @@ public final class XMLUtils {
AccessController.doPrivileged(
(PrivilegedAction) () -> Boolean.getBoolean("com.sun.org.apache.xml.internal.security.ignoreLineBreaks"));
- private static final com.sun.org.slf4j.internal.Logger LOG =
- com.sun.org.slf4j.internal.LoggerFactory.getLogger(XMLUtils.class);
+ private static final Logger LOG = LoggerFactory.getLogger(XMLUtils.class);
@SuppressWarnings("removal")
private static XMLParser xmlParserImpl =
@@ -74,7 +81,7 @@ public final class XMLUtils {
return (XMLParser) JavaUtils.newInstanceWithEmptyConstructor(
ClassLoaderUtils.loadClass(xmlParserClass, XMLUtils.class));
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
- LOG.error("Error instantiating XMLParser. Falling back to XMLParserImpl");
+ LOG.error("Error instantiating XMLParser. Falling back to XMLParserImpl", e);
}
}
return new XMLParserImpl();
@@ -149,18 +156,18 @@ public static Element getNextElement(Node el) {
* @param rootNode
* @param result
* @param exclude
- * @param com whether comments or not
+ * @param comments whether comments or not
*/
- public static void getSet(Node rootNode, Set result, Node exclude, boolean com) {
+ public static void getSet(Node rootNode, Set result, Node exclude, boolean comments) {
if (exclude != null && isDescendantOrSelf(exclude, rootNode)) {
return;
}
- getSetRec(rootNode, result, exclude, com);
+ getSetRec(rootNode, result, exclude, comments);
}
@SuppressWarnings("fallthrough")
private static void getSetRec(final Node rootNode, final Set result,
- final Node exclude, final boolean com) {
+ final Node exclude, final boolean comments) {
if (rootNode == exclude) {
return;
}
@@ -187,11 +194,11 @@ private static void getSetRec(final Node rootNode, final Set result,
return;
}
}
- getSetRec(r, result, exclude, com);
+ getSetRec(r, result, exclude, comments);
}
break;
case Node.COMMENT_NODE:
- if (com) {
+ if (comments) {
result.add(rootNode);
}
break;
@@ -202,6 +209,18 @@ private static void getSetRec(final Node rootNode, final Set result,
}
}
+ /**
+ * Outputs a DOM tree to a {@link File}.
+ *
+ * @param contextNode root node of the DOM tree
+ * @param outputFile the file to write to
+ * @throws IOException
+ */
+ public static void outputDOM(Node contextNode, File outputFile) throws IOException {
+ try (OutputStream os = new BufferedOutputStream(Files.newOutputStream(outputFile.toPath()), 8192)) {
+ outputDOM(contextNode, os, false);
+ }
+ }
/**
* Outputs a DOM tree to an {@link OutputStream}.
@@ -210,7 +229,7 @@ private static void getSetRec(final Node rootNode, final Set result,
* @param os the {@link OutputStream}
*/
public static void outputDOM(Node contextNode, OutputStream os) {
- XMLUtils.outputDOM(contextNode, os, false);
+ outputDOM(contextNode, os, false);
}
/**
@@ -225,13 +244,12 @@ public static void outputDOM(Node contextNode, OutputStream os) {
public static void outputDOM(Node contextNode, OutputStream os, boolean addPreamble) {
try {
if (addPreamble) {
- os.write("\n".getBytes(java.nio.charset.StandardCharsets.UTF_8));
+ os.write("\n".getBytes(UTF_8));
}
-
Canonicalizer.getInstance(
Canonicalizer.ALGO_ID_C14N_PHYSICAL).canonicalizeSubtree(contextNode, os);
} catch (IOException | InvalidCanonicalizerException | CanonicalizationException ex) {
- LOG.debug(ex.getMessage(), ex);
+ LOG.error(ex.getMessage(), ex);
}
}
@@ -253,7 +271,7 @@ public static void outputDOMc14nWithComments(Node contextNode, OutputStream os)
Canonicalizer.getInstance(
Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS).canonicalizeSubtree(contextNode, os);
} catch (InvalidCanonicalizerException | CanonicalizationException ex) {
- LOG.debug(ex.getMessage(), ex);
+ LOG.error(ex.getMessage(), ex);
// throw new RuntimeException(ex.getMessage());
}
}
@@ -862,7 +880,7 @@ public static boolean protectAgainstWrappingAttack(Node startNode, String value)
// Continue searching to find duplicates
foundElement = attr.getOwnerElement();
} else {
- LOG.debug("Multiple elements with the same 'Id' attribute value!");
+ LOG.warn("Multiple elements with the same 'Id' attribute value!");
return false;
}
}
@@ -921,8 +939,8 @@ public static boolean protectAgainstWrappingAttack(
int length = attributes.getLength();
for (int i = 0; i < length; i++) {
Attr attr = (Attr)attributes.item(i);
- if (attr.isId() && id.equals(attr.getValue()) && se != knownElement) {
- LOG.debug("Multiple elements with the same 'Id' attribute value!");
+ if (attr.isId() && id.equals(attr.getValue()) && !knownElement.isSameNode(se)) {
+ LOG.warn("Multiple elements with the same 'Id' attribute value!");
return false;
}
}
@@ -952,6 +970,49 @@ public static boolean protectAgainstWrappingAttack(
return true;
}
+ /**
+ * Reads a document from the input stream.
+ *
+ * @param file
+ * @param disallowDocTypeDeclarations
+ * @return {@link Document}
+ * @throws XMLParserException
+ * @throws IOException
+ */
+ public static Document read(File file, boolean disallowDocTypeDeclarations) throws XMLParserException, IOException {
+ try (InputStream inputStream = new BufferedInputStream(Files.newInputStream(file.toPath()), 8192)) {
+ return read(inputStream, disallowDocTypeDeclarations);
+ }
+ }
+
+ /**
+ * Reads a document from the input stream and closes it.
+ *
+ * @param name - resource name to be opened by the class loader
+ * @param loader
+ * @param disallowDocTypeDeclarations
+ * @return {@link Document}
+ * @throws XMLParserException
+ * @throws IOException inputStream.close() failed.
+ */
+ public static Document readResource(String name, ClassLoader loader, boolean disallowDocTypeDeclarations)
+ throws XMLParserException, IOException {
+ // Delegate to XMLParser implementation
+ try (InputStream inputStream = loader.getResourceAsStream(name)) {
+ return read(inputStream, disallowDocTypeDeclarations);
+ }
+
+ }
+
+ /**
+ * Reads a document from the input stream.
+ * Caller is responsible for closing the stream.
+ *
+ * @param inputStream
+ * @param disallowDocTypeDeclarations
+ * @return {@link Document}
+ * @throws XMLParserException
+ */
public static Document read(InputStream inputStream, boolean disallowDocTypeDeclarations) throws XMLParserException {
// Delegate to XMLParser implementation
return xmlParserImpl.parse(inputStream, disallowDocTypeDeclarations);
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java
index c1f9e199fb2c8..deda69e98b960 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java
@@ -27,8 +27,8 @@
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.Proxy;
-import java.net.URISyntaxException;
import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
@@ -205,6 +205,7 @@ private URLConnection openConnection(URL url, ResourceResolverContext context) t
* @param context
* @return true if can be resolved
*/
+ @Override
public boolean engineCanResolveURI(ResourceResolverContext context) {
if (context.uriToResolve == null) {
LOG.debug("quick fail, uri == null");
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverFragment.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverFragment.java
index 9af7ee1feff2f..4526a8a1d51a5 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverFragment.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverFragment.java
@@ -110,6 +110,7 @@ public XMLSignatureInput engineResolveURI(ResourceResolverContext context)
* {@inheritDoc}
* @param context
*/
+ @Override
public boolean engineCanResolveURI(ResourceResolverContext context) {
if (context.uriToResolve == null) {
LOG.debug("Quick fail for null uri");
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverLocalFilesystem.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverLocalFilesystem.java
index 9d7e00bdbd6bd..d3970a3ea6940 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverLocalFilesystem.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverLocalFilesystem.java
@@ -66,6 +66,7 @@ public XMLSignatureInput engineResolveURI(ResourceResolverContext context)
/**
* {@inheritDoc}
*/
+ @Override
public boolean engineCanResolveURI(ResourceResolverContext context) {
if (context.uriToResolve == null) {
return false;
diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverXPointer.java b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverXPointer.java
index c3608800ece17..fc0447ec21b6c 100644
--- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverXPointer.java
+++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverXPointer.java
@@ -104,6 +104,7 @@ public XMLSignatureInput engineResolveURI(ResourceResolverContext context)
/**
* {@inheritDoc}
*/
+ @Override
public boolean engineCanResolveURI(ResourceResolverContext context) {
return isXPointerSlash(context.uriToResolve) || isXPointerId(context.uriToResolve);
}
diff --git a/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/SignatureMethod.java b/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/SignatureMethod.java
index 6bb1b2d2da090..bf7bb59c9e161 100644
--- a/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/SignatureMethod.java
+++ b/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/SignatureMethod.java
@@ -275,6 +275,43 @@ public interface SignatureMethod extends XMLStructure, AlgorithmMethod {
*/
String ED448 = "http://www.w3.org/2021/04/xmldsig-more#eddsa-ed448";
+ /**
+ * The
+ * SHA3-224-RSA-MGF1 (PKCS #1) signature method algorithm URI.
+ *
+ * @since 22
+ */
+ String SHA3_224_RSA_MGF1 =
+ "http://www.w3.org/2007/05/xmldsig-more#sha3-224-rsa-MGF1";
+
+ /**
+ * The
+ * SHA3-256-RSA-MGF1 (PKCS #1) signature method algorithm URI.
+ *
+ * @since 22
+ */
+ String SHA3_256_RSA_MGF1 =
+ "http://www.w3.org/2007/05/xmldsig-more#sha3-256-rsa-MGF1";
+
+ /**
+ * The
+ * SHA3-384-RSA-MGF1 (PKCS #1) signature method algorithm URI.
+ *
+ * @since 22
+ */
+ String SHA3_384_RSA_MGF1 =
+ "http://www.w3.org/2007/05/xmldsig-more#sha3-384-rsa-MGF1";
+
+ /**
+ * The
+ * SHA3-512-RSA-MGF1 (PKCS #1) signature method algorithm URI.
+ *
+ * @since 22
+ */
+ String SHA3_512_RSA_MGF1 =
+ "http://www.w3.org/2007/05/xmldsig-more#sha3-512-rsa-MGF1";
+
+
/**
* Returns the algorithm-specific input parameters of this
* SignatureMethod.
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/DigesterOutputStream.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/DigesterOutputStream.java
index 774eb36206521..3b03dc8024bb1 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/DigesterOutputStream.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/DigesterOutputStream.java
@@ -71,6 +71,7 @@ public DigesterOutputStream(MessageDigest md, boolean buffer) {
}
}
+ @Override
public void write(int input) {
if (buffer) {
bos.write(input);
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/MacOutputStream.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/MacOutputStream.java
index be554308928ad..727b3b966a03f 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/MacOutputStream.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/MacOutputStream.java
@@ -23,6 +23,7 @@
package org.jcp.xml.dsig.internal;
import java.io.ByteArrayOutputStream;
+
import javax.crypto.Mac;
/**
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/AbstractDOMSignatureMethod.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/AbstractDOMSignatureMethod.java
index 4bc0a543117b5..75b21c16a02f4 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/AbstractDOMSignatureMethod.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/AbstractDOMSignatureMethod.java
@@ -23,20 +23,22 @@
package org.jcp.xml.dsig.internal.dom;
-import java.security.Key;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
+import java.security.Key;
import java.security.SignatureException;
import java.security.spec.AlgorithmParameterSpec;
+
import javax.xml.crypto.MarshalException;
import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.SignatureMethod;
import javax.xml.crypto.dsig.SignedInfo;
+import javax.xml.crypto.dsig.XMLSignContext;
import javax.xml.crypto.dsig.XMLSignature;
import javax.xml.crypto.dsig.XMLSignatureException;
-import javax.xml.crypto.dsig.XMLSignContext;
import javax.xml.crypto.dsig.XMLValidateContext;
import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java
index 7655866ad7402..5dff44e3ec0d3 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java
@@ -28,11 +28,16 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
-import java.security.spec.AlgorithmParameterSpec;
import java.security.InvalidAlgorithmParameterException;
+import java.security.spec.AlgorithmParameterSpec;
import java.util.Set;
-import javax.xml.crypto.*;
+import javax.xml.crypto.Data;
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.NodeSetData;
+import javax.xml.crypto.OctetStreamData;
+import javax.xml.crypto.XMLCryptoContext;
+import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.TransformException;
import javax.xml.crypto.dsig.TransformService;
@@ -61,11 +66,13 @@ public abstract class ApacheCanonicalizer extends TransformService {
protected Document ownerDoc;
protected Element transformElem;
+ @Override
public final AlgorithmParameterSpec getParameterSpec()
{
return params;
}
+ @Override
public void init(XMLStructure parent, XMLCryptoContext context)
throws InvalidAlgorithmParameterException
{
@@ -84,6 +91,7 @@ public void init(XMLStructure parent, XMLCryptoContext context)
ownerDoc = DOMUtils.getOwnerDocument(transformElem);
}
+ @Override
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
throws MarshalException
{
@@ -182,6 +190,7 @@ private byte[] getC14nBytes(OutputStream outputStream, boolean isByteArrayOutput
return null;
}
+ @Override
public Data transform(Data data, XMLCryptoContext xc, OutputStream os)
throws TransformException
{
@@ -249,6 +258,7 @@ public Data transform(Data data, XMLCryptoContext xc, OutputStream os)
}
}
+ @Override
public final boolean isFeatureSupported(String feature) {
if (feature == null) {
throw new NullPointerException();
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheData.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheData.java
index 109309d008601..0515066bbd5b6 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheData.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheData.java
@@ -26,6 +26,7 @@
package org.jcp.xml.dsig.internal.dom;
import javax.xml.crypto.Data;
+
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
/**
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java
index b15c8784d5c90..a59e41cce308c 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java
@@ -30,13 +30,14 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+
import javax.xml.crypto.NodeSetData;
-import com.sun.org.apache.xml.internal.security.transforms.TransformationException;
-import org.w3c.dom.Node;
import com.sun.org.apache.xml.internal.security.signature.NodeFilter;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
+import com.sun.org.apache.xml.internal.security.transforms.TransformationException;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+import org.w3c.dom.Node;
public class ApacheNodeSetData implements ApacheData, NodeSetData {
@@ -46,6 +47,7 @@ public ApacheNodeSetData(XMLSignatureInput xi) {
this.xi = xi;
}
+ @Override
public Iterator iterator() {
// If nodefilters are set, must execute them first to create node-set
try {
@@ -61,6 +63,7 @@ public Iterator iterator() {
}
}
+ @Override
public XMLSignatureInput getXMLSignatureInput() {
return xi;
}
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java
index f00bb802cfcb8..9b919fcd9099a 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java
@@ -26,7 +26,9 @@
package org.jcp.xml.dsig.internal.dom;
import java.io.IOException;
+
import javax.xml.crypto.OctetStreamData;
+
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
public class ApacheOctetStreamData extends OctetStreamData
@@ -41,6 +43,7 @@ public ApacheOctetStreamData(XMLSignatureInput xi)
this.xi = xi;
}
+ @Override
public XMLSignatureInput getXMLSignatureInput() {
return xi;
}
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java
index 25211920f6853..2efbcb8b54086 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java
@@ -30,17 +30,26 @@
import java.security.spec.AlgorithmParameterSpec;
import java.util.Set;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
-import com.sun.org.apache.xml.internal.security.transforms.Transform;
-import javax.xml.crypto.*;
+import javax.xml.crypto.Data;
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.NodeSetData;
+import javax.xml.crypto.OctetStreamData;
+import javax.xml.crypto.XMLCryptoContext;
+import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dom.DOMCryptoContext;
-import javax.xml.crypto.dsig.*;
+import javax.xml.crypto.dsig.TransformException;
+import javax.xml.crypto.dsig.TransformService;
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
+import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
+import com.sun.org.apache.xml.internal.security.transforms.Transform;
+import com.sun.org.apache.xml.internal.security.transforms.Transforms;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
/**
* This is a wrapper/glue class which invokes the Apache XML-Security
* Transform.
@@ -64,6 +73,7 @@ public final AlgorithmParameterSpec getParameterSpec() {
return params;
}
+ @Override
public void init(XMLStructure parent, XMLCryptoContext context)
throws InvalidAlgorithmParameterException
{
@@ -82,6 +92,7 @@ public void init(XMLStructure parent, XMLCryptoContext context)
ownerDoc = DOMUtils.getOwnerDocument(transformElem);
}
+ @Override
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
throws MarshalException
{
@@ -100,6 +111,7 @@ public void marshalParams(XMLStructure parent, XMLCryptoContext context)
ownerDoc = DOMUtils.getOwnerDocument(transformElem);
}
+ @Override
public Data transform(Data data, XMLCryptoContext xc)
throws TransformException
{
@@ -109,6 +121,7 @@ public Data transform(Data data, XMLCryptoContext xc)
return transformIt(data, xc, null);
}
+ @Override
public Data transform(Data data, XMLCryptoContext xc, OutputStream os)
throws TransformException
{
@@ -197,6 +210,7 @@ private Data transformIt(Data data, XMLCryptoContext xc, OutputStream os)
}
}
+ @Override
public final boolean isFeatureSupported(String feature) {
if (feature == null) {
throw new NullPointerException();
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14N11Method.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14N11Method.java
index 1c6c192e634a3..4ea74c62cc9b4 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14N11Method.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14N11Method.java
@@ -25,12 +25,13 @@
*/
package org.jcp.xml.dsig.internal.dom;
-import javax.xml.crypto.*;
-import javax.xml.crypto.dsig.*;
-import javax.xml.crypto.dsig.spec.TransformParameterSpec;
-
import java.security.InvalidAlgorithmParameterException;
+import javax.xml.crypto.Data;
+import javax.xml.crypto.XMLCryptoContext;
+import javax.xml.crypto.dsig.TransformException;
+import javax.xml.crypto.dsig.spec.TransformParameterSpec;
+
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerException;
@@ -45,6 +46,7 @@ public final class DOMCanonicalXMLC14N11Method extends ApacheCanonicalizer {
public static final String C14N_11_WITH_COMMENTS
= "http://www.w3.org/2006/12/xml-c14n11#WithComments";
+ @Override
public void init(TransformParameterSpec params)
throws InvalidAlgorithmParameterException {
if (params != null) {
@@ -53,6 +55,7 @@ public void init(TransformParameterSpec params)
}
}
+ @Override
public Data transform(Data data, XMLCryptoContext xc)
throws TransformException {
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java
index e2d524b3450d8..4b60015766426 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java
@@ -25,12 +25,14 @@
*/
package org.jcp.xml.dsig.internal.dom;
-import javax.xml.crypto.*;
-import javax.xml.crypto.dsig.*;
-import javax.xml.crypto.dsig.spec.TransformParameterSpec;
-
import java.security.InvalidAlgorithmParameterException;
+import javax.xml.crypto.Data;
+import javax.xml.crypto.XMLCryptoContext;
+import javax.xml.crypto.dsig.CanonicalizationMethod;
+import javax.xml.crypto.dsig.TransformException;
+import javax.xml.crypto.dsig.spec.TransformParameterSpec;
+
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerException;
@@ -41,6 +43,7 @@
*/
public final class DOMCanonicalXMLC14NMethod extends ApacheCanonicalizer {
+ @Override
public void init(TransformParameterSpec params)
throws InvalidAlgorithmParameterException {
if (params != null) {
@@ -49,6 +52,7 @@ public void init(TransformParameterSpec params)
}
}
+ @Override
public Data transform(Data data, XMLCryptoContext xc)
throws TransformException {
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalizationMethod.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalizationMethod.java
index ecef17f35aed0..c182a2253630b 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalizationMethod.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalizationMethod.java
@@ -33,10 +33,14 @@
import java.util.HashSet;
import java.util.Set;
-import org.w3c.dom.Element;
+import javax.xml.crypto.Data;
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.XMLCryptoContext;
+import javax.xml.crypto.dsig.CanonicalizationMethod;
+import javax.xml.crypto.dsig.TransformException;
+import javax.xml.crypto.dsig.TransformService;
-import javax.xml.crypto.*;
-import javax.xml.crypto.dsig.*;
+import org.w3c.dom.Element;
/**
* DOM-based abstract implementation of CanonicalizationMethod.
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java
index 9a81a215d220b..1b1248104510b 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java
@@ -26,7 +26,8 @@
package org.jcp.xml.dsig.internal.dom;
import java.math.BigInteger;
-import javax.xml.crypto.*;
+
+import javax.xml.crypto.MarshalException;
import javax.xml.crypto.dom.DOMCryptoContext;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java
index a4d5fea4ab60a..259c7a988fcad 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java
@@ -25,13 +25,15 @@
*/
package org.jcp.xml.dsig.internal.dom;
-import javax.xml.crypto.*;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.spec.AlgorithmParameterSpec;
+
+import javax.xml.crypto.MarshalException;
import javax.xml.crypto.dom.DOMCryptoContext;
-import javax.xml.crypto.dsig.*;
+import javax.xml.crypto.dsig.DigestMethod;
+import javax.xml.crypto.dsig.XMLSignature;
import javax.xml.crypto.dsig.spec.DigestMethodParameterSpec;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.spec.AlgorithmParameterSpec;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -147,6 +149,7 @@ void checkParams(DigestMethodParameterSpec params)
}
}
+ @Override
public final AlgorithmParameterSpec getParameterSpec() {
return params;
}
@@ -251,9 +254,11 @@ static final class SHA1 extends DOMDigestMethod {
SHA1(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return DigestMethod.SHA1;
}
+ @Override
String getMessageDigestAlgorithm() {
return "SHA-1";
}
@@ -285,9 +290,11 @@ static final class SHA256 extends DOMDigestMethod {
SHA256(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return DigestMethod.SHA256;
}
+ @Override
String getMessageDigestAlgorithm() {
return "SHA-256";
}
@@ -301,9 +308,11 @@ static final class SHA384 extends DOMDigestMethod {
SHA384(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return SHA384;
}
+ @Override
String getMessageDigestAlgorithm() {
return "SHA-384";
}
@@ -317,9 +326,11 @@ static final class SHA512 extends DOMDigestMethod {
SHA512(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return DigestMethod.SHA512;
}
+ @Override
String getMessageDigestAlgorithm() {
return "SHA-512";
}
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMEnvelopedTransform.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMEnvelopedTransform.java
index a43cb81567c8e..9a0ba0b2cae66 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMEnvelopedTransform.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMEnvelopedTransform.java
@@ -26,6 +26,7 @@
package org.jcp.xml.dsig.internal.dom;
import java.security.InvalidAlgorithmParameterException;
+
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
/**
@@ -35,6 +36,7 @@
*/
public final class DOMEnvelopedTransform extends ApacheTransform {
+ @Override
public void init(TransformParameterSpec params)
throws InvalidAlgorithmParameterException {
if (params != null) {
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java
index a8cd434874cf9..0490e78153735 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java
@@ -25,19 +25,24 @@
*/
package org.jcp.xml.dsig.internal.dom;
-import javax.xml.crypto.*;
-import javax.xml.crypto.dsig.*;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.crypto.Data;
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.XMLCryptoContext;
+import javax.xml.crypto.XMLStructure;
+import javax.xml.crypto.dsig.CanonicalizationMethod;
+import javax.xml.crypto.dsig.TransformException;
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
import javax.xml.crypto.dsig.spec.ExcC14NParameterSpec;
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.spec.AlgorithmParameterSpec;
-import java.util.*;
-
-import org.w3c.dom.Element;
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerException;
+import org.w3c.dom.Element;
/**
* DOM-based implementation of CanonicalizationMethod for Exclusive
@@ -47,6 +52,7 @@
*/
public final class DOMExcC14NMethod extends ApacheCanonicalizer {
+ @Override
public void init(TransformParameterSpec params)
throws InvalidAlgorithmParameterException
{
@@ -59,6 +65,7 @@ public void init(TransformParameterSpec params)
}
}
+ @Override
public void init(XMLStructure parent, XMLCryptoContext context)
throws InvalidAlgorithmParameterException
{
@@ -137,6 +144,7 @@ public String getParamsNSURI() {
return CanonicalizationMethod.EXCLUSIVE;
}
+ @Override
public Data transform(Data data, XMLCryptoContext xc)
throws TransformException
{
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java
index 40bb99c3145c1..0a9ef187573ce 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java
@@ -25,11 +25,6 @@
*/
package org.jcp.xml.dsig.internal.dom;
-import javax.xml.crypto.*;
-import javax.xml.crypto.dsig.*;
-import javax.xml.crypto.dsig.spec.HMACParameterSpec;
-import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
-
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
@@ -38,12 +33,22 @@
import java.security.Provider;
import java.security.SignatureException;
import java.security.spec.AlgorithmParameterSpec;
+
import javax.crypto.Mac;
import javax.crypto.SecretKey;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.dsig.SignatureMethod;
+import javax.xml.crypto.dsig.SignedInfo;
+import javax.xml.crypto.dsig.XMLSignContext;
+import javax.xml.crypto.dsig.XMLSignature;
+import javax.xml.crypto.dsig.XMLSignatureException;
+import javax.xml.crypto.dsig.XMLValidateContext;
+import javax.xml.crypto.dsig.spec.HMACParameterSpec;
+import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
import org.jcp.xml.dsig.internal.MacOutputStream;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
* DOM-based implementation of HMAC SignatureMethod.
@@ -118,10 +123,12 @@ void checkParams(SignatureMethodParameterSpec params)
}
}
+ @Override
public final AlgorithmParameterSpec getParameterSpec() {
return params;
}
+ @Override
SignatureMethodParameterSpec unmarshalParams(Element paramsElem)
throws MarshalException
{
@@ -135,6 +142,7 @@ SignatureMethodParameterSpec unmarshalParams(Element paramsElem)
return new HMACParameterSpec(outputLength);
}
+ @Override
void marshalParams(Element parent, String prefix)
throws MarshalException
{
@@ -147,6 +155,7 @@ void marshalParams(Element parent, String prefix)
parent.appendChild(hmacElem);
}
+ @Override
boolean verify(Key key, SignedInfo si, byte[] sig,
XMLValidateContext context)
throws InvalidKeyException, SignatureException, XMLSignatureException
@@ -178,6 +187,7 @@ boolean verify(Key key, SignedInfo si, byte[] sig,
return MessageDigest.isEqual(sig, result);
}
+ @Override
byte[] sign(Key key, SignedInfo si, XMLSignContext context)
throws InvalidKeyException, XMLSignatureException
{
@@ -206,6 +216,7 @@ byte[] sign(Key key, SignedInfo si, XMLSignContext context)
return hmac.doFinal();
}
+ @Override
boolean paramsEqual(AlgorithmParameterSpec spec) {
if (getParameterSpec() == spec) {
return true;
@@ -218,6 +229,7 @@ boolean paramsEqual(AlgorithmParameterSpec spec) {
return outputLength == ospec.getOutputLength();
}
+ @Override
Type getAlgorithmType() {
return Type.HMAC;
}
@@ -235,12 +247,15 @@ static final class SHA1 extends DOMHMACSignatureMethod {
SHA1(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return SignatureMethod.HMAC_SHA1;
}
+ @Override
String getJCAAlgorithm() {
return "HmacSHA1";
}
+ @Override
int getDigestLength() {
return 160;
}
@@ -276,12 +291,15 @@ static final class SHA256 extends DOMHMACSignatureMethod {
SHA256(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return HMAC_SHA256;
}
+ @Override
String getJCAAlgorithm() {
return "HmacSHA256";
}
+ @Override
int getDigestLength() {
return 256;
}
@@ -295,12 +313,15 @@ static final class SHA384 extends DOMHMACSignatureMethod {
SHA384(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return HMAC_SHA384;
}
+ @Override
String getJCAAlgorithm() {
return "HmacSHA384";
}
+ @Override
int getDigestLength() {
return 384;
}
@@ -314,12 +335,15 @@ static final class SHA512 extends DOMHMACSignatureMethod {
SHA512(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return HMAC_SHA512;
}
+ @Override
String getJCAAlgorithm() {
return "HmacSHA512";
}
+ @Override
int getDigestLength() {
return 512;
}
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java
index 19cedafd9fc09..d13b47ccdcfb0 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java
@@ -141,14 +141,17 @@ public DOMKeyInfo(Element kiElem, XMLCryptoContext context,
keyInfoTypes = Collections.unmodifiableList(content);
}
+ @Override
public String getId() {
return id;
}
+ @Override
public List getContent() {
return keyInfoTypes;
}
+ @Override
public void marshal(XMLStructure parent, XMLCryptoContext context)
throws MarshalException
{
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java
index 99ca1dce72204..cec1224affade 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java
@@ -28,8 +28,8 @@
import java.math.BigInteger;
import java.security.KeyException;
import java.security.PublicKey;
-import java.security.interfaces.ECPublicKey;
import java.security.interfaces.DSAPublicKey;
+import java.security.interfaces.ECPublicKey;
import java.security.interfaces.RSAPublicKey;
import java.util.List;
@@ -59,20 +59,24 @@ public final class DOMKeyInfoFactory extends KeyInfoFactory {
public DOMKeyInfoFactory() { }
+ @Override
@SuppressWarnings("rawtypes")
public KeyInfo newKeyInfo(List content) {
return newKeyInfo(content, null);
}
+ @Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public KeyInfo newKeyInfo(List content, String id) {
return new DOMKeyInfo(content, id);
}
+ @Override
public KeyName newKeyName(String name) {
return new DOMKeyName(name);
}
+ @Override
public KeyValue newKeyValue(PublicKey key) throws KeyException {
String algorithm = key.getAlgorithm();
if ("DSA".equals(algorithm)) {
@@ -86,24 +90,29 @@ public KeyValue newKeyValue(PublicKey key) throws KeyException {
}
}
+ @Override
public PGPData newPGPData(byte[] keyId) {
return newPGPData(keyId, null, null);
}
+ @Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public PGPData newPGPData(byte[] keyId, byte[] keyPacket, List other) {
return new DOMPGPData(keyId, keyPacket, other);
}
+ @Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public PGPData newPGPData(byte[] keyPacket, List other) {
return new DOMPGPData(keyPacket, other);
}
+ @Override
public RetrievalMethod newRetrievalMethod(String uri) {
return newRetrievalMethod(uri, null, null);
}
+ @Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public RetrievalMethod newRetrievalMethod(String uri, String type,
List transforms) {
@@ -113,6 +122,7 @@ public RetrievalMethod newRetrievalMethod(String uri, String type,
return new DOMRetrievalMethod(uri, type, transforms);
}
+ @Override
@SuppressWarnings({ "rawtypes" })
public X509Data newX509Data(List content) {
return new DOMX509Data(content);
@@ -124,6 +134,7 @@ public X509IssuerSerial newX509IssuerSerial(String issuerName,
return new DOMX509IssuerSerial(issuerName, serialNumber);
}
+ @Override
public boolean isFeatureSupported(String feature) {
if (feature == null) {
throw new NullPointerException();
@@ -132,6 +143,7 @@ public boolean isFeatureSupported(String feature) {
}
}
+ @Override
public URIDereferencer getURIDereferencer() {
return DOMURIDereferencer.INSTANCE;
}
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyName.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyName.java
index 888a9c760247a..3c83e48880bc2 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyName.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyName.java
@@ -64,6 +64,7 @@ public DOMKeyName(Element knElem) {
name = knElem.getFirstChild().getNodeValue();
}
+ @Override
public String getName() {
return name;
}
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java
index 307d0ae45ce20..0933c21bfd3d4 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java
@@ -101,6 +101,7 @@ static KeyValue unmarshal(Element kvElem) throws MarshalException {
}
}
+ @Override
public PublicKey getPublicKey() throws KeyException {
if (publicKey == null) {
throw new KeyException("can't convert KeyValue to PublicKey");
@@ -198,6 +199,7 @@ static final class RSA extends DOMKeyValue {
super(elem);
}
+ @Override
void marshalPublicKey(Node parent, Document doc, String dsPrefix,
DOMCryptoContext context) throws MarshalException {
Element rsaElem = DOMUtils.createElement(doc, "RSAKeyValue",
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java
index be65eb8fb1f35..6ed7ee8025dcb 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java
@@ -25,12 +25,17 @@
*/
package org.jcp.xml.dsig.internal.dom;
-import javax.xml.crypto.*;
-import javax.xml.crypto.dom.DOMCryptoContext;
-import javax.xml.crypto.dsig.*;
-
import java.security.Provider;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.XMLCryptoContext;
+import javax.xml.crypto.dom.DOMCryptoContext;
+import javax.xml.crypto.dsig.Manifest;
+import javax.xml.crypto.dsig.Reference;
+import javax.xml.crypto.dsig.XMLSignature;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -114,6 +119,7 @@ public DOMManifest(Element manElem, XMLCryptoContext context,
this.references = Collections.unmodifiableList(refs);
}
+ @Override
public String getId() {
return id;
}
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java
index f9802c4698d10..df591ce00ef64 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java
@@ -25,19 +25,21 @@
*/
package org.jcp.xml.dsig.internal.dom;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
-import javax.xml.crypto.*;
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.XMLSignature;
import javax.xml.crypto.dsig.keyinfo.PGPData;
+import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
-
/**
* DOM-based implementation of PGPData.
*
@@ -171,14 +173,17 @@ public DOMPGPData(Element pdElem) throws MarshalException {
this.externalElements = Collections.unmodifiableList(other);
}
+ @Override
public byte[] getKeyId() {
return keyId == null ? null : keyId.clone();
}
+ @Override
public byte[] getKeyPacket() {
return keyPacket == null ? null : keyPacket.clone();
}
+ @Override
public List getExternalElements() {
return externalElements;
}
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRSAPSSSignatureMethod.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRSAPSSSignatureMethod.java
index 8e4c2424eb7fb..c131ab689d735 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRSAPSSSignatureMethod.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRSAPSSSignatureMethod.java
@@ -25,25 +25,33 @@
*/
package org.jcp.xml.dsig.internal.dom;
-import javax.xml.crypto.*;
-import javax.xml.crypto.dsig.*;
-import javax.xml.crypto.dsig.spec.RSAPSSParameterSpec;
-import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
-
import java.io.IOException;
-import java.security.*;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.Provider;
+import java.security.PublicKey;
+import java.security.Signature;
+import java.security.SignatureException;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.MGF1ParameterSpec;
import java.security.spec.PSSParameterSpec;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Text;
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.dsig.*;
+import javax.xml.crypto.dsig.spec.RSAPSSParameterSpec;
+import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
+
import org.jcp.xml.dsig.internal.SignerOutputStream;
import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureBaseRSA.SignatureRSASSAPSS.DigestAlgorithm;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
/**
* DOM-based abstract implementation of SignatureMethod for RSA-PSS.
@@ -125,10 +133,12 @@ void checkParams(SignatureMethodParameterSpec params)
LOG.debug("Setting RSAPSSParameterSpec to: {}", params.toString());
}
+ @Override
public final AlgorithmParameterSpec getParameterSpec() {
return params;
}
+ @Override
void marshalParams(Element parent, String prefix)
throws MarshalException
{
@@ -203,6 +213,7 @@ private static DigestAlgorithm validateDigestAlgorithm(String input)
}
}
+ @Override
SignatureMethodParameterSpec unmarshalParams(Element paramsElem)
throws MarshalException
{
@@ -250,6 +261,7 @@ SignatureMethodParameterSpec unmarshalParams(Element paramsElem)
return DEFAULT_PSS_SPEC;
}
+ @Override
boolean verify(Key key, SignedInfo si, byte[] sig,
XMLValidateContext context)
throws InvalidKeyException, SignatureException, XMLSignatureException
@@ -291,6 +303,7 @@ boolean verify(Key key, SignedInfo si, byte[] sig,
}
}
+ @Override
byte[] sign(Key key, SignedInfo si, XMLSignContext context)
throws InvalidKeyException, XMLSignatureException
{
@@ -318,7 +331,6 @@ byte[] sign(Key key, SignedInfo si, XMLSignContext context)
throw new XMLSignatureException(e);
}
LOG.debug("Signature provider: {}", signature.getProvider());
- LOG.debug("Signing with key: {}", key);
LOG.debug("JCA Algorithm: {}", getJCAAlgorithm());
try (SignerOutputStream outputStream = new SignerOutputStream(signature)) {
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java
index d278808ea0572..69215340089b8 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java
@@ -32,28 +32,52 @@
*/
package org.jcp.xml.dsig.internal.dom;
-import javax.xml.crypto.*;
-import javax.xml.crypto.dsig.*;
-import javax.xml.crypto.dom.DOMCryptoContext;
-import javax.xml.crypto.dom.DOMURIReference;
-
-import java.io.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
-import java.security.*;
-import java.util.*;
+import java.security.AccessController;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivilegedAction;
+import java.security.Provider;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.crypto.Data;
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.NodeSetData;
+import javax.xml.crypto.OctetStreamData;
+import javax.xml.crypto.URIDereferencer;
+import javax.xml.crypto.URIReferenceException;
+import javax.xml.crypto.XMLCryptoContext;
+import javax.xml.crypto.dom.DOMCryptoContext;
+import javax.xml.crypto.dom.DOMURIReference;
+import javax.xml.crypto.dsig.CanonicalizationMethod;
+import javax.xml.crypto.dsig.DigestMethod;
+import javax.xml.crypto.dsig.Reference;
+import javax.xml.crypto.dsig.Transform;
+import javax.xml.crypto.dsig.TransformException;
+import javax.xml.crypto.dsig.TransformService;
+import javax.xml.crypto.dsig.XMLSignContext;
+import javax.xml.crypto.dsig.XMLSignature;
+import javax.xml.crypto.dsig.XMLSignatureException;
+import javax.xml.crypto.dsig.XMLValidateContext;
+import org.jcp.xml.dsig.internal.DigesterOutputStream;
+import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
+import com.sun.org.apache.xml.internal.security.utils.UnsyncBufferedOutputStream;
+import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
-
-import org.jcp.xml.dsig.internal.DigesterOutputStream;
-import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
-import com.sun.org.apache.xml.internal.security.utils.UnsyncBufferedOutputStream;
-
/**
* DOM-based implementation of Reference.
*
@@ -270,30 +294,37 @@ public DOMReference(Element refElem, XMLCryptoContext context,
this.provider = provider;
}
+ @Override
public DigestMethod getDigestMethod() {
return digestMethod;
}
+ @Override
public String getId() {
return id;
}
+ @Override
public String getURI() {
return uri;
}
+ @Override
public String getType() {
return type;
}
+ @Override
public List getTransforms() {
return Collections.unmodifiableList(allTransforms);
}
+ @Override
public byte[] getDigestValue() {
return digestValue == null ? null : digestValue.clone();
}
+ @Override
public byte[] getCalculatedDigestValue() {
return calcDigestValue == null ? null
: calcDigestValue.clone();
@@ -372,6 +403,7 @@ public void digest(XMLSignContext signContext)
LOG.debug("Reference digesting completed");
}
+ @Override
public boolean validate(XMLValidateContext validateContext)
throws XMLSignatureException
{
@@ -394,10 +426,12 @@ public boolean validate(XMLValidateContext validateContext)
return validationStatus;
}
+ @Override
public Data getDereferencedData() {
return derefData;
}
+ @Override
public InputStream getDigestInputStream() {
return dis;
}
@@ -568,6 +602,7 @@ private byte[] transform(Data dereferencedData,
}
}
+ @Override
public Node getHere() {
return here;
}
@@ -631,6 +666,7 @@ private static Data copyDerefData(Data dereferencedData) {
try {
final Set s = xsi.getNodeSet();
return new NodeSetData() {
+ @Override
public Iterator iterator() { return s.iterator(); }
};
} catch (Exception e) {
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java
index 33343808fadc4..e5c92e8c5352c 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java
@@ -176,14 +176,17 @@ public DOMRetrievalMethod(Element rmElem, XMLCryptoContext context,
}
}
+ @Override
public String getURI() {
return uri;
}
+ @Override
public String getType() {
return type;
}
+ @Override
public List getTransforms() {
return transforms;
}
@@ -219,10 +222,12 @@ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
here = rmElem.getAttributeNodeNS(null, "URI");
}
+ @Override
public Node getHere() {
return here;
}
+ @Override
public Data dereference(XMLCryptoContext context)
throws URIReferenceException
{
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java
index 267e29d901d69..5e44ccaeae8b0 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java
@@ -25,23 +25,36 @@
*/
package org.jcp.xml.dsig.internal.dom;
-import javax.xml.crypto.*;
-import javax.xml.crypto.dsig.*;
-import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
-
import java.io.IOException;
-import java.security.*;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.Provider;
+import java.security.PublicKey;
+import java.security.Signature;
+import java.security.SignatureException;
import java.security.interfaces.DSAKey;
import java.security.interfaces.ECPrivateKey;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.MGF1ParameterSpec;
import java.security.spec.PSSParameterSpec;
-import org.w3c.dom.Element;
+import javax.xml.crypto.XMLCryptoContext;
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.dsig.SignatureMethod;
+import javax.xml.crypto.dsig.SignedInfo;
+import javax.xml.crypto.dsig.XMLSignContext;
+import javax.xml.crypto.dsig.XMLSignatureException;
+import javax.xml.crypto.dsig.XMLValidateContext;
+import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
+import org.jcp.xml.dsig.internal.SignerOutputStream;
import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureECDSA;
import com.sun.org.apache.xml.internal.security.utils.JavaUtils;
-import org.jcp.xml.dsig.internal.SignerOutputStream;
+import org.w3c.dom.Element;
+
import sun.security.util.KeyUtil;
/**
@@ -103,6 +116,14 @@ public abstract class DOMSignatureMethod extends AbstractDOMSignatureMethod {
"http://www.w3.org/2007/05/xmldsig-more#sha512-rsa-MGF1";
static final String RSA_RIPEMD160_MGF1 =
"http://www.w3.org/2007/05/xmldsig-more#ripemd160-rsa-MGF1";
+ static final String RSA_SHA3_224_MGF1 =
+ "http://www.w3.org/2007/05/xmldsig-more#sha3-224-rsa-MGF1";
+ static final String RSA_SHA3_256_MGF1 =
+ "http://www.w3.org/2007/05/xmldsig-more#sha3-256-rsa-MGF1";
+ static final String RSA_SHA3_384_MGF1 =
+ "http://www.w3.org/2007/05/xmldsig-more#sha3-384-rsa-MGF1";
+ static final String RSA_SHA3_512_MGF1 =
+ "http://www.w3.org/2007/05/xmldsig-more#sha3-512-rsa-MGF1";
/**
* Creates a {@code DOMSignatureMethod}.
@@ -194,6 +215,14 @@ static SignatureMethod unmarshal(Element smElem) throws MarshalException {
return new SHA384withRSAandMGF1(smElem);
} else if (alg.equals(RSA_SHA512_MGF1)) {
return new SHA512withRSAandMGF1(smElem);
+ } else if (alg.equals(RSA_SHA3_224_MGF1)) {
+ return new SHA3_224withRSAandMGF1(smElem);
+ } else if (alg.equals(RSA_SHA3_256_MGF1)) {
+ return new SHA3_256withRSAandMGF1(smElem);
+ } else if (alg.equals(RSA_SHA3_384_MGF1)) {
+ return new SHA3_384withRSAandMGF1(smElem);
+ } else if (alg.equals(RSA_SHA3_512_MGF1)) {
+ return new SHA3_512withRSAandMGF1(smElem);
} else if (alg.equals(DOMRSAPSSSignatureMethod.RSA_PSS)) {
return new DOMRSAPSSSignatureMethod.RSAPSS(smElem);
} else if (alg.equals(RSA_RIPEMD160_MGF1)) {
@@ -236,6 +265,7 @@ static SignatureMethod unmarshal(Element smElem) throws MarshalException {
}
}
+ @Override
public final AlgorithmParameterSpec getParameterSpec() {
return params;
}
@@ -257,6 +287,7 @@ Signature getSignature(Provider p)
: Signature.getInstance(getJCAAlgorithm(), p);
}
+ @Override
boolean verify(Key key, SignedInfo si, byte[] sig,
XMLValidateContext context)
throws InvalidKeyException, SignatureException, XMLSignatureException
@@ -323,6 +354,7 @@ private static void checkKeySize(XMLCryptoContext context, Key key)
}
}
+ @Override
byte[] sign(Key key, SignedInfo si, XMLSignContext context)
throws InvalidKeyException, XMLSignatureException
{
@@ -344,7 +376,6 @@ byte[] sign(Key key, SignedInfo si, XMLSignContext context)
}
signature.initSign((PrivateKey)key);
LOG.debug("Signature provider: {}", signature.getProvider());
- LOG.debug("Signing with key: {}", key);
LOG.debug("JCA Algorithm: {}", getJCAAlgorithm());
try (SignerOutputStream outputStream = new SignerOutputStream(signature)) {
@@ -383,6 +414,11 @@ byte[] postSignFormat(Key key, byte[] sig) {
byte[] preVerifyFormat(Key key, byte[] sig) {
return sig;
}
+
+ @Override
+ Type getAlgorithmType() {
+ return Type.RSA;
+ }
}
abstract static class AbstractRSAPSSSignatureMethod
@@ -397,7 +433,7 @@ abstract static class AbstractRSAPSSSignatureMethod
super(dmElem);
}
- abstract public PSSParameterSpec getPSSParameterSpec();
+ public abstract PSSParameterSpec getPSSParameterSpec();
@Override
Signature getSignature(Provider p)
@@ -413,9 +449,7 @@ Signature getSignature(Provider p)
}
return s;
} catch (NoSuchAlgorithmException nsae) {
- return (p == null)
- ? Signature.getInstance(getJCAAlgorithm())
- : Signature.getInstance(getJCAAlgorithm(), p);
+ return super.getSignature(p);
}
}
}
@@ -509,6 +543,11 @@ byte[] preVerifyFormat(Key key, byte[] sig) throws IOException {
return sig;
}
}
+
+ @Override
+ Type getAlgorithmType() {
+ return Type.DSA;
+ }
}
abstract static class AbstractECDSASignatureMethod
@@ -550,6 +589,11 @@ byte[] preVerifyFormat(Key key, byte[] sig) throws IOException {
return sig;
}
}
+
+ @Override
+ Type getAlgorithmType() {
+ return Type.ECDSA;
+ }
}
abstract static class AbstractEDDSASignatureMethod
@@ -583,6 +627,10 @@ byte[] preVerifyFormat(Key key, byte[] sig) {
return sig;
}
+ @Override
+ Type getAlgorithmType() {
+ return Type.EDDSA;
+ }
}
static final class SHA1withRSA extends AbstractRSASignatureMethod {
@@ -601,10 +649,6 @@ public String getAlgorithm() {
String getJCAAlgorithm() {
return "SHA1withRSA";
}
- @Override
- Type getAlgorithmType() {
- return Type.RSA;
- }
}
static final class SHA224withRSA extends AbstractRSASignatureMethod {
@@ -615,15 +659,14 @@ static final class SHA224withRSA extends AbstractRSASignatureMethod {
SHA224withRSA(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return RSA_SHA224;
}
+ @Override
String getJCAAlgorithm() {
return "SHA224withRSA";
}
- Type getAlgorithmType() {
- return Type.RSA;
- }
}
static final class SHA256withRSA extends AbstractRSASignatureMethod {
@@ -634,15 +677,14 @@ static final class SHA256withRSA extends AbstractRSASignatureMethod {
SHA256withRSA(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return RSA_SHA256;
}
+ @Override
String getJCAAlgorithm() {
return "SHA256withRSA";
}
- Type getAlgorithmType() {
- return Type.RSA;
- }
}
static final class SHA384withRSA extends AbstractRSASignatureMethod {
@@ -653,15 +695,14 @@ static final class SHA384withRSA extends AbstractRSASignatureMethod {
SHA384withRSA(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return RSA_SHA384;
}
+ @Override
String getJCAAlgorithm() {
return "SHA384withRSA";
}
- Type getAlgorithmType() {
- return Type.RSA;
- }
}
static final class SHA512withRSA extends AbstractRSASignatureMethod {
@@ -672,15 +713,14 @@ static final class SHA512withRSA extends AbstractRSASignatureMethod {
SHA512withRSA(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return RSA_SHA512;
}
+ @Override
String getJCAAlgorithm() {
return "SHA512withRSA";
}
- Type getAlgorithmType() {
- return Type.RSA;
- }
}
static final class RIPEMD160withRSA extends AbstractRSASignatureMethod {
@@ -699,15 +739,11 @@ public String getAlgorithm() {
String getJCAAlgorithm() {
return "RIPEMD160withRSA";
}
- @Override
- Type getAlgorithmType() {
- return Type.RSA;
- }
}
static final class SHA1withRSAandMGF1 extends AbstractRSAPSSSignatureMethod {
- private static PSSParameterSpec spec
+ private static final PSSParameterSpec SHA1_MGF1_PARAMS
= new PSSParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1,
20, PSSParameterSpec.TRAILER_FIELD_BC);
@@ -724,21 +760,17 @@ public String getAlgorithm() {
}
@Override
public PSSParameterSpec getPSSParameterSpec() {
- return spec;
+ return SHA1_MGF1_PARAMS;
}
@Override
String getJCAAlgorithm() {
return "SHA1withRSAandMGF1";
}
- @Override
- Type getAlgorithmType() {
- return Type.RSA;
- }
}
static final class SHA224withRSAandMGF1 extends AbstractRSAPSSSignatureMethod {
- private static PSSParameterSpec spec
+ private static final PSSParameterSpec SHA224_MGF1_PARAMS
= new PSSParameterSpec("SHA-224", "MGF1", MGF1ParameterSpec.SHA224,
28, PSSParameterSpec.TRAILER_FIELD_BC);
@@ -755,21 +787,17 @@ public String getAlgorithm() {
}
@Override
public PSSParameterSpec getPSSParameterSpec() {
- return spec;
+ return SHA224_MGF1_PARAMS;
}
@Override
String getJCAAlgorithm() {
return "SHA224withRSAandMGF1";
}
- @Override
- Type getAlgorithmType() {
- return Type.RSA;
- }
}
static final class SHA256withRSAandMGF1 extends AbstractRSAPSSSignatureMethod {
- private static PSSParameterSpec spec
+ private static final PSSParameterSpec SHA256_MGF1_PARAMS
= new PSSParameterSpec("SHA-256", "MGF1", MGF1ParameterSpec.SHA256,
32, PSSParameterSpec.TRAILER_FIELD_BC);
@@ -786,21 +814,17 @@ public String getAlgorithm() {
}
@Override
public PSSParameterSpec getPSSParameterSpec() {
- return spec;
+ return SHA256_MGF1_PARAMS;
}
@Override
String getJCAAlgorithm() {
return "SHA256withRSAandMGF1";
}
- @Override
- Type getAlgorithmType() {
- return Type.RSA;
- }
}
static final class SHA384withRSAandMGF1 extends AbstractRSAPSSSignatureMethod {
- private static PSSParameterSpec spec
+ private static final PSSParameterSpec SHA384_MGF1_PARAMS
= new PSSParameterSpec("SHA-384", "MGF1", MGF1ParameterSpec.SHA384,
48, PSSParameterSpec.TRAILER_FIELD_BC);
@@ -817,21 +841,17 @@ public String getAlgorithm() {
}
@Override
public PSSParameterSpec getPSSParameterSpec() {
- return spec;
+ return SHA384_MGF1_PARAMS;
}
@Override
String getJCAAlgorithm() {
return "SHA384withRSAandMGF1";
}
- @Override
- Type getAlgorithmType() {
- return Type.RSA;
- }
}
static final class SHA512withRSAandMGF1 extends AbstractRSAPSSSignatureMethod {
- private static PSSParameterSpec spec
+ private static final PSSParameterSpec SHA512_MGF1_PARAMS
= new PSSParameterSpec("SHA-512", "MGF1", MGF1ParameterSpec.SHA512,
64, PSSParameterSpec.TRAILER_FIELD_BC);
@@ -848,15 +868,123 @@ public String getAlgorithm() {
}
@Override
public PSSParameterSpec getPSSParameterSpec() {
- return spec;
+ return SHA512_MGF1_PARAMS;
}
@Override
String getJCAAlgorithm() {
return "SHA512withRSAandMGF1";
}
+ }
+
+ static final class SHA3_224withRSAandMGF1 extends AbstractRSAPSSSignatureMethod {
+
+ private static final PSSParameterSpec SHA3_224_MGF1_PARAMS
+ = new PSSParameterSpec("SHA3-224", "MGF1",
+ new MGF1ParameterSpec("SHA3-224"), 28,
+ PSSParameterSpec.TRAILER_FIELD_BC);
+
+ SHA3_224withRSAandMGF1(AlgorithmParameterSpec params)
+ throws InvalidAlgorithmParameterException {
+ super(params);
+ }
+ SHA3_224withRSAandMGF1(Element dmElem) throws MarshalException {
+ super(dmElem);
+ }
@Override
- Type getAlgorithmType() {
- return Type.RSA;
+ public String getAlgorithm() {
+ return RSA_SHA3_224_MGF1;
+ }
+ @Override
+ public PSSParameterSpec getPSSParameterSpec() {
+ return SHA3_224_MGF1_PARAMS;
+ }
+ @Override
+ String getJCAAlgorithm() {
+ return "SHA3-224withRSAandMGF1";
+ }
+ }
+
+ static final class SHA3_256withRSAandMGF1 extends AbstractRSAPSSSignatureMethod {
+
+ private static final PSSParameterSpec SHA3_256_MGF1_PARAMS
+ = new PSSParameterSpec("SHA3-256", "MGF1",
+ new MGF1ParameterSpec("SHA3-256"), 32,
+ PSSParameterSpec.TRAILER_FIELD_BC);
+
+ SHA3_256withRSAandMGF1(AlgorithmParameterSpec params)
+ throws InvalidAlgorithmParameterException {
+ super(params);
+ }
+ SHA3_256withRSAandMGF1(Element dmElem) throws MarshalException {
+ super(dmElem);
+ }
+ @Override
+ public String getAlgorithm() {
+ return RSA_SHA3_256_MGF1;
+ }
+ @Override
+ public PSSParameterSpec getPSSParameterSpec() {
+ return SHA3_256_MGF1_PARAMS;
+ }
+ @Override
+ String getJCAAlgorithm() {
+ return "SHA3-256withRSAandMGF1";
+ }
+ }
+
+ static final class SHA3_384withRSAandMGF1 extends AbstractRSAPSSSignatureMethod {
+
+ private static final PSSParameterSpec SHA3_384_MGF1_PARAMS
+ = new PSSParameterSpec("SHA3-384", "MGF1",
+ new MGF1ParameterSpec("SHA3-384"), 48,
+ PSSParameterSpec.TRAILER_FIELD_BC);
+
+ SHA3_384withRSAandMGF1(AlgorithmParameterSpec params)
+ throws InvalidAlgorithmParameterException {
+ super(params);
+ }
+ SHA3_384withRSAandMGF1(Element dmElem) throws MarshalException {
+ super(dmElem);
+ }
+ @Override
+ public String getAlgorithm() {
+ return RSA_SHA3_384_MGF1;
+ }
+ @Override
+ public PSSParameterSpec getPSSParameterSpec() {
+ return SHA3_384_MGF1_PARAMS;
+ }
+ @Override
+ String getJCAAlgorithm() {
+ return "SHA3-384withRSAandMGF1";
+ }
+ }
+
+ static final class SHA3_512withRSAandMGF1 extends AbstractRSAPSSSignatureMethod {
+
+ private static final PSSParameterSpec SHA3_512_MGF1_PARAMS
+ = new PSSParameterSpec("SHA3-512", "MGF1",
+ new MGF1ParameterSpec("SHA3-512"), 64,
+ PSSParameterSpec.TRAILER_FIELD_BC);
+
+ SHA3_512withRSAandMGF1(AlgorithmParameterSpec params)
+ throws InvalidAlgorithmParameterException {
+ super(params);
+ }
+ SHA3_512withRSAandMGF1(Element dmElem) throws MarshalException {
+ super(dmElem);
+ }
+ @Override
+ public String getAlgorithm() {
+ return RSA_SHA3_512_MGF1;
+ }
+ @Override
+ public PSSParameterSpec getPSSParameterSpec() {
+ return SHA3_512_MGF1_PARAMS;
+ }
+ @Override
+ String getJCAAlgorithm() {
+ return "SHA3-512withRSAandMGF1";
}
}
@@ -876,10 +1004,6 @@ public String getAlgorithm() {
String getJCAAlgorithm() {
return "RIPEMD160withRSAandMGF1";
}
- @Override
- Type getAlgorithmType() {
- return Type.RSA;
- }
}
static final class SHA1withDSA extends AbstractDSASignatureMethod {
@@ -890,18 +1014,18 @@ static final class SHA1withDSA extends AbstractDSASignatureMethod {
SHA1withDSA(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return SignatureMethod.DSA_SHA1;
}
+ @Override
String getJCAAlgorithm() {
return "SHA1withDSAinP1363Format";
}
+ @Override
String getJCAFallbackAlgorithm() {
return "SHA1withDSA";
}
- Type getAlgorithmType() {
- return Type.DSA;
- }
}
static final class SHA256withDSA extends AbstractDSASignatureMethod {
@@ -912,18 +1036,18 @@ static final class SHA256withDSA extends AbstractDSASignatureMethod {
SHA256withDSA(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return DSA_SHA256;
}
+ @Override
String getJCAAlgorithm() {
return "SHA256withDSAinP1363Format";
}
+ @Override
String getJCAFallbackAlgorithm() {
return "SHA256withDSA";
}
- Type getAlgorithmType() {
- return Type.DSA;
- }
}
static final class SHA1withECDSA extends AbstractECDSASignatureMethod {
@@ -934,18 +1058,18 @@ static final class SHA1withECDSA extends AbstractECDSASignatureMethod {
SHA1withECDSA(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return ECDSA_SHA1;
}
+ @Override
String getJCAAlgorithm() {
return "SHA1withECDSAinP1363Format";
}
+ @Override
String getJCAFallbackAlgorithm() {
return "SHA1withECDSA";
}
- Type getAlgorithmType() {
- return Type.ECDSA;
- }
}
static final class SHA224withECDSA extends AbstractECDSASignatureMethod {
@@ -964,13 +1088,10 @@ public String getAlgorithm() {
String getJCAAlgorithm() {
return "SHA224withECDSAinP1363Format";
}
+ @Override
String getJCAFallbackAlgorithm() {
return "SHA224withECDSA";
}
- @Override
- Type getAlgorithmType() {
- return Type.ECDSA;
- }
}
static final class SHA256withECDSA extends AbstractECDSASignatureMethod {
@@ -981,18 +1102,18 @@ static final class SHA256withECDSA extends AbstractECDSASignatureMethod {
SHA256withECDSA(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return ECDSA_SHA256;
}
+ @Override
String getJCAAlgorithm() {
return "SHA256withECDSAinP1363Format";
}
+ @Override
String getJCAFallbackAlgorithm() {
return "SHA256withECDSA";
}
- Type getAlgorithmType() {
- return Type.ECDSA;
- }
}
static final class SHA384withECDSA extends AbstractECDSASignatureMethod {
@@ -1003,18 +1124,18 @@ static final class SHA384withECDSA extends AbstractECDSASignatureMethod {
SHA384withECDSA(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return ECDSA_SHA384;
}
+ @Override
String getJCAAlgorithm() {
return "SHA384withECDSAinP1363Format";
}
+ @Override
String getJCAFallbackAlgorithm() {
return "SHA384withECDSA";
}
- Type getAlgorithmType() {
- return Type.ECDSA;
- }
}
static final class SHA512withECDSA extends AbstractECDSASignatureMethod {
@@ -1025,18 +1146,18 @@ static final class SHA512withECDSA extends AbstractECDSASignatureMethod {
SHA512withECDSA(Element dmElem) throws MarshalException {
super(dmElem);
}
+ @Override
public String getAlgorithm() {
return ECDSA_SHA512;
}
+ @Override
String getJCAAlgorithm() {
return "SHA512withECDSAinP1363Format";
}
+ @Override
String getJCAFallbackAlgorithm() {
return "SHA512withECDSA";
}
- Type getAlgorithmType() {
- return Type.ECDSA;
- }
}
static final class RIPEMD160withECDSA extends AbstractECDSASignatureMethod {
@@ -1055,13 +1176,10 @@ public String getAlgorithm() {
String getJCAAlgorithm() {
return "RIPEMD160withECDSAinP1363Format"; // Is this real?
}
+ @Override
String getJCAFallbackAlgorithm() {
return "RIPEMD160withECDSA";
}
- @Override
- Type getAlgorithmType() {
- return Type.ECDSA;
- }
}
static final class EDDSA_ED25519 extends AbstractEDDSASignatureMethod {
@@ -1084,11 +1202,6 @@ public String getAlgorithm() {
String getJCAAlgorithm() {
return "Ed25519";
}
-
- @Override
- Type getAlgorithmType() {
- return Type.EDDSA;
- }
}
static final class EDDSA_ED448 extends AbstractEDDSASignatureMethod {
@@ -1110,10 +1223,5 @@ public String getAlgorithm() {
String getJCAAlgorithm() {
return "Ed448";
}
-
- @Override
- Type getAlgorithmType() {
- return Type.EDDSA;
- }
}
}
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java
index efa9d3fc80ab3..ba72b2725ea1d 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java
@@ -25,11 +25,15 @@
*/
package org.jcp.xml.dsig.internal.dom;
-import javax.xml.crypto.*;
-import javax.xml.crypto.dom.DOMCryptoContext;
-import javax.xml.crypto.dsig.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
-import java.util.*;
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.dom.DOMCryptoContext;
+import javax.xml.crypto.dsig.SignatureProperties;
+import javax.xml.crypto.dsig.SignatureProperty;
+import javax.xml.crypto.dsig.XMLSignature;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -117,10 +121,12 @@ public DOMSignatureProperties(Element propsElem)
}
}
+ @Override
public List getProperties() {
return properties;
}
+ @Override
public String getId() {
return id;
}
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java
index 136847b491f0b..61994cd85f815 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java
@@ -25,11 +25,15 @@
*/
package org.jcp.xml.dsig.internal.dom;
-import javax.xml.crypto.*;
-import javax.xml.crypto.dom.DOMCryptoContext;
-import javax.xml.crypto.dsig.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
-import java.util.*;
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.XMLStructure;
+import javax.xml.crypto.dom.DOMCryptoContext;
+import javax.xml.crypto.dsig.SignatureProperty;
+import javax.xml.crypto.dsig.XMLSignature;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -117,14 +121,17 @@ public DOMSignatureProperty(Element propElem)
}
}
+ @Override
public List getContent() {
return content;
}
+ @Override
public String getId() {
return id;
}
+ @Override
public String getTarget() {
return target;
}
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java
index f4f8bfd438667..170b179564b99 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java
@@ -25,28 +25,38 @@
*/
package org.jcp.xml.dsig.internal.dom;
-import javax.xml.crypto.*;
-import javax.xml.crypto.dom.DOMCryptoContext;
-import javax.xml.crypto.dsig.*;
-import javax.xml.crypto.dsig.spec.RSAPSSParameterSpec;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.IOException;
import java.security.Provider;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.MGF1ParameterSpec;
import java.security.spec.PSSParameterSpec;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.XMLCryptoContext;
+import javax.xml.crypto.dom.DOMCryptoContext;
+import javax.xml.crypto.dsig.CanonicalizationMethod;
+import javax.xml.crypto.dsig.Reference;
+import javax.xml.crypto.dsig.SignatureMethod;
+import javax.xml.crypto.dsig.SignedInfo;
+import javax.xml.crypto.dsig.TransformException;
+import javax.xml.crypto.dsig.XMLSignature;
+import javax.xml.crypto.dsig.XMLSignatureException;
+import javax.xml.crypto.dsig.spec.RSAPSSParameterSpec;
import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureBaseRSA;
+import com.sun.org.apache.xml.internal.security.utils.UnsyncBufferedOutputStream;
+import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import com.sun.org.apache.xml.internal.security.utils.UnsyncBufferedOutputStream;
-import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+
/**
* DOM-based implementation of SignedInfo.
@@ -57,9 +67,9 @@ public final class DOMSignedInfo extends DOMStructure implements SignedInfo {
private static final com.sun.org.slf4j.internal.Logger LOG =
com.sun.org.slf4j.internal.LoggerFactory.getLogger(DOMSignedInfo.class);
- private List references;
- private CanonicalizationMethod canonicalizationMethod;
- private SignatureMethod signatureMethod;
+ private final List references;
+ private final CanonicalizationMethod canonicalizationMethod;
+ private final SignatureMethod signatureMethod;
private String id;
private Document ownerDoc;
private Element localSiElem;
@@ -86,17 +96,13 @@ public DOMSignedInfo(CanonicalizationMethod cm, SignatureMethod sm,
}
this.canonicalizationMethod = cm;
this.signatureMethod = sm;
- this.references = Collections.unmodifiableList(
- new ArrayList<>(references));
+ this.references = Collections.unmodifiableList(new ArrayList<>(references));
if (this.references.isEmpty()) {
- throw new IllegalArgumentException("list of references must " +
- "contain at least one entry");
+ throw new IllegalArgumentException("list of references must contain at least one entry");
}
- for (int i = 0, size = this.references.size(); i < size; i++) {
- Object obj = this.references.get(i);
+ for (Object obj : this.references) {
if (!(obj instanceof Reference)) {
- throw new ClassCastException("list of references contains " +
- "an illegal type");
+ throw new ClassCastException("list of references contains an illegal " + obj.getClass());
}
}
}
@@ -210,22 +216,27 @@ public DOMSignedInfo(Element siElem, XMLCryptoContext context, Provider provider
references = Collections.unmodifiableList(refList);
}
+ @Override
public CanonicalizationMethod getCanonicalizationMethod() {
return canonicalizationMethod;
}
+ @Override
public SignatureMethod getSignatureMethod() {
return signatureMethod;
}
+ @Override
public String getId() {
return id;
}
+ @Override
public List getReferences() {
return references;
}
+ @Override
public InputStream getCanonicalizedData() {
return canonData;
}
@@ -249,8 +260,8 @@ public void canonicalize(XMLCryptoContext context, ByteArrayOutputStream bos)
if (LOG.isDebugEnabled()) {
LOG.debug("Canonicalized SignedInfo:");
StringBuilder sb = new StringBuilder(signedInfoBytes.length);
- for (int i = 0; i < signedInfoBytes.length; i++) {
- sb.append((char)signedInfoBytes[i]);
+ for (byte signedInfoByte : signedInfoBytes) {
+ sb.append((char) signedInfoByte);
}
LOG.debug(sb.toString());
LOG.debug("Data to be signed/verified:" + XMLUtils.encodeToString(signedInfoBytes));
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMStructure.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMStructure.java
index e7ddd0050dfc0..77818ea27c27b 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMStructure.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMStructure.java
@@ -25,12 +25,13 @@
*/
package org.jcp.xml.dsig.internal.dom;
+import java.util.List;
+
import javax.xml.crypto.MarshalException;
import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dom.DOMCryptoContext;
-import org.w3c.dom.Node;
-import java.util.List;
+import org.w3c.dom.Node;
/**
* DOM-based abstract implementation of XMLStructure.
@@ -38,6 +39,7 @@
*/
public abstract class DOMStructure implements XMLStructure {
+ @Override
public final boolean isFeatureSupported(String feature) {
if (feature == null) {
throw new NullPointerException();
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java
index 404942e72bf4b..dab41a917e05f 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java
@@ -25,12 +25,14 @@
*/
package org.jcp.xml.dsig.internal.dom;
-import javax.xml.crypto.NodeSetData;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException;
+
+import javax.xml.crypto.NodeSetData;
+
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -79,6 +81,7 @@ static class DelayedNodeIterator implements Iterator {
this.withComments = !excludeComments;
}
+ @Override
public boolean hasNext() {
if (nodeSet == null) {
nodeSet = dereferenceSameDocumentURI(root);
@@ -87,6 +90,7 @@ public boolean hasNext() {
return li.hasNext();
}
+ @Override
public Node next() {
if (nodeSet == null) {
nodeSet = dereferenceSameDocumentURI(root);
@@ -99,6 +103,7 @@ public Node next() {
}
}
+ @Override
public void remove() {
throw new UnsupportedOperationException();
}
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java
index fd6a89229c49d..0e6fce6e60129 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java
@@ -98,10 +98,12 @@ public DOMTransform(Element transElem, XMLCryptoContext context,
}
}
+ @Override
public final AlgorithmParameterSpec getParameterSpec() {
return spi.getParameterSpec();
}
+ @Override
public final String getAlgorithm() {
return spi.getAlgorithm();
}
@@ -145,6 +147,7 @@ public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
* @throws XMLSignatureException if an unexpected error occurs while
* executing the transform
*/
+ @Override
public Data transform(Data data, XMLCryptoContext xc)
throws TransformException
{
@@ -164,6 +167,7 @@ public Data transform(Data data, XMLCryptoContext xc)
* @throws XMLSignatureException if an unexpected error occurs while
* executing the transform
*/
+ @Override
public Data transform(Data data, XMLCryptoContext xc, OutputStream os)
throws TransformException
{
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java
index e72642bbff355..212ffc9676ddd 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java
@@ -25,18 +25,23 @@
*/
package org.jcp.xml.dsig.internal.dom;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
+import javax.xml.crypto.Data;
+import javax.xml.crypto.URIDereferencer;
+import javax.xml.crypto.URIReference;
+import javax.xml.crypto.URIReferenceException;
+import javax.xml.crypto.XMLCryptoContext;
+import javax.xml.crypto.dom.DOMCryptoContext;
+import javax.xml.crypto.dom.DOMURIReference;
import com.sun.org.apache.xml.internal.security.Init;
+import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolver;
import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverContext;
-import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
-import javax.xml.crypto.*;
-import javax.xml.crypto.dom.*;
import java.net.URI;
/**
@@ -53,6 +58,7 @@ private DOMURIDereferencer() {
Init.init();
}
+ @Override
public Data dereference(URIReference uriRef, XMLCryptoContext context)
throws URIReferenceException {
diff --git a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java
index bf8de888bb5b3..2da7628d266b5 100644
--- a/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java
+++ b/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java
@@ -46,12 +46,11 @@
import javax.xml.crypto.dsig.keyinfo.X509Data;
import javax.xml.crypto.dsig.keyinfo.X509IssuerSerial;
+import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
-
/**
* DOM-based implementation of X509Data.
*
@@ -134,6 +133,7 @@ public DOMX509Data(Element xdElem) throws MarshalException {
this.content = Collections.unmodifiableList(newContent);
}
+ @Override
public List
+correctly, the system property
+jdk.test.lib.artifacts.<NAME> is required on Ubuntu
+18.04 to specify the alternative NSS lib directory. The
+<NAME> component should be replaced with the name
+element of the appropriate @Artifact class. (See
+test/jdk/sun/security/pkcs11/PKCS11Test.java)
For example:
$ make test TEST="jtreg:sun/security/pkcs11/Secmod/AddTrustedCert.java" \
- JTREG="JAVA_OPTIONS=-Dtest.nss.lib.paths=/path/to/your/latest/NSS-libs"
+ * The JDK has a built-in catalog that hosts the following DTDs defined by the Java Platform:
+ *
+ *
DTD for {@link java.util.prefs.Preferences java.util.prefs.Preferences}, preferences.dtd
+ *
DTD for {@link java.util.Properties java.util.Properties}, properties.dtd
+ *
+ *
+ * The catalog is loaded once when the first JAXP processor factory is created.
+ *
+ *
External Resource Resolution Process with the built-in Catalog
+ * The JDK creates a {@link javax.xml.catalog.CatalogResolver CatalogResolver}
+ * with the built-in catalog when needed. This CatalogResolver is used as the
+ * default external resource resolver.
+ *
+ * XML processors may use resolvers (such as {@link org.xml.sax.EntityResolver EntityResolver},
+ * {@link javax.xml.stream.XMLResolver XMLResolver}, and {@link javax.xml.catalog.CatalogResolver CatalogResolver})
+ * to handle external references. In the absence of the user-defined resolvers,
+ * the JDK XML processors fall back to the default CatalogResolver to attempt to
+ * find a resolution before making a connection to fetch the resources. The fall-back
+ * also takes place if a user-defined resolver exists but allows the process to
+ * continue when unable to resolve the resource.
+ *
+ * If the default CatalogResolver is unable to locate a resource, it may signal
+ * the XML processors to continue processing, or skip the resource, or
+ * throw a CatalogException. The behavior is configured with the
+ * {@code jdk.xml.jdkcatalog.resolve} property.
+ *
*
Implementation Specific Properties
* In addition to the standard JAXP Properties,
* the JDK implementation supports a number of implementation specific properties
@@ -752,7 +784,7 @@
*
Instructs the JDK default CatalogResolver to act in accordance with the setting
+ * of this property when unable to resolve an external reference with the built-in Catalog.
+ * The options are:
+ *
+ *
+ * {@code continue} -- Indicates that the processing should continue
+ *
+ *
+ * {@code ignore} -- Indicates that the reference is skipped
+ *
+ *
+ * {@code strict} -- Indicates that the resolver should throw a CatalogException
+ *
+ *
+ *
+ *
String
+ *
+ * {@code continue, ignore, and strict}. Values are case-insensitive.
+ *
{@code @see MyClass.MY_CONSTANT a constant} returns {@code false}
+ *
+ *
+ * The result will be {@code true} (meaning, displayed in plain font) if
+ * any of the following are true about the label:
+ *
+ *
+ *
There is more than a single item in the list of nodes,
+ * suggesting there may be formatting nodes.
+ *
There is whitespace outside any parentheses,
+ * suggesting the label is a phrase
+ *
There are nested parentheses, or content after the parentheses,
+ * which cannot occur in a standalone signature
+ *
The simple name inferred from the reference does not match
+ * any simple name inferred from the label
+ *
+ *
+ * @param refSignature the signature of the target of the reference
+ * @param label the label
+ */
+ private boolean isPlain(String refSignature, List extends DocTree> label) {
+ if (label.isEmpty()) {
+ return false;
+ } else if (label.size() > 1) {
+ return true;
+ }
+
+ var l0 = label.get(0);
+ String s;
+ if (l0 instanceof TextTree t) {
+ s = t.getBody().trim();
+ } else {
+ return true;
+ }
+
+ // look for whitespace outside any parens, nested parens, or characters after parens:
+ // all of which will not be found in a simple signature
+ var inParens = false;
+ var ids = new ArrayList();
+ var sb = new StringBuilder();
+ for (var i = 0; i < s.length(); i++) {
+ var ch = s.charAt(i);
+ if (!sb.isEmpty() && !Character.isJavaIdentifierPart(ch)) {
+ ids.add(sb.toString());
+ sb.setLength(0);
+ }
+ switch (ch) {
+ case '(' -> {
+ if (inParens) {
+ return true;
+ } else {
+ inParens = true;
+ }
+ }
+ case ')' -> {
+ if (inParens && i < s.length() - 1) {
+ return true;
+ } else {
+ inParens = false;
+ }
+ }
+ default -> {
+ if (!inParens) {
+ if (Character.isJavaIdentifierStart(ch)
+ || (!sb.isEmpty() && Character.isJavaIdentifierPart(ch))) {
+ sb.append(ch);
+ } else if (Character.isWhitespace(ch)) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ if (!sb.isEmpty()) {
+ ids.add(sb.toString());
+ }
+
+ if (ids.isEmpty()) {
+ return true;
+ }
+
+ // final check: does the simple name inferred from the label
+ // match the simple name inferred from the reference
+ var labelSimpleName = ids.get(ids.size() - 1);
+ var refSimpleName = getSimpleName(refSignature);
+ return !labelSimpleName.equals((refSimpleName));
+ }
+
+ /**
+ * {@return the simple name from a signature}
+ *
+ * If there is a member part in the signature, the simple name is the
+ * identifier after the {@code #} character.
+ * Otherwise, the simple name is the last identifier in the signature.
+ *
+ * @param sig the signature
+ */
+ private String getSimpleName(String sig) {
+ int hash = sig.indexOf('#');
+ if (hash == -1 ) {
+ int lastDot = sig.lastIndexOf(".");
+ return lastDot == -1 ? sig : sig.substring(lastDot + 1);
+ } else {
+ int parens = sig.indexOf("(", hash);
+ return parens == -1 ? sig.substring(hash + 1) : sig.substring(hash + 1, parens);
+ }
}
}
diff --git a/test/langtools/jdk/javadoc/doclet/testGenericTypeLink/TestGenericTypeLink.java b/test/langtools/jdk/javadoc/doclet/testGenericTypeLink/TestGenericTypeLink.java
index c0b45b3491453..d8bf1fc2bdfcf 100644
--- a/test/langtools/jdk/javadoc/doclet/testGenericTypeLink/TestGenericTypeLink.java
+++ b/test/langtools/jdk/javadoc/doclet/testGenericTypeLink/TestGenericTypeLink.java
@@ -112,8 +112,8 @@ interface in java.util" class="external-link">link to generic type with labelString,A.SomeException>
+ s or interface in java.util" class="external-link">Link to generic type with label<\
+ /a>
"""
diff --git a/test/langtools/jdk/javadoc/doclet/testSeeLinkAnchor/TestSeeLinkAnchor.java b/test/langtools/jdk/javadoc/doclet/testSeeLinkAnchor/TestSeeLinkAnchor.java
index 4fc515f9427dc..626e487040107 100644
--- a/test/langtools/jdk/javadoc/doclet/testSeeLinkAnchor/TestSeeLinkAnchor.java
+++ b/test/langtools/jdk/javadoc/doclet/testSeeLinkAnchor/TestSeeLinkAnchor.java
@@ -79,8 +79,8 @@ public void testPackage(Path base) throws Exception {
"""
Plain link to sub heading above""",
"""
-
""",
"",
diff --git a/test/langtools/jdk/javadoc/doclet/testSeeTag/TestSeeTagFont.java b/test/langtools/jdk/javadoc/doclet/testSeeTag/TestSeeTagFont.java
new file mode 100644
index 0000000000000..3892ec6d999e4
--- /dev/null
+++ b/test/langtools/jdk/javadoc/doclet/testSeeTag/TestSeeTagFont.java
@@ -0,0 +1,145 @@
+/*
+ * 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 8320207
+ * @summary doclet incorrectly chooses code font for a See Also link
+ * @library /tools/lib ../../lib
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
+ * @build toolbox.ToolBox javadoc.tester.*
+ * @run main TestSeeTagFont
+ */
+
+import java.nio.file.Path;
+
+import javadoc.tester.JavadocTester;
+import toolbox.ToolBox;
+
+public class TestSeeTagFont extends JavadocTester {
+ public static void main(String... args) throws Exception {
+ var tester = new TestSeeTagFont();
+ tester.runTests();
+ }
+
+ private final ToolBox tb = new ToolBox();
+
+ @Test
+ public void testPlain(Path base) throws Exception {
+ Path src = base.resolve("src");
+ tb.writeJavaFiles(src,
+ """
+ package p;
+ import p2.Other;
+ /**
+ * Description.
+ * @see Other multi-word phrase
+ * @see Other Other
+ * @see Other Other() with trailing text
+ * @see Other simpleNameMismatch
+ *
+ * @see Other#Other() multi-word phrase
+ * @see Other#Other() Other#Other() with trailing text
+ * @see Other#Other() simpleNameMismatch
+ *
+ * @see Other#m() Other.m with formatting and trailing text
+ */
+ public class C { }
+ """,
+ """
+ package p2;
+ /** Lorem ipsum. */
+ public class Other {
+ /** Lorem ipsum. */
+ public void m() { }
+ }
+ """);
+
+ javadoc("-d", base.resolve("api").toString(),
+ "-Xdoclint:none",
+ "-sourcepath", src.toString(),
+ "p", "p2");
+ checkExit(Exit.OK);
+
+ // none of the following should contain ...
+ checkOutput("p/C.html", true,
+ """
+
+ """);
+ }
+}
From 30462f9da40d3a7ec18fcf46e2154fabb5fd4753 Mon Sep 17 00:00:00 2001
From: Aleksey Shipilev
Date: Wed, 22 Nov 2023 17:55:17 +0000
Subject: [PATCH 031/250] 8318986: Improve GenericWaitBarrier performance
Reviewed-by: rehn, iwalulya, pchilanomate
---
.../share/utilities/waitBarrier_generic.cpp | 261 ++++++++++++++----
.../share/utilities/waitBarrier_generic.hpp | 74 ++++-
2 files changed, 274 insertions(+), 61 deletions(-)
diff --git a/src/hotspot/share/utilities/waitBarrier_generic.cpp b/src/hotspot/share/utilities/waitBarrier_generic.cpp
index b5d9ff67eb782..dbf4db336c2f5 100644
--- a/src/hotspot/share/utilities/waitBarrier_generic.cpp
+++ b/src/hotspot/share/utilities/waitBarrier_generic.cpp
@@ -1,5 +1,6 @@
/*
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright Amazon.com Inc. 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,66 +30,228 @@
#include "utilities/waitBarrier_generic.hpp"
#include "utilities/spinYield.hpp"
+// Implements the striped semaphore wait barrier.
+//
+// To guarantee progress and safety, we need to make sure that new barrier tag
+// starts with the completely empty set of waiters and free semaphore. This
+// requires either waiting for all threads to leave wait() for current barrier
+// tag on disarm(), or waiting for all threads to leave the previous tag before
+// reusing the semaphore in arm().
+//
+// When there are multiple threads, it is normal for some threads to take
+// significant time to leave the barrier. Waiting for these threads introduces
+// stalls on barrier reuse.
+//
+// If we wait on disarm(), this stall is nearly guaranteed to happen if some threads
+// are de-scheduled by prior wait(). It would be especially bad if there are more
+// waiting threads than CPUs: every thread would need to wake up and register itself
+// as leaving, before we can unblock from disarm().
+//
+// If we wait on arm(), we can get lucky that most threads would be able to catch up,
+// exit wait(), and so we arrive to arm() with semaphore ready for reuse. However,
+// that is still insufficient in practice.
+//
+// Therefore, this implementation goes a step further and implements the _striped_
+// semaphores. We maintain several semaphores in cells. The barrier tags are assigned
+// to cells in some simple manner. Most of the current uses have sequential barrier
+// tags, so simple modulo works well. We then operate on a cell like we would operate
+// on a single semaphore: we wait at arm() for all threads to catch up before reusing
+// the cell. For the cost of maintaining just a few cells, we have enough window for
+// threads to catch up.
+//
+// The correctness is guaranteed by using a single atomic state variable per cell,
+// with updates always done with CASes:
+//
+// [.......... barrier tag ..........][.......... waiters ..........]
+// 63 31 0
+//
+// Cell starts with zero tag and zero waiters. Arming the cell swings barrier tag from
+// zero to some tag, while checking that no waiters have appeared. Disarming swings
+// the barrier tag back from tag to zero. Every waiter registers itself by incrementing
+// the "waiters", while checking that barrier tag is still the same. Every completing waiter
+// decrements the "waiters". When all waiters complete, a cell ends up in initial state,
+// ready to be armed again. This allows accurate tracking of how many signals
+// to issue and does not race with disarm.
+//
+// The implementation uses the strongest (default) barriers for extra safety, even
+// when not strictly required to do so for correctness. Extra barrier overhead is
+// dominated by the actual wait/notify latency anyway.
+//
+
void GenericWaitBarrier::arm(int barrier_tag) {
- assert(_barrier_tag == 0, "Already armed");
- assert(_waiters == 0, "We left a thread hanging");
- _barrier_tag = barrier_tag;
- _waiters = 0;
+ assert(barrier_tag != 0, "Pre arm: Should be arming with armed value");
+ assert(Atomic::load(&_barrier_tag) == 0,
+ "Pre arm: Should not be already armed. Tag: %d",
+ Atomic::load(&_barrier_tag));
+ Atomic::release_store(&_barrier_tag, barrier_tag);
+
+ Cell &cell = tag_to_cell(barrier_tag);
+ cell.arm(barrier_tag);
+
+ // API specifies arm() must provide a trailing fence.
OrderAccess::fence();
}
-int GenericWaitBarrier::wake_if_needed() {
- assert(_barrier_tag == 0, "Not disarmed");
- int w = _waiters;
- if (w == 0) {
- // Load of _barrier_threads in caller must not pass the load of _waiters.
- OrderAccess::loadload();
- return 0;
- }
- assert(w > 0, "Bad counting");
- // We need an exact count which never goes below zero,
- // otherwise the semaphore may be signalled too many times.
- if (Atomic::cmpxchg(&_waiters, w, w - 1) == w) {
- _sem_barrier.signal();
- return w - 1;
- }
- return w;
+void GenericWaitBarrier::disarm() {
+ int barrier_tag = Atomic::load_acquire(&_barrier_tag);
+ assert(barrier_tag != 0, "Pre disarm: Should be armed. Tag: %d", barrier_tag);
+ Atomic::release_store(&_barrier_tag, 0);
+
+ Cell &cell = tag_to_cell(barrier_tag);
+ cell.disarm(barrier_tag);
+
+ // API specifies disarm() must provide a trailing fence.
+ OrderAccess::fence();
}
-void GenericWaitBarrier::disarm() {
- assert(_barrier_tag != 0, "Not armed");
- _barrier_tag = 0;
- // Loads of _barrier_threads/_waiters must not float above disarm store and
- // disarm store must not sink below.
+void GenericWaitBarrier::wait(int barrier_tag) {
+ assert(barrier_tag != 0, "Pre wait: Should be waiting on armed value");
+
+ Cell &cell = tag_to_cell(barrier_tag);
+ cell.wait(barrier_tag);
+
+ // API specifies wait() must provide a trailing fence.
OrderAccess::fence();
- int left;
+}
+
+void GenericWaitBarrier::Cell::arm(int32_t requested_tag) {
+ // Before we continue to arm, we need to make sure that all threads
+ // have left the previous cell.
+
+ int64_t state;
+
SpinYield sp;
- do {
- left = GenericWaitBarrier::wake_if_needed();
- if (left == 0 && _barrier_threads > 0) {
- // There is no thread to wake but we still have barrier threads.
+ while (true) {
+ state = Atomic::load_acquire(&_state);
+ assert(decode_tag(state) == 0,
+ "Pre arm: Should not be armed. "
+ "Tag: " INT32_FORMAT "; Waiters: " INT32_FORMAT,
+ decode_tag(state), decode_waiters(state));
+ if (decode_waiters(state) == 0) {
+ break;
+ }
+ sp.wait();
+ }
+
+ // Try to swing cell to armed. This should always succeed after the check above.
+ int64_t new_state = encode(requested_tag, 0);
+ int64_t prev_state = Atomic::cmpxchg(&_state, state, new_state);
+ if (prev_state != state) {
+ fatal("Cannot arm the wait barrier. "
+ "Tag: " INT32_FORMAT "; Waiters: " INT32_FORMAT,
+ decode_tag(prev_state), decode_waiters(prev_state));
+ }
+}
+
+int GenericWaitBarrier::Cell::signal_if_needed(int max) {
+ int signals = 0;
+ while (true) {
+ int cur = Atomic::load_acquire(&_outstanding_wakeups);
+ if (cur == 0) {
+ // All done, no more waiters.
+ return 0;
+ }
+ assert(cur > 0, "Sanity");
+
+ int prev = Atomic::cmpxchg(&_outstanding_wakeups, cur, cur - 1);
+ if (prev != cur) {
+ // Contention, return to caller for early return or backoff.
+ return prev;
+ }
+
+ // Signal!
+ _sem.signal();
+
+ if (++signals >= max) {
+ // Signalled requested number of times, break out.
+ return prev;
+ }
+ }
+}
+
+void GenericWaitBarrier::Cell::disarm(int32_t expected_tag) {
+ int32_t waiters;
+
+ while (true) {
+ int64_t state = Atomic::load_acquire(&_state);
+ int32_t tag = decode_tag(state);
+ waiters = decode_waiters(state);
+
+ assert((tag == expected_tag) && (waiters >= 0),
+ "Mid disarm: Should be armed with expected tag and have sane waiters. "
+ "Tag: " INT32_FORMAT "; Waiters: " INT32_FORMAT,
+ tag, waiters);
+
+ int64_t new_state = encode(0, waiters);
+ if (Atomic::cmpxchg(&_state, state, new_state) == state) {
+ // Successfully disarmed.
+ break;
+ }
+ }
+
+ // Wake up waiters, if we have at least one.
+ // Allow other threads to assist with wakeups, if possible.
+ if (waiters > 0) {
+ Atomic::release_store(&_outstanding_wakeups, waiters);
+ SpinYield sp;
+ while (signal_if_needed(INT_MAX) > 0) {
sp.wait();
}
- // We must loop here until there are no waiters or potential waiters.
- } while (left > 0 || _barrier_threads > 0);
- // API specifies disarm() must provide a trailing fence.
- OrderAccess::fence();
+ }
+ assert(Atomic::load(&_outstanding_wakeups) == 0, "Post disarm: Should not have outstanding wakeups");
}
-void GenericWaitBarrier::wait(int barrier_tag) {
- assert(barrier_tag != 0, "Trying to wait on disarmed value");
- if (barrier_tag != _barrier_tag) {
- // API specifies wait() must provide a trailing fence.
- OrderAccess::fence();
- return;
+void GenericWaitBarrier::Cell::wait(int32_t expected_tag) {
+ // Try to register ourselves as pending waiter.
+ while (true) {
+ int64_t state = Atomic::load_acquire(&_state);
+ int32_t tag = decode_tag(state);
+ if (tag != expected_tag) {
+ // Cell tag had changed while waiting here. This means either the cell had
+ // been disarmed, or we are late and the cell was armed with a new tag.
+ // Exit without touching anything else.
+ return;
+ }
+ int32_t waiters = decode_waiters(state);
+
+ assert((tag == expected_tag) && (waiters >= 0 && waiters < INT32_MAX),
+ "Before wait: Should be armed with expected tag and waiters are in range. "
+ "Tag: " INT32_FORMAT "; Waiters: " INT32_FORMAT,
+ tag, waiters);
+
+ int64_t new_state = encode(tag, waiters + 1);
+ if (Atomic::cmpxchg(&_state, state, new_state) == state) {
+ // Success! Proceed to wait.
+ break;
+ }
}
- Atomic::add(&_barrier_threads, 1);
- if (barrier_tag != 0 && barrier_tag == _barrier_tag) {
- Atomic::add(&_waiters, 1);
- _sem_barrier.wait();
- // We help out with posting, but we need to do so before we decrement the
- // _barrier_threads otherwise we might wake threads up in next wait.
- GenericWaitBarrier::wake_if_needed();
+
+ // Wait for notification.
+ _sem.wait();
+
+ // Unblocked! We help out with waking up two siblings. This allows to avalanche
+ // the wakeups for many threads, even if some threads are lagging behind.
+ // Note that we can only do this *before* reporting back as completed waiter,
+ // otherwise we might prematurely wake up threads for another barrier tag.
+ // Current arm() sequence protects us from this trouble by waiting until all waiters
+ // leave.
+ signal_if_needed(2);
+
+ // Register ourselves as completed waiter before leaving.
+ while (true) {
+ int64_t state = Atomic::load_acquire(&_state);
+ int32_t tag = decode_tag(state);
+ int32_t waiters = decode_waiters(state);
+
+ assert((tag == 0) && (waiters > 0),
+ "After wait: Should be not armed and have non-complete waiters. "
+ "Tag: " INT32_FORMAT "; Waiters: " INT32_FORMAT,
+ tag, waiters);
+
+ int64_t new_state = encode(tag, waiters - 1);
+ if (Atomic::cmpxchg(&_state, state, new_state) == state) {
+ // Success!
+ break;
+ }
}
- Atomic::add(&_barrier_threads, -1);
}
diff --git a/src/hotspot/share/utilities/waitBarrier_generic.hpp b/src/hotspot/share/utilities/waitBarrier_generic.hpp
index 50bfea6aebfb7..d3a45b33b82ef 100644
--- a/src/hotspot/share/utilities/waitBarrier_generic.hpp
+++ b/src/hotspot/share/utilities/waitBarrier_generic.hpp
@@ -26,29 +26,79 @@
#define SHARE_UTILITIES_WAITBARRIER_GENERIC_HPP
#include "memory/allocation.hpp"
+#include "memory/padded.hpp"
#include "runtime/semaphore.hpp"
#include "utilities/globalDefinitions.hpp"
-// In addition to the barrier tag, it uses two counters to keep the semaphore
-// count correct and not leave any late thread waiting.
class GenericWaitBarrier : public CHeapObj {
+private:
+ class Cell : public CHeapObj {
+ private:
+ // Pad out the cells to avoid interference between the cells.
+ // This would insulate from stalls when adjacent cells have returning
+ // workers and contend over the cache line for current latency-critical
+ // cell.
+ DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, 0);
+
+ Semaphore _sem;
+
+ // Cell state, tracks the arming + waiters status
+ volatile int64_t _state;
+
+ // Wakeups to deliver for current waiters
+ volatile int _outstanding_wakeups;
+
+ int signal_if_needed(int max);
+
+ static int64_t encode(int32_t barrier_tag, int32_t waiters) {
+ int64_t val = (((int64_t) barrier_tag) << 32) |
+ (((int64_t) waiters) & 0xFFFFFFFF);
+ assert(decode_tag(val) == barrier_tag, "Encoding is reversible");
+ assert(decode_waiters(val) == waiters, "Encoding is reversible");
+ return val;
+ }
+
+ static int32_t decode_tag(int64_t value) {
+ return (int32_t)(value >> 32);
+ }
+
+ static int32_t decode_waiters(int64_t value) {
+ return (int32_t)(value & 0xFFFFFFFF);
+ }
+
+ public:
+ Cell() : _sem(0), _state(encode(0, 0)), _outstanding_wakeups(0) {}
+ NONCOPYABLE(Cell);
+
+ void arm(int32_t requested_tag);
+ void disarm(int32_t expected_tag);
+ void wait(int32_t expected_tag);
+ };
+
+ // Should be enough for most uses without exploding the footprint.
+ static constexpr int CELLS_COUNT = 16;
+
+ Cell _cells[CELLS_COUNT];
+
+ // Trailing padding to protect the last cell.
+ DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, 0);
+
volatile int _barrier_tag;
- // The number of threads waiting on or about to wait on the semaphore.
- volatile int _waiters;
- // The number of threads in the wait path, before or after the tag check.
- // These threads can become waiters.
- volatile int _barrier_threads;
- Semaphore _sem_barrier;
+
+ // Trailing padding to insulate the rest of the barrier from adjacent
+ // data structures. The leading padding is not needed, as cell padding
+ // handles this for us.
+ DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, 0);
NONCOPYABLE(GenericWaitBarrier);
- int wake_if_needed();
+ Cell& tag_to_cell(int tag) { return _cells[tag & (CELLS_COUNT - 1)]; }
- public:
- GenericWaitBarrier() : _barrier_tag(0), _waiters(0), _barrier_threads(0), _sem_barrier(0) {}
+public:
+ GenericWaitBarrier() : _cells(), _barrier_tag(0) {}
~GenericWaitBarrier() {}
- const char* description() { return "semaphore"; }
+ const char* description() { return "striped semaphore"; }
void arm(int barrier_tag);
void disarm();
From 572b14ac8697497d9c0aefe92864075e712c171e Mon Sep 17 00:00:00 2001
From: Chris Plummer
Date: Wed, 22 Nov 2023 17:59:42 +0000
Subject: [PATCH 032/250] 8320536: problemlist failing
serviceability/attach/ConcAttachTest.java test on macosx
Reviewed-by: amenkov, dholmes
---
test/hotspot/jtreg/ProblemList.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt
index 01a47f51898d9..e5395c0837241 100644
--- a/test/hotspot/jtreg/ProblemList.txt
+++ b/test/hotspot/jtreg/ProblemList.txt
@@ -134,7 +134,7 @@ serviceability/sa/ClhsdbPstack.java#core 8267433 macosx-x64
serviceability/sa/TestJmapCore.java 8267433 macosx-x64
serviceability/sa/TestJmapCoreMetaspace.java 8267433 macosx-x64
-serviceability/attach/ConcAttachTest.java 8290043 linux-all
+serviceability/attach/ConcAttachTest.java 8290043,8318866 linux-all,macosx-all
serviceability/jvmti/stress/StackTrace/NotSuspended/GetStackTraceNotSuspendedStressTest.java 8315980 linux-all,windows-x64
From aac43184319d852eb792c83dfb52d74a3126108d Mon Sep 17 00:00:00 2001
From: Oliver Lockwood
Date: Wed, 22 Nov 2023 18:25:44 +0000
Subject: [PATCH 033/250] 8320577: Improve MessageHeader's toString() function
to make HttpURLConnection's debug log readable
Reviewed-by: dfuchs, jpai
---
src/java.base/share/classes/sun/net/www/MessageHeader.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/java.base/share/classes/sun/net/www/MessageHeader.java b/src/java.base/share/classes/sun/net/www/MessageHeader.java
index 5542193b9a990..6c6d18453ca7c 100644
--- a/src/java.base/share/classes/sun/net/www/MessageHeader.java
+++ b/src/java.base/share/classes/sun/net/www/MessageHeader.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -554,7 +554,7 @@ public void mergeHeader(InputStream is) throws java.io.IOException {
}
public synchronized String toString() {
- String result = super.toString() + nkeys + " pairs: ";
+ String result = super.toString() + " " + nkeys + " pairs: ";
for (int i = 0; i < keys.length && i < nkeys; i++) {
result += "{"+keys[i]+": "+values[i]+"}";
}
From 6016536ab96e154f4eaff10ac19f590c812e5377 Mon Sep 17 00:00:00 2001
From: Erik Gahlin
Date: Wed, 22 Nov 2023 20:48:42 +0000
Subject: [PATCH 034/250] 8314745: JFR: @StackFilter
Reviewed-by: mgronlun
---
src/hotspot/share/jfr/jni/jfrJavaSupport.cpp | 27 ++
src/hotspot/share/jfr/jni/jfrJavaSupport.hpp | 1 +
src/hotspot/share/jfr/jni/jfrJniMethod.cpp | 14 +-
src/hotspot/share/jfr/jni/jfrJniMethod.hpp | 6 +-
.../jfr/jni/jfrJniMethodRegistration.cpp | 6 +-
.../recorder/stacktrace/jfrStackFilter.cpp | 61 ++++
.../recorder/stacktrace/jfrStackFilter.hpp | 45 +++
.../stacktrace/jfrStackFilterRegistry.cpp | 95 ++++++
.../stacktrace/jfrStackFilterRegistry.hpp | 43 +++
.../jfr/recorder/stacktrace/jfrStackTrace.cpp | 15 +-
.../jfr/recorder/stacktrace/jfrStackTrace.hpp | 4 +-
.../stacktrace/jfrStackTraceRepository.cpp | 11 +-
.../stacktrace/jfrStackTraceRepository.hpp | 4 +-
.../jdk/jfr/events/ProcessStartEvent.java | 1 +
.../SecurityPropertyModificationEvent.java | 1 +
.../events/SecurityProviderServiceEvent.java | 1 +
.../classes/jdk/jfr/events/StackFilter.java | 65 ++++
.../jdk/jfr/events/TLSHandshakeEvent.java | 1 +
.../jdk/jfr/events/ThreadSleepEvent.java | 5 +-
.../jdk/jfr/internal/EventControl.java | 78 +++++
.../share/classes/jdk/jfr/internal/JVM.java | 35 +-
.../jdk/jfr/internal/MetadataRepository.java | 7 +
.../jdk/jfr/internal/PlatformEventType.java | 13 +
.../classes/jdk/jfr/internal/TypeLibrary.java | 11 +-
.../jdk/jfr/internal/event/EventWriter.java | 2 +-
.../metadata/annotations/TestStackFilter.java | 319 ++++++++++++++++++
.../metadata/annotations/UnloadableClass.java | 64 ++++
.../jdk/jfr/event/os/TestProcessStart.java | 3 +-
.../event/runtime/TestThreadSleepEvent.java | 18 +-
...TestSecurityPropertyModificationEvent.java | 3 +-
.../TestSecurityProviderServiceEvent.java | 27 +-
.../event/security/TestTLSHandshakeEvent.java | 6 +-
test/jdk/jdk/jfr/jvm/TestGetStackTraceId.java | 4 +-
test/lib/jdk/test/lib/jfr/Events.java | 38 ++-
34 files changed, 982 insertions(+), 52 deletions(-)
create mode 100644 src/hotspot/share/jfr/recorder/stacktrace/jfrStackFilter.cpp
create mode 100644 src/hotspot/share/jfr/recorder/stacktrace/jfrStackFilter.hpp
create mode 100644 src/hotspot/share/jfr/recorder/stacktrace/jfrStackFilterRegistry.cpp
create mode 100644 src/hotspot/share/jfr/recorder/stacktrace/jfrStackFilterRegistry.hpp
create mode 100644 src/jdk.jfr/share/classes/jdk/jfr/events/StackFilter.java
create mode 100644 test/jdk/jdk/jfr/api/metadata/annotations/TestStackFilter.java
create mode 100644 test/jdk/jdk/jfr/api/metadata/annotations/UnloadableClass.java
diff --git a/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp b/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp
index 0f147f137dc40..866f8c1df1363 100644
--- a/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp
+++ b/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp
@@ -525,6 +525,33 @@ const char* JfrJavaSupport::c_str(jstring string, Thread* thread, bool c_heap /*
return string != nullptr ? c_str(resolve_non_null(string), thread, c_heap) : nullptr;
}
+static Symbol** allocate_symbol_array(bool c_heap, int length, Thread* thread) {
+ return c_heap ?
+ NEW_C_HEAP_ARRAY(Symbol*, length, mtTracing) :
+ NEW_RESOURCE_ARRAY_IN_THREAD(thread, Symbol*, length);
+}
+
+Symbol** JfrJavaSupport::symbol_array(jobjectArray string_array, JavaThread* thread, intptr_t* result_array_size, bool c_heap /* false */) {
+ DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(thread));
+ assert(string_array != nullptr, "invariant");
+ assert(result_array_size != nullptr, "invariant");
+ objArrayOop arrayOop = objArrayOop(resolve_non_null(string_array));
+ const int length = arrayOop->length();
+ *result_array_size = length;
+ Symbol** result_array = allocate_symbol_array(c_heap, length, thread);
+ assert(result_array != nullptr, "invariant");
+ for (int i = 0; i < length; i++) {
+ oop object = arrayOop->obj_at(i);
+ Symbol* symbol = nullptr;
+ if (object != nullptr) {
+ const char* text = c_str(arrayOop->obj_at(i), thread, c_heap);
+ symbol = SymbolTable::new_symbol(text);
+ }
+ result_array[i] = symbol;
+ }
+ return result_array;
+}
+
/*
* Exceptions and errors
*/
diff --git a/src/hotspot/share/jfr/jni/jfrJavaSupport.hpp b/src/hotspot/share/jfr/jni/jfrJavaSupport.hpp
index 05559573e4a0e..8b4ecf18dc148 100644
--- a/src/hotspot/share/jfr/jni/jfrJavaSupport.hpp
+++ b/src/hotspot/share/jfr/jni/jfrJavaSupport.hpp
@@ -86,6 +86,7 @@ class JfrJavaSupport : public AllStatic {
static Klass* klass(const jobject handle);
static const char* c_str(jstring string, Thread* thread, bool c_heap = false);
static const char* c_str(oop string, Thread* thread, bool c_heap = false);
+ static Symbol** symbol_array(jobjectArray string_array, JavaThread* thread, intptr_t* result_size, bool c_heap = false);
// exceptions
static void throw_illegal_state_exception(const char* message, TRAPS);
diff --git a/src/hotspot/share/jfr/jni/jfrJniMethod.cpp b/src/hotspot/share/jfr/jni/jfrJniMethod.cpp
index 4951e74dfd48c..82f26d7bdd062 100644
--- a/src/hotspot/share/jfr/jni/jfrJniMethod.cpp
+++ b/src/hotspot/share/jfr/jni/jfrJniMethod.cpp
@@ -36,6 +36,8 @@
#include "jfr/recorder/repository/jfrEmergencyDump.hpp"
#include "jfr/recorder/service/jfrEventThrottler.hpp"
#include "jfr/recorder/service/jfrOptionSet.hpp"
+#include "jfr/recorder/stacktrace/jfrStackFilter.hpp"
+#include "jfr/recorder/stacktrace/jfrStackFilterRegistry.hpp"
#include "jfr/recorder/stacktrace/jfrStackTraceRepository.hpp"
#include "jfr/recorder/stringpool/jfrStringPool.hpp"
#include "jfr/jni/jfrJavaSupport.hpp"
@@ -239,8 +241,8 @@ JVM_ENTRY_NO_ENV(jlong, jfr_class_id(JNIEnv* env, jclass jvm, jclass jc))
return JfrTraceId::load(jc);
JVM_END
-JVM_ENTRY_NO_ENV(jlong, jfr_stacktrace_id(JNIEnv* env, jclass jvm, jint skip))
- return JfrStackTraceRepository::record(thread, skip);
+JVM_ENTRY_NO_ENV(jlong, jfr_stacktrace_id(JNIEnv* env, jclass jvm, jint skip, jlong stack_filter_id))
+ return JfrStackTraceRepository::record(thread, skip, stack_filter_id);
JVM_END
JVM_ENTRY_NO_ENV(void, jfr_log(JNIEnv* env, jclass jvm, jint tag_set, jint level, jstring message))
@@ -397,3 +399,11 @@ JVM_END
JVM_ENTRY_NO_ENV(void, jfr_emit_data_loss(JNIEnv* env, jclass jvm, jlong bytes))
EventDataLoss::commit(bytes, min_jlong);
JVM_END
+
+JVM_ENTRY_NO_ENV(jlong, jfr_register_stack_filter(JNIEnv* env, jclass jvm, jobjectArray classes, jobjectArray methods))
+ return JfrStackFilterRegistry::add(classes, methods, thread);
+JVM_END
+
+JVM_ENTRY_NO_ENV(void, jfr_unregister_stack_filter(JNIEnv* env, jclass jvm, jlong id))
+ JfrStackFilterRegistry::remove(id);
+JVM_END
diff --git a/src/hotspot/share/jfr/jni/jfrJniMethod.hpp b/src/hotspot/share/jfr/jni/jfrJniMethod.hpp
index 28bafc4b73f21..b37841aeac297 100644
--- a/src/hotspot/share/jfr/jni/jfrJniMethod.hpp
+++ b/src/hotspot/share/jfr/jni/jfrJniMethod.hpp
@@ -57,7 +57,7 @@ jlong JNICALL jfr_class_id(JNIEnv* env, jclass jvm, jclass jc);
jstring JNICALL jfr_get_pid(JNIEnv* env, jclass jvm);
-jlong JNICALL jfr_stacktrace_id(JNIEnv* env, jclass jvm, jint skip);
+jlong JNICALL jfr_stacktrace_id(JNIEnv* env, jclass jvm, jint skip, jlong stack_filter_id);
jlong JNICALL jfr_elapsed_frequency(JNIEnv* env, jclass jvm);
@@ -159,6 +159,10 @@ jlong JNICALL jfr_host_total_memory(JNIEnv* env, jclass jvm);
void JNICALL jfr_emit_data_loss(JNIEnv* env, jclass jvm, jlong bytes);
+jlong JNICALL jfr_register_stack_filter(JNIEnv* env, jobject classes, jobject methods);
+
+jlong JNICALL jfr_unregister_stack_filter(JNIEnv* env, jlong start_filter_id);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp b/src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp
index 7c571abbd695f..f8475881ff8ad 100644
--- a/src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp
+++ b/src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp
@@ -46,7 +46,7 @@ JfrJniMethodRegistration::JfrJniMethodRegistration(JNIEnv* env) {
(char*)"getAllEventClasses", (char*)"()Ljava/util/List;", (void*)jfr_get_all_event_classes,
(char*)"getClassId", (char*)"(Ljava/lang/Class;)J", (void*)jfr_class_id,
(char*)"getPid", (char*)"()Ljava/lang/String;", (void*)jfr_get_pid,
- (char*)"getStackTraceId", (char*)"(I)J", (void*)jfr_stacktrace_id,
+ (char*)"getStackTraceId", (char*)"(IJ)J", (void*)jfr_stacktrace_id,
(char*)"getThreadId", (char*)"(Ljava/lang/Thread;)J", (void*)jfr_id_for_thread,
(char*)"getTicksFrequency", (char*)"()J", (void*)jfr_elapsed_frequency,
(char*)"subscribeLogLevel", (char*)"(Ljdk/jfr/internal/LogTag;I)V", (void*)jfr_subscribe_log_level,
@@ -97,7 +97,9 @@ JfrJniMethodRegistration::JfrJniMethodRegistration(JNIEnv* env) {
(char*)"isInstrumented", (char*)"(Ljava/lang/Class;)Z", (void*) jfr_is_class_instrumented,
(char*)"isContainerized", (char*)"()Z", (void*) jfr_is_containerized,
(char*)"hostTotalMemory", (char*)"()J", (void*) jfr_host_total_memory,
- (char*)"emitDataLoss", (char*)"(J)V", (void*)jfr_emit_data_loss
+ (char*)"emitDataLoss", (char*)"(J)V", (void*)jfr_emit_data_loss,
+ (char*)"registerStackFilter", (char*)"([Ljava/lang/String;[Ljava/lang/String;)J", (void*)jfr_register_stack_filter,
+ (char*)"unregisterStackFilter", (char*)"(J)V", (void*)jfr_unregister_stack_filter
};
const size_t method_array_length = sizeof(method) / sizeof(JNINativeMethod);
diff --git a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackFilter.cpp b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackFilter.cpp
new file mode 100644
index 0000000000000..bf10c531c637a
--- /dev/null
+++ b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackFilter.cpp
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "jfr/recorder/stacktrace/jfrStackFilter.hpp"
+#include "oops/method.hpp"
+#include "oops/symbol.hpp"
+
+JfrStackFilter::JfrStackFilter(Symbol** class_names, Symbol** method_names, size_t count)
+ : _count(count),
+ _class_names(class_names),
+ _method_names(method_names) {
+ assert(_class_names != nullptr, "invariant");
+ assert(_method_names != nullptr, "invariant");
+}
+
+bool JfrStackFilter::match(const Method* method) const {
+ assert(method != nullptr, "Invariant");
+ const Symbol* const method_name = method->name();
+ const Symbol* const klass_name = method->klass_name();
+ for (size_t i = 0; i < _count; i++) {
+ const Symbol* m = _method_names[i];
+ if (m == nullptr || m == method_name) {
+ const Symbol* c = _class_names[i];
+ if (c == nullptr || c == klass_name) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+JfrStackFilter::~JfrStackFilter() {
+ for (size_t i = 0; i < _count; i++) {
+ Symbol::maybe_decrement_refcount(_method_names[i]);
+ Symbol::maybe_decrement_refcount(_class_names[i]);
+ }
+ FREE_C_HEAP_ARRAY(Symbol*, _method_names);
+ FREE_C_HEAP_ARRAY(Symbol*, _class_names);
+}
diff --git a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackFilter.hpp b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackFilter.hpp
new file mode 100644
index 0000000000000..19c1821149ca3
--- /dev/null
+++ b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackFilter.hpp
@@ -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.
+ *
+ */
+
+#ifndef SHARE_JFR_RECORDER_STACKTRACE_JFRSTACKFILTER_HPP
+#define SHARE_JFR_RECORDER_STACKTRACE_JFRSTACKFILTER_HPP
+
+#include "jfr/utilities/jfrAllocation.hpp"
+
+class Mathod;
+class Symbol;
+
+class JfrStackFilter : public JfrCHeapObj {
+ private:
+ size_t _count;
+ Symbol** _class_names;
+ Symbol** _method_names;
+
+ public:
+ JfrStackFilter(Symbol** class_names, Symbol** method_names, size_t count);
+ ~JfrStackFilter();
+ bool match(const Method* method) const;
+};
+
+#endif // SHARE_JFR_RECORDER_STACKTRACE_JFRSTACKFILTER_HPP
diff --git a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackFilterRegistry.cpp b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackFilterRegistry.cpp
new file mode 100644
index 0000000000000..481dcbdc840c6
--- /dev/null
+++ b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackFilterRegistry.cpp
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ *
+ */
+
+
+#include "precompiled.hpp"
+#include "jfr/jni/jfrJavaSupport.hpp"
+#include "jfr/recorder/stacktrace/jfrStackFilter.hpp"
+#include "jfr/recorder/stacktrace/jfrStackFilterRegistry.hpp"
+#include "logging/log.hpp"
+
+static const intptr_t STACK_FILTER_ELEMENTS_SIZE = 4096;
+static const intptr_t STACK_FILTER_ERROR_CODE = -1;
+static const JfrStackFilter* _elements[STACK_FILTER_ELEMENTS_SIZE];
+static intptr_t _free_list[STACK_FILTER_ELEMENTS_SIZE];
+static intptr_t _index = 0;
+static intptr_t _free_list_index = 0;
+
+int64_t JfrStackFilterRegistry::add(jobjectArray classes, jobjectArray methods, JavaThread* jt) {
+ intptr_t c_size = 0;
+ Symbol** class_names = JfrJavaSupport::symbol_array(classes, jt, &c_size, true);
+ assert(class_names != nullptr, "invariant");
+ intptr_t m_size = 0;
+ Symbol** method_names = JfrJavaSupport::symbol_array(methods, jt, &m_size, true);
+ assert(method_names != nullptr, "invariant");
+ if (c_size != m_size) {
+ FREE_C_HEAP_ARRAY(Symbol*, class_names);
+ FREE_C_HEAP_ARRAY(Symbol*, method_names);
+ JfrJavaSupport::throw_internal_error("Method array size doesn't match class array size", jt);
+ return STACK_FILTER_ERROR_CODE;
+ }
+ assert(c_size >= 0, "invariant");
+ const JfrStackFilter* filter = new JfrStackFilter(class_names, method_names, static_cast(c_size));
+ return JfrStackFilterRegistry::add(filter);
+}
+
+#ifdef ASSERT
+static bool range_check(int64_t idx) {
+ return idx < STACK_FILTER_ELEMENTS_SIZE && idx >= 0;
+}
+#endif
+
+int64_t JfrStackFilterRegistry::add(const JfrStackFilter* filter) {
+ if (_free_list_index > 0) {
+ assert(range_check(_free_list_index), "invariant");
+ const intptr_t free_index = _free_list[_free_list_index - 1];
+ _elements[free_index] = filter;
+ _free_list_index--;
+ return free_index;
+ }
+ if (_index >= STACK_FILTER_ELEMENTS_SIZE - 1) {
+ log_warning(jfr)("Maximum number of @StackFrame in use has been reached.");
+ return STACK_FILTER_ERROR_CODE;
+ }
+ assert(range_check(_index), "invariant");
+ _elements[_index] = filter;
+ return _index++;
+}
+
+const JfrStackFilter* JfrStackFilterRegistry::lookup(int64_t id) {
+ if (id < 0) {
+ return nullptr;
+ }
+ assert(range_check(id), "invariant");
+ return _elements[id];
+}
+
+void JfrStackFilterRegistry::remove(int64_t index) {
+ assert(range_check(index), "invariant");
+ delete _elements[index];
+ if (_free_list_index < STACK_FILTER_ELEMENTS_SIZE - 1) {
+ assert(range_check(_free_list_index), "invariant");
+ _free_list[_free_list_index++] = index;
+ }
+}
diff --git a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackFilterRegistry.hpp b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackFilterRegistry.hpp
new file mode 100644
index 0000000000000..e35fb90938fe6
--- /dev/null
+++ b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackFilterRegistry.hpp
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ *
+ */
+
+#ifndef SHARE_JFR_RECORDER_STACKTRACE_JFRSTCKFILTERREGISTRY_HPP
+#define SHARE_JFR_RECORDER_STACKTRACE_JFRSTCKFILTERREGISTRY_HPP
+
+#include "jni.h"
+#include "jfr/utilities/jfrAllocation.hpp"
+
+class JavaThread;
+class JfrStackFilter;
+
+class JfrStackFilterRegistry : AllStatic {
+ private:
+ static int64_t add(const JfrStackFilter* frame);
+ public:
+ static int64_t add(jobjectArray classes, jobjectArray methods, JavaThread* jt);
+ static void remove(int64_t id);
+ static const JfrStackFilter* lookup(int64_t id);
+};
+
+#endif // SHARE_JFR_RECORDER_STACKTRACE_JFRSTCKFILTERREGISTRY_HPP
diff --git a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTrace.cpp b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTrace.cpp
index c70f626a2fe3a..55e1e2ac3747d 100644
--- a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTrace.cpp
+++ b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTrace.cpp
@@ -30,6 +30,8 @@
#include "jfr/recorder/storage/jfrBuffer.hpp"
#include "jfr/support/jfrMethodLookup.hpp"
#include "jfr/support/jfrThreadLocal.hpp"
+#include "jfrStackFilter.hpp"
+#include "jfrStackFilterRegistry.hpp"
#include "memory/allocation.inline.hpp"
#include "oops/instanceKlass.inline.hpp"
#include "runtime/continuation.hpp"
@@ -284,7 +286,7 @@ bool JfrStackTrace::record_async(JavaThread* jt, const frame& frame) {
return count > 0;
}
-bool JfrStackTrace::record(JavaThread* jt, const frame& frame, int skip) {
+bool JfrStackTrace::record(JavaThread* jt, const frame& frame, int skip, int64_t stack_filter_id) {
assert(jt != nullptr, "invariant");
assert(jt == Thread::current(), "invariant");
assert(jt->thread_state() != _thread_in_native, "invariant");
@@ -302,6 +304,7 @@ bool JfrStackTrace::record(JavaThread* jt, const frame& frame, int skip) {
}
vfs.next_vframe();
}
+ const JfrStackFilter* stack_filter = JfrStackFilterRegistry::lookup(stack_filter_id);
_hash = 1;
while (!vfs.at_end()) {
if (count >= _max_frames) {
@@ -309,6 +312,12 @@ bool JfrStackTrace::record(JavaThread* jt, const frame& frame, int skip) {
break;
}
const Method* method = vfs.method();
+ if (stack_filter != nullptr) {
+ if (stack_filter->match(method)) {
+ vfs.next_vframe();
+ continue;
+ }
+ }
const traceid mid = JfrTraceId::load(method);
u1 type = vfs.is_interpreted_frame() ? JfrStackFrame::FRAME_INTERPRETER : JfrStackFrame::FRAME_JIT;
int bci = 0;
@@ -335,13 +344,13 @@ bool JfrStackTrace::record(JavaThread* jt, const frame& frame, int skip) {
return count > 0;
}
-bool JfrStackTrace::record(JavaThread* current_thread, int skip) {
+bool JfrStackTrace::record(JavaThread* current_thread, int skip, int64_t stack_filter_id) {
assert(current_thread != nullptr, "invariant");
assert(current_thread == Thread::current(), "invariant");
if (!current_thread->has_last_Java_frame()) {
return false;
}
- return record(current_thread, current_thread->last_frame(), skip);
+ return record(current_thread, current_thread->last_frame(), skip, stack_filter_id);
}
void JfrStackFrame::resolve_lineno() const {
diff --git a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTrace.hpp b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTrace.hpp
index acd9d41fbf71c..8b2ca022443fe 100644
--- a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTrace.hpp
+++ b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTrace.hpp
@@ -93,8 +93,8 @@ class JfrStackTrace : public JfrCHeapObj {
void set_reached_root(bool reached_root) { _reached_root = reached_root; }
void resolve_linenos() const;
- bool record(JavaThread* current_thread, int skip);
- bool record(JavaThread* current_thread, const frame& frame, int skip);
+ bool record(JavaThread* current_thread, int skip, int64_t stack_frame_id);
+ bool record(JavaThread* current_thread, const frame& frame, int skip, int64_t stack_frame_id);
bool record_async(JavaThread* other_thread, const frame& frame);
bool have_lineno() const { return _lineno; }
diff --git a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp
index 26056141a72ed..1c207f5bb2b47 100644
--- a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp
+++ b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp
@@ -146,7 +146,7 @@ size_t JfrStackTraceRepository::clear(JfrStackTraceRepository& repo) {
return processed;
}
-traceid JfrStackTraceRepository::record(Thread* current_thread, int skip /* 0 */) {
+traceid JfrStackTraceRepository::record(Thread* current_thread, int skip /* 0 */, int64_t stack_filter_id /* -1 */) {
assert(current_thread == Thread::current(), "invariant");
JfrThreadLocal* const tl = current_thread->jfr_thread_local();
assert(tl != nullptr, "invariant");
@@ -163,13 +163,14 @@ traceid JfrStackTraceRepository::record(Thread* current_thread, int skip /* 0 */
}
assert(frames != nullptr, "invariant");
assert(tl->stackframes() == frames, "invariant");
- return instance().record(JavaThread::cast(current_thread), skip, frames, tl->stackdepth());
+ return instance().record(JavaThread::cast(current_thread), skip, stack_filter_id, frames, tl->stackdepth());
}
-traceid JfrStackTraceRepository::record(JavaThread* current_thread, int skip, JfrStackFrame *frames, u4 max_frames) {
+traceid JfrStackTraceRepository::record(JavaThread* current_thread, int skip, int64_t stack_filter_id, JfrStackFrame *frames, u4 max_frames) {
JfrStackTrace stacktrace(frames, max_frames);
- return stacktrace.record(current_thread, skip) ? add(instance(), stacktrace) : 0;
+ return stacktrace.record(current_thread, skip, stack_filter_id) ? add(instance(), stacktrace) : 0;
}
+
traceid JfrStackTraceRepository::add(JfrStackTraceRepository& repo, const JfrStackTrace& stacktrace) {
traceid tid = repo.add_trace(stacktrace);
if (tid == 0) {
@@ -191,7 +192,7 @@ void JfrStackTraceRepository::record_for_leak_profiler(JavaThread* current_threa
assert(tl != nullptr, "invariant");
assert(!tl->has_cached_stack_trace(), "invariant");
JfrStackTrace stacktrace(tl->stackframes(), tl->stackdepth());
- stacktrace.record(current_thread, skip);
+ stacktrace.record(current_thread, skip, -1);
const traceid hash = stacktrace.hash();
if (hash != 0) {
tl->set_cached_stack_trace_id(add(leak_profiler_instance(), stacktrace), hash);
diff --git a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.hpp b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.hpp
index d59dd5f57e0a8..abcf88450ffea 100644
--- a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.hpp
+++ b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.hpp
@@ -67,10 +67,10 @@ class JfrStackTraceRepository : public JfrCHeapObj {
traceid add_trace(const JfrStackTrace& stacktrace);
static traceid add(JfrStackTraceRepository& repo, const JfrStackTrace& stacktrace);
static traceid add(const JfrStackTrace& stacktrace);
- traceid record(JavaThread* current_thread, int skip, JfrStackFrame* frames, u4 max_frames);
+ traceid record(JavaThread* current_thread, int skip, int64_t stack_filter_id, JfrStackFrame* frames, u4 max_frames);
public:
- static traceid record(Thread* current_thread, int skip = 0);
+ static traceid record(Thread* current_thread, int skip = 0, int64_t stack_filter_id = -1);
};
#endif // SHARE_JFR_RECORDER_STACKTRACE_JFRSTACKTRACEREPOSITORY_HPP
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/events/ProcessStartEvent.java b/src/jdk.jfr/share/classes/jdk/jfr/events/ProcessStartEvent.java
index b936099aa743a..5ad2dc82fc1de 100644
--- a/src/jdk.jfr/share/classes/jdk/jfr/events/ProcessStartEvent.java
+++ b/src/jdk.jfr/share/classes/jdk/jfr/events/ProcessStartEvent.java
@@ -38,6 +38,7 @@
@Description("Operating system process started")
@MirrorEvent(className = "jdk.internal.event.ProcessStartEvent")
@RemoveFields("duration")
+@StackFilter({"java.lang.ProcessBuilder", "java.lang.Runtime::exec"})
public final class ProcessStartEvent extends AbstractJDKEvent {
@Label("Process Id")
public long pid;
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/events/SecurityPropertyModificationEvent.java b/src/jdk.jfr/share/classes/jdk/jfr/events/SecurityPropertyModificationEvent.java
index df2e9c241de06..7f4e5045c9d23 100644
--- a/src/jdk.jfr/share/classes/jdk/jfr/events/SecurityPropertyModificationEvent.java
+++ b/src/jdk.jfr/share/classes/jdk/jfr/events/SecurityPropertyModificationEvent.java
@@ -35,6 +35,7 @@
@Description("Modification of Security property")
@MirrorEvent(className = "jdk.internal.event.SecurityPropertyModificationEvent")
@RemoveFields("duration")
+@StackFilter({"java.security.Security::setProperty"})
public final class SecurityPropertyModificationEvent extends AbstractJDKEvent {
@Label("Key")
public String key;
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/events/SecurityProviderServiceEvent.java b/src/jdk.jfr/share/classes/jdk/jfr/events/SecurityProviderServiceEvent.java
index 193bfa54ae255..8bbbf09d87df5 100644
--- a/src/jdk.jfr/share/classes/jdk/jfr/events/SecurityProviderServiceEvent.java
+++ b/src/jdk.jfr/share/classes/jdk/jfr/events/SecurityProviderServiceEvent.java
@@ -38,6 +38,7 @@
@Description("Details of Provider.getInstance(String type, String algorithm) calls")
@MirrorEvent(className = "jdk.internal.event.SecurityProviderServiceEvent")
@RemoveFields("duration")
+@StackFilter({"java.security.Provider::getService"})
public final class SecurityProviderServiceEvent extends AbstractJDKEvent {
@Label("Type of Service")
public String type;
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/events/StackFilter.java b/src/jdk.jfr/share/classes/jdk/jfr/events/StackFilter.java
new file mode 100644
index 0000000000000..f0c6a45bf836f
--- /dev/null
+++ b/src/jdk.jfr/share/classes/jdk/jfr/events/StackFilter.java
@@ -0,0 +1,65 @@
+package jdk.jfr.events;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import jdk.jfr.MetadataDefinition;
+
+/**
+* Event annotation, specifies method names or classes to exclude in a stack
+* trace.
+*
+* The following example illustrates how the {@code StackFilter} annotation can
+* be used to remove the {@code Logger::log} method in a stack trace:
+*
+* {@snippet :
+* package com.example;
+*
+* @Name("example.LogMessage")
+* @Label("Log Message")
+* @StackFilter("com.example.Logger::log")
+* class LogMessage extends Event {
+* @Label("Message")
+* String message;
+* }
+*
+* public class Logger {
+*
+* public static void log(String message) {
+* System.out.print(Instant.now() + " : " + message);
+* LogMessage event = new LogMessage();
+* event.message = message;
+* event.commit();
+* }
+* }
+* }
+*
+* @since 22
+*/
+@Target({ ElementType.TYPE })
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+@MetadataDefinition
+public @interface StackFilter {
+ /**
+ * The methods or classes that should not be part of an event stack trace.
+ *
+ * A filter is formed by using the fully qualified class name concatenated with
+ * the method name using {@code "::"} as separator, for example
+ * {@code "java.lang.String::toString"}
+ *
+ * If only the name of a class is specified, for example {@code
+ * "java.lang.String"}, all methods in that class are filtered out.
+ *
+ * Methods can't be qualified using method parameters or return types.
+ *
+ * Instance methods belonging to an interface can't be filtered out.
+ *
+ * Wilcards are not permitted.
+ *
+ * @return the method names, not {@code null}
+ */
+ String[] value();
+}
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/events/TLSHandshakeEvent.java b/src/jdk.jfr/share/classes/jdk/jfr/events/TLSHandshakeEvent.java
index ce5e8c8576804..df2f4cfc2ed55 100644
--- a/src/jdk.jfr/share/classes/jdk/jfr/events/TLSHandshakeEvent.java
+++ b/src/jdk.jfr/share/classes/jdk/jfr/events/TLSHandshakeEvent.java
@@ -39,6 +39,7 @@
@Description("Parameters used in TLS Handshake")
@MirrorEvent(className = "jdk.internal.event.TLSHandshakeEvent")
@RemoveFields("duration")
+@StackFilter("sun.security.ssl.Finished::recordEvent")
public final class TLSHandshakeEvent extends AbstractJDKEvent {
@Label("Peer Host")
public String peerHost;
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/events/ThreadSleepEvent.java b/src/jdk.jfr/share/classes/jdk/jfr/events/ThreadSleepEvent.java
index ab606d8d6de4d..216ad370acafd 100644
--- a/src/jdk.jfr/share/classes/jdk/jfr/events/ThreadSleepEvent.java
+++ b/src/jdk.jfr/share/classes/jdk/jfr/events/ThreadSleepEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 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
@@ -35,6 +35,9 @@
@Label("Java Thread Sleep")
@Name("jdk.ThreadSleep")
@MirrorEvent(className = "jdk.internal.event.ThreadSleepEvent")
+@StackFilter({"java.lang.Thread::afterSleep",
+ "java.lang.Thread::sleepNanos",
+ "java.lang.Thread::sleep"})
public final class ThreadSleepEvent extends AbstractJDKEvent {
@Label("Sleep Time")
@Timespan(Timespan.NANOSECONDS)
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventControl.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/EventControl.java
index d2327a189b54e..a83d244f1d773 100644
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventControl.java
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/EventControl.java
@@ -34,6 +34,7 @@
import java.util.Collections;
import java.util.List;
+import jdk.internal.module.Checks;
import jdk.internal.module.Modules;
import jdk.jfr.AnnotationElement;
import jdk.jfr.Enabled;
@@ -44,6 +45,8 @@
import jdk.jfr.StackTrace;
import jdk.jfr.Threshold;
import jdk.jfr.events.ActiveSettingEvent;
+import jdk.jfr.events.StackFilter;
+import jdk.jfr.internal.JVM;
import jdk.jfr.internal.settings.CutoffSetting;
import jdk.jfr.internal.settings.EnabledSetting;
import jdk.jfr.internal.settings.PeriodSetting;
@@ -65,6 +68,7 @@ record NamedControl(String name, Control control) {
private static final Type TYPE_PERIOD = TypeLibrary.createType(PeriodSetting.class);
private static final Type TYPE_CUTOFF = TypeLibrary.createType(CutoffSetting.class);
private static final Type TYPE_THROTTLE = TypeLibrary.createType(ThrottleSetting.class);
+ private static final long STACK_FILTER_ID = Type.getTypeId(StackFilter.class);
private final ArrayList settingControls = new ArrayList<>();
private final ArrayList namedControls = new ArrayList<>(5);
@@ -89,6 +93,7 @@ record NamedControl(String name, Control control) {
}
addControl(Enabled.NAME, defineEnabled(eventType));
+ addStackFilters(eventType);
List aes = new ArrayList<>(eventType.getAnnotationElements());
remove(eventType, aes, Threshold.class);
remove(eventType, aes, Period.class);
@@ -96,11 +101,84 @@ record NamedControl(String name, Control control) {
remove(eventType, aes, StackTrace.class);
remove(eventType, aes, Cutoff.class);
remove(eventType, aes, Throttle.class);
+ remove(eventType, aes, StackFilter.class);
eventType.setAnnotations(aes);
this.type = eventType;
this.idName = String.valueOf(eventType.getId());
}
+ private void addStackFilters(PlatformEventType eventType) {
+ String[] filter = getStackFilter(eventType);
+ if (filter != null) {
+ int size = filter.length;
+ List types = new ArrayList<>(size);
+ List methods = new ArrayList<>(size);
+ for (String frame : filter) {
+ int index = frame.indexOf("::");
+ String clazz = null;
+ String method = null;
+ boolean valid = false;
+ if (index != -1) {
+ clazz = frame.substring(0, index);
+ method = frame.substring(index + 2);
+ if (clazz.isEmpty()) {
+ clazz = null;
+ valid = isValidMethod(method);
+ } else {
+ valid = isValidType(clazz) && isValidMethod(method);
+ }
+ } else {
+ clazz = frame;
+ valid = isValidType(frame);
+ }
+ if (valid) {
+ if (clazz == null) {
+ types.add(null);
+ } else {
+ types.add(clazz.replace(".", "/"));
+ }
+ // If unqualified class name equals method name, it's a constructor
+ String className = clazz.substring(clazz.lastIndexOf(".") + 1);
+ if (className.equals(method)) {
+ method = "";
+ }
+ methods.add(method);
+ } else {
+ Logger.log(LogTag.JFR, LogLevel.WARN, "@StackFrameFilter element ignored, not a valid Java identifier.");
+ }
+ }
+ if (!types.isEmpty()) {
+ String[] typeArray = types.toArray(new String[0]);
+ String[] methodArray = methods.toArray(new String[0]);
+ long id = MetadataRepository.getInstance().registerStackFilter(typeArray, methodArray);
+ eventType.setStackFilterId(id);
+ }
+ }
+ }
+
+ private String[] getStackFilter(PlatformEventType eventType) {
+ for (var a : eventType.getAnnotationElements()) {
+ if (a.getTypeId() == STACK_FILTER_ID) {
+ return (String[])a.getValue("value");
+ }
+ }
+ return null;
+ }
+
+ private boolean isValidType(String className) {
+ if (className.length() < 1 || className.length() > 65535) {
+ return false;
+ }
+ return Checks.isClassName(className);
+ }
+
+ private boolean isValidMethod(String method) {
+ if (method.length() < 1 || method.length() > 65535) {
+ return false;
+ }
+ return Checks.isJavaIdentifier(method);
+ }
+
private boolean hasControl(String name) {
for (NamedControl nc : namedControls) {
if (name.equals(nc.name)) {
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java
index 986b6f2450bac..3f37924c9a72f 100644
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java
@@ -149,10 +149,15 @@ private static class ChunkRotationMonitor {}
*
* Requires that JFR has been started with {@link #createNativeJFR()}
*
- * @param skipCount number of frames to skip
+ * @param skipCount number of frames to skip, or 0 if no frames should be
+ * skipped
+ *
+ * @param ID ID of the filter that should be used, or -1 if no filter should
+ * be used
+ *
* @return a unique stack trace identifier
*/
- public static native long getStackTraceId(int skipCount);
+ public static native long getStackTraceId(int skipCount, long stackFilerId);
/**
* Return identifier for thread
@@ -628,4 +633,30 @@ private static class ChunkRotationMonitor {}
* @param bytes number of bytes that were lost
*/
public static native void emitDataLoss(long bytes);
+
+ /**
+ * Registers stack filters that should be used with getStackTrace(int, long)
+ *
+ * Method name at an array index is for class at the same array index.
+ *
+ * This method should be called holding the MetadataRepository lock and before
+ * bytecode for the associated event class has been added.
+ *
+ * @param classes, name of classes, for example {"java/lang/String"}, not
+ * {@code null}
+ * @param methods, name of method, for example {"toString"}, not {@code null}
+ *
+ * @return an ID that can be used to unregister the start frames, or -1 if it could not be registered
+ */
+ public static native long registerStackFilter(String[] classes, String[] methods);
+
+ /**
+ * Unregisters a set of stack filters.
+ *
+ * This method should be called holding the MetadataRepository lock and after
+ * the associated event class has been unloaded.
+ *
+ * @param stackFilterId the stack filter ID to unregister
+ */
+ public static native void unregisterStackFilter(long stackFilterId);
}
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java
index 417238c06f8af..c83e9de7893cf 100644
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataRepository.java
@@ -321,6 +321,9 @@ private void unregisterUnloaded() {
if (!knownIds.contains(pe.getId())) {
if (!pe.isJVM()) {
pe.setRegistered(false);
+ if (pe.hasStackFilters()) {
+ JVM.unregisterStackFilter(pe.getStackFilterId());
+ }
}
}
}
@@ -355,4 +358,8 @@ static void unhideInternalTypes() {
public synchronized List getVisibleTypes() {
return TypeLibrary.getVisibleTypes();
}
+
+ public synchronized long registerStackFilter(String[] typeArray, String[] methodArray) {
+ return JVM.registerStackFilter(typeArray, methodArray);
+ }
}
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformEventType.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformEventType.java
index e600a0c70fe0c..e8621c56794d9 100644
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformEventType.java
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformEventType.java
@@ -46,6 +46,7 @@ public final class PlatformEventType extends Type {
private final List settings = new ArrayList<>(5);
private final boolean dynamicSettings;
private final int stackTraceOffset;
+ private long startFilterId = -1;
// default values
private boolean largeSize = false;
@@ -339,4 +340,16 @@ public void setLargeSize() {
public boolean isMethodSampling() {
return isMethodSampling;
}
+
+ public void setStackFilterId(long id) {
+ startFilterId = id;
+ }
+
+ public boolean hasStackFilters() {
+ return startFilterId >= 0;
+ }
+
+ public long getStackFilterId() {
+ return startFilterId;
+ }
}
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/TypeLibrary.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/TypeLibrary.java
index 0a1f1c05dee57..f461212659d37 100644
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/TypeLibrary.java
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/TypeLibrary.java
@@ -60,6 +60,7 @@
import jdk.jfr.ValueDescriptor;
import jdk.jfr.internal.util.Utils;
import jdk.jfr.internal.util.ImplicitFields;
+import jdk.internal.module.Modules;
public final class TypeLibrary {
private static boolean implicitFieldTypes;
@@ -165,7 +166,6 @@ public static synchronized AnnotationElement createAnnotation(Annotation annotat
for (ValueDescriptor v : type.getFields()) {
values.add(invokeAnnotation(annotation, v.getName()));
}
-
return PrivateAccess.getInstance().newAnnotation(type, values, annotation.annotationType().getClassLoader() == null);
}
return null;
@@ -178,6 +178,15 @@ private static Object invokeAnnotation(Annotation annotation, String methodName)
} catch (NoSuchMethodException e1) {
throw (Error) new InternalError("Could not locate method " + methodName + " in annotation " + annotation.getClass().getName());
}
+ // Add export from JDK proxy module
+ if (annotation.getClass().getClassLoader() == null) {
+ if (annotation.getClass().getName().contains("Proxy")) {
+ Module proxyModule = annotation.getClass().getModule();
+ String proxyPackage = annotation.getClass().getPackageName();
+ Module jfrModule = TypeLibrary.class.getModule();
+ Modules.addExports(proxyModule, proxyPackage, jfrModule);
+ }
+ }
SecuritySupport.setAccessible(m);
try {
return m.invoke(annotation, new Object[0]);
diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/event/EventWriter.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/event/EventWriter.java
index 43fc613049558..833fb087e2420 100644
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/event/EventWriter.java
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/event/EventWriter.java
@@ -188,7 +188,7 @@ public void putClass(Class> aClass) {
public void putStackTrace() {
if (eventType.getStackTraceEnabled()) {
- putLong(JVM.getStackTraceId(eventType.getStackTraceOffset()));
+ putLong(JVM.getStackTraceId(eventType.getStackTraceOffset(), eventType.getStackFilterId()));
} else {
putLong(0L);
}
diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/TestStackFilter.java b/test/jdk/jdk/jfr/api/metadata/annotations/TestStackFilter.java
new file mode 100644
index 0000000000000..2acd369b6cd8f
--- /dev/null
+++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestStackFilter.java
@@ -0,0 +1,319 @@
+/*
+ * 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 jdk.jfr.api.metadata.annotations;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import jdk.jfr.api.metadata.annotations.UnloadableClass;
+import jdk.jfr.Event;
+import jdk.jfr.AnnotationElement;
+import jdk.jfr.consumer.RecordedEvent;
+import jdk.jfr.consumer.RecordedFrame;
+import jdk.jfr.consumer.RecordedMethod;
+import jdk.jfr.consumer.RecordedStackTrace;
+import jdk.jfr.consumer.RecordingStream;
+import jdk.jfr.events.StackFilter;
+import jdk.jfr.Recording;
+import jdk.jfr.Name;
+import jdk.jfr.EventType;
+import jdk.jfr.EventFactory;
+import jdk.jfr.FlightRecorder;
+import jdk.test.lib.jfr.Events;
+import jdk.test.lib.jfr.TestClassLoader;
+
+/**
+ * @test
+ * @key jfr
+ * @requires vm.hasJFR
+ * @modules jdk.jfr/jdk.jfr.events
+ * @library /test/lib /test/jdk
+ * @run main/othervm -Xlog:jfr=warning jdk.jfr.api.metadata.annotations.TestStackFilter
+ */
+public class TestStackFilter {
+ private static class Quux {
+ private static void one() throws Exception {
+ two();
+ }
+ private static void two() throws Exception {
+ three();
+ }
+
+ private static void three() throws Exception {
+ TestStackFilter.qux();
+ }
+ }
+ private final static String PACKAGE = "jdk.jfr.api.metadata.annotations.TestStackFilter";
+ private final static String M1 = PACKAGE + "::foo";
+ private final static String M2 = PACKAGE + "::baz";
+ private final static String C1 = PACKAGE + "$Quux";
+
+ @StackFilter({ M1, M2 })
+ @Name("MethodFilter")
+ public static class MethodFilterEvent extends Event {
+ }
+
+ @StackFilter(C1)
+ @Name("ClassFilter")
+ public static class ClassFilterEvent extends Event {
+ }
+
+ @StackFilter({})
+ @Name("Empty")
+ public static class EmptyEvent extends Event {
+ }
+
+ @StackFilter(PACKAGE + "::testUnload")
+ @Name("Unload")
+ public static class UnloadEvent extends Event {
+ }
+
+ @StackFilter(PACKAGE + "::emitCommitter")
+ @Name("Reuse")
+ public static class ReuseEvent extends Event {
+ }
+
+ @StackFilter(PACKAGE + "::emitCommitter")
+ @Name("Max")
+ public static class ExceedMaxEvent extends Event {
+ }
+
+ public static void main(String[] args) throws Exception {
+ testMethodFilter();
+ testClassFilter();
+ testUnload();
+ testReuse();
+ testExceedMax();
+ }
+
+ // Use more stack filters than there is capacity for
+ private static void testExceedMax() throws Exception {
+ try (Recording r = new Recording()) {
+ r.start();
+ // Maximum number of simultaneous event classes that can
+ // use a filter is 4096. Additional filters will be ignored.
+ var classes = new ArrayList<>();
+ for (int i = 0; i < 4200; i++) {
+ Class eventClass = UnloadableClass.load(ExceedMaxEvent.class);
+ emitCommitter(eventClass);
+ classes.add(eventClass);
+ }
+ List events = Events.fromRecording(r);
+ if (events.size() != 4200) {
+ throw new Exception("Expected 4200 'Max' events");
+ }
+ int emitCommitterCount = 0;
+ int textExceedMaxCount = 0;
+ for (RecordedEvent event : events) {
+ RecordedStackTrace s = event.getStackTrace();
+ if (s == null) {
+ System.out.println(event);
+ throw new Exception("Expected stack trace for 'Max' event");
+ }
+
+ RecordedFrame f = s.getFrames().get(0);
+ if (!f.isJavaFrame()) {
+ throw new Exception("Expected Java frame for 'Max' event");
+ }
+ String methodName = f.getMethod().getName();
+ switch (methodName) {
+ case "emitCommitter":
+ emitCommitterCount++;
+ break;
+ case "testExceedMax":
+ textExceedMaxCount++;
+ break;
+ default:
+ System.out.println(event);
+ throw new Exception("Unexpected top frame " + methodName + " for 'Max' event");
+ }
+ }
+ // Can't match exact because filters from previous tests may be in use
+ // or because filters added by JDK events filters
+ if (emitCommitterCount == 0) {
+ throw new Exception("Expected at least some events with emitCommitter() as top frame, found " + emitCommitterCount);
+ }
+ if (textExceedMaxCount < 500) {
+ throw new Exception("Expected at least 500 events with testExceedMax() as top frame, found " + textExceedMaxCount);
+ }
+ }
+ }
+
+ // Tests that event classes with @StackFilter that are unloaded
+ // reuses the memory slot used to bookkeep things in native
+ private static void testReuse() throws Exception {
+ try (Recording r = new Recording()) {
+ r.enable("Reuse");
+ r.start();
+ for (int i = 0; i < 48; i++) {
+ Class eventClass = UnloadableClass.load(ReuseEvent.class);
+ emitCommitter(eventClass);
+ if (i % 16 == 0) {
+ System.gc();
+ rotate();
+ }
+ }
+ r.stop();
+ List events = Events.fromRecording(r);
+ if (events.size() != 48) {
+ throw new Exception("Expected 48 'Reuse' events");
+ }
+ for (RecordedEvent event : events) {
+ assertTopFrame(event, "testReuse");
+ }
+ }
+
+ }
+
+ // This test registers a stack filter, emits an event with the filter
+ // and unregisters it. While this is happening, another
+ // filter is being used.
+ private static void testUnload() throws Exception {
+ try (Recording r = new Recording()) {
+ r.start();
+ Class eventClass = UnloadableClass.load(UnloadEvent.class);
+ emitCommitter(eventClass);
+ EventType type = getType("Unload");
+ if (type == null) {
+ throw new Exception("Expected event type named 'Unload'");
+ }
+ eventClass = null;
+ while (true) {
+ System.gc();
+ rotate();
+ type = getType("Unload");
+ if (type == null) {
+ return;
+ }
+ System.out.println("Unload class not unloaded. Retrying ...");
+ }
+ }
+ }
+
+ private static void testMethodFilter() throws Exception {
+ try (Recording r = new Recording()) {
+ r.enable(MethodFilterEvent.class);
+ r.start();
+ foo();
+ bar();
+ empty();
+ r.stop();
+ List events = Events.fromRecording(r);
+ if (events.isEmpty()) {
+ throw new Exception("Excected events");
+ }
+
+ RecordedEvent e1 = events.get(0);
+ assertTopFrame(e1, "testMethodFilter");
+
+ RecordedEvent e2 = events.get(1);
+ assertTopFrame(e2, "bar");
+
+ RecordedEvent e3 = events.get(2);
+ assertTopFrame(e3, "empty");
+ }
+ }
+
+ private static void testClassFilter() throws Exception {
+ try (Recording r = new Recording()) {
+ r.enable(MethodFilterEvent.class);
+ r.start();
+ Quux.one();
+ r.stop();
+ List events = Events.fromRecording(r);
+ if (events.isEmpty()) {
+ throw new Exception("Excected events");
+ }
+
+ RecordedEvent e = events.get(0);
+ assertTopFrame(e, "qux");
+ for (RecordedFrame f : e.getStackTrace().getFrames()) {
+ if (f.getMethod().getType().getName().contains("Quux")) {
+ System.out.println(e);
+ throw new Exception("Didn't expect Quux class in stack trace");
+ }
+ }
+ }
+ }
+
+ private static void empty() {
+ EmptyEvent event = new EmptyEvent();
+ event.commit();
+ }
+
+ static void foo() {
+ baz();
+ }
+
+ static void bar() {
+ baz();
+ }
+
+ static void baz() {
+ MethodFilterEvent event = new MethodFilterEvent();
+ event.commit();
+ }
+
+ static void qux() {
+ ClassFilterEvent event = new ClassFilterEvent();
+ event.commit();
+ }
+
+ private static void rotate() {
+ try (Recording r = new Recording()) {
+ r.start();
+ }
+ }
+
+ private static EventType getType(String name) {
+ for (EventType et : FlightRecorder.getFlightRecorder().getEventTypes()) {
+ if (et.getName().equals(name)) {
+ return et;
+ }
+
+ }
+ return null;
+ }
+
+ private static void emitCommitter(Class extends Event> eventClass) throws Exception {
+ Event event = eventClass.getConstructor().newInstance();
+ event.commit();
+ }
+
+ private static void assertTopFrame(RecordedEvent event, String methodName) throws Exception {
+ RecordedStackTrace stackTrace = event.getStackTrace();
+ if (stackTrace == null) {
+ System.out.println(event);
+ throw new Exception("No stack trace found when looking for top frame '" + methodName + "'");
+ }
+ RecordedFrame frame = stackTrace.getFrames().get(0);
+ RecordedMethod method = frame.getMethod();
+ if (!methodName.equals(method.getName())) {
+ System.out.println(event);
+ throw new Exception("Expected top frame '" + methodName + "'");
+ }
+ }
+}
diff --git a/test/jdk/jdk/jfr/api/metadata/annotations/UnloadableClass.java b/test/jdk/jdk/jfr/api/metadata/annotations/UnloadableClass.java
new file mode 100644
index 0000000000000..4a4a57a0e55d9
--- /dev/null
+++ b/test/jdk/jdk/jfr/api/metadata/annotations/UnloadableClass.java
@@ -0,0 +1,64 @@
+/*
+ * 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 jdk.jfr.api.metadata.annotations;
+
+import java.io.DataInputStream;
+import java.security.CodeSource;
+import java.security.ProtectionDomain;
+import java.security.cert.Certificate;
+
+/* Purpose of this class is to load a specified class in its
+ * own class loader, but delegate every other class.
+ */
+public final class UnloadableClass extends ClassLoader {
+ private final String className;
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public static Class load(Class clazz) throws ClassNotFoundException {
+ UnloadableClass cl = new UnloadableClass(clazz.getName());
+ return cl.loadClass(cl.className);
+ }
+
+ private UnloadableClass(String className) {
+ super("Class loader for class " + className, ClassLoader.getSystemClassLoader());
+ this.className = className;
+ }
+
+ public Class> loadClass(String name) throws ClassNotFoundException {
+ if (!className.equals(name)) {
+ return super.loadClass(name);
+ }
+ String resourceName = name.replace('.', '/') + ".class";
+ try (var is = getResourceAsStream(resourceName); var dis = new DataInputStream(is)) {
+ int size = is.available();
+ byte buffer[] = new byte[size];
+ dis.readFully(buffer);
+ CodeSource cs = new CodeSource(getResource(resourceName), (Certificate[]) null);
+ ProtectionDomain pd = new ProtectionDomain(cs, null);
+ return defineClass(name, buffer, 0, buffer.length, pd);
+ } catch (Exception e) {
+ throw new InternalError(e);
+ }
+ }
+}
diff --git a/test/jdk/jdk/jfr/event/os/TestProcessStart.java b/test/jdk/jdk/jfr/event/os/TestProcessStart.java
index 32d3be0e980f2..bcf216857bb9b 100644
--- a/test/jdk/jdk/jfr/event/os/TestProcessStart.java
+++ b/test/jdk/jdk/jfr/event/os/TestProcessStart.java
@@ -47,7 +47,7 @@ public class TestProcessStart {
public static void main(String[] args) throws Throwable {
try (Recording recording = new Recording()) {
- recording.enable(EVENT_NAME);
+ recording.enable(EVENT_NAME).withStackTrace();
recording.start();
List commandList = new ArrayList<>();
if (Platform.isWindows()) {
@@ -74,6 +74,7 @@ public static void main(String[] args) throws Throwable {
Events.assertField(event, "pid").equal(p.pid());
Events.assertField(event, "directory").equal(pb.directory().toString());
Events.assertField(event, "command").equal(command.toString());
+ Events.assertTopFrame(event, TestProcessStart.class, "main");
}
}
}
diff --git a/test/jdk/jdk/jfr/event/runtime/TestThreadSleepEvent.java b/test/jdk/jdk/jfr/event/runtime/TestThreadSleepEvent.java
index afd96b66540b8..c084808ce79ae 100644
--- a/test/jdk/jdk/jfr/event/runtime/TestThreadSleepEvent.java
+++ b/test/jdk/jdk/jfr/event/runtime/TestThreadSleepEvent.java
@@ -56,13 +56,7 @@ public static void main(String[] args) throws Throwable {
recording.enable(EVENT_NAME).withoutThreshold().withStackTrace();
recording.start();
Thread.sleep(SLEEP_TIME_MS);
- Thread virtualThread = Thread.ofVirtual().start(() -> {
- try {
- Thread.sleep(SLEEP_TIME_MS);
- } catch (InterruptedException ie) {
- throw new RuntimeException(ie);
- }
- });
+ Thread virtualThread = Thread.ofVirtual().start(TestThreadSleepEvent::virtualSleep);
virtualThread.join();
recording.stop();
@@ -74,14 +68,24 @@ public static void main(String[] args) throws Throwable {
System.out.println(event.getStackTrace());
if (event.getThread().getJavaThreadId() == Thread.currentThread().getId()) {
threadCount--;
+ Events.assertTopFrame(event, TestThreadSleepEvent.class, "main");
Events.assertDuration(event, "time", Duration.ofMillis(SLEEP_TIME_MS));
}
if (event.getThread().getJavaThreadId() == virtualThread.getId()) {
threadCount--;
+ Events.assertTopFrame(event, TestThreadSleepEvent.class, "virtualSleep");
Events.assertDuration(event, "time", Duration.ofMillis(SLEEP_TIME_MS));
}
}
Asserts.assertEquals(threadCount, 0, "Could not find all expected events");
}
}
+
+ private static void virtualSleep() {
+ try {
+ Thread.sleep(SLEEP_TIME_MS);
+ } catch (InterruptedException ie) {
+ throw new RuntimeException(ie);
+ }
+ }
}
diff --git a/test/jdk/jdk/jfr/event/security/TestSecurityPropertyModificationEvent.java b/test/jdk/jdk/jfr/event/security/TestSecurityPropertyModificationEvent.java
index 0c1e5b32c5cb4..ff5919b25909a 100644
--- a/test/jdk/jdk/jfr/event/security/TestSecurityPropertyModificationEvent.java
+++ b/test/jdk/jdk/jfr/event/security/TestSecurityPropertyModificationEvent.java
@@ -58,7 +58,7 @@ public static void main(String[] args) throws Exception {
}
try (Recording recording = new Recording()) {
- recording.enable(EventNames.SecurityProperty);
+ recording.enable(EventNames.SecurityProperty).withStackTrace();
recording.start();
for (String key: keys) {
Security.setProperty(key, keyValue);
@@ -78,6 +78,7 @@ private static void assertEvent(List events) throws Exception {
if (keys.contains(e.getString("key"))) {
Events.assertField(e, "value").equal(keyValue);
i++;
+ Events.assertTopFrame(e, TestSecurityPropertyModificationEvent.class, "main");
} else {
System.out.println(events);
throw new Exception("Unexpected event at index:" + i);
diff --git a/test/jdk/jdk/jfr/event/security/TestSecurityProviderServiceEvent.java b/test/jdk/jdk/jfr/event/security/TestSecurityProviderServiceEvent.java
index a886a7e3b2047..df801c5190742 100644
--- a/test/jdk/jdk/jfr/event/security/TestSecurityProviderServiceEvent.java
+++ b/test/jdk/jdk/jfr/event/security/TestSecurityProviderServiceEvent.java
@@ -52,32 +52,38 @@ public class TestSecurityProviderServiceEvent {
public static void main(String[] args) throws Exception {
testAlg(cipherFunc, "AES", "SunJCE",
- "SunEC", "Cipher", 1, Collections.emptyList());
+ "SunEC", "Cipher", 1, Collections.emptyList(),
+ javax.crypto.Cipher.class.getName(), "getInstance");
testAlg(signatureFunc, "SHA256withRSA", "SunRsaSign",
- "SunEC", "Signature", 2, List.of("MessageDigest"));
+ "SunEC", "Signature", 2, List.of("MessageDigest"),
+ "sun.security.jca.GetInstance", "getService");
testAlg(messageDigestFunc, "SHA-512", "SUN",
- "SunEC", "MessageDigest", 1, Collections.emptyList());
+ "SunEC", "MessageDigest", 1, Collections.emptyList(),
+ "sun.security.jca.GetInstance", "getService");
testAlg(keystoreFunc, "PKCS12", "SUN",
- "SunEC", "KeyStore", 1, Collections.emptyList());
+ "SunEC", "KeyStore", 1, Collections.emptyList(),
+ "sun.security.jca.GetInstance", "getService");
testAlg(certPathBuilderFunc, "PKIX", "SUN",
- "SunEC", "CertPathBuilder", 2, List.of("CertificateFactory"));
+ "SunEC", "CertPathBuilder", 2, List.of("CertificateFactory"),
+ "sun.security.jca.GetInstance", "getService");
}
private static void testAlg(BiFunction bif, String alg,
String workingProv, String brokenProv, String algType,
- int expected, List other) throws Exception {
+ int expected, List other,
+ String clazz, String method) throws Exception {
// bootstrap security Provider services
Provider p = bif.apply(alg, workingProv);
try (Recording recording = new Recording()) {
- recording.enable(EventNames.SecurityProviderService);
+ recording.enable(EventNames.SecurityProviderService).withStackTrace();
recording.start();
p = bif.apply(alg, workingProv);
bif.apply(alg, brokenProv);
recording.stop();
List events = Events.fromRecording(recording);
Asserts.assertEquals(events.size(), expected, "Incorrect number of events");
- assertEvent(events, algType, alg, p.getName(), other);
+ assertEvent(events, algType, alg, p.getName(), other, clazz, method);
}
}
@@ -137,7 +143,8 @@ private static void testAlg(BiFunction bif, String alg
};
private static void assertEvent(List events, String type,
- String alg, String workingProv, List other) {
+ String alg, String workingProv, List other, String clazz,
+ String method) {
boolean secondaryEventOK = other.isEmpty() ? true : false;
for (RecordedEvent e : events) {
if (other.contains(e.getValue("type"))) {
@@ -148,10 +155,10 @@ private static void assertEvent(List events, String type,
Events.assertField(e, "provider").equal(workingProv);
Events.assertField(e, "type").equal(type);
Events.assertField(e, "algorithm").equal(alg);
+ Events.assertTopFrame(e, clazz, method);
}
if (!secondaryEventOK) {
throw new RuntimeException("Secondary events missing");
}
-
}
}
diff --git a/test/jdk/jdk/jfr/event/security/TestTLSHandshakeEvent.java b/test/jdk/jdk/jfr/event/security/TestTLSHandshakeEvent.java
index 48e1fdfdd590d..7c5240a2a72e5 100644
--- a/test/jdk/jdk/jfr/event/security/TestTLSHandshakeEvent.java
+++ b/test/jdk/jdk/jfr/event/security/TestTLSHandshakeEvent.java
@@ -43,7 +43,7 @@
public class TestTLSHandshakeEvent {
public static void main(String[] args) throws Exception {
try (Recording recording = new Recording()) {
- recording.enable(EventNames.TLSHandshake);
+ recording.enable(EventNames.TLSHandshake).withStackTrace();
recording.start();
TestTLSHandshake handshake = new TestTLSHandshake();
handshake.run();
@@ -63,6 +63,10 @@ private static void assertEvent(List events, TestTLSHandshake han
Events.assertField(e, "protocolVersion").equal(handshake.protocolVersion);
Events.assertField(e, "certificateId").equal(TestTLSHandshake.CERT_ID);
Events.assertField(e, "cipherSuite").equal(TestTLSHandshake.CIPHER_SUITE);
+ var method = e.getStackTrace().getFrames().get(0).getMethod();
+ if (method.getName().equals("recordEvent")) {
+ throw new Exception("Didn't expected recordEvent as top frame");
+ }
return;
}
}
diff --git a/test/jdk/jdk/jfr/jvm/TestGetStackTraceId.java b/test/jdk/jdk/jfr/jvm/TestGetStackTraceId.java
index cdb8a9a5c43ef..8a23e55140886 100644
--- a/test/jdk/jdk/jfr/jvm/TestGetStackTraceId.java
+++ b/test/jdk/jdk/jfr/jvm/TestGetStackTraceId.java
@@ -52,7 +52,7 @@ public static void main(String... args) {
}
private static void assertMaxSkip() {
- Asserts.assertEquals(JVM.getStackTraceId(Integer.MAX_VALUE), 0L, "Insane skip level "
+ Asserts.assertEquals(JVM.getStackTraceId(Integer.MAX_VALUE, -1), 0L, "Insane skip level "
+ Integer.MAX_VALUE + " should not return a valid stack trace id");
}
@@ -64,6 +64,6 @@ public static long getStackIdOfDepth(int depth) {
if (depth > 0) {
return getStackIdOfDepth(depth - 1);
}
- return JVM.getStackTraceId(0);
+ return JVM.getStackTraceId(0, -1);
}
}
diff --git a/test/lib/jdk/test/lib/jfr/Events.java b/test/lib/jdk/test/lib/jfr/Events.java
index 620e5b0fcc3e7..e3e5979817962 100644
--- a/test/lib/jdk/test/lib/jfr/Events.java
+++ b/test/lib/jdk/test/lib/jfr/Events.java
@@ -365,20 +365,42 @@ private static boolean containsEvent(List events, String name) {
return false;
}
+ public static void assertTopFrame(RecordedEvent event, Class> expectedClass, String expectedMethodName) {
+ assertTopFrame(event, expectedClass.getName(), expectedMethodName);
+ }
+
+ public static void assertTopFrame(RecordedEvent event, String expectedClass, String expectedMethodName) {
+ RecordedStackTrace stackTrace = event.getStackTrace();
+ Asserts.assertNotNull(stackTrace, "Missing stack trace");
+ RecordedFrame topFrame = stackTrace.getFrames().get(0);
+ if (isFrame(topFrame, expectedClass, expectedMethodName)) {
+ return;
+ }
+ String expected = expectedClass + "::" + expectedMethodName;
+ Asserts.fail("Expected top frame " + expected + ". Found " + topFrame);
+ }
+
public static void assertFrame(RecordedEvent event, Class> expectedClass, String expectedMethodName) {
RecordedStackTrace stackTrace = event.getStackTrace();
Asserts.assertNotNull(stackTrace, "Missing stack trace");
for (RecordedFrame frame : stackTrace.getFrames()) {
- if (frame.isJavaFrame()) {
- RecordedMethod method = frame.getMethod();
- RecordedClass type = method.getType();
- if (expectedClass.getName().equals(type.getName())) {
- if (expectedMethodName.equals(method.getName())) {
- return;
- }
- }
+ if (isFrame(frame, expectedClass.getName(), expectedMethodName)) {
+ return;
}
}
Asserts.fail("Expected " + expectedClass.getName() + "::"+ expectedMethodName + " in stack trace");
}
+
+ private static boolean isFrame(RecordedFrame frame, String expectedClass, String expectedMethodName) {
+ if (frame.isJavaFrame()) {
+ RecordedMethod method = frame.getMethod();
+ RecordedClass type = method.getType();
+ if (expectedClass.equals(type.getName())) {
+ if (expectedMethodName.equals(method.getName())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
}
From 2bb4b9398d65e3f37f34e45476c969ff0afb1540 Mon Sep 17 00:00:00 2001
From: Justin Lu
Date: Thu, 23 Nov 2023 00:27:27 +0000
Subject: [PATCH 035/250] 8319569: Several java/util tests should be updated to
accept VM flags
Reviewed-by: naoto, lancea
---
.../SupplementalJapaneseEraTestRun.java | 36 +++++-----
test/jdk/java/util/Currency/PropertiesTest.sh | 12 ++--
.../java/util/Locale/LocaleProvidersRun.java | 31 ++++-----
.../Control/MissingResourceCauseTestRun.java | 18 +++--
.../modules/ModuleTestUtil.java | 66 +++++++++----------
.../modules/layer/LayerTest.java | 19 +++---
.../modules/unnamed/UnNamedTest.java | 53 +++++++--------
.../modules/visibility/VisibilityTest.java | 17 ++---
.../util/TimeZone/CustomTzIDCheckDST.java | 6 +-
.../TimeZoneDatePermissionCheckRun.java | 22 +++----
.../java/util/logging/LoggingDeadlock2.java | 21 +++---
test/jdk/java/util/zip/EntryCount64k.java | 7 +-
12 files changed, 143 insertions(+), 165 deletions(-)
diff --git a/test/jdk/java/util/Calendar/SupplementalJapaneseEraTestRun.java b/test/jdk/java/util/Calendar/SupplementalJapaneseEraTestRun.java
index 34363bf711d1c..5383d0d124055 100644
--- a/test/jdk/java/util/Calendar/SupplementalJapaneseEraTestRun.java
+++ b/test/jdk/java/util/Calendar/SupplementalJapaneseEraTestRun.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2019, 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
@@ -34,10 +34,15 @@
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
-import static java.util.Calendar.*;
+import java.util.stream.Stream;
+
+import static java.util.Calendar.DAY_OF_YEAR;
+import static java.util.Calendar.ERA;
+import static java.util.Calendar.FEBRUARY;
+import static java.util.Calendar.LONG;
+import static java.util.Calendar.YEAR;
import jdk.test.lib.process.ProcessTools;
-import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.Utils;
import org.testng.annotations.DataProvider;
@@ -91,19 +96,18 @@ public void InvalidPropertyValuesTest(String prop)
}
private static void testRun(String property, List javaParam)
- throws Throwable{
- JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
- launcher.addToolArg("-ea")
- .addToolArg("-esa")
- .addToolArg("-cp")
- .addToolArg(Utils.TEST_CLASS_PATH)
- .addToolArg("-Djdk.calendar.japanese.supplemental.era=" + property)
- .addToolArg("SupplementalJapaneseEraTest");
- for (String para: javaParam) {
- launcher.addToolArg(para);
- }
- int exitCode = ProcessTools.executeCommand(launcher.getCommand())
- .getExitValue();
+ throws Throwable {
+ List params = List.of(
+ "-ea", "-esa",
+ "-cp", Utils.TEST_CLASS_PATH,
+ "-Djdk.calendar.japanese.supplemental.era=" + property,
+ "SupplementalJapaneseEraTest");
+ // Build process (with VM flags)
+ ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
+ Stream.concat(params.stream(), javaParam.stream()).toList());
+ // Evaluate process status
+ int exitCode = ProcessTools.executeCommand(pb).getExitValue();
+
System.out.println(property + ":pass");
if (exitCode != 0) {
System.out.println(property + ":fail");
diff --git a/test/jdk/java/util/Currency/PropertiesTest.sh b/test/jdk/java/util/Currency/PropertiesTest.sh
index 6e8bbc2397029..f7825640480af 100644
--- a/test/jdk/java/util/Currency/PropertiesTest.sh
+++ b/test/jdk/java/util/Currency/PropertiesTest.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-# Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 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
@@ -76,7 +76,7 @@ failures=0
run() {
echo ''
- ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp ${TESTCLASSES} $* 2>&1
+ ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} $* 2>&1
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
}
@@ -110,23 +110,23 @@ echo "Properties location: ${PROPLOCATION}"
# run
echo ''
-${WRITABLEJDK}${FS}bin${FS}java ${TESTVMOPTS} -cp ${TESTCLASSES} PropertiesTest -d dump3
+${WRITABLEJDK}${FS}bin${FS}java ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} PropertiesTest -d dump3
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
if [ ! -f dump3 ]; then echo "file dump3 not created. Test cannot execute. Failed."; exit 1; fi
# run bug7102969 test
echo ''
-${WRITABLEJDK}${FS}bin${FS}java ${TESTVMOPTS} -cp ${TESTCLASSES} PropertiesTest bug7102969
+${WRITABLEJDK}${FS}bin${FS}java ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} PropertiesTest bug7102969
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
# run bug8157138 test
echo ''
-${WRITABLEJDK}${FS}bin${FS}java ${TESTVMOPTS} -cp ${TESTCLASSES} PropertiesTest bug8157138
+${WRITABLEJDK}${FS}bin${FS}java ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} PropertiesTest bug8157138
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
# run bug8190904 test
echo ''
-${WRITABLEJDK}${FS}bin${FS}java ${TESTVMOPTS} -cp ${TESTCLASSES} PropertiesTest bug8190904
+${WRITABLEJDK}${FS}bin${FS}java ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} PropertiesTest bug8190904
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
# Cleanup
diff --git a/test/jdk/java/util/Locale/LocaleProvidersRun.java b/test/jdk/java/util/Locale/LocaleProvidersRun.java
index beeb1444e935b..aae8ff03c11a0 100644
--- a/test/jdk/java/util/Locale/LocaleProvidersRun.java
+++ b/test/jdk/java/util/Locale/LocaleProvidersRun.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2021, 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,7 +39,6 @@
import java.util.Locale;
-import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.Utils;
@@ -178,22 +177,18 @@ public static void main(String[] args) throws Throwable {
}
private static void testRun(String prefList, String methodName,
- String param1, String param2, String param3) throws Throwable{
- JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
- launcher.addToolArg("-ea")
- .addToolArg("-esa")
- .addToolArg("-cp")
- .addToolArg(Utils.TEST_CLASS_PATH)
- .addToolArg("-Djava.util.logging.config.class=LocaleProviders$LogConfig")
- .addToolArg("-Djava.locale.providers=" + prefList)
- .addToolArg("--add-exports=java.base/sun.util.locale.provider=ALL-UNNAMED")
- .addToolArg("LocaleProviders")
- .addToolArg(methodName)
- .addToolArg(param1)
- .addToolArg(param2)
- .addToolArg(param3);
- int exitCode = ProcessTools.executeCommand(launcher.getCommand())
- .getExitValue();
+ String param1, String param2, String param3) throws Throwable {
+
+ // Build process (with VM flags)
+ ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
+ "-ea", "-esa",
+ "-cp", Utils.TEST_CLASS_PATH,
+ "-Djava.util.logging.config.class=LocaleProviders$LogConfig",
+ "-Djava.locale.providers=" + prefList,
+ "--add-exports=java.base/sun.util.locale.provider=ALL-UNNAMED",
+ "LocaleProviders", methodName, param1, param2, param3);
+ // Evaluate process status
+ int exitCode = ProcessTools.executeCommand(pb).getExitValue();
if (exitCode != 0) {
throw new RuntimeException("Unexpected exit code: " + exitCode);
}
diff --git a/test/jdk/java/util/ResourceBundle/Control/MissingResourceCauseTestRun.java b/test/jdk/java/util/ResourceBundle/Control/MissingResourceCauseTestRun.java
index 0ed86582846bb..30cd81757df6d 100644
--- a/test/jdk/java/util/ResourceBundle/Control/MissingResourceCauseTestRun.java
+++ b/test/jdk/java/util/ResourceBundle/Control/MissingResourceCauseTestRun.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -84,15 +84,13 @@ private static void runCmd() throws Throwable {
// UnreadableRB.properties is in current directory
String cp = Utils.TEST_CLASSES + File.pathSeparator + Utils.TEST_SRC
+ File.pathSeparator + ".";
- JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
- launcher.addToolArg("-ea")
- .addToolArg("-esa")
- .addToolArg("-cp")
- .addToolArg(cp)
- .addToolArg("MissingResourceCauseTest");
-
- int exitCode = ProcessTools.executeCommand(launcher.getCommand())
- .getExitValue();
+ // Build process (with VM flags)
+ ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
+ "-ea", "-esa",
+ "-cp", cp,
+ "MissingResourceCauseTest");
+ // Evaluate process status
+ int exitCode = ProcessTools.executeCommand(pb).getExitValue();
if (exitCode != 0) {
throw new RuntimeException("Execution of the test failed. "
+ "Unexpected exit code: " + exitCode);
diff --git a/test/jdk/java/util/ResourceBundle/modules/ModuleTestUtil.java b/test/jdk/java/util/ResourceBundle/modules/ModuleTestUtil.java
index 1d8bdbb89db15..24c6e181ccc04 100644
--- a/test/jdk/java/util/ResourceBundle/modules/ModuleTestUtil.java
+++ b/test/jdk/java/util/ResourceBundle/modules/ModuleTestUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, 2021, 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
@@ -29,6 +29,7 @@
import java.util.stream.Stream;
import jdk.test.lib.JDKToolLauncher;
+import jdk.test.lib.Utils;
import jdk.test.lib.compiler.CompilerUtils;
import jdk.test.lib.process.ProcessTools;
@@ -133,17 +134,15 @@ public static void copyResFiles(Path src, Path dest, String mn,
*/
public static void runModule(String mp, String mn, List localeList)
throws Throwable {
- JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
- launcher.addToolArg("-ea")
- .addToolArg("-esa")
- .addToolArg("-p")
- .addToolArg(mp)
- .addToolArg("-m")
- .addToolArg(mn);
- localeList.forEach(launcher::addToolArg);
-
- int exitCode = ProcessTools.executeCommand(launcher.getCommand())
- .getExitValue();
+ List args = List.of(
+ "-ea", "-esa",
+ "-p", mp,
+ "-m", mn);
+ // Build process (with VM flags)
+ ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
+ Stream.concat(args.stream(), localeList.stream()).toList());
+ // Evaluate process status
+ int exitCode = ProcessTools.executeCommand(pb).getExitValue();
if (exitCode != 0) {
throw new RuntimeException("Execution of the test failed. "
+ "Unexpected exit code: " + exitCode);
@@ -161,19 +160,17 @@ public static void runModule(String mp, String mn, List localeList)
*/
public static void runModuleWithCp(String cp, String mp, String mn,
List localeList, boolean expected) throws Throwable {
- JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
- launcher.addToolArg("-ea")
- .addToolArg("-esa")
- .addToolArg("-cp")
- .addToolArg(cp)
- .addToolArg("-p")
- .addToolArg(mp)
- .addToolArg("-m")
- .addToolArg(mn);
- localeList.forEach(launcher::addToolArg);
+ List args = List.of(
+ "-ea", "-esa",
+ "-cp", cp,
+ "-p", mp,
+ "-m", mn);
+ // Build process (with VM flags)
+ ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
+ Stream.concat(args.stream(), localeList.stream()).toList());
+ // Evaluate process status
+ int exitCode = ProcessTools.executeCommand(pb).getExitValue();
- int exitCode = ProcessTools.executeCommand(launcher.getCommand())
- .getExitValue();
if (expected) {
if (exitCode != 0) {
throw new RuntimeException("Execution of the test loads bundles "
@@ -198,18 +195,17 @@ public static void runModuleWithCp(String cp, String mp, String mn,
*/
public static void runModuleWithLegacyCode(String mp, String mn, List localeList)
throws Throwable {
- JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
- launcher.addToolArg("-ea")
- .addToolArg("-esa")
- .addToolArg("-Djava.locale.useOldISOCodes=true")
- .addToolArg("-p")
- .addToolArg(mp)
- .addToolArg("-m")
- .addToolArg(mn);
- localeList.forEach(launcher::addToolArg);
+ List args = List.of(
+ "-ea", "-esa",
+ "-Djava.locale.useOldISOCodes=true",
+ "-p", mp,
+ "-m", mn);
+ // Build process (with VM flags)
+ ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
+ Stream.concat(args.stream(), localeList.stream()).toList());
+ // Evaluate process status
+ int exitCode = ProcessTools.executeCommand(pb).getExitValue();
- int exitCode = ProcessTools.executeCommand(launcher.getCommand())
- .getExitValue();
if (exitCode != 0) {
throw new RuntimeException("Execution of the test failed. "
+ "Unexpected exit code: " + exitCode);
diff --git a/test/jdk/java/util/ResourceBundle/modules/layer/LayerTest.java b/test/jdk/java/util/ResourceBundle/modules/layer/LayerTest.java
index b1c79c0367f6f..85e8e531a31ab 100644
--- a/test/jdk/java/util/ResourceBundle/modules/layer/LayerTest.java
+++ b/test/jdk/java/util/ResourceBundle/modules/layer/LayerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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
@@ -71,16 +71,13 @@ private static void compileCmd() throws Throwable {
}
private static void runCmd() throws Throwable {
- JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
- launcher.addToolArg("-ea")
- .addToolArg("-esa")
- .addToolArg("-cp")
- .addToolArg(Utils.TEST_CLASSES)
- .addToolArg("Main")
- .addToolArg(Utils.TEST_CLASSES);
-
- int exitCode = ProcessTools.executeCommand(launcher.getCommand())
- .getExitValue();
+ // Build process (with VM flags)
+ ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
+ "-ea", "-esa",
+ "-cp", Utils.TEST_CLASSES,
+ "Main", Utils.TEST_CLASSES);
+ // Evaluate process status
+ int exitCode = ProcessTools.executeCommand(pb).getExitValue();
if (exitCode != 0) {
throw new RuntimeException("Execution of the test failed. "
+ "Unexpected exit code: " + exitCode);
diff --git a/test/jdk/java/util/ResourceBundle/modules/unnamed/UnNamedTest.java b/test/jdk/java/util/ResourceBundle/modules/unnamed/UnNamedTest.java
index 4540d5a378b1a..e9567fcdaadc9 100644
--- a/test/jdk/java/util/ResourceBundle/modules/unnamed/UnNamedTest.java
+++ b/test/jdk/java/util/ResourceBundle/modules/unnamed/UnNamedTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
+import java.util.stream.Stream;
import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.Utils;
@@ -73,42 +74,34 @@ private static void compileCmd() throws Throwable {
private static void runCmd() throws Throwable {
// access resource bundles that are exported private unconditionally.
- JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
- launcher.addToolArg("-ea")
- .addToolArg("-esa")
- .addToolArg("-cp")
- .addToolArg(Utils.TEST_CLASSES)
- .addToolArg("--module-path")
- .addToolArg(MODS_DIR.toString())
- .addToolArg("--add-modules")
- .addToolArg("bundles")
- .addToolArg("Main");
- LOCALE_LIST.forEach(launcher::addToolArg);
-
- int exitCode = ProcessTools.executeCommand(launcher.getCommand())
- .getExitValue();
+ List args = List.of(
+ "-ea", "-esa",
+ "-cp", Utils.TEST_CLASSES,
+ "--module-path", MODS_DIR.toString(),
+ "--add-modules", "bundles",
+ "Main");
+ ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
+ Stream.concat(args.stream(), LOCALE_LIST.stream()).toList());
+ // Evaluate process status
+ int exitCode = ProcessTools.executeCommand(pb).getExitValue();
if (exitCode != 0) {
throw new RuntimeException("Execution of the test1 failed. "
+ "Unexpected exit code: " + exitCode);
}
// --add-exports can't open resources
- launcher = JDKToolLauncher.createUsingTestJDK("java");
- launcher.addToolArg("-ea")
- .addToolArg("-esa")
- .addToolArg("-cp")
- .addToolArg(Utils.TEST_CLASSES)
- .addToolArg("--module-path")
- .addToolArg(MODS_DIR.toString())
- .addToolArg("--add-modules")
- .addToolArg("bundles")
- .addToolArg("--add-opens")
- .addToolArg("bundles/jdk.test.internal.resources=ALL-UNNAMED")
- .addToolArg("Main");
- LOCALE_LIST.forEach(launcher::addToolArg);
+ List argsWithOpens = List.of(
+ "-ea", "-esa",
+ "-cp", Utils.TEST_CLASSES,
+ "--module-path", MODS_DIR.toString(),
+ "--add-modules", "bundles",
+ "--add-opens", "bundles/jdk.test.internal.resources=ALL-UNNAMED",
+ "Main");
+ pb = ProcessTools.createTestJavaProcessBuilder(
+ Stream.concat(argsWithOpens.stream(), LOCALE_LIST.stream()).toList());
- exitCode = ProcessTools.executeCommand(launcher.getCommand())
- .getExitValue();
+ // Evaluate process status
+ exitCode = ProcessTools.executeCommand(pb).getExitValue();
if (exitCode != 0) {
throw new RuntimeException("Execution of the test2 failed. "
+ "Unexpected exit code: " + exitCode);
diff --git a/test/jdk/java/util/ResourceBundle/modules/visibility/VisibilityTest.java b/test/jdk/java/util/ResourceBundle/modules/visibility/VisibilityTest.java
index 7f9405863376d..b81c69a426938 100644
--- a/test/jdk/java/util/ResourceBundle/modules/visibility/VisibilityTest.java
+++ b/test/jdk/java/util/ResourceBundle/modules/visibility/VisibilityTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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,10 +39,12 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
+import java.util.stream.Stream;
import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.Utils;
import jdk.test.lib.process.ProcessTools;
+
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -328,11 +330,10 @@ public void RunWithPkgRes(List argsList) throws Throwable {
}
private int runCmd(List argsList) throws Throwable {
- JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
- launcher.addToolArg("-ea")
- .addToolArg("-esa");
- argsList.forEach(launcher::addToolArg);
-
- return ProcessTools.executeCommand(launcher.getCommand()).getExitValue();
+ // Build process (with VM flags)
+ ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
+ Stream.concat(Stream.of("-ea", "-esa"), argsList.stream()).toList());
+ // Evaluate process status
+ return ProcessTools.executeCommand(pb).getExitValue();
}
-}
\ No newline at end of file
+}
diff --git a/test/jdk/java/util/TimeZone/CustomTzIDCheckDST.java b/test/jdk/java/util/TimeZone/CustomTzIDCheckDST.java
index ece90a9d7cd5e..5fd48efadcc3a 100644
--- a/test/jdk/java/util/TimeZone/CustomTzIDCheckDST.java
+++ b/test/jdk/java/util/TimeZone/CustomTzIDCheckDST.java
@@ -29,16 +29,18 @@
* @requires os.family != "windows"
* @run main/othervm CustomTzIDCheckDST
*/
+
import java.util.Calendar;
import java.util.Date;
-import java.util.List;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
import java.time.DayOfWeek;
import java.time.ZonedDateTime;
import java.time.temporal.TemporalAdjusters;
+
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
+
public class CustomTzIDCheckDST {
// Northern Hemisphere
private static String CUSTOM_TZ = "MEZ-1MESZ,M3.5.0,M10.5.0/3";
@@ -46,7 +48,7 @@ public class CustomTzIDCheckDST {
private static String CUSTOM_TZ2 = "MEZ-1MESZ,M10.5.0,M3.5.0/3";
public static void main(String args[]) throws Throwable {
if (args.length == 0) {
- ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(List.of("CustomTzIDCheckDST", "runTZTest"));
+ ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("CustomTzIDCheckDST", "runTZTest");
pb.environment().put("TZ", CUSTOM_TZ);
OutputAnalyzer output = ProcessTools.executeProcess(pb);
output.shouldHaveExitValue(0);
diff --git a/test/jdk/java/util/TimeZone/TimeZoneDatePermissionCheckRun.java b/test/jdk/java/util/TimeZone/TimeZoneDatePermissionCheckRun.java
index c510c39cd165b..f5d80cd6069a3 100644
--- a/test/jdk/java/util/TimeZone/TimeZoneDatePermissionCheckRun.java
+++ b/test/jdk/java/util/TimeZone/TimeZoneDatePermissionCheckRun.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -66,17 +66,15 @@ public static void main(String[] args) throws Throwable {
//run it with the security manager on, plus accesscontroller debugging
//will go into infinite recursion trying to get enough permissions for
//printing Date of failing certificate unless fix is applied.
- JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
- launcher.addToolArg("-Djava.security.manager")
- .addToolArg("-Djava.security.debug=access,failure,policy")
- .addToolArg("-ea")
- .addToolArg("-esa")
- .addToolArg("-cp")
- .addToolArg(jarPath)
- .addToolArg("TimeZoneDatePermissionCheck");
-
- int exitCode = ProcessTools.executeCommand(launcher.getCommand())
- .getExitValue();
+ // Build process (with VM flags)
+ ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
+ "-Djava.security.manager",
+ "-Djava.security.debug=access,failure,policy",
+ "-ea", "-esa",
+ "-cp", jarPath,
+ "TimeZoneDatePermissionCheck");
+ // Evaluate process status
+ int exitCode = ProcessTools.executeCommand(pb).getExitValue();
if (exitCode != 0) {
throw new RuntimeException("Unexpected exit code: " + exitCode);
}
diff --git a/test/jdk/java/util/logging/LoggingDeadlock2.java b/test/jdk/java/util/logging/LoggingDeadlock2.java
index 4aa3121abc1cd..e8a0bb49d87d6 100644
--- a/test/jdk/java/util/logging/LoggingDeadlock2.java
+++ b/test/jdk/java/util/logging/LoggingDeadlock2.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -25,11 +25,12 @@
* @test
* @bug 6467152 6716076 6829503 8132550
* @summary deadlock occurs in LogManager initialization and JVM termination
+ * @key randomness
+ * @library /test/lib
* @author Serguei Spitsyn / Hitachi / Martin Buchholz
*
* @build LoggingDeadlock2
* @run main LoggingDeadlock2
- * @key randomness
*/
/*
@@ -50,7 +51,6 @@
* This is a regression test for this bug.
*/
-import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CyclicBarrier;
@@ -63,6 +63,8 @@
import java.io.Reader;
import java.util.concurrent.TimeUnit;
+import jdk.test.lib.process.ProcessTools;
+
public class LoggingDeadlock2 {
// ask child process to dumpstack after 60secs
@@ -74,7 +76,9 @@ public class LoggingDeadlock2 {
public static void realMain(String arg[]) throws Throwable {
try {
System.out.println(javaChildArgs);
- ProcessBuilder pb = new ProcessBuilder(javaChildArgs);
+ // Build process (with VM flags)
+ ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
+ javaChildArgs);
ProcessResults r = run(pb.start());
equal(r.exitValue(), 99);
@@ -151,9 +155,6 @@ public void run() {
//----------------------------------------------------------------
// The rest of this test is copied from ProcessBuilder/Basic.java
//----------------------------------------------------------------
- private static final String javaExe =
- System.getProperty("java.home") +
- File.separator + "bin" + File.separator + "java";
private static final String jstackExe =
System.getProperty("java.home") +
File.separator + "bin" + File.separator + "jstack";
@@ -161,10 +162,8 @@ public void run() {
private static final String classpath =
System.getProperty("java.class.path");
- private static final List javaChildArgs =
- Arrays.asList(new String[]
- { javaExe, "-classpath", classpath,
- "LoggingDeadlock2$JavaChild"});
+ private static final List javaChildArgs = List.of(
+ "-classpath", classpath, "LoggingDeadlock2$JavaChild");
private static class ProcessResults {
private final String out;
diff --git a/test/jdk/java/util/zip/EntryCount64k.java b/test/jdk/java/util/zip/EntryCount64k.java
index 68b86e50ece23..08d896a124a2a 100644
--- a/test/jdk/java/util/zip/EntryCount64k.java
+++ b/test/jdk/java/util/zip/EntryCount64k.java
@@ -37,7 +37,6 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.RandomAccessFile;
-import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -161,11 +160,7 @@ static void checkCanRead(File zipFile, int entryCount) throws Throwable {
}
// Check java -jar
- String javaHome = System.getProperty("java.home");
- String java = Paths.get(javaHome, "bin", "java").toString();
- String[] cmd = { java, "-jar", zipFile.getName() };
- ProcessBuilder pb = new ProcessBuilder(cmd);
- OutputAnalyzer a = ProcessTools.executeProcess(pb);
+ OutputAnalyzer a = ProcessTools.executeTestJvm("-jar", zipFile.getName());
a.shouldHaveExitValue(0);
a.stdoutShouldMatch("\\AMain\\Z");
a.stderrShouldMatch("\\A\\Z");
From 864b39a89398731bfde9af10c3d7797ff5d05760 Mon Sep 17 00:00:00 2001
From: Feilong Jiang
Date: Thu, 23 Nov 2023 00:50:27 +0000
Subject: [PATCH 036/250] 8320564: RISC-V: Minimal build failed after
JDK-8316592
Reviewed-by: fyang, shade
---
.../cpu/riscv/macroAssembler_riscv.cpp | 35 ++++++++++---------
.../cpu/riscv/macroAssembler_riscv.hpp | 7 ++--
2 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
index 5201486c8c634..8f516f38e7d9a 100644
--- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
+++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
@@ -2048,23 +2048,6 @@ void MacroAssembler::cmp_klass(Register oop, Register trial_klass, Register tmp1
beq(trial_klass, tmp1, L);
}
-// Multiply and multiply-accumulate unsigned 64-bit registers.
-void MacroAssembler::wide_mul(Register prod_lo, Register prod_hi, Register n, Register m) {
- assert_different_registers(prod_lo, prod_hi);
-
- mul(prod_lo, n, m);
- mulhu(prod_hi, n, m);
-}
-void MacroAssembler::wide_madd(Register sum_lo, Register sum_hi, Register n,
- Register m, Register tmp1, Register tmp2) {
- assert_different_registers(sum_lo, sum_hi);
- assert_different_registers(sum_hi, tmp2);
-
- wide_mul(tmp1, tmp2, n, m);
- cad(sum_lo, sum_lo, tmp1, tmp1); // Add tmp1 to sum_lo with carry output to tmp1
- adc(sum_hi, sum_hi, tmp2, tmp1); // Add tmp2 with carry to sum_hi
-}
-
// Move an oop into a register.
void MacroAssembler::movoop(Register dst, jobject obj) {
int oop_index;
@@ -3576,6 +3559,24 @@ void MacroAssembler::mul_add(Register out, Register in, Register offset,
bind(L_end);
}
+// Multiply and multiply-accumulate unsigned 64-bit registers.
+void MacroAssembler::wide_mul(Register prod_lo, Register prod_hi, Register n, Register m) {
+ assert_different_registers(prod_lo, prod_hi);
+
+ mul(prod_lo, n, m);
+ mulhu(prod_hi, n, m);
+}
+
+void MacroAssembler::wide_madd(Register sum_lo, Register sum_hi, Register n,
+ Register m, Register tmp1, Register tmp2) {
+ assert_different_registers(sum_lo, sum_hi);
+ assert_different_registers(sum_hi, tmp2);
+
+ wide_mul(tmp1, tmp2, n, m);
+ cad(sum_lo, sum_lo, tmp1, tmp1); // Add tmp1 to sum_lo with carry output to tmp1
+ adc(sum_hi, sum_hi, tmp2, tmp1); // Add tmp2 with carry to sum_hi
+}
+
// add two unsigned input and output carry
void MacroAssembler::cad(Register dst, Register src1, Register src2, Register carry)
{
diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp
index 51bcba2f1a3fc..1a8271166a9cc 100644
--- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp
+++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp
@@ -198,10 +198,6 @@ class MacroAssembler: public Assembler {
void store_klass(Register dst, Register src, Register tmp = t0);
void cmp_klass(Register oop, Register trial_klass, Register tmp1, Register tmp2, Label &L);
- void wide_mul(Register prod_lo, Register prod_hi, Register n, Register m);
- void wide_madd(Register sum_lo, Register sum_hi, Register n,
- Register m, Register tmp1, Register tmp2);
-
void encode_klass_not_null(Register r, Register tmp = t0);
void decode_klass_not_null(Register r, Register tmp = t0);
void encode_klass_not_null(Register dst, Register src, Register tmp);
@@ -1204,6 +1200,9 @@ class MacroAssembler: public Assembler {
#ifdef COMPILER2
void mul_add(Register out, Register in, Register offset,
Register len, Register k, Register tmp);
+ void wide_mul(Register prod_lo, Register prod_hi, Register n, Register m);
+ void wide_madd(Register sum_lo, Register sum_hi, Register n,
+ Register m, Register tmp1, Register tmp2);
void cad(Register dst, Register src1, Register src2, Register carry);
void cadc(Register dst, Register src1, Register src2, Register carry);
void adc(Register dst, Register src1, Register src2, Register carry);
From 14193a049ebcbd3639962729c631293b8d3a9114 Mon Sep 17 00:00:00 2001
From: Jan Lahoda
Date: Thu, 23 Nov 2023 07:15:43 +0000
Subject: [PATCH 037/250] 8314614: jdk/jshell/ImportTest.java failed with
"InternalError: Failed remote listen" 8312140: jdk/jshell tests failed with
JDI socket timeouts
Reviewed-by: asotona
---
.../jdk/jshell/AnalyzeSnippetTest.java | 1 +
.../jdk/jshell/CustomInputToolBuilder.java | 3 +-
.../jdk/jshell/ExecutionControlTestBase.java | 20 +------
.../FailOverDirectExecutionControlTest.java | 10 +---
...ilOverExecutionControlDyingLaunchTest.java | 4 +-
...OverExecutionControlHangingLaunchTest.java | 4 +-
...OverExecutionControlHangingListenTest.java | 4 +-
.../jshell/FailOverExecutionControlTest.java | 4 +-
.../langtools/jdk/jshell/IdGeneratorTest.java | 3 +-
test/langtools/jdk/jshell/KullaTesting.java | 7 ++-
test/langtools/jdk/jshell/Presets.java | 59 +++++++++++++++++++
.../langtools/jdk/jshell/ReplToolTesting.java | 2 +-
.../langtools/jdk/jshell/StartOptionTest.java | 2 +-
test/langtools/jdk/jshell/ToolReloadTest.java | 2 +-
test/langtools/jdk/jshell/UITesting.java | 3 +-
15 files changed, 88 insertions(+), 40 deletions(-)
create mode 100644 test/langtools/jdk/jshell/Presets.java
diff --git a/test/langtools/jdk/jshell/AnalyzeSnippetTest.java b/test/langtools/jdk/jshell/AnalyzeSnippetTest.java
index b566a023caff0..3e2e1a839e2bd 100644
--- a/test/langtools/jdk/jshell/AnalyzeSnippetTest.java
+++ b/test/langtools/jdk/jshell/AnalyzeSnippetTest.java
@@ -64,6 +64,7 @@ public void setUp() {
state = JShell.builder()
.out(new PrintStream(new ByteArrayOutputStream()))
.err(new PrintStream(new ByteArrayOutputStream()))
+ .executionEngine(Presets.TEST_DEFAULT_EXECUTION)
.build();
sca = state.sourceCodeAnalysis();
}
diff --git a/test/langtools/jdk/jshell/CustomInputToolBuilder.java b/test/langtools/jdk/jshell/CustomInputToolBuilder.java
index 3b3d5616a9468..523981b3d915c 100644
--- a/test/langtools/jdk/jshell/CustomInputToolBuilder.java
+++ b/test/langtools/jdk/jshell/CustomInputToolBuilder.java
@@ -90,7 +90,8 @@ private void doTest(boolean interactiveTerminal, String code, String... expected
.interactiveTerminal(interactiveTerminal)
.promptCapture(true)
.persistence(new HashMap<>())
- .start("--no-startup");
+ .start("--no-startup",
+ "--execution", Presets.TEST_DEFAULT_EXECUTION);
String actual = new String(out.toByteArray());
List actualLines = Arrays.asList(actual.split("\\R"));
diff --git a/test/langtools/jdk/jshell/ExecutionControlTestBase.java b/test/langtools/jdk/jshell/ExecutionControlTestBase.java
index 9035d84d4a56f..20336c902cffc 100644
--- a/test/langtools/jdk/jshell/ExecutionControlTestBase.java
+++ b/test/langtools/jdk/jshell/ExecutionControlTestBase.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -25,28 +25,14 @@
import org.testng.annotations.Test;
import jdk.jshell.VarSnippet;
-import java.net.InetAddress;
import static jdk.jshell.Snippet.Status.VALID;
import static jdk.jshell.Snippet.SubKind.*;
public class ExecutionControlTestBase extends KullaTesting {
- String standardListenSpec() {
- String loopback = InetAddress.getLoopbackAddress().getHostAddress();
- return "jdi:hostname(" + loopback + ")";
- }
-
- String standardLaunchSpec() {
- return "jdi:launch(true)";
- }
-
- String standardJdiSpec() {
- return "jdi";
- }
-
- String standardSpecs() {
- return "5(" + standardListenSpec() + "), 6(" + standardLaunchSpec() + "), 7(" + standardJdiSpec() + ")";
+ String alwaysPassingSpec() {
+ return "5(local)";
}
@Test
diff --git a/test/langtools/jdk/jshell/FailOverDirectExecutionControlTest.java b/test/langtools/jdk/jshell/FailOverDirectExecutionControlTest.java
index da838798f8ee3..a094ed4a86f3d 100644
--- a/test/langtools/jdk/jshell/FailOverDirectExecutionControlTest.java
+++ b/test/langtools/jdk/jshell/FailOverDirectExecutionControlTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -129,9 +129,7 @@ public void setUp() {
Map pm = provider.defaultParameters();
pm.put("0", "alwaysFailing");
pm.put("1", "alwaysFailing");
- pm.put("2", standardListenSpec());
- pm.put("3", standardLaunchSpec());
- pm.put("4", standardJdiSpec());
+ pm.put("2", "local");
setUp(builder -> builder.executionEngine(provider, pm));
}
@@ -159,9 +157,7 @@ public void variables() {
assertTrue(log.contains("This operation intentionally broken"), log);
log = logged.get(Level.FINEST).get(0);
assertTrue(
- log.contains("Success failover -- 2 = " + standardListenSpec())
- || log.contains("Success failover -- 3 = " + standardLaunchSpec())
- || log.contains("Success failover -- 4 = " + standardJdiSpec()),
+ log.contains("Success failover -- 2 = local"),
log);
}
}
diff --git a/test/langtools/jdk/jshell/FailOverExecutionControlDyingLaunchTest.java b/test/langtools/jdk/jshell/FailOverExecutionControlDyingLaunchTest.java
index f3218fab7c76d..31011960880dd 100644
--- a/test/langtools/jdk/jshell/FailOverExecutionControlDyingLaunchTest.java
+++ b/test/langtools/jdk/jshell/FailOverExecutionControlDyingLaunchTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -43,6 +43,6 @@ public class FailOverExecutionControlDyingLaunchTest extends ExecutionControlTes
public void setUp() {
setUp(builder -> builder.executionEngine(
"failover:0(jdi:remoteAgent(DyingRemoteAgent),launch(true)), "
- + standardSpecs()));
+ + alwaysPassingSpec()));
}
}
diff --git a/test/langtools/jdk/jshell/FailOverExecutionControlHangingLaunchTest.java b/test/langtools/jdk/jshell/FailOverExecutionControlHangingLaunchTest.java
index 778d004915c20..9958b7a3284e6 100644
--- a/test/langtools/jdk/jshell/FailOverExecutionControlHangingLaunchTest.java
+++ b/test/langtools/jdk/jshell/FailOverExecutionControlHangingLaunchTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -42,6 +42,6 @@ public class FailOverExecutionControlHangingLaunchTest extends ExecutionControlT
public void setUp() {
setUp(builder -> builder.executionEngine(
"failover:0(jdi:remoteAgent(HangingRemoteAgent),launch(true)), "
- + standardSpecs()));
+ + alwaysPassingSpec()));
}
}
diff --git a/test/langtools/jdk/jshell/FailOverExecutionControlHangingListenTest.java b/test/langtools/jdk/jshell/FailOverExecutionControlHangingListenTest.java
index f22dd821f4049..4f29bfe9c7a82 100644
--- a/test/langtools/jdk/jshell/FailOverExecutionControlHangingListenTest.java
+++ b/test/langtools/jdk/jshell/FailOverExecutionControlHangingListenTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -45,6 +45,6 @@ public void setUp() {
String loopback = InetAddress.getLoopbackAddress().getHostAddress();
setUp(builder -> builder.executionEngine(
"failover:0(jdi:remoteAgent(HangingRemoteAgent),hostname(" + loopback + ")),"
- + standardSpecs()));
+ + alwaysPassingSpec()));
}
}
diff --git a/test/langtools/jdk/jshell/FailOverExecutionControlTest.java b/test/langtools/jdk/jshell/FailOverExecutionControlTest.java
index 0843351815f87..80dc56d72c484 100644
--- a/test/langtools/jdk/jshell/FailOverExecutionControlTest.java
+++ b/test/langtools/jdk/jshell/FailOverExecutionControlTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -41,7 +41,7 @@ public class FailOverExecutionControlTest extends ExecutionControlTestBase {
@Override
public void setUp() {
setUp(builder -> builder.executionEngine("failover:0(expectedFailureNonExistent1), 1(expectedFailureNonExistent2), "
- + standardSpecs()));
+ + alwaysPassingSpec()));
}
}
diff --git a/test/langtools/jdk/jshell/IdGeneratorTest.java b/test/langtools/jdk/jshell/IdGeneratorTest.java
index 23727aef643a8..e8a38dfe7f05f 100644
--- a/test/langtools/jdk/jshell/IdGeneratorTest.java
+++ b/test/langtools/jdk/jshell/IdGeneratorTest.java
@@ -53,7 +53,8 @@ public JShell.Builder getBuilder() {
return JShell.builder()
.in(inStream)
.out(new PrintStream(outStream))
- .err(new PrintStream(errStream));
+ .err(new PrintStream(errStream))
+ .executionEngine(Presets.TEST_DEFAULT_EXECUTION);
}
public void testTempNameGenerator() {
diff --git a/test/langtools/jdk/jshell/KullaTesting.java b/test/langtools/jdk/jshell/KullaTesting.java
index 369b2ed1f44a2..d74f3484f4bd8 100644
--- a/test/langtools/jdk/jshell/KullaTesting.java
+++ b/test/langtools/jdk/jshell/KullaTesting.java
@@ -100,7 +100,9 @@ public class KullaTesting {
private Set allSnippets = new LinkedHashSet<>();
static {
- JShell js = JShell.create();
+ JShell js = JShell.builder()
+ .executionEngine(Presets.TEST_DEFAULT_EXECUTION)
+ .build();
MAIN_SNIPPET = js.eval("MAIN_SNIPPET").get(0).snippet();
js.close();
assertTrue(MAIN_SNIPPET != null, "Bad MAIN_SNIPPET set-up -- must not be null");
@@ -192,7 +194,8 @@ public int read(byte[] b, int off, int len) throws IOException {
JShell.Builder builder = JShell.builder()
.in(in)
.out(new PrintStream(outStream))
- .err(new PrintStream(errStream));
+ .err(new PrintStream(errStream))
+ .executionEngine(Presets.TEST_DEFAULT_EXECUTION);
bc.accept(builder);
state = builder.build();
allSnippets = new LinkedHashSet<>();
diff --git a/test/langtools/jdk/jshell/Presets.java b/test/langtools/jdk/jshell/Presets.java
new file mode 100644
index 0000000000000..b9a93c967dc71
--- /dev/null
+++ b/test/langtools/jdk/jshell/Presets.java
@@ -0,0 +1,59 @@
+/*
+ * 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.net.InetAddress;
+import java.util.*;
+
+public class Presets {
+ public static final String TEST_DEFAULT_EXECUTION;
+ public static final String TEST_STANDARD_EXECUTION;
+
+ static {
+ String loopback = InetAddress.getLoopbackAddress().getHostAddress();
+
+ TEST_DEFAULT_EXECUTION = "failover:0(jdi:hostname(" + loopback + "))," +
+ "1(jdi:launch(true)), 2(jdi), 3(local)";
+ TEST_STANDARD_EXECUTION = "failover:0(jdi:hostname(" + loopback + "))," +
+ "1(jdi:launch(true)), 2(jdi)";
+ }
+
+ public static String[] addExecutionIfMissing(String[] args) {
+ if (Arrays.stream(args).noneMatch(Presets::remoteRelatedOption)) {
+ List augmentedArgs = new ArrayList<>();
+
+ augmentedArgs.add("--execution");
+ augmentedArgs.add(Presets.TEST_DEFAULT_EXECUTION);
+ augmentedArgs.addAll(List.of(args));
+
+ return augmentedArgs.toArray(s -> new String[s]);
+ }
+
+ return args;
+ }
+
+ private static boolean remoteRelatedOption(String option) {
+ return "--execution".equals(option) ||
+ "--add-modules".equals(option) ||
+ option.startsWith("-R");
+ }
+}
diff --git a/test/langtools/jdk/jshell/ReplToolTesting.java b/test/langtools/jdk/jshell/ReplToolTesting.java
index 09ee4117c1817..52eb2d5798c6f 100644
--- a/test/langtools/jdk/jshell/ReplToolTesting.java
+++ b/test/langtools/jdk/jshell/ReplToolTesting.java
@@ -304,7 +304,7 @@ protected JavaShellToolBuilder builder(Locale locale) {
private void testRaw(Locale locale, String[] args,
String expectedErrorOutput, ReplTest... tests) {
testRawInit(tests);
- testRawRun(locale, args);
+ testRawRun(locale, Presets.addExecutionIfMissing(args));
testRawCheck(locale, expectedErrorOutput);
}
diff --git a/test/langtools/jdk/jshell/StartOptionTest.java b/test/langtools/jdk/jshell/StartOptionTest.java
index df445d49750a8..aa8d9be03a9ef 100644
--- a/test/langtools/jdk/jshell/StartOptionTest.java
+++ b/test/langtools/jdk/jshell/StartOptionTest.java
@@ -81,7 +81,7 @@ private JavaShellToolBuilder builder() {
protected int runShell(String... args) {
try {
return builder()
- .start(args);
+ .start(Presets.addExecutionIfMissing(args));
} catch (Exception ex) {
fail("Repl tool died with exception", ex);
}
diff --git a/test/langtools/jdk/jshell/ToolReloadTest.java b/test/langtools/jdk/jshell/ToolReloadTest.java
index 13d583e51f5c1..4709584cd1268 100644
--- a/test/langtools/jdk/jshell/ToolReloadTest.java
+++ b/test/langtools/jdk/jshell/ToolReloadTest.java
@@ -201,7 +201,7 @@ public void testReloadCrashRestore() {
}
public void testEnvBadModule() {
- test(
+ test(new String[] {"--execution", Presets.TEST_STANDARD_EXECUTION},
(a) -> assertVariable(a, "int", "x", "5", "5"),
(a) -> assertMethod(a, "int m(int z) { return z * z; }",
"(int)int", "m"),
diff --git a/test/langtools/jdk/jshell/UITesting.java b/test/langtools/jdk/jshell/UITesting.java
index 484bfde266212..473ba36c5aedb 100644
--- a/test/langtools/jdk/jshell/UITesting.java
+++ b/test/langtools/jdk/jshell/UITesting.java
@@ -93,7 +93,8 @@ protected void doRunTest(Test test) throws Exception {
.promptCapture(true)
.persistence(new HashMap<>())
.locale(Locale.US)
- .run("--no-startup");
+ .run("--no-startup",
+ "--execution", Presets.TEST_DEFAULT_EXECUTION);
} catch (Exception ex) {
throw new IllegalStateException(ex);
}
From 06d957fd7c1ff59f314315969a545a8f4a5137be Mon Sep 17 00:00:00 2001
From: Aleksey Shipilev
Date: Thu, 23 Nov 2023 08:20:38 +0000
Subject: [PATCH 038/250] 8320582: Zero: Misplaced CX8 enablement flag
Reviewed-by: dholmes
---
src/hotspot/cpu/zero/vm_version_zero.cpp | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/hotspot/cpu/zero/vm_version_zero.cpp b/src/hotspot/cpu/zero/vm_version_zero.cpp
index 07f99d647ac60..a99885a533df8 100644
--- a/src/hotspot/cpu/zero/vm_version_zero.cpp
+++ b/src/hotspot/cpu/zero/vm_version_zero.cpp
@@ -137,6 +137,12 @@ void VM_Version::initialize() {
#ifdef ASSERT
UNSUPPORTED_OPTION(CountCompiledCalls);
#endif
+
+ // Supports 8-byte cmpxchg with compiler built-ins.
+ // These built-ins are supposed to be implemented on
+ // all platforms (even if not natively), so we claim
+ // the support unconditionally.
+ _supports_cx8 = true;
}
void VM_Version::initialize_cpu_information(void) {
@@ -145,12 +151,6 @@ void VM_Version::initialize_cpu_information(void) {
return;
}
- // Supports 8-byte cmpxchg with compiler built-ins.
- // These built-ins are supposed to be implemented on
- // all platforms (even if not natively), so we claim
- // the support unconditionally.
- _supports_cx8 = true;
-
_no_of_cores = os::processor_count();
_no_of_threads = _no_of_cores;
_no_of_sockets = _no_of_cores;
From c49fb4fca278a35795023116df1023c9018f0844 Mon Sep 17 00:00:00 2001
From: Christian Hagedorn
Date: Thu, 23 Nov 2023 08:36:34 +0000
Subject: [PATCH 039/250] 8320403: C2: PrintIdeal is no longer dumped to tty
when xtty is set
Reviewed-by: kvn, thartmann
---
src/hotspot/share/opto/compile.cpp | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/hotspot/share/opto/compile.cpp b/src/hotspot/share/opto/compile.cpp
index 9d899933c2e8f..cda46c11841db 100644
--- a/src/hotspot/share/opto/compile.cpp
+++ b/src/hotspot/share/opto/compile.cpp
@@ -590,10 +590,12 @@ void Compile::print_ideal_ir(const char* phase_name) {
compile_id(),
is_osr_compilation() ? " compile_kind='osr'" : "",
phase_name);
- xtty->print("%s", ss.as_string()); // print to tty would use xml escape encoding
+ }
+
+ tty->print("%s", ss.as_string());
+
+ if (xtty != nullptr) {
xtty->tail("ideal");
- } else {
- tty->print("%s", ss.as_string());
}
}
#endif
From 8db7bad992a0f31de9c7e00c2657c18670539102 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Lund=C3=A9n?=
Date: Thu, 23 Nov 2023 08:42:09 +0000
Subject: [PATCH 040/250] 8319813: Remove upper limit on number of compiler
phases in phasetype.hpp
Reviewed-by: chagedorn, rcastanedalo, epeter
---
.../share/compiler/compilerDirectives.cpp | 20 ++++++++--------
.../share/compiler/compilerDirectives.hpp | 12 +++++++---
src/hotspot/share/compiler/compilerOracle.cpp | 3 +--
.../share/compiler/directivesParser.cpp | 5 ++--
src/hotspot/share/opto/compile.cpp | 2 +-
src/hotspot/share/opto/phasetype.hpp | 23 +++++++++++++------
6 files changed, 40 insertions(+), 25 deletions(-)
diff --git a/src/hotspot/share/compiler/compilerDirectives.cpp b/src/hotspot/share/compiler/compilerDirectives.cpp
index c76ef6de01d46..d7d4c5b60ed7f 100644
--- a/src/hotspot/share/compiler/compilerDirectives.cpp
+++ b/src/hotspot/share/compiler/compilerDirectives.cpp
@@ -297,8 +297,11 @@ void DirectiveSet::init_control_intrinsic() {
}
}
-DirectiveSet::DirectiveSet(CompilerDirectives* d) :_inlinematchers(nullptr), _directive(d) {
- _ideal_phase_name_mask = 0;
+DirectiveSet::DirectiveSet(CompilerDirectives* d) :
+ _inlinematchers(nullptr),
+ _directive(d),
+ _ideal_phase_name_set(PHASE_NUM_TYPES, mtCompiler)
+{
#define init_defaults_definition(name, type, dvalue, compiler) this->name##Option = dvalue;
compilerdirectives_common_flags(init_defaults_definition)
compilerdirectives_c2_flags(init_defaults_definition)
@@ -427,18 +430,17 @@ DirectiveSet* DirectiveSet::compilecommand_compatibility_init(const methodHandle
compilerdirectives_c1_flags(init_default_cc)
#undef init_default_cc
- // Parse PrintIdealPhaseName and create an efficient lookup mask
+ // Parse PrintIdealPhaseName and create a lookup set
#ifndef PRODUCT
#ifdef COMPILER2
if (!_modified[PrintIdealPhaseIndex]) {
- // Parse ccstr and create mask
+ // Parse ccstr and create set
ccstrlist option;
if (CompilerOracle::has_option_value(method, CompileCommand::PrintIdealPhase, option)) {
- uint64_t mask = 0;
- PhaseNameValidator validator(option, mask);
+ PhaseNameValidator validator(option);
if (validator.is_valid()) {
- assert(mask != 0, "Must be set");
- set.cloned()->_ideal_phase_name_mask = mask;
+ assert(!validator.phase_name_set().is_empty(), "Phase name set must be non-empty");
+ set.cloned()->set_ideal_phase_name_set(validator.phase_name_set());
}
}
}
@@ -621,7 +623,7 @@ DirectiveSet* DirectiveSet::clone(DirectiveSet const* src) {
#undef copy_string_members_definition
set->_intrinsic_control_words = src->_intrinsic_control_words;
- set->_ideal_phase_name_mask = src->_ideal_phase_name_mask;
+ set->set_ideal_phase_name_set(src->_ideal_phase_name_set);
return set;
}
diff --git a/src/hotspot/share/compiler/compilerDirectives.hpp b/src/hotspot/share/compiler/compilerDirectives.hpp
index a252ad02889c3..4c9b51724f9a3 100644
--- a/src/hotspot/share/compiler/compilerDirectives.hpp
+++ b/src/hotspot/share/compiler/compilerDirectives.hpp
@@ -31,6 +31,8 @@
#include "compiler/compiler_globals.hpp"
#include "compiler/methodMatcher.hpp"
#include "compiler/compilerOracle.hpp"
+#include "opto/phasetype.hpp"
+#include "utilities/bitMap.hpp"
#include "utilities/exceptions.hpp"
#include "utilities/tribool.hpp"
@@ -128,7 +130,7 @@ class DirectiveSet : public CHeapObj {
InlineMatcher* _inlinematchers;
CompilerDirectives* _directive;
TriBoolArray<(size_t)vmIntrinsics::number_of_intrinsics(), int> _intrinsic_control_words;
- uint64_t _ideal_phase_name_mask;
+ CHeapBitMap _ideal_phase_name_set;
public:
DirectiveSet(CompilerDirectives* directive);
@@ -197,8 +199,12 @@ void set_##name(void* value) { \
compilerdirectives_c1_string_flags(set_string_function_definition)
#undef set_string_function_definition
- void set_ideal_phase_mask(uint64_t mask) { _ideal_phase_name_mask = mask; };
- uint64_t ideal_phase_mask() { return _ideal_phase_name_mask; };
+ void set_ideal_phase_name_set(const BitMap& set) {
+ _ideal_phase_name_set.set_from(set);
+ };
+ bool should_print_phase(const CompilerPhaseType cpt) const {
+ return _ideal_phase_name_set.at(cpt);
+ };
void print_intx(outputStream* st, ccstr n, intx v, bool mod) { if (mod) { st->print("%s:" INTX_FORMAT " ", n, v); } }
void print_uintx(outputStream* st, ccstr n, intx v, bool mod) { if (mod) { st->print("%s:" UINTX_FORMAT " ", n, v); } }
diff --git a/src/hotspot/share/compiler/compilerOracle.cpp b/src/hotspot/share/compiler/compilerOracle.cpp
index 695d5eee0cc29..66eea29fcc136 100644
--- a/src/hotspot/share/compiler/compilerOracle.cpp
+++ b/src/hotspot/share/compiler/compilerOracle.cpp
@@ -777,8 +777,7 @@ static void scan_value(enum OptionType type, char* line, int& total_bytes_read,
}
#ifndef PRODUCT
else if (option == CompileCommand::PrintIdealPhase) {
- uint64_t mask = 0;
- PhaseNameValidator validator(value, mask);
+ PhaseNameValidator validator(value);
if (!validator.is_valid()) {
jio_snprintf(errorbuf, buf_size, "Unrecognized phase name in %s: %s", option2name(option), validator.what());
diff --git a/src/hotspot/share/compiler/directivesParser.cpp b/src/hotspot/share/compiler/directivesParser.cpp
index 0f6978bade86b..60955615133e2 100644
--- a/src/hotspot/share/compiler/directivesParser.cpp
+++ b/src/hotspot/share/compiler/directivesParser.cpp
@@ -336,12 +336,11 @@ bool DirectivesParser::set_option_flag(JSON_TYPE t, JSON_VAL* v, const key* opti
error(VALUE_ERROR, "Unrecognized intrinsic detected in DisableIntrinsic: %s", validator.what());
}
} else if (strncmp(option_key->name, "PrintIdealPhase", 15) == 0) {
- uint64_t mask = 0;
- PhaseNameValidator validator(s, mask);
+ PhaseNameValidator validator(s);
valid = validator.is_valid();
if (valid) {
- set->set_ideal_phase_mask(mask);
+ set->set_ideal_phase_name_set(validator.phase_name_set());
} else {
error(VALUE_ERROR, "Unrecognized phase name detected in PrintIdealPhase: %s", validator.what());
}
diff --git a/src/hotspot/share/opto/compile.cpp b/src/hotspot/share/opto/compile.cpp
index cda46c11841db..8a5e98eda9218 100644
--- a/src/hotspot/share/opto/compile.cpp
+++ b/src/hotspot/share/opto/compile.cpp
@@ -5143,7 +5143,7 @@ void Compile::end_method() {
bool Compile::should_print_phase(CompilerPhaseType cpt) {
#ifndef PRODUCT
- if ((_directive->ideal_phase_mask() & CompilerPhaseTypeHelper::to_bitmask(cpt)) != 0) {
+ if (_directive->should_print_phase(cpt)) {
return true;
}
#endif
diff --git a/src/hotspot/share/opto/phasetype.hpp b/src/hotspot/share/opto/phasetype.hpp
index ce27cd2a7f172..c21f2b50418c8 100644
--- a/src/hotspot/share/opto/phasetype.hpp
+++ b/src/hotspot/share/opto/phasetype.hpp
@@ -25,6 +25,8 @@
#ifndef SHARE_OPTO_PHASETYPE_HPP
#define SHARE_OPTO_PHASETYPE_HPP
+#include "utilities/bitMap.inline.hpp"
+
#define COMPILER_PHASES(flags) \
flags(BEFORE_STRINGOPTS, "Before StringOpts") \
flags(AFTER_STRINGOPTS, "After StringOpts") \
@@ -100,9 +102,6 @@ class CompilerPhaseTypeHelper {
static const char* to_description(CompilerPhaseType cpt) {
return phase_descriptions[cpt];
}
- static uint64_t to_bitmask(CompilerPhaseType cpt) {
- return (UINT64_C(1) << cpt);
- }
};
static CompilerPhaseType find_phase(const char* str) {
@@ -157,11 +156,16 @@ class PhaseNameIter {
class PhaseNameValidator {
private:
+ CHeapBitMap _phase_name_set;
bool _valid;
char* _bad;
public:
- PhaseNameValidator(ccstrlist option, uint64_t& mask) : _valid(true), _bad(nullptr) {
+ PhaseNameValidator(ccstrlist option) :
+ _phase_name_set(PHASE_NUM_TYPES, mtCompiler),
+ _valid(true),
+ _bad(nullptr)
+ {
for (PhaseNameIter iter(option); *iter != nullptr && _valid; ++iter) {
CompilerPhaseType cpt = find_phase(*iter);
@@ -172,10 +176,10 @@ class PhaseNameValidator {
strncpy(_bad, *iter, len);
_valid = false;
} else if (PHASE_ALL == cpt) {
- mask = ~(UINT64_C(0));
+ _phase_name_set.set_range(0, PHASE_NUM_TYPES);
} else {
- assert(cpt < 64, "out of bounds");
- mask |= CompilerPhaseTypeHelper::to_bitmask(cpt);
+ assert(cpt < PHASE_NUM_TYPES, "out of bounds");
+ _phase_name_set.set_bit(cpt);
}
}
}
@@ -186,6 +190,11 @@ class PhaseNameValidator {
}
}
+ const BitMap& phase_name_set() const {
+ assert(is_valid(), "Use of invalid phase name set");
+ return _phase_name_set;
+ }
+
bool is_valid() const {
return _valid;
}
From 99b9cb0a2eae1196f2127cd48e4085f19a90c4b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ivan=20=C5=A0ipka?=
Date: Thu, 23 Nov 2023 10:31:23 +0000
Subject: [PATCH 041/250] 8320586: update manual test/jdk/TEST.groups
Reviewed-by: msheppar
---
test/jdk/TEST.groups | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/test/jdk/TEST.groups b/test/jdk/TEST.groups
index 2f39f3fdceffb..ce127ca579b57 100644
--- a/test/jdk/TEST.groups
+++ b/test/jdk/TEST.groups
@@ -579,7 +579,9 @@ jdk_nio_networkchannel = \
jdk_core_manual = \
:jdk_core_manual_no_input \
- :jdk_core_manual_no_input_security
+ :jdk_security_manual_no_input \
+ :jdk_core_manual_interactive \
+ :jdk_security_manual_interactive
jdk_core_manual_no_input = \
java/net/HugeDataTransferTest.java \
@@ -598,7 +600,7 @@ jdk_core_manual_no_input = \
com/sun/net/httpserver/simpleserver/jwebserver/CommandLinePortNotSpecifiedTest.java \
javax/xml/jaxp/datatype/8033980/GregorianCalAndDurSerDataUtil.java
-jdk_core_manual_no_input_security = \
+jdk_security_manual_no_input = \
com/sun/crypto/provider/Cipher/DES/PerformanceTest.java \
com/sun/crypto/provider/Cipher/AEAD/GCMIncrementByte4.java \
com/sun/crypto/provider/Cipher/AEAD/GCMIncrementDirect4.java \
@@ -625,14 +627,15 @@ jdk_core_manual_no_input_security = \
jdk_core_manual_interactive = \
com/sun/jndi/dns/Test6991580.java \
java/util/TimeZone/DefaultTimeZoneTest.java \
- sun/security/tools/keytool/i18n.java \
java/nio/MappedByteBuffer/PmemTest.java \
java/rmi/registry/nonLocalRegistry/NonLocalRegistryTest.java \
- java/rmi/registry/nonLocalRegistry/NonLocalSkeletonTest.java \
+ java/rmi/registry/nonLocalRegistry/NonLocalSkeletonTest.java
+
+jdk_security_manual_interactive = \
+ sun/security/tools/keytool/i18n.java \
java/security/Policy/Root/Root.java \
sun/security/krb5/config/native/TestDynamicStore.java
-
# Test sets for running inside container environment
jdk_containers_extended = \
:jdk_io \
From 3787ff8d1d8dbcaaebb9616c5bc543e2fe21a90c Mon Sep 17 00:00:00 2001
From: Axel Boldt-Christmas
Date: Thu, 23 Nov 2023 12:41:51 +0000
Subject: [PATCH 042/250] 8319700: [AArch64] C2 compilation fails with "Field
too big for insn"
Reviewed-by: aph, thartmann
---
.../cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.cpp | 9 +++++++++
.../cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.hpp | 2 ++
src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad | 2 +-
src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp | 3 +++
src/hotspot/share/gc/z/c2/zBarrierSetC2.hpp | 2 +-
5 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.cpp
index 3a9e5db2ef7ae..ebaf18299728d 100644
--- a/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.cpp
@@ -1290,6 +1290,9 @@ static bool aarch64_test_and_branch_reachable(int branch_offset, int target_offs
return test_and_branch_to_trampoline_delta < test_and_branch_delta_limit;
}
+ZLoadBarrierStubC2Aarch64::ZLoadBarrierStubC2Aarch64(const MachNode* node, Address ref_addr, Register ref)
+ : ZLoadBarrierStubC2(node, ref_addr, ref), _test_and_branch_reachable_entry(), _offset(), _deferred_emit(false), _test_and_branch_reachable(false) {}
+
ZLoadBarrierStubC2Aarch64::ZLoadBarrierStubC2Aarch64(const MachNode* node, Address ref_addr, Register ref, int offset)
: ZLoadBarrierStubC2(node, ref_addr, ref), _test_and_branch_reachable_entry(), _offset(offset), _deferred_emit(false), _test_and_branch_reachable(false) {
PhaseOutput* const output = Compile::current()->output();
@@ -1319,6 +1322,12 @@ int ZLoadBarrierStubC2Aarch64::get_stub_size() {
return cb.insts_size();
}
+ZLoadBarrierStubC2Aarch64* ZLoadBarrierStubC2Aarch64::create(const MachNode* node, Address ref_addr, Register ref) {
+ ZLoadBarrierStubC2Aarch64* const stub = new (Compile::current()->comp_arena()) ZLoadBarrierStubC2Aarch64(node, ref_addr, ref);
+ register_stub(stub);
+ return stub;
+}
+
ZLoadBarrierStubC2Aarch64* ZLoadBarrierStubC2Aarch64::create(const MachNode* node, Address ref_addr, Register ref, int offset) {
ZLoadBarrierStubC2Aarch64* const stub = new (Compile::current()->comp_arena()) ZLoadBarrierStubC2Aarch64(node, ref_addr, ref, offset);
register_stub(stub);
diff --git a/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.hpp
index 00714e5c0c04b..82334b34adeca 100644
--- a/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.hpp
+++ b/src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.hpp
@@ -265,10 +265,12 @@ class ZLoadBarrierStubC2Aarch64 : public ZLoadBarrierStubC2 {
bool _deferred_emit;
bool _test_and_branch_reachable;
+ ZLoadBarrierStubC2Aarch64(const MachNode* node, Address ref_addr, Register ref);
ZLoadBarrierStubC2Aarch64(const MachNode* node, Address ref_addr, Register ref, int offset);
int get_stub_size();
public:
+ static ZLoadBarrierStubC2Aarch64* create(const MachNode* node, Address ref_addr, Register ref);
static ZLoadBarrierStubC2Aarch64* create(const MachNode* node, Address ref_addr, Register ref, int offset);
virtual void emit_code(MacroAssembler& masm);
diff --git a/src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad b/src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad
index 8c698635ad0f5..23564a3f23c38 100644
--- a/src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad
+++ b/src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad
@@ -48,7 +48,7 @@ static void z_keep_alive_load_barrier(MacroAssembler& _masm, const MachNode* nod
__ relocate(barrier_Relocation::spec(), ZBarrierRelocationFormatMarkBadBeforeMov);
__ movzw(tmp, barrier_Relocation::unpatched);
__ tst(ref, tmp);
- ZLoadBarrierStubC2* const stub = ZLoadBarrierStubC2::create(node, ref_addr, ref);
+ ZLoadBarrierStubC2Aarch64* const stub = ZLoadBarrierStubC2Aarch64::create(node, ref_addr, ref);
__ br(Assembler::NE, *stub->entry());
z_uncolor(_masm, node, ref);
__ bind(*stub->continuation());
diff --git a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp
index e5fb50a26e4fb..70b9bd6eaa7de 100644
--- a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp
+++ b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp
@@ -42,6 +42,7 @@
#include "opto/rootnode.hpp"
#include "opto/runtime.hpp"
#include "opto/type.hpp"
+#include "utilities/debug.hpp"
#include "utilities/growableArray.hpp"
#include "utilities/macros.hpp"
@@ -226,6 +227,7 @@ Label* ZBarrierStubC2::continuation() {
}
ZLoadBarrierStubC2* ZLoadBarrierStubC2::create(const MachNode* node, Address ref_addr, Register ref) {
+ AARCH64_ONLY(fatal("Should use ZLoadBarrierStubC2Aarch64::create"));
ZLoadBarrierStubC2* const stub = new (Compile::current()->comp_arena()) ZLoadBarrierStubC2(node, ref_addr, ref);
register_stub(stub);
@@ -275,6 +277,7 @@ void ZLoadBarrierStubC2::emit_code(MacroAssembler& masm) {
}
ZStoreBarrierStubC2* ZStoreBarrierStubC2::create(const MachNode* node, Address ref_addr, Register new_zaddress, Register new_zpointer, bool is_native, bool is_atomic) {
+ AARCH64_ONLY(fatal("Should use ZStoreBarrierStubC2Aarch64::create"));
ZStoreBarrierStubC2* const stub = new (Compile::current()->comp_arena()) ZStoreBarrierStubC2(node, ref_addr, new_zaddress, new_zpointer, is_native, is_atomic);
register_stub(stub);
diff --git a/src/hotspot/share/gc/z/c2/zBarrierSetC2.hpp b/src/hotspot/share/gc/z/c2/zBarrierSetC2.hpp
index a0f29fbc51076..7af70c6409678 100644
--- a/src/hotspot/share/gc/z/c2/zBarrierSetC2.hpp
+++ b/src/hotspot/share/gc/z/c2/zBarrierSetC2.hpp
@@ -52,9 +52,9 @@ static void inc_trampoline_stubs_count();
static int trampoline_stubs_count();
static int stubs_start_offset();
-public:
ZBarrierStubC2(const MachNode* node);
+public:
RegMask& live() const;
Label* entry();
Label* continuation();
From beaa79c28b4b61229613d0323b1519606d413a4a Mon Sep 17 00:00:00 2001
From: Magnus Ihse Bursie
Date: Thu, 23 Nov 2023 15:15:12 +0000
Subject: [PATCH 043/250] 8320663: Fix C syntax in LIB_SETUP_HSDIS_BINUTILS
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: Galder Zamarreño
Reviewed-by: rehn
---
make/autoconf/lib-hsdis.m4 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/make/autoconf/lib-hsdis.m4 b/make/autoconf/lib-hsdis.m4
index 4414e54886cf9..c020bf4505424 100644
--- a/make/autoconf/lib-hsdis.m4
+++ b/make/autoconf/lib-hsdis.m4
@@ -278,7 +278,7 @@ AC_DEFUN([LIB_SETUP_HSDIS_BINUTILS],
fi
AC_MSG_CHECKING([Checking binutils API])
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include $disasm_header],[[void foo() {init_disassemble_info(0, 0, 0, 0);}]])],
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include $disasm_header],[[init_disassemble_info(0, 0, 0, 0);]])],
[
AC_MSG_RESULT([New API])
HSDIS_CFLAGS="$HSDIS_CFLAGS -DBINUTILS_NEW_API"
From 06f040ba3ad4dab5588b79e9d0b013a4edd8ef73 Mon Sep 17 00:00:00 2001
From: Pavel Rappo
Date: Thu, 23 Nov 2023 15:52:04 +0000
Subject: [PATCH 044/250] 8320645: DocLint should use javax.lang.model to
detect default constructors
Reviewed-by: jlahoda, jjg
---
.../classes/jdk/javadoc/internal/doclint/Checker.java | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java
index b097866a2d85a..871acd26ec3ab 100644
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java
@@ -1248,14 +1248,8 @@ private boolean isAnonymous() {
}
private boolean isDefaultConstructor() {
- if (env.currElement.getKind() == ElementKind.CONSTRUCTOR) {
- // A synthetic default constructor has the same pos as the
- // enclosing class
- TreePath p = env.currPath;
- return env.getPos(p) == env.getPos(p.getParentPath());
- } else {
- return false;
- }
+ return env.currElement.getKind() == ElementKind.CONSTRUCTOR
+ && env.elements.getOrigin(env.currElement) == Elements.Origin.MANDATED;
}
private boolean isDeclaredType() {
From 6d79e0aa3c32f687d5120811de955d5ae19e0fb2 Mon Sep 17 00:00:00 2001
From: Yuri Gaevsky
Date: Thu, 23 Nov 2023 16:06:05 +0000
Subject: [PATCH 045/250] 8318159: RISC-V: Improve itable_stub
Reviewed-by: fyang, rehn
---
.../cpu/riscv/macroAssembler_riscv.cpp | 103 ++++++++++++++++++
.../cpu/riscv/macroAssembler_riscv.hpp | 9 ++
src/hotspot/cpu/riscv/vtableStubs_riscv.cpp | 23 +---
3 files changed, 116 insertions(+), 19 deletions(-)
diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
index 8f516f38e7d9a..82a4df29326cb 100644
--- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
+++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
@@ -2519,6 +2519,109 @@ void MacroAssembler::lookup_interface_method(Register recv_klass,
}
}
+// Look up the method for a megamorphic invokeinterface call in a single pass over itable:
+// - check recv_klass (actual object class) is a subtype of resolved_klass from CompiledICHolder
+// - find a holder_klass (class that implements the method) vtable offset and get the method from vtable by index
+// The target method is determined by .
+// The receiver klass is in recv_klass.
+// On success, the result will be in method_result, and execution falls through.
+// On failure, execution transfers to the given label.
+void MacroAssembler::lookup_interface_method_stub(Register recv_klass,
+ Register holder_klass,
+ Register resolved_klass,
+ Register method_result,
+ Register temp_itbl_klass,
+ Register scan_temp,
+ int itable_index,
+ Label& L_no_such_interface) {
+ // 'method_result' is only used as output register at the very end of this method.
+ // Until then we can reuse it as 'holder_offset'.
+ Register holder_offset = method_result;
+ assert_different_registers(resolved_klass, recv_klass, holder_klass, temp_itbl_klass, scan_temp, holder_offset);
+
+ int vtable_start_offset_bytes = in_bytes(Klass::vtable_start_offset());
+ int scan_step = itableOffsetEntry::size() * wordSize;
+ int ioffset_bytes = in_bytes(itableOffsetEntry::interface_offset());
+ int ooffset_bytes = in_bytes(itableOffsetEntry::offset_offset());
+ int itmentry_off_bytes = in_bytes(itableMethodEntry::method_offset());
+ const int vte_scale = exact_log2(vtableEntry::size_in_bytes());
+
+ Label L_loop_search_resolved_entry, L_resolved_found, L_holder_found;
+
+ lwu(scan_temp, Address(recv_klass, Klass::vtable_length_offset()));
+ add(recv_klass, recv_klass, vtable_start_offset_bytes + ioffset_bytes);
+ // itableOffsetEntry[] itable = recv_klass + Klass::vtable_start_offset()
+ // + sizeof(vtableEntry) * (recv_klass->_vtable_len);
+ // scan_temp = &(itable[0]._interface)
+ // temp_itbl_klass = itable[0]._interface;
+ shadd(scan_temp, scan_temp, recv_klass, scan_temp, vte_scale);
+ ld(temp_itbl_klass, Address(scan_temp));
+ mv(holder_offset, zr);
+
+ // Initial checks:
+ // - if (holder_klass != resolved_klass), go to "scan for resolved"
+ // - if (itable[0] == holder_klass), shortcut to "holder found"
+ // - if (itable[0] == 0), no such interface
+ bne(resolved_klass, holder_klass, L_loop_search_resolved_entry);
+ beq(holder_klass, temp_itbl_klass, L_holder_found);
+ beqz(temp_itbl_klass, L_no_such_interface);
+
+ // Loop: Look for holder_klass record in itable
+ // do {
+ // temp_itbl_klass = *(scan_temp += scan_step);
+ // if (temp_itbl_klass == holder_klass) {
+ // goto L_holder_found; // Found!
+ // }
+ // } while (temp_itbl_klass != 0);
+ // goto L_no_such_interface // Not found.
+ Label L_search_holder;
+ bind(L_search_holder);
+ add(scan_temp, scan_temp, scan_step);
+ ld(temp_itbl_klass, Address(scan_temp));
+ beq(holder_klass, temp_itbl_klass, L_holder_found);
+ bnez(temp_itbl_klass, L_search_holder);
+
+ j(L_no_such_interface);
+
+ // Loop: Look for resolved_class record in itable
+ // while (true) {
+ // temp_itbl_klass = *(scan_temp += scan_step);
+ // if (temp_itbl_klass == 0) {
+ // goto L_no_such_interface;
+ // }
+ // if (temp_itbl_klass == resolved_klass) {
+ // goto L_resolved_found; // Found!
+ // }
+ // if (temp_itbl_klass == holder_klass) {
+ // holder_offset = scan_temp;
+ // }
+ // }
+ //
+ Label L_loop_search_resolved;
+ bind(L_loop_search_resolved);
+ add(scan_temp, scan_temp, scan_step);
+ ld(temp_itbl_klass, Address(scan_temp));
+ bind(L_loop_search_resolved_entry);
+ beqz(temp_itbl_klass, L_no_such_interface);
+ beq(resolved_klass, temp_itbl_klass, L_resolved_found);
+ bne(holder_klass, temp_itbl_klass, L_loop_search_resolved);
+ mv(holder_offset, scan_temp);
+ j(L_loop_search_resolved);
+
+ // See if we already have a holder klass. If not, go and scan for it.
+ bind(L_resolved_found);
+ beqz(holder_offset, L_search_holder);
+ mv(scan_temp, holder_offset);
+
+ // Finally, scan_temp contains holder_klass vtable offset
+ bind(L_holder_found);
+ lwu(method_result, Address(scan_temp, ooffset_bytes - ioffset_bytes));
+ add(recv_klass, recv_klass, itable_index * wordSize + itmentry_off_bytes
+ - vtable_start_offset_bytes - ioffset_bytes); // substract offsets to restore the original value of recv_klass
+ add(method_result, recv_klass, method_result);
+ ld(method_result, Address(method_result));
+}
+
// virtual method calling
void MacroAssembler::lookup_virtual_method(Register recv_klass,
RegisterOrConstant vtable_index,
diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp
index 1a8271166a9cc..8308ea255c7e8 100644
--- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp
+++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp
@@ -254,6 +254,15 @@ class MacroAssembler: public Assembler {
Label& no_such_interface,
bool return_method = true);
+ void lookup_interface_method_stub(Register recv_klass,
+ Register holder_klass,
+ Register resolved_klass,
+ Register method_result,
+ Register temp_reg,
+ Register temp_reg2,
+ int itable_index,
+ Label& L_no_such_interface);
+
// virtual method calling
// n.n. x86 allows RegisterOrConstant for vtable_index
void lookup_virtual_method(Register recv_klass,
diff --git a/src/hotspot/cpu/riscv/vtableStubs_riscv.cpp b/src/hotspot/cpu/riscv/vtableStubs_riscv.cpp
index 6ab3a26232345..9d08796681f3f 100644
--- a/src/hotspot/cpu/riscv/vtableStubs_riscv.cpp
+++ b/src/hotspot/cpu/riscv/vtableStubs_riscv.cpp
@@ -178,7 +178,7 @@ VtableStub* VtableStubs::create_itable_stub(int itable_index) {
// so all registers except arguments are free at this point.
const Register recv_klass_reg = x18;
const Register holder_klass_reg = x19; // declaring interface klass (DECC)
- const Register resolved_klass_reg = xmethod; // resolved interface klass (REFC)
+ const Register resolved_klass_reg = x30; // resolved interface klass (REFC)
const Register temp_reg = x28;
const Register temp_reg2 = x29;
const Register icholder_reg = t1;
@@ -195,28 +195,13 @@ VtableStub* VtableStubs::create_itable_stub(int itable_index) {
__ load_klass(recv_klass_reg, j_rarg0);
// Receiver subtype check against REFC.
- __ lookup_interface_method(// inputs: rec. class, interface
- recv_klass_reg, resolved_klass_reg, noreg,
- // outputs: scan temp. reg1, scan temp. reg2
- temp_reg2, temp_reg,
- L_no_such_interface,
- /*return_method=*/false);
-
- const ptrdiff_t typecheckSize = __ pc() - start_pc;
- start_pc = __ pc();
-
// Get selected method from declaring class and itable index
- __ lookup_interface_method(// inputs: rec. class, interface, itable index
- recv_klass_reg, holder_klass_reg, itable_index,
- // outputs: method, scan temp. reg
- xmethod, temp_reg,
- L_no_such_interface);
-
- const ptrdiff_t lookupSize = __ pc() - start_pc;
+ __ lookup_interface_method_stub(recv_klass_reg, holder_klass_reg, resolved_klass_reg, xmethod,
+ temp_reg, temp_reg2, itable_index, L_no_such_interface);
// Reduce "estimate" such that "padding" does not drop below 8.
const ptrdiff_t estimate = 256;
- const ptrdiff_t codesize = typecheckSize + lookupSize;
+ const ptrdiff_t codesize = __ pc() - start_pc;
slop_delta = (int)(estimate - codesize);
slop_bytes += slop_delta;
assert(slop_delta >= 0, "itable #%d: Code size estimate (%d) for lookup_interface_method too small, required: %d", itable_index, (int)estimate, (int)codesize);
From cb95e393b638d49a2ac07d3173f1ad7581176e7b Mon Sep 17 00:00:00 2001
From: Abhishek Kumar
Date: Thu, 23 Nov 2023 16:18:46 +0000
Subject: [PATCH 046/250] 8224261: JProgressBar always with border painted
around it
Reviewed-by: aivanov, dnguyen
---
.../swing/plaf/synth/SynthProgressBarUI.java | 9 +-
.../JProgressBar/TestProgressBarBorder.java | 108 ++++++++++++++++++
2 files changed, 114 insertions(+), 3 deletions(-)
create mode 100644 test/jdk/javax/swing/JProgressBar/TestProgressBarBorder.java
diff --git a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java
index 0adf45df1ff0a..ee50976bbf4f9 100644
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java
@@ -215,9 +215,12 @@ public void update(Graphics g, JComponent c) {
SynthContext context = getContext(c);
SynthLookAndFeel.update(context, g);
- context.getPainter().paintProgressBarBackground(context,
- g, 0, 0, c.getWidth(), c.getHeight(),
- progressBar.getOrientation());
+
+ if (((JProgressBar) c).isBorderPainted()) {
+ context.getPainter().paintProgressBarBackground(context,
+ g, 0, 0, c.getWidth(), c.getHeight(),
+ progressBar.getOrientation());
+ }
paint(context, g);
}
diff --git a/test/jdk/javax/swing/JProgressBar/TestProgressBarBorder.java b/test/jdk/javax/swing/JProgressBar/TestProgressBarBorder.java
new file mode 100644
index 0000000000000..06ccfc3b9bfbc
--- /dev/null
+++ b/test/jdk/javax/swing/JProgressBar/TestProgressBarBorder.java
@@ -0,0 +1,108 @@
+/*
+ * 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.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+import javax.imageio.ImageIO;
+import javax.swing.JComponent;
+import javax.swing.JProgressBar;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+
+import static java.awt.image.BufferedImage.TYPE_INT_RGB;
+
+/*
+ * @test
+ * @bug 8224261
+ * @key headful
+ * @library ../regtesthelpers
+ * @build Util
+ * @summary Verifies JProgressBar border is not painted when border
+ * painting is set to false
+ * @run main TestProgressBarBorder
+ */
+
+public class TestProgressBarBorder {
+ public static void main(String[] args) throws Exception {
+ for (UIManager.LookAndFeelInfo laf :
+ UIManager.getInstalledLookAndFeels()) {
+ if (!laf.getName().contains("Nimbus") && !laf.getName().contains("GTK")) {
+ continue;
+ }
+ System.out.println("Testing LAF: " + laf.getName());
+ SwingUtilities.invokeAndWait(() -> test(laf));
+ }
+ }
+
+ private static void test(UIManager.LookAndFeelInfo laf) {
+ setLookAndFeel(laf);
+ JProgressBar progressBar = createProgressBar();
+ progressBar.setBorderPainted(true);
+ BufferedImage withBorder = paintToImage(progressBar);
+ progressBar.setBorderPainted(false);
+ BufferedImage withoutBorder = paintToImage(progressBar);
+
+ boolean equal = Util.compareBufferedImages(withBorder, withoutBorder);
+ if (equal) {
+ try {
+ ImageIO.write(withBorder, "png", new File("withBorder.png"));
+ ImageIO.write(withoutBorder, "png", new File("withoutBorder.png"));
+ } catch (IOException ignored) {}
+
+ throw new RuntimeException("JProgressBar border is painted when border " +
+ "painting is set to false");
+ }
+ }
+
+ private static void setLookAndFeel(UIManager.LookAndFeelInfo laf) {
+ try {
+ UIManager.setLookAndFeel(laf.getClassName());
+ } catch (UnsupportedLookAndFeelException ignored) {
+ System.out.println("Unsupported LAF: " + laf.getClassName());
+ } catch (ClassNotFoundException | InstantiationException
+ | IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static JProgressBar createProgressBar() {
+ JProgressBar progressBar = new JProgressBar();
+ progressBar.setSize(100, 50);
+ progressBar.setValue(0);
+ progressBar.setStringPainted(true);
+ return progressBar;
+ }
+
+ private static BufferedImage paintToImage(JComponent content) {
+ BufferedImage im = new BufferedImage(content.getWidth(), content.getHeight(),
+ TYPE_INT_RGB);
+ Graphics g = im.getGraphics();
+ content.paint(g);
+ g.dispose();
+ return im;
+ }
+}
From 6f263111a1812873291e91870e341ccce804d049 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gerg=C3=B6=20Barany?=
Date: Thu, 23 Nov 2023 18:33:19 +0000
Subject: [PATCH 047/250] 8318490: Increase timeout for JDK tests that are
close to the limit when run with libgraal
Reviewed-by: dnsimon, never, thartmann
---
.../intrinsics/string/TestStringIntrinsicRangeChecks.java | 2 +-
.../jtreg/compiler/vectorapi/reshape/TestVectorCastAVX1.java | 2 +-
.../jtreg/compiler/vectorapi/reshape/TestVectorCastAVX2.java | 2 +-
.../jtreg/compiler/vectorapi/reshape/TestVectorCastAVX512.java | 2 +-
.../compiler/vectorapi/reshape/TestVectorCastAVX512BW.java | 2 +-
.../compiler/vectorapi/reshape/TestVectorCastAVX512DQ.java | 2 +-
.../jtreg/compiler/vectorapi/reshape/TestVectorCastNeon.java | 2 +-
.../jtreg/compiler/vectorapi/reshape/TestVectorCastSVE.java | 2 +-
test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread007.java | 2 +-
test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread008.java | 2 +-
test/jdk/jdk/incubator/vector/Byte128VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Byte256VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Byte512VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Byte64VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Double128VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Double256VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Double512VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Double64VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Float128VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Float256VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Float512VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Float64VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Int128VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Int256VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Int512VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Int64VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/IntMaxVectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Long128VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Long256VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Long512VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Long64VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/LongMaxVectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Short128VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Short256VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Short512VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/Short64VectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java | 2 +-
test/jdk/jdk/incubator/vector/templates/Unit-header.template | 2 +-
41 files changed, 41 insertions(+), 41 deletions(-)
diff --git a/test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsicRangeChecks.java b/test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsicRangeChecks.java
index 76bfda0f51fa7..a7d2cfe7fa7ff 100644
--- a/test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsicRangeChecks.java
+++ b/test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsicRangeChecks.java
@@ -27,7 +27,7 @@
* @summary Verifies that string intrinsics throw array out of bounds exceptions.
* @library /compiler/patches /test/lib
* @build java.base/java.lang.Helper
- * @run main/othervm -Xbatch -XX:CompileThreshold=100 compiler.intrinsics.string.TestStringIntrinsicRangeChecks
+ * @run main/othervm/timeout=300 -Xbatch -XX:CompileThreshold=100 compiler.intrinsics.string.TestStringIntrinsicRangeChecks
*/
package compiler.intrinsics.string;
diff --git a/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX1.java b/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX1.java
index 050777505e21f..944a48750ba15 100644
--- a/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX1.java
+++ b/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX1.java
@@ -36,7 +36,7 @@
* @summary Test that vector cast intrinsics work as intended on avx1.
* @requires vm.cpu.features ~= ".*avx.*"
* @library /test/lib /
- * @run main compiler.vectorapi.reshape.TestVectorCastAVX1
+ * @run main/timeout=300 compiler.vectorapi.reshape.TestVectorCastAVX1
*/
public class TestVectorCastAVX1 {
public static void main(String[] args) {
diff --git a/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX2.java b/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX2.java
index 2c5cfe7de99c2..d748b82cb84a8 100644
--- a/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX2.java
+++ b/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX2.java
@@ -36,7 +36,7 @@
* @summary Test that vector cast intrinsics work as intended on avx2.
* @requires vm.cpu.features ~= ".*avx2.*"
* @library /test/lib /
- * @run main compiler.vectorapi.reshape.TestVectorCastAVX2
+ * @run main/timeout=300 compiler.vectorapi.reshape.TestVectorCastAVX2
*/
public class TestVectorCastAVX2 {
public static void main(String[] args) {
diff --git a/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX512.java b/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX512.java
index 903958943e3a0..fa11d1a5df756 100644
--- a/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX512.java
+++ b/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX512.java
@@ -36,7 +36,7 @@
* @summary Test that vector cast intrinsics work as intended on avx512.
* @requires vm.cpu.features ~= ".*avx512.*"
* @library /test/lib /
- * @run main compiler.vectorapi.reshape.TestVectorCastAVX512
+ * @run main/timeout=300 compiler.vectorapi.reshape.TestVectorCastAVX512
*/
public class TestVectorCastAVX512 {
public static void main(String[] args) {
diff --git a/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX512BW.java b/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX512BW.java
index d98379ae8009a..16e577b48a688 100644
--- a/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX512BW.java
+++ b/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX512BW.java
@@ -36,7 +36,7 @@
* @summary Test that vector cast intrinsics work as intended on avx512bw.
* @requires vm.cpu.features ~= ".*avx512bw.*"
* @library /test/lib /
- * @run main compiler.vectorapi.reshape.TestVectorCastAVX512BW
+ * @run main/timeout=300 compiler.vectorapi.reshape.TestVectorCastAVX512BW
*/
public class TestVectorCastAVX512BW {
public static void main(String[] args) {
diff --git a/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX512DQ.java b/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX512DQ.java
index 952794236514c..3aa1b62650f18 100644
--- a/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX512DQ.java
+++ b/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastAVX512DQ.java
@@ -36,7 +36,7 @@
* @summary Test that vector cast intrinsics work as intended on avx512dq.
* @requires vm.cpu.features ~= ".*avx512dq.*"
* @library /test/lib /
- * @run main compiler.vectorapi.reshape.TestVectorCastAVX512DQ
+ * @run main/timeout=300 compiler.vectorapi.reshape.TestVectorCastAVX512DQ
*/
public class TestVectorCastAVX512DQ {
public static void main(String[] args) {
diff --git a/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastNeon.java b/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastNeon.java
index 75a8fada91ee0..b70517104dc38 100644
--- a/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastNeon.java
+++ b/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastNeon.java
@@ -36,7 +36,7 @@
* @summary Test that vector cast intrinsics work as intended on neon.
* @requires vm.cpu.features ~= ".*asimd.*"
* @library /test/lib /
- * @run main compiler.vectorapi.reshape.TestVectorCastNeon
+ * @run main/timeout=300 compiler.vectorapi.reshape.TestVectorCastNeon
*/
public class TestVectorCastNeon {
public static void main(String[] args) {
diff --git a/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastSVE.java b/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastSVE.java
index e1cd1f0fdac4b..72624692352a8 100644
--- a/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastSVE.java
+++ b/test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastSVE.java
@@ -36,7 +36,7 @@
* @summary Test that vector cast intrinsics work as intended on sve.
* @requires vm.cpu.features ~= ".*sve.*"
* @library /test/lib /
- * @run main compiler.vectorapi.reshape.TestVectorCastSVE
+ * @run main/timeout=300 compiler.vectorapi.reshape.TestVectorCastSVE
*/
public class TestVectorCastSVE {
public static void main(String[] args) {
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread007.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread007.java
index 07031a783bfd2..26388c28d0a6b 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread007.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread007.java
@@ -32,7 +32,7 @@
* Try to start the given number of threads starting simultaneously
* when notifyall() is signaled at the stopLine object.
*
- * @run main/othervm nsk.stress.thread.thread007 500 2m 5s
+ * @run main/othervm/timeout=300 nsk.stress.thread.thread007 500 2m 5s
*/
package nsk.stress.thread;
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread008.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread008.java
index 40a76e00d11f8..2cbc198a69348 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread008.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/thread/thread008.java
@@ -33,7 +33,7 @@
* starting simultaneously when notifyall() is signaled at the
* stopLine object.
*
- * @run main/othervm nsk.stress.thread.thread008 500 2m 5s
+ * @run main/othervm/timeout=300 nsk.stress.thread.thread008 500 2m 5s
*/
package nsk.stress.thread;
diff --git a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java
index 9d656f0e33854..65a0acf6dac5c 100644
--- a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Byte128VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Byte128VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java
index 31ecc509c3917..87c5f3a39c2b3 100644
--- a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Byte256VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Byte256VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java
index b677d6fde5959..97e70d2f85d5f 100644
--- a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Byte512VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Byte512VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java
index 3c33d91854c05..92019e6957a6b 100644
--- a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Byte64VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Byte64VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java
index 3d19d2ab6d0b6..921b2be725ceb 100644
--- a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java
+++ b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation ByteMaxVectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation ByteMaxVectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Double128VectorTests.java b/test/jdk/jdk/incubator/vector/Double128VectorTests.java
index 5e81cb946bcaf..f7c955a08ce13 100644
--- a/test/jdk/jdk/incubator/vector/Double128VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Double128VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Double128VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Double128VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Double256VectorTests.java b/test/jdk/jdk/incubator/vector/Double256VectorTests.java
index ef4f3f0f97511..27f9c0df19425 100644
--- a/test/jdk/jdk/incubator/vector/Double256VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Double256VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Double256VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Double256VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Double512VectorTests.java b/test/jdk/jdk/incubator/vector/Double512VectorTests.java
index 21209c23ea10e..440a553dc335d 100644
--- a/test/jdk/jdk/incubator/vector/Double512VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Double512VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Double512VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Double512VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Double64VectorTests.java b/test/jdk/jdk/incubator/vector/Double64VectorTests.java
index 360445a6b7f2e..73ac9b00c05f9 100644
--- a/test/jdk/jdk/incubator/vector/Double64VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Double64VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Double64VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Double64VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java b/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java
index 01d72b64d2d92..296e23a70231e 100644
--- a/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java
+++ b/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation DoubleMaxVectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation DoubleMaxVectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Float128VectorTests.java b/test/jdk/jdk/incubator/vector/Float128VectorTests.java
index 9f1b28a80c6a5..bf61881e3d8d5 100644
--- a/test/jdk/jdk/incubator/vector/Float128VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Float128VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Float128VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Float128VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Float256VectorTests.java b/test/jdk/jdk/incubator/vector/Float256VectorTests.java
index 649b06a007d6c..7292f55aa6d5a 100644
--- a/test/jdk/jdk/incubator/vector/Float256VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Float256VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Float256VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Float256VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Float512VectorTests.java b/test/jdk/jdk/incubator/vector/Float512VectorTests.java
index 5bd3932cef158..01d1e27209b50 100644
--- a/test/jdk/jdk/incubator/vector/Float512VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Float512VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Float512VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Float512VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Float64VectorTests.java b/test/jdk/jdk/incubator/vector/Float64VectorTests.java
index 1922be94f403f..b7fd8ab276787 100644
--- a/test/jdk/jdk/incubator/vector/Float64VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Float64VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Float64VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Float64VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java b/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java
index 3e72f9077f624..5592f5985b043 100644
--- a/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java
+++ b/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation FloatMaxVectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation FloatMaxVectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Int128VectorTests.java b/test/jdk/jdk/incubator/vector/Int128VectorTests.java
index f69423c12e2b5..fcfe286034d2c 100644
--- a/test/jdk/jdk/incubator/vector/Int128VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Int128VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Int128VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Int128VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Int256VectorTests.java b/test/jdk/jdk/incubator/vector/Int256VectorTests.java
index f580c39c0910d..64cad182a24bd 100644
--- a/test/jdk/jdk/incubator/vector/Int256VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Int256VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Int256VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Int256VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Int512VectorTests.java b/test/jdk/jdk/incubator/vector/Int512VectorTests.java
index 89cd557ec9b89..468a2c3a8f13f 100644
--- a/test/jdk/jdk/incubator/vector/Int512VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Int512VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Int512VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Int512VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Int64VectorTests.java b/test/jdk/jdk/incubator/vector/Int64VectorTests.java
index 0affccd742b53..14b853c1e7222 100644
--- a/test/jdk/jdk/incubator/vector/Int64VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Int64VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Int64VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Int64VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java
index c0fdcbf58a317..b608b548ceeb2 100644
--- a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java
+++ b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation IntMaxVectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation IntMaxVectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Long128VectorTests.java b/test/jdk/jdk/incubator/vector/Long128VectorTests.java
index a706b884f8bc5..e80497c358441 100644
--- a/test/jdk/jdk/incubator/vector/Long128VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Long128VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Long128VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Long128VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Long256VectorTests.java b/test/jdk/jdk/incubator/vector/Long256VectorTests.java
index 3056c8cbcaa65..b3762b4c15a17 100644
--- a/test/jdk/jdk/incubator/vector/Long256VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Long256VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Long256VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Long256VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Long512VectorTests.java b/test/jdk/jdk/incubator/vector/Long512VectorTests.java
index 5a0a5d106bf33..57ba7738d13aa 100644
--- a/test/jdk/jdk/incubator/vector/Long512VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Long512VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Long512VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Long512VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Long64VectorTests.java b/test/jdk/jdk/incubator/vector/Long64VectorTests.java
index 1a3ecebd57c7d..8917281196f42 100644
--- a/test/jdk/jdk/incubator/vector/Long64VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Long64VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Long64VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Long64VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java
index d467107e9f2a1..913f7d6f52779 100644
--- a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java
+++ b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation LongMaxVectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation LongMaxVectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Short128VectorTests.java b/test/jdk/jdk/incubator/vector/Short128VectorTests.java
index 81568661570f0..e40a40686c980 100644
--- a/test/jdk/jdk/incubator/vector/Short128VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Short128VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Short128VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Short128VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Short256VectorTests.java b/test/jdk/jdk/incubator/vector/Short256VectorTests.java
index 14a54fcc1df77..02138e3e8aa2f 100644
--- a/test/jdk/jdk/incubator/vector/Short256VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Short256VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Short256VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Short256VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Short512VectorTests.java b/test/jdk/jdk/incubator/vector/Short512VectorTests.java
index 8d869e5a66f24..9577f22f58cdf 100644
--- a/test/jdk/jdk/incubator/vector/Short512VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Short512VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Short512VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Short512VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/Short64VectorTests.java b/test/jdk/jdk/incubator/vector/Short64VectorTests.java
index 47f37beecb616..71b3c6046b45c 100644
--- a/test/jdk/jdk/incubator/vector/Short64VectorTests.java
+++ b/test/jdk/jdk/incubator/vector/Short64VectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Short64VectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Short64VectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java
index 7e657a3f39832..4a6adbf2c8ea0 100644
--- a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java
+++ b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation ShortMaxVectorTests
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation ShortMaxVectorTests
*/
// -- This file was mechanically generated: Do not edit! -- //
diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-header.template b/test/jdk/jdk/incubator/vector/templates/Unit-header.template
index 87364836f7cbf..4d3795ea3d170 100644
--- a/test/jdk/jdk/incubator/vector/templates/Unit-header.template
+++ b/test/jdk/jdk/incubator/vector/templates/Unit-header.template
@@ -24,7 +24,7 @@
/*
* @test
* @modules jdk.incubator.vector
- * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation $vectorteststype$
+ * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation $vectorteststype$
*/
#warn This file is preprocessed before being compiled
From 28026434f74726d72857e781b8f1c3d12aba9125 Mon Sep 17 00:00:00 2001
From: Jiangli Zhou
Date: Thu, 23 Nov 2023 19:25:29 +0000
Subject: [PATCH 048/250] 8314243: Make
VM_Exit::wait_for_threads_in_native_to_block wait for user threads time
configurable
Reviewed-by: dholmes
---
src/hotspot/share/runtime/globals.hpp | 7 +++++++
src/hotspot/share/runtime/vmOperations.cpp | 14 +++++++-------
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp
index 76621ac014d32..c02b0afed3c3b 100644
--- a/src/hotspot/share/runtime/globals.hpp
+++ b/src/hotspot/share/runtime/globals.hpp
@@ -835,6 +835,13 @@ const int ObjectAlignmentInBytes = 8;
"JVM aborts, producing an error log and core/mini dump, on the " \
"first occurrence of an out-of-memory error thrown from JVM") \
\
+ product(intx, UserThreadWaitAttemptsAtExit, 30, \
+ "The number of times to wait for user threads to stop executing " \
+ "native code during JVM exit. Each wait lasts 10 milliseconds. " \
+ "The maximum number of waits is 1000, to wait at most 10 " \
+ "seconds.") \
+ range(0, 1000) \
+ \
/* tracing */ \
\
develop(bool, StressRewriter, false, \
diff --git a/src/hotspot/share/runtime/vmOperations.cpp b/src/hotspot/share/runtime/vmOperations.cpp
index 7438814255c66..cad9dd2ad54c5 100644
--- a/src/hotspot/share/runtime/vmOperations.cpp
+++ b/src/hotspot/share/runtime/vmOperations.cpp
@@ -494,10 +494,9 @@ int VM_Exit::wait_for_threads_in_native_to_block() {
// don't have to wait for user threads to be quiescent, but it's always
// better to terminate VM when current thread is the only active thread, so
// wait for user threads too. Numbers are in 10 milliseconds.
- int max_wait_user_thread = 30; // at least 300 milliseconds
- int max_wait_compiler_thread = 1000; // at least 10 seconds
-
- int max_wait = max_wait_compiler_thread;
+ int wait_time_per_attempt = 10; // in milliseconds
+ int max_wait_attempts_user_thread = UserThreadWaitAttemptsAtExit;
+ int max_wait_attempts_compiler_thread = 1000; // at least 10 seconds
int attempts = 0;
JavaThreadIteratorWithHandle jtiwh;
@@ -530,16 +529,17 @@ int VM_Exit::wait_for_threads_in_native_to_block() {
if (num_active == 0) {
return 0;
- } else if (attempts > max_wait) {
+ } else if (attempts >= max_wait_attempts_compiler_thread) {
return num_active;
- } else if (num_active_compiler_thread == 0 && attempts > max_wait_user_thread) {
+ } else if (num_active_compiler_thread == 0 &&
+ attempts >= max_wait_attempts_user_thread) {
return num_active;
}
attempts++;
MonitorLocker ml(&timer, Mutex::_no_safepoint_check_flag);
- ml.wait(10);
+ ml.wait(wait_time_per_attempt);
}
}
From 14557e72ef55c6161a3fa0c1960f7be618a34bf1 Mon Sep 17 00:00:00 2001
From: Afshin Zafari
Date: Thu, 23 Nov 2023 22:16:57 +0000
Subject: [PATCH 049/250] 8314502: Change the comparator taking version of
GrowableArray::find to be a template method
Reviewed-by: jsjolen, sspitsyn, stefank
---
.../share/gc/parallel/mutableNUMASpace.cpp | 13 ++--
.../share/gc/parallel/mutableNUMASpace.hpp | 6 +-
src/hotspot/share/prims/jvmtiImpl.cpp | 14 +----
src/hotspot/share/prims/jvmtiImpl.hpp | 14 ++---
src/hotspot/share/runtime/perfData.cpp | 14 ++---
src/hotspot/share/runtime/perfData.hpp | 5 +-
src/hotspot/share/runtime/unhandledOops.cpp | 13 ++--
src/hotspot/share/runtime/unhandledOops.hpp | 7 ++-
.../share/services/diagnosticFramework.cpp | 5 +-
.../share/services/diagnosticFramework.hpp | 3 +-
src/hotspot/share/services/management.cpp | 4 +-
src/hotspot/share/utilities/growableArray.hpp | 20 ++++--
.../gtest/utilities/test_growableArray.cpp | 62 +++++++++++++++++++
13 files changed, 123 insertions(+), 57 deletions(-)
diff --git a/src/hotspot/share/gc/parallel/mutableNUMASpace.cpp b/src/hotspot/share/gc/parallel/mutableNUMASpace.cpp
index 93fa7c5519076..2a39ce7b4700d 100644
--- a/src/hotspot/share/gc/parallel/mutableNUMASpace.cpp
+++ b/src/hotspot/share/gc/parallel/mutableNUMASpace.cpp
@@ -142,6 +142,11 @@ size_t MutableNUMASpace::free_in_words() const {
return s;
}
+int MutableNUMASpace::lgrp_space_index(int lgrp_id) const {
+ return lgrp_spaces()->find_if([&](LGRPSpace* space) {
+ return space->lgrp_id() == checked_cast(lgrp_id);
+ });
+}
size_t MutableNUMASpace::tlab_capacity(Thread *thr) const {
guarantee(thr != nullptr, "No thread");
@@ -160,7 +165,7 @@ size_t MutableNUMASpace::tlab_capacity(Thread *thr) const {
}
}
// That's the normal case, where we know the locality group of the thread.
- int i = lgrp_spaces()->find(&lgrp_id, LGRPSpace::equals);
+ int i = lgrp_space_index(lgrp_id);
if (i == -1) {
return 0;
}
@@ -179,7 +184,7 @@ size_t MutableNUMASpace::tlab_used(Thread *thr) const {
return 0;
}
}
- int i = lgrp_spaces()->find(&lgrp_id, LGRPSpace::equals);
+ int i = lgrp_space_index(lgrp_id);
if (i == -1) {
return 0;
}
@@ -199,7 +204,7 @@ size_t MutableNUMASpace::unsafe_max_tlab_alloc(Thread *thr) const {
return 0;
}
}
- int i = lgrp_spaces()->find(&lgrp_id, LGRPSpace::equals);
+ int i = lgrp_space_index(lgrp_id);
if (i == -1) {
return 0;
}
@@ -569,7 +574,7 @@ HeapWord* MutableNUMASpace::cas_allocate(size_t size) {
thr->set_lgrp_id(lgrp_id);
}
- int i = lgrp_spaces()->find(&lgrp_id, LGRPSpace::equals);
+ int i = lgrp_space_index(lgrp_id);
// It is possible that a new CPU has been hotplugged and
// we haven't reshaped the space accordingly.
if (i == -1) {
diff --git a/src/hotspot/share/gc/parallel/mutableNUMASpace.hpp b/src/hotspot/share/gc/parallel/mutableNUMASpace.hpp
index 8ed25006ccf24..77ecb4da46671 100644
--- a/src/hotspot/share/gc/parallel/mutableNUMASpace.hpp
+++ b/src/hotspot/share/gc/parallel/mutableNUMASpace.hpp
@@ -93,10 +93,6 @@ class MutableNUMASpace : public MutableSpace {
delete _alloc_rate;
}
- static bool equals(void* lgrp_id_value, LGRPSpace* p) {
- return *(uint*)lgrp_id_value == p->lgrp_id();
- }
-
// Report a failed allocation.
void set_allocation_failed() { _allocation_failed = true; }
@@ -158,6 +154,8 @@ class MutableNUMASpace : public MutableSpace {
void select_tails(MemRegion new_region, MemRegion intersection,
MemRegion* bottom_region, MemRegion *top_region);
+ int lgrp_space_index(int lgrp_id) const;
+
public:
GrowableArray* lgrp_spaces() const { return _lgrp_spaces; }
MutableNUMASpace(size_t alignment);
diff --git a/src/hotspot/share/prims/jvmtiImpl.cpp b/src/hotspot/share/prims/jvmtiImpl.cpp
index c9c3974b591a5..21122539af847 100644
--- a/src/hotspot/share/prims/jvmtiImpl.cpp
+++ b/src/hotspot/share/prims/jvmtiImpl.cpp
@@ -119,14 +119,6 @@ void GrowableCache::recache() {
_listener_fun(_this_obj,_cache);
}
-bool GrowableCache::equals(void* v, GrowableElement *e2) {
- GrowableElement *e1 = (GrowableElement *) v;
- assert(e1 != nullptr, "e1 != nullptr");
- assert(e2 != nullptr, "e2 != nullptr");
-
- return e1->equals(e2);
-}
-
//
// class GrowableCache - public methods
//
@@ -163,8 +155,8 @@ GrowableElement* GrowableCache::at(int index) {
return e;
}
-int GrowableCache::find(GrowableElement* e) {
- return _elements->find(e, GrowableCache::equals);
+int GrowableCache::find(const GrowableElement* e) const {
+ return _elements->find_if([&](const GrowableElement* other_e) { return e->equals(other_e); });
}
// append a copy of the element to the end of the collection
@@ -216,7 +208,7 @@ void JvmtiBreakpoint::copy(JvmtiBreakpoint& bp) {
_class_holder = OopHandle(JvmtiExport::jvmti_oop_storage(), bp._class_holder.resolve());
}
-bool JvmtiBreakpoint::equals(JvmtiBreakpoint& bp) {
+bool JvmtiBreakpoint::equals(const JvmtiBreakpoint& bp) const {
return _method == bp._method
&& _bci == bp._bci;
}
diff --git a/src/hotspot/share/prims/jvmtiImpl.hpp b/src/hotspot/share/prims/jvmtiImpl.hpp
index 851dec72ee7db..c93abe5eedf88 100644
--- a/src/hotspot/share/prims/jvmtiImpl.hpp
+++ b/src/hotspot/share/prims/jvmtiImpl.hpp
@@ -66,9 +66,9 @@ class JvmtiBreakpoints;
class GrowableElement : public CHeapObj {
public:
virtual ~GrowableElement() {}
- virtual address getCacheValue() =0;
- virtual bool equals(GrowableElement* e) =0;
- virtual GrowableElement *clone() =0;
+ virtual address getCacheValue() =0;
+ virtual bool equals(const GrowableElement* e) const =0;
+ virtual GrowableElement* clone() =0;
};
class GrowableCache {
@@ -88,8 +88,6 @@ class GrowableCache {
// (but NOT when cached elements are recomputed).
void (*_listener_fun)(void *, address*);
- static bool equals(void *, GrowableElement *);
-
// recache all elements after size change, notify listener
void recache();
@@ -104,7 +102,7 @@ class GrowableCache {
// get the value of the index element in the collection
GrowableElement* at(int index);
// find the index of the element, -1 if it doesn't exist
- int find(GrowableElement* e);
+ int find(const GrowableElement* e) const;
// append a copy of the element to the end of the collection, notify listener
void append(GrowableElement* e);
// remove the element at index, notify listener
@@ -165,7 +163,7 @@ class JvmtiBreakpoint : public GrowableElement {
JvmtiBreakpoint() : _method(nullptr), _bci(0) {}
JvmtiBreakpoint(Method* m_method, jlocation location);
virtual ~JvmtiBreakpoint();
- bool equals(JvmtiBreakpoint& bp);
+ bool equals(const JvmtiBreakpoint& bp) const;
void copy(JvmtiBreakpoint& bp);
address getBcp() const;
void each_method_version_do(method_action meth_act);
@@ -177,7 +175,7 @@ class JvmtiBreakpoint : public GrowableElement {
// GrowableElement implementation
address getCacheValue() { return getBcp(); }
- bool equals(GrowableElement* e) { return equals((JvmtiBreakpoint&) *e); }
+ bool equals(const GrowableElement* e) const { return equals((const JvmtiBreakpoint&) *e); }
GrowableElement *clone() {
JvmtiBreakpoint *bp = new JvmtiBreakpoint();
diff --git a/src/hotspot/share/runtime/perfData.cpp b/src/hotspot/share/runtime/perfData.cpp
index d1caa2edeabcb..e2549a11f10ea 100644
--- a/src/hotspot/share/runtime/perfData.cpp
+++ b/src/hotspot/share/runtime/perfData.cpp
@@ -185,6 +185,10 @@ void PerfData::create_entry(BasicType dtype, size_t dsize, size_t vlen) {
PerfMemory::mark_updated();
}
+bool PerfData::name_equals(const char* name) const {
+ return strcmp(name, this->name()) == 0;
+}
+
PerfLong::PerfLong(CounterNS ns, const char* namep, Units u, Variability v)
: PerfData(ns, namep, u, v) {
@@ -501,17 +505,9 @@ PerfDataList::~PerfDataList() {
}
-bool PerfDataList::by_name(void* name, PerfData* pd) {
-
- if (pd == nullptr)
- return false;
-
- return strcmp((const char*)name, pd->name()) == 0;
-}
-
PerfData* PerfDataList::find_by_name(const char* name) {
- int i = _set->find((void*)name, PerfDataList::by_name);
+ int i = _set->find_if([&](PerfData* pd) { return pd->name_equals(name); });
if (i >= 0 && i <= _set->length())
return _set->at(i);
diff --git a/src/hotspot/share/runtime/perfData.hpp b/src/hotspot/share/runtime/perfData.hpp
index 5c7b3d104e972..968e0813bdbc3 100644
--- a/src/hotspot/share/runtime/perfData.hpp
+++ b/src/hotspot/share/runtime/perfData.hpp
@@ -319,7 +319,8 @@ class PerfData : public CHeapObj {
// PerfData memory region. This redundancy is maintained for
// security reasons as the PerfMemory region may be in shared
// memory.
- const char* name() { return _name; }
+ const char* name() const { return _name; }
+ bool name_equals(const char* name) const;
// returns the variability classification associated with this item
Variability variability() { return _v; }
@@ -576,7 +577,7 @@ class PerfDataList : public CHeapObj {
PerfDataArray* _set;
// method to search for a instrumentation object by name
- static bool by_name(void* name, PerfData* pd);
+ static bool by_name(const char* name, PerfData* pd);
protected:
// we expose the implementation here to facilitate the clone
diff --git a/src/hotspot/share/runtime/unhandledOops.cpp b/src/hotspot/share/runtime/unhandledOops.cpp
index 11c8160fe03fc..cd1bde76c775f 100644
--- a/src/hotspot/share/runtime/unhandledOops.cpp
+++ b/src/hotspot/share/runtime/unhandledOops.cpp
@@ -71,11 +71,6 @@ void UnhandledOops::register_unhandled_oop(oop* op) {
_oop_list->push(entry);
}
-
-bool match_oop_entry(void *op, UnhandledOopEntry e) {
- return (e.oop_ptr() == op);
-}
-
// Mark unhandled oop as okay for GC - the containing struct has an oops_do and
// for some reason the oop has to be on the stack.
// May not be called for the current thread, as in the case of
@@ -83,7 +78,9 @@ bool match_oop_entry(void *op, UnhandledOopEntry e) {
void UnhandledOops::allow_unhandled_oop(oop* op) {
assert (CheckUnhandledOops, "should only be called with checking option");
- int i = _oop_list->find_from_end(op, match_oop_entry);
+ int i = _oop_list->find_from_end_if([&](const UnhandledOopEntry& e) {
+ return e.match_oop_entry(op);
+ });
assert(i!=-1, "safe for gc oop not in unhandled_oop_list");
UnhandledOopEntry entry = _oop_list->at(i);
@@ -105,7 +102,9 @@ void UnhandledOops::unregister_unhandled_oop(oop* op) {
}
_level--;
- int i = _oop_list->find_from_end(op, match_oop_entry);
+ int i = _oop_list->find_from_end_if([&](const UnhandledOopEntry& e) {
+ return e.match_oop_entry(op);
+ });
assert(i!=-1, "oop not in unhandled_oop_list");
_oop_list->remove_at(i);
}
diff --git a/src/hotspot/share/runtime/unhandledOops.hpp b/src/hotspot/share/runtime/unhandledOops.hpp
index 400e6dd554382..09ebbe68be357 100644
--- a/src/hotspot/share/runtime/unhandledOops.hpp
+++ b/src/hotspot/share/runtime/unhandledOops.hpp
@@ -53,14 +53,17 @@ class UnhandledOopEntry : public CHeapObj {
private:
oop* _oop_ptr;
bool _ok_for_gc;
+
+ bool match_oop_entry(oop* op) const {
+ return _oop_ptr == op;
+ }
+
public:
- oop* oop_ptr() { return _oop_ptr; }
UnhandledOopEntry() : _oop_ptr(nullptr), _ok_for_gc(false) {}
UnhandledOopEntry(oop* op) :
_oop_ptr(op), _ok_for_gc(false) {}
};
-
class UnhandledOops : public CHeapObj {
friend class Thread;
private:
diff --git a/src/hotspot/share/services/diagnosticFramework.cpp b/src/hotspot/share/services/diagnosticFramework.cpp
index d17e426ee8a86..006c08cb63ff8 100644
--- a/src/hotspot/share/services/diagnosticFramework.cpp
+++ b/src/hotspot/share/services/diagnosticFramework.cpp
@@ -144,9 +144,8 @@ bool DCmdArgIter::next(TRAPS) {
return _key_len != 0;
}
-bool DCmdInfo::by_name(void* cmd_name, DCmdInfo* info) {
- if (info == nullptr) return false;
- return strcmp((const char*)cmd_name, info->name()) == 0;
+bool DCmdInfo::name_equals(const char* name) const {
+ return strcmp(name, this->name()) == 0;
}
void DCmdParser::add_dcmd_option(GenDCmdArgument* arg) {
diff --git a/src/hotspot/share/services/diagnosticFramework.hpp b/src/hotspot/share/services/diagnosticFramework.hpp
index 8313954aaecbe..898f29274eaa1 100644
--- a/src/hotspot/share/services/diagnosticFramework.hpp
+++ b/src/hotspot/share/services/diagnosticFramework.hpp
@@ -140,13 +140,12 @@ class DCmdInfo : public ResourceObj {
: _name(name), _description(description), _impact(impact), _permission(permission),
_num_arguments(num_arguments), _is_enabled(enabled) {}
const char* name() const { return _name; }
+ bool name_equals(const char* cmd_name) const;
const char* description() const { return _description; }
const char* impact() const { return _impact; }
const JavaPermission& permission() const { return _permission; }
int num_arguments() const { return _num_arguments; }
bool is_enabled() const { return _is_enabled; }
-
- static bool by_name(void* name, DCmdInfo* info);
};
// A DCmdArgumentInfo instance provides a description of a diagnostic command
diff --git a/src/hotspot/share/services/management.cpp b/src/hotspot/share/services/management.cpp
index a9c50a8bf06df..8e9249f5a61bc 100644
--- a/src/hotspot/share/services/management.cpp
+++ b/src/hotspot/share/services/management.cpp
@@ -2004,7 +2004,9 @@ JVM_ENTRY(void, jmm_GetDiagnosticCommandInfo(JNIEnv *env, jobjectArray cmds,
THROW_MSG(vmSymbols::java_lang_NullPointerException(),
"Command name cannot be null.");
}
- int pos = info_list->find((void*)cmd_name,DCmdInfo::by_name);
+ int pos = info_list->find_if([&](DCmdInfo* info) {
+ return info->name_equals(cmd_name);
+ });
if (pos == -1) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
"Unknown diagnostic command");
diff --git a/src/hotspot/share/utilities/growableArray.hpp b/src/hotspot/share/utilities/growableArray.hpp
index d9c47e8360fdb..e9abd9fae9a3a 100644
--- a/src/hotspot/share/utilities/growableArray.hpp
+++ b/src/hotspot/share/utilities/growableArray.hpp
@@ -209,17 +209,29 @@ class GrowableArrayView : public GrowableArrayBase {
return -1;
}
- int find(void* token, bool f(void*, E)) const {
+ // Find first element that matches the given predicate.
+ //
+ // Predicate: bool predicate(const E& elem)
+ //
+ // Returns the index of the element or -1 if no element matches the predicate
+ template
+ int find_if(Predicate predicate) const {
for (int i = 0; i < _len; i++) {
- if (f(token, _data[i])) return i;
+ if (predicate(_data[i])) return i;
}
return -1;
}
- int find_from_end(void* token, bool f(void*, E)) const {
+ // Find last element that matches the given predicate.
+ //
+ // Predicate: bool predicate(const E& elem)
+ //
+ // Returns the index of the element or -1 if no element matches the predicate
+ template
+ int find_from_end_if(Predicate predicate) const {
// start at the end of the array
for (int i = _len-1; i >= 0; i--) {
- if (f(token, _data[i])) return i;
+ if (predicate(_data[i])) return i;
}
return -1;
}
diff --git a/test/hotspot/gtest/utilities/test_growableArray.cpp b/test/hotspot/gtest/utilities/test_growableArray.cpp
index cb70dfb57b393..cd269e092121e 100644
--- a/test/hotspot/gtest/utilities/test_growableArray.cpp
+++ b/test/hotspot/gtest/utilities/test_growableArray.cpp
@@ -601,3 +601,65 @@ TEST(GrowableArrayCHeap, sanity) {
delete a;
}
}
+
+TEST(GrowableArrayCHeap, find_if) {
+ struct Element {
+ int value;
+ };
+ GrowableArrayCHeap array;
+ array.push({1});
+ array.push({2});
+ array.push({3});
+
+ {
+ int index = array.find_if([&](const Element& elem) {
+ return elem.value == 1;
+ });
+ ASSERT_EQ(index, 0);
+ }
+
+ {
+ int index = array.find_if([&](const Element& elem) {
+ return elem.value > 1;
+ });
+ ASSERT_EQ(index, 1);
+ }
+
+ {
+ int index = array.find_if([&](const Element& elem) {
+ return elem.value == 4;
+ });
+ ASSERT_EQ(index, -1);
+ }
+}
+
+TEST(GrowableArrayCHeap, find_from_end_if) {
+ struct Element {
+ int value;
+ };
+ GrowableArrayCHeap array;
+ array.push({1});
+ array.push({2});
+ array.push({3});
+
+ {
+ int index = array.find_from_end_if([&](const Element& elem) {
+ return elem.value == 1;
+ });
+ ASSERT_EQ(index, 0);
+ }
+
+ {
+ int index = array.find_from_end_if([&](const Element& elem) {
+ return elem.value > 1;
+ });
+ ASSERT_EQ(index, 2);
+ }
+
+ {
+ int index = array.find_from_end_if([&](const Element& elem) {
+ return elem.value == 4;
+ });
+ ASSERT_EQ(index, -1);
+ }
+}
From c75c38871ee7b5c9f7f0c195d649c16967f786bb Mon Sep 17 00:00:00 2001
From: David Holmes
Date: Thu, 23 Nov 2023 22:23:42 +0000
Subject: [PATCH 050/250] 8318776: Require supports_cx8 to always be true
Reviewed-by: eosterlund, shade, dcubed
---
make/data/hotspot-symbols/symbols-unix | 1 -
.../cpu/aarch64/c1_LIRAssembler_aarch64.cpp | 1 -
.../cpu/aarch64/vm_version_aarch64.cpp | 1 -
src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp | 1 -
src/hotspot/cpu/arm/vm_version_arm_32.cpp | 8 +-
src/hotspot/cpu/ppc/vm_version_ppc.cpp | 4 -
.../cpu/riscv/c1_LIRAssembler_riscv.cpp | 1 -
src/hotspot/cpu/riscv/vm_version_riscv.cpp | 1 -
src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp | 1 -
src/hotspot/cpu/s390/vm_version_s390.cpp | 5 -
src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp | 2 +-
.../x86/gc/shenandoah/shenandoah_x86_64.ad | 2 -
src/hotspot/cpu/x86/vm_version_x86.cpp | 2 -
src/hotspot/cpu/x86/vm_version_x86.hpp | 1 -
src/hotspot/cpu/x86/x86.ad | 5 -
src/hotspot/cpu/x86/x86_32.ad | 2 -
src/hotspot/cpu/x86/x86_64.ad | 6 +-
src/hotspot/cpu/zero/vm_version_zero.cpp | 4 +-
.../os_cpu/linux_arm/atomic_linux_arm.hpp | 1 -
src/hotspot/share/c1/c1_Compiler.cpp | 1 -
src/hotspot/share/include/jvm.h | 6 -
.../checkpoint/types/traceid/jfrTraceId.cpp | 3 -
.../share/jfr/utilities/jfrAllocation.cpp | 2 -
.../share/jfr/utilities/jfrSpinlockHelper.hpp | 2 -
src/hotspot/share/oops/accessBackend.cpp | 49 -------
src/hotspot/share/oops/accessBackend.hpp | 48 +------
.../share/oops/accessBackend.inline.hpp | 38 ------
src/hotspot/share/prims/jvm.cpp | 6 -
.../share/runtime/abstract_vm_version.cpp | 2 +
.../share/runtime/abstract_vm_version.hpp | 4 +
src/hotspot/share/runtime/atomic.hpp | 12 +-
src/hotspot/share/runtime/mutexLocker.cpp | 7 -
src/hotspot/share/runtime/mutexLocker.hpp | 4 -
src/hotspot/share/runtime/vm_version.cpp | 4 +-
.../util/concurrent/atomic/AtomicLong.java | 14 --
.../atomic/AtomicLongFieldUpdater.java | 125 +-----------------
.../share/native/libjava/AtomicLong.c | 34 -----
test/hotspot/gtest/runtime/test_atomic.cpp | 12 --
.../util/concurrent/atomic/VMSupportsCS8.java | 53 --------
39 files changed, 31 insertions(+), 444 deletions(-)
delete mode 100644 src/java.base/share/native/libjava/AtomicLong.c
delete mode 100644 test/jdk/java/util/concurrent/atomic/VMSupportsCS8.java
diff --git a/make/data/hotspot-symbols/symbols-unix b/make/data/hotspot-symbols/symbols-unix
index d2be2cca7e829..9ca040794f36e 100644
--- a/make/data/hotspot-symbols/symbols-unix
+++ b/make/data/hotspot-symbols/symbols-unix
@@ -203,7 +203,6 @@ JVM_SetStackWalkContinuation
JVM_SetThreadPriority
JVM_SleepNanos
JVM_StartThread
-JVM_SupportsCX8
JVM_TotalMemory
JVM_UnloadLibrary
JVM_WaitForReferencePendingList
diff --git a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp
index b8a58849c01e5..92df369593877 100644
--- a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp
@@ -1511,7 +1511,6 @@ void LIR_Assembler::casl(Register addr, Register newval, Register cmpval) {
void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
- assert(VM_Version::supports_cx8(), "wrong machine");
Register addr;
if (op->addr()->is_register()) {
addr = as_reg(op->addr());
diff --git a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp
index 081e94341bde6..df28ca284c5cf 100644
--- a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp
@@ -68,7 +68,6 @@ static SpinWait get_spin_wait_desc() {
}
void VM_Version::initialize() {
- _supports_cx8 = true;
_supports_atomic_getset4 = true;
_supports_atomic_getadd4 = true;
_supports_atomic_getset8 = true;
diff --git a/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp b/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp
index 45786898458bc..72993b3211f9d 100644
--- a/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp
+++ b/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp
@@ -1385,7 +1385,6 @@ void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
__ mov(dest, 1, eq);
__ mov(dest, 0, ne);
} else if (op->code() == lir_cas_long) {
- assert(VM_Version::supports_cx8(), "wrong machine");
Register cmp_value_lo = op->cmp_value()->as_register_lo();
Register cmp_value_hi = op->cmp_value()->as_register_hi();
Register new_value_lo = op->new_value()->as_register_lo();
diff --git a/src/hotspot/cpu/arm/vm_version_arm_32.cpp b/src/hotspot/cpu/arm/vm_version_arm_32.cpp
index 44f2179db986d..d3ba352f78b15 100644
--- a/src/hotspot/cpu/arm/vm_version_arm_32.cpp
+++ b/src/hotspot/cpu/arm/vm_version_arm_32.cpp
@@ -128,10 +128,16 @@ void VM_Version::early_initialize() {
// use proper dmb instruction
get_os_cpu_info();
+ // Future cleanup: if SUPPORTS_NATIVE_CX8 is defined then we should not need
+ // any alternative solutions. At present this allows for the theoretical
+ // possibility of building for ARMv7 and then running on ARMv5 or 6. If that
+ // is impossible then the ARM port folk should clean this up.
_kuser_helper_version = *(int*)KUSER_HELPER_VERSION_ADDR;
+#ifndef SUPPORTS_NATIVE_CX8
// armv7 has the ldrexd instruction that can be used to implement cx8
// armv5 with linux >= 3.1 can use kernel helper routine
_supports_cx8 = (supports_ldrexd() || supports_kuser_cmpxchg64());
+#endif
}
void VM_Version::initialize() {
@@ -278,7 +284,7 @@ void VM_Version::initialize() {
_supports_atomic_getadd8 = supports_ldrexd();
#ifdef COMPILER2
- assert(_supports_cx8 && _supports_atomic_getset4 && _supports_atomic_getadd4
+ assert(supports_cx8() && _supports_atomic_getset4 && _supports_atomic_getadd4
&& _supports_atomic_getset8 && _supports_atomic_getadd8, "C2: atomic operations must be supported");
#endif
char buf[512];
diff --git a/src/hotspot/cpu/ppc/vm_version_ppc.cpp b/src/hotspot/cpu/ppc/vm_version_ppc.cpp
index 0b6824943b9ba..5a9d035be6034 100644
--- a/src/hotspot/cpu/ppc/vm_version_ppc.cpp
+++ b/src/hotspot/cpu/ppc/vm_version_ppc.cpp
@@ -200,10 +200,6 @@ void VM_Version::initialize() {
print_features();
}
- // PPC64 supports 8-byte compare-exchange operations (see Atomic::cmpxchg)
- // and 'atomic long memory ops' (see Unsafe_GetLongVolatile).
- _supports_cx8 = true;
-
// Used by C1.
_supports_atomic_getset4 = true;
_supports_atomic_getadd4 = true;
diff --git a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp
index 953478d05ae7e..99dc81438a700 100644
--- a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp
+++ b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp
@@ -1251,7 +1251,6 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
}
void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
- assert(VM_Version::supports_cx8(), "wrong machine");
Register addr;
if (op->addr()->is_register()) {
addr = as_reg(op->addr());
diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.cpp b/src/hotspot/cpu/riscv/vm_version_riscv.cpp
index 2f1fb5055f609..fc83e62985837 100644
--- a/src/hotspot/cpu/riscv/vm_version_riscv.cpp
+++ b/src/hotspot/cpu/riscv/vm_version_riscv.cpp
@@ -46,7 +46,6 @@ RV_FEATURE_FLAGS(ADD_RV_FEATURE_IN_LIST)
nullptr};
void VM_Version::initialize() {
- _supports_cx8 = true;
_supports_atomic_getset4 = true;
_supports_atomic_getadd4 = true;
_supports_atomic_getset8 = true;
diff --git a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp
index f79d647b48c9b..542ade8ed0ec3 100644
--- a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp
+++ b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp
@@ -2670,7 +2670,6 @@ void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
Register addr = op->addr()->as_pointer_register();
Register t1_cmp = Z_R1_scratch;
if (op->code() == lir_cas_long) {
- assert(VM_Version::supports_cx8(), "wrong machine");
Register cmp_value_lo = op->cmp_value()->as_register_lo();
Register new_value_lo = op->new_value()->as_register_lo();
__ z_lgr(t1_cmp, cmp_value_lo);
diff --git a/src/hotspot/cpu/s390/vm_version_s390.cpp b/src/hotspot/cpu/s390/vm_version_s390.cpp
index 23e9e975531bb..af0903884fb4f 100644
--- a/src/hotspot/cpu/s390/vm_version_s390.cpp
+++ b/src/hotspot/cpu/s390/vm_version_s390.cpp
@@ -287,11 +287,6 @@ void VM_Version::initialize() {
FLAG_SET_DEFAULT(UsePopCountInstruction, true);
}
- // z/Architecture supports 8-byte compare-exchange operations
- // (see Atomic::cmpxchg)
- // and 'atomic long memory ops' (see Unsafe_GetLongVolatile).
- _supports_cx8 = true;
-
_supports_atomic_getadd4 = VM_Version::has_LoadAndALUAtomicV1();
_supports_atomic_getadd8 = VM_Version::has_LoadAndALUAtomicV1();
diff --git a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp
index c6f469d433916..46c6c7e92641e 100644
--- a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp
+++ b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp
@@ -1929,7 +1929,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
- if (LP64_ONLY(false &&) op->code() == lir_cas_long && VM_Version::supports_cx8()) {
+ if (LP64_ONLY(false &&) op->code() == lir_cas_long) {
assert(op->cmp_value()->as_register_lo() == rax, "wrong register");
assert(op->cmp_value()->as_register_hi() == rdx, "wrong register");
assert(op->new_value()->as_register_lo() == rbx, "wrong register");
diff --git a/src/hotspot/cpu/x86/gc/shenandoah/shenandoah_x86_64.ad b/src/hotspot/cpu/x86/gc/shenandoah/shenandoah_x86_64.ad
index 3df65d037ae51..cb595f161686f 100644
--- a/src/hotspot/cpu/x86/gc/shenandoah/shenandoah_x86_64.ad
+++ b/src/hotspot/cpu/x86/gc/shenandoah/shenandoah_x86_64.ad
@@ -33,7 +33,6 @@ instruct compareAndSwapP_shenandoah(rRegI res,
rax_RegP oldval, rRegP newval,
rFlagsReg cr)
%{
- predicate(VM_Version::supports_cx8());
match(Set res (ShenandoahCompareAndSwapP mem_ptr (Binary oldval newval)));
match(Set res (ShenandoahWeakCompareAndSwapP mem_ptr (Binary oldval newval)));
effect(TEMP tmp1, TEMP tmp2, KILL cr, KILL oldval);
@@ -95,7 +94,6 @@ instruct compareAndExchangeP_shenandoah(memory mem_ptr,
rRegP tmp1, rRegP tmp2,
rFlagsReg cr)
%{
- predicate(VM_Version::supports_cx8());
match(Set oldval (ShenandoahCompareAndExchangeP mem_ptr (Binary oldval newval)));
effect(KILL cr, TEMP tmp1, TEMP tmp2);
ins_cost(1000);
diff --git a/src/hotspot/cpu/x86/vm_version_x86.cpp b/src/hotspot/cpu/x86/vm_version_x86.cpp
index 0ead388415efe..1517e456e8230 100644
--- a/src/hotspot/cpu/x86/vm_version_x86.cpp
+++ b/src/hotspot/cpu/x86/vm_version_x86.cpp
@@ -816,7 +816,6 @@ void VM_Version::get_processor_features() {
_L1_data_cache_line_size = L1_line_size();
}
- _supports_cx8 = supports_cmpxchg8();
// xchg and xadd instructions
_supports_atomic_getset4 = true;
_supports_atomic_getadd4 = true;
@@ -3236,4 +3235,3 @@ bool VM_Version::is_intrinsic_supported(vmIntrinsicID id) {
}
return true;
}
-
diff --git a/src/hotspot/cpu/x86/vm_version_x86.hpp b/src/hotspot/cpu/x86/vm_version_x86.hpp
index 078f14221dd9b..454a8f312553a 100644
--- a/src/hotspot/cpu/x86/vm_version_x86.hpp
+++ b/src/hotspot/cpu/x86/vm_version_x86.hpp
@@ -643,7 +643,6 @@ class VM_Version : public Abstract_VM_Version {
// Feature identification
//
static bool supports_cpuid() { return _features != 0; }
- static bool supports_cmpxchg8() { return (_features & CPU_CX8) != 0; }
static bool supports_cmov() { return (_features & CPU_CMOV) != 0; }
static bool supports_fxsr() { return (_features & CPU_FXSR) != 0; }
static bool supports_ht() { return (_features & CPU_HT) != 0; }
diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad
index 2567246b2060b..681abd7199fee 100644
--- a/src/hotspot/cpu/x86/x86.ad
+++ b/src/hotspot/cpu/x86/x86.ad
@@ -1510,9 +1510,6 @@ bool Matcher::match_rule_supported(int opcode) {
#ifdef _LP64
case Op_CompareAndSwapP:
#endif
- if (!VM_Version::supports_cx8()) {
- return false;
- }
break;
case Op_StrIndexOf:
if (!UseSSE42Intrinsics) {
@@ -10119,5 +10116,3 @@ instruct DoubleClassCheck_reg_reg_vfpclass(rRegI dst, regD src, kReg ktmp, rFlag
%}
ins_pipe(pipe_slow);
%}
-
-
diff --git a/src/hotspot/cpu/x86/x86_32.ad b/src/hotspot/cpu/x86/x86_32.ad
index d2d3c6b6fa199..07b3cb35a388d 100644
--- a/src/hotspot/cpu/x86/x86_32.ad
+++ b/src/hotspot/cpu/x86/x86_32.ad
@@ -7281,7 +7281,6 @@ instruct castDD_PR( regDPR dst ) %{
// No flag versions for CompareAndSwap{P,I,L} because matcher can't match them
instruct compareAndSwapL( rRegI res, eSIRegP mem_ptr, eADXRegL oldval, eBCXRegL newval, eFlagsReg cr ) %{
- predicate(VM_Version::supports_cx8());
match(Set res (CompareAndSwapL mem_ptr (Binary oldval newval)));
match(Set res (WeakCompareAndSwapL mem_ptr (Binary oldval newval)));
effect(KILL cr, KILL oldval);
@@ -7350,7 +7349,6 @@ instruct compareAndSwapI( rRegI res, pRegP mem_ptr, eAXRegI oldval, eCXRegI newv
%}
instruct compareAndExchangeL( eSIRegP mem_ptr, eADXRegL oldval, eBCXRegL newval, eFlagsReg cr ) %{
- predicate(VM_Version::supports_cx8());
match(Set oldval (CompareAndExchangeL mem_ptr (Binary oldval newval)));
effect(KILL cr);
format %{ "CMPXCHG8 [$mem_ptr],$newval\t# If EDX:EAX==[$mem_ptr] Then store $newval into [$mem_ptr]\n\t" %}
diff --git a/src/hotspot/cpu/x86/x86_64.ad b/src/hotspot/cpu/x86/x86_64.ad
index e41cadb4d4f96..94844cd4e7f9d 100644
--- a/src/hotspot/cpu/x86/x86_64.ad
+++ b/src/hotspot/cpu/x86/x86_64.ad
@@ -7174,7 +7174,7 @@ instruct compareAndSwapP(rRegI res,
rax_RegP oldval, rRegP newval,
rFlagsReg cr)
%{
- predicate(VM_Version::supports_cx8() && n->as_LoadStore()->barrier_data() == 0);
+ predicate(n->as_LoadStore()->barrier_data() == 0);
match(Set res (CompareAndSwapP mem_ptr (Binary oldval newval)));
match(Set res (WeakCompareAndSwapP mem_ptr (Binary oldval newval)));
effect(KILL cr, KILL oldval);
@@ -7197,7 +7197,6 @@ instruct compareAndSwapL(rRegI res,
rax_RegL oldval, rRegL newval,
rFlagsReg cr)
%{
- predicate(VM_Version::supports_cx8());
match(Set res (CompareAndSwapL mem_ptr (Binary oldval newval)));
match(Set res (WeakCompareAndSwapL mem_ptr (Binary oldval newval)));
effect(KILL cr, KILL oldval);
@@ -7358,7 +7357,6 @@ instruct compareAndExchangeL(
rax_RegL oldval, rRegL newval,
rFlagsReg cr)
%{
- predicate(VM_Version::supports_cx8());
match(Set oldval (CompareAndExchangeL mem_ptr (Binary oldval newval)));
effect(KILL cr);
@@ -7392,7 +7390,7 @@ instruct compareAndExchangeP(
rax_RegP oldval, rRegP newval,
rFlagsReg cr)
%{
- predicate(VM_Version::supports_cx8() && n->as_LoadStore()->barrier_data() == 0);
+ predicate(n->as_LoadStore()->barrier_data() == 0);
match(Set oldval (CompareAndExchangeP mem_ptr (Binary oldval newval)));
effect(KILL cr);
diff --git a/src/hotspot/cpu/zero/vm_version_zero.cpp b/src/hotspot/cpu/zero/vm_version_zero.cpp
index a99885a533df8..1fcf4b1086253 100644
--- a/src/hotspot/cpu/zero/vm_version_zero.cpp
+++ b/src/hotspot/cpu/zero/vm_version_zero.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright 2009 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -138,11 +138,13 @@ void VM_Version::initialize() {
UNSUPPORTED_OPTION(CountCompiledCalls);
#endif
+#ifndef SUPPORTS_NATIVE_CX8
// Supports 8-byte cmpxchg with compiler built-ins.
// These built-ins are supposed to be implemented on
// all platforms (even if not natively), so we claim
// the support unconditionally.
_supports_cx8 = true;
+#endif
}
void VM_Version::initialize_cpu_information(void) {
diff --git a/src/hotspot/os_cpu/linux_arm/atomic_linux_arm.hpp b/src/hotspot/os_cpu/linux_arm/atomic_linux_arm.hpp
index 513217649e633..4346920cd3765 100644
--- a/src/hotspot/os_cpu/linux_arm/atomic_linux_arm.hpp
+++ b/src/hotspot/os_cpu/linux_arm/atomic_linux_arm.hpp
@@ -153,7 +153,6 @@ inline int32_t reorder_cmpxchg_func(int32_t exchange_value,
inline int64_t reorder_cmpxchg_long_func(int64_t exchange_value,
int64_t volatile* dest,
int64_t compare_value) {
- assert(VM_Version::supports_cx8(), "Atomic compare and exchange int64_t not supported on this architecture!");
// Warning: Arguments are swapped to avoid moving them for kernel call
return (*ARMAtomicFuncs::_cmpxchg_long_func)(compare_value, exchange_value, dest);
}
diff --git a/src/hotspot/share/c1/c1_Compiler.cpp b/src/hotspot/share/c1/c1_Compiler.cpp
index def4b63fdf6b1..bdbeb39f89a4a 100644
--- a/src/hotspot/share/c1/c1_Compiler.cpp
+++ b/src/hotspot/share/c1/c1_Compiler.cpp
@@ -110,7 +110,6 @@ bool Compiler::is_intrinsic_supported(const methodHandle& method) {
bool Compiler::is_intrinsic_supported(vmIntrinsics::ID id) {
switch (id) {
case vmIntrinsics::_compareAndSetLong:
- if (!VM_Version::supports_cx8()) return false;
break;
case vmIntrinsics::_getAndAddInt:
if (!VM_Version::supports_atomic_getadd4()) return false;
diff --git a/src/hotspot/share/include/jvm.h b/src/hotspot/share/include/jvm.h
index 049c454c241a6..cc1b3d94cbd32 100644
--- a/src/hotspot/share/include/jvm.h
+++ b/src/hotspot/share/include/jvm.h
@@ -781,12 +781,6 @@ JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls);
JNIEXPORT jobject JNICALL
JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused);
-/*
- * java.util.concurrent.atomic.AtomicLong
- */
-JNIEXPORT jboolean JNICALL
-JVM_SupportsCX8(void);
-
/*
* java.lang.ref.Finalizer
*/
diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.cpp
index fd50628602334..f07078eaf06de 100644
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.cpp
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.cpp
@@ -35,12 +35,10 @@
#include "runtime/atomic.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/jniHandles.inline.hpp"
-#include "runtime/vm_version.hpp"
#include "utilities/growableArray.hpp"
// returns updated value
static traceid atomic_inc(traceid volatile* const dest, traceid stride = 1) {
- assert(VM_Version::supports_cx8(), "invariant");
traceid compare_value;
traceid exchange_value;
do {
@@ -294,4 +292,3 @@ void JfrTraceId::untag_jdk_jfr_event_sub(const Klass* k) {
}
assert(IS_NOT_AN_EVENT_SUB_KLASS(k), "invariant");
}
-
diff --git a/src/hotspot/share/jfr/utilities/jfrAllocation.cpp b/src/hotspot/share/jfr/utilities/jfrAllocation.cpp
index e9e41ac7cd875..c94765bbc8fe7 100644
--- a/src/hotspot/share/jfr/utilities/jfrAllocation.cpp
+++ b/src/hotspot/share/jfr/utilities/jfrAllocation.cpp
@@ -29,14 +29,12 @@
#include "memory/allocation.inline.hpp"
#include "nmt/memTracker.hpp"
#include "runtime/atomic.hpp"
-#include "runtime/vm_version.hpp"
#include "utilities/debug.hpp"
#include "utilities/macros.hpp"
#include "utilities/nativeCallStack.hpp"
#ifdef ASSERT
static jlong atomic_add_jlong(jlong value, jlong volatile* const dest) {
- assert(VM_Version::supports_cx8(), "unsupported");
jlong compare_value;
jlong exchange_value;
do {
diff --git a/src/hotspot/share/jfr/utilities/jfrSpinlockHelper.hpp b/src/hotspot/share/jfr/utilities/jfrSpinlockHelper.hpp
index a155b2690a054..8d381a646ee07 100644
--- a/src/hotspot/share/jfr/utilities/jfrSpinlockHelper.hpp
+++ b/src/hotspot/share/jfr/utilities/jfrSpinlockHelper.hpp
@@ -27,8 +27,6 @@
#include "runtime/javaThread.hpp"
-// this utility could be useful for non cx8 platforms
-
class JfrSpinlockHelper {
private:
volatile int* const _lock;
diff --git a/src/hotspot/share/oops/accessBackend.cpp b/src/hotspot/share/oops/accessBackend.cpp
index 61f58f1d33526..853f42f6f7e4c 100644
--- a/src/hotspot/share/oops/accessBackend.cpp
+++ b/src/hotspot/share/oops/accessBackend.cpp
@@ -28,60 +28,11 @@
#include "oops/oop.inline.hpp"
#include "runtime/javaThread.inline.hpp"
#include "runtime/mutexLocker.hpp"
-#include "runtime/vm_version.hpp"
#include "utilities/copy.hpp"
#include "utilities/debug.hpp"
#include "utilities/vmError.hpp"
namespace AccessInternal {
- // VM_Version::supports_cx8() is a surrogate for 'supports atomic long memory ops'.
- //
- // On platforms which do not support atomic compare-and-swap of jlong (8 byte)
- // values we have to use a lock-based scheme to enforce atomicity. This has to be
- // applied to all Unsafe operations that set the value of a jlong field. Even so
- // the compareAndSwapLong operation will not be atomic with respect to direct stores
- // to the field from Java code. It is important therefore that any Java code that
- // utilizes these Unsafe jlong operations does not perform direct stores. To permit
- // direct loads of the field from Java code we must also use Atomic::store within the
- // locked regions. And for good measure, in case there are direct stores, we also
- // employ Atomic::load within those regions. Note that the field in question must be
- // volatile and so must have atomic load/store accesses applied at the Java level.
- //
- // The locking scheme could utilize a range of strategies for controlling the locking
- // granularity: from a lock per-field through to a single global lock. The latter is
- // the simplest and is used for the current implementation. Note that the Java object
- // that contains the field, can not, in general, be used for locking. To do so can lead
- // to deadlocks as we may introduce locking into what appears to the Java code to be a
- // lock-free path.
- //
- // As all the locked-regions are very short and themselves non-blocking we can treat
- // them as leaf routines and elide safepoint checks (ie we don't perform any thread
- // state transitions even when blocking for the lock). Note that if we do choose to
- // add safepoint checks and thread state transitions, we must ensure that we calculate
- // the address of the field _after_ we have acquired the lock, else the object may have
- // been moved by the GC
-
-#ifndef SUPPORTS_NATIVE_CX8
-
- // This is intentionally in the cpp file rather than the .inline.hpp file. It seems
- // desirable to trade faster JDK build times (not propagating vm_version.hpp)
- // for slightly worse runtime atomic jlong performance on 32 bit machines with
- // support for 64 bit atomics.
- bool wide_atomic_needs_locking() {
- return !VM_Version::supports_cx8();
- }
-
- AccessLocker::AccessLocker() {
- assert(!VM_Version::supports_cx8(), "why else?");
- UnsafeJlong_lock->lock_without_safepoint_check();
- }
-
- AccessLocker::~AccessLocker() {
- UnsafeJlong_lock->unlock();
- }
-
-#endif
-
// These forward copying calls to Copy without exposing the Copy type in headers unnecessarily
void arraycopy_arrayof_conjoint_oops(void* src, void* dst, size_t length) {
diff --git a/src/hotspot/share/oops/accessBackend.hpp b/src/hotspot/share/oops/accessBackend.hpp
index c711a241ef947..5299b57ca4637 100644
--- a/src/hotspot/share/oops/accessBackend.hpp
+++ b/src/hotspot/share/oops/accessBackend.hpp
@@ -81,15 +81,6 @@ namespace AccessInternal {
reinterpret_cast((void*)base) + byte_offset);
}
- // This metafunction returns whether it is possible for a type T to require
- // locking to support wide atomics or not.
- template
-#ifdef SUPPORTS_NATIVE_CX8
- struct PossiblyLockedAccess: public std::false_type {};
-#else
- struct PossiblyLockedAccess: public std::integral_constant 4)> {};
-#endif
-
template
struct AccessFunctionTypes {
typedef T (*load_at_func_t)(oop base, ptrdiff_t offset);
@@ -140,13 +131,6 @@ namespace AccessInternal {
template
typename AccessFunction::type resolve_oop_barrier();
- class AccessLocker {
- public:
- AccessLocker();
- ~AccessLocker();
- };
- bool wide_atomic_needs_locking();
-
void* field_addr(oop base, ptrdiff_t offset);
// Forward calls to Copy:: in the cpp file to reduce dependencies and allow
@@ -281,34 +265,6 @@ class RawAccessBarrier: public AllStatic {
HasDecorator::value, T>::type
atomic_xchg_internal(void* addr, T new_value);
- // The following *_locked mechanisms serve the purpose of handling atomic operations
- // that are larger than a machine can handle, and then possibly opt for using
- // a slower path using a mutex to perform the operation.
-
- template
- static inline typename EnableIf<
- !AccessInternal::PossiblyLockedAccess::value, T>::type
- atomic_cmpxchg_maybe_locked(void* addr, T compare_value, T new_value) {
- return atomic_cmpxchg_internal(addr, compare_value, new_value);
- }
-
- template
- static typename EnableIf<
- AccessInternal::PossiblyLockedAccess::value, T>::type
- atomic_cmpxchg_maybe_locked(void* addr, T compare_value, T new_value);
-
- template
- static inline typename EnableIf<
- !AccessInternal::PossiblyLockedAccess::value, T>::type
- atomic_xchg_maybe_locked(void* addr, T new_value) {
- return atomic_xchg_internal(addr, new_value);
- }
-
- template
- static typename EnableIf<
- AccessInternal::PossiblyLockedAccess::value, T>::type
- atomic_xchg_maybe_locked(void* addr, T new_value);
-
public:
template
static inline void store(void* addr, T value) {
@@ -322,12 +278,12 @@ class RawAccessBarrier: public AllStatic {
template
static inline T atomic_cmpxchg(void* addr, T compare_value, T new_value) {
- return atomic_cmpxchg_maybe_locked(addr, compare_value, new_value);
+ return atomic_cmpxchg_internal(addr, compare_value, new_value);
}
template
static inline T atomic_xchg(void* addr, T new_value) {
- return atomic_xchg_maybe_locked(addr, new_value);
+ return atomic_xchg_internal(addr, new_value);
}
template
diff --git a/src/hotspot/share/oops/accessBackend.inline.hpp b/src/hotspot/share/oops/accessBackend.inline.hpp
index 677af8115c3d2..e0d4f5aca92a4 100644
--- a/src/hotspot/share/oops/accessBackend.inline.hpp
+++ b/src/hotspot/share/oops/accessBackend.inline.hpp
@@ -214,44 +214,6 @@ RawAccessBarrier::atomic_xchg_internal(void* addr, T new_value) {
new_value);
}
-// For platforms that do not have native support for wide atomics,
-// we can emulate the atomicity using a lock. So here we check
-// whether that is necessary or not.
-
-template
-template
-inline typename EnableIf<
- AccessInternal::PossiblyLockedAccess::value, T>::type
-RawAccessBarrier::atomic_xchg_maybe_locked(void* addr, T new_value) {
- if (!AccessInternal::wide_atomic_needs_locking()) {
- return atomic_xchg_internal(addr, new_value);
- } else {
- AccessInternal::AccessLocker access_lock;
- volatile T* p = reinterpret_cast(addr);
- T old_val = RawAccess<>::load(p);
- RawAccess<>::store(p, new_value);
- return old_val;
- }
-}
-
-template
-template
-inline typename EnableIf<
- AccessInternal::PossiblyLockedAccess::value, T>::type
-RawAccessBarrier::atomic_cmpxchg_maybe_locked(void* addr, T compare_value, T new_value) {
- if (!AccessInternal::wide_atomic_needs_locking()) {
- return atomic_cmpxchg_internal(addr, compare_value, new_value);
- } else {
- AccessInternal::AccessLocker access_lock;
- volatile T* p = reinterpret_cast(addr);
- T old_val = RawAccess<>::load(p);
- if (old_val == compare_value) {
- RawAccess<>::store(p, new_value);
- }
- return old_val;
- }
-}
-
class RawAccessBarrierArrayCopy: public AllStatic {
template struct IsHeapWordSized: public std::integral_constant { };
public:
diff --git a/src/hotspot/share/prims/jvm.cpp b/src/hotspot/share/prims/jvm.cpp
index 539122746b2f5..f0a30ee0311ad 100644
--- a/src/hotspot/share/prims/jvm.cpp
+++ b/src/hotspot/share/prims/jvm.cpp
@@ -3586,12 +3586,6 @@ JVM_ENTRY(jobject, JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjec
return res;
JVM_END
-// Atomic ///////////////////////////////////////////////////////////////////////////////////////////
-
-JVM_LEAF(jboolean, JVM_SupportsCX8())
- return VM_Version::supports_cx8();
-JVM_END
-
JVM_ENTRY(void, JVM_InitializeFromArchive(JNIEnv* env, jclass cls))
Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls));
assert(k->is_klass(), "just checking");
diff --git a/src/hotspot/share/runtime/abstract_vm_version.cpp b/src/hotspot/share/runtime/abstract_vm_version.cpp
index 2fdb820982a93..ac62523aed0eb 100644
--- a/src/hotspot/share/runtime/abstract_vm_version.cpp
+++ b/src/hotspot/share/runtime/abstract_vm_version.cpp
@@ -35,7 +35,9 @@ const char* Abstract_VM_Version::_s_internal_vm_info_string = Abstract_VM_Versio
uint64_t Abstract_VM_Version::_features = 0;
const char* Abstract_VM_Version::_features_string = "";
+#ifndef SUPPORTS_NATIVE_CX8
bool Abstract_VM_Version::_supports_cx8 = false;
+#endif
bool Abstract_VM_Version::_supports_atomic_getset4 = false;
bool Abstract_VM_Version::_supports_atomic_getset8 = false;
bool Abstract_VM_Version::_supports_atomic_getadd4 = false;
diff --git a/src/hotspot/share/runtime/abstract_vm_version.hpp b/src/hotspot/share/runtime/abstract_vm_version.hpp
index d9ed84f47510a..d8ffca8de81fb 100644
--- a/src/hotspot/share/runtime/abstract_vm_version.hpp
+++ b/src/hotspot/share/runtime/abstract_vm_version.hpp
@@ -59,7 +59,9 @@ class Abstract_VM_Version: AllStatic {
static const char* _features_string;
// These are set by machine-dependent initializations
+#ifndef SUPPORTS_NATIVE_CX8
static bool _supports_cx8;
+#endif
static bool _supports_atomic_getset4;
static bool _supports_atomic_getset8;
static bool _supports_atomic_getadd4;
@@ -133,6 +135,8 @@ class Abstract_VM_Version: AllStatic {
static void print_platform_virtualization_info(outputStream*) { }
// does HW support an 8-byte compare-exchange operation?
+ // Required to be true but still dynamically checked at runtime
+ // for platforms that don't set SUPPORTS_NATIVE_CX8
static bool supports_cx8() {
#ifdef SUPPORTS_NATIVE_CX8
return true;
diff --git a/src/hotspot/share/runtime/atomic.hpp b/src/hotspot/share/runtime/atomic.hpp
index ac0ce49d26e56..399a78fd3fce1 100644
--- a/src/hotspot/share/runtime/atomic.hpp
+++ b/src/hotspot/share/runtime/atomic.hpp
@@ -55,11 +55,13 @@ enum ScopedFenceType {
class Atomic : AllStatic {
public:
- // Atomic operations on int64 types are not available on all 32-bit
- // platforms. If atomic ops on int64 are defined here they must only
- // be used from code that verifies they are available at runtime and
- // can provide an alternative action if not - see supports_cx8() for
- // a means to test availability.
+ // Atomic operations on int64 types are required to be available on
+ // all platforms. At a minimum a 64-bit cmpxchg must be available
+ // from which other atomic operations can be constructed if needed.
+ // The legacy `Abstract_VMVersion::supports_cx8()` function used to
+ // indicate if this support existed, allowing for alternative lock-
+ // based mechanism to be used. But today this function is required
+ // to return true and in the future will be removed entirely.
// The memory operations that are mentioned with each of the atomic
// function families come from src/share/vm/runtime/orderAccess.hpp,
diff --git a/src/hotspot/share/runtime/mutexLocker.cpp b/src/hotspot/share/runtime/mutexLocker.cpp
index 62a685736c2c2..efd8490cd80e5 100644
--- a/src/hotspot/share/runtime/mutexLocker.cpp
+++ b/src/hotspot/share/runtime/mutexLocker.cpp
@@ -123,9 +123,6 @@ Mutex* JfrBuffer_lock = nullptr;
Monitor* JfrThreadSampler_lock = nullptr;
#endif
-#ifndef SUPPORTS_NATIVE_CX8
-Mutex* UnsafeJlong_lock = nullptr;
-#endif
Mutex* CodeHeapStateAnalytics_lock = nullptr;
Monitor* ContinuationRelativize_lock = nullptr;
@@ -298,10 +295,6 @@ void mutex_init() {
MUTEX_DEFN(JfrThreadSampler_lock , PaddedMonitor, nosafepoint);
#endif
-#ifndef SUPPORTS_NATIVE_CX8
- MUTEX_DEFN(UnsafeJlong_lock , PaddedMutex , nosafepoint);
-#endif
-
MUTEX_DEFN(ContinuationRelativize_lock , PaddedMonitor, nosafepoint-3);
MUTEX_DEFN(CodeHeapStateAnalytics_lock , PaddedMutex , safepoint);
MUTEX_DEFN(ThreadsSMRDelete_lock , PaddedMonitor, service-2); // Holds ConcurrentHashTableResize_lock
diff --git a/src/hotspot/share/runtime/mutexLocker.hpp b/src/hotspot/share/runtime/mutexLocker.hpp
index 9a0f9b9ab1ebe..840d01e62fa05 100644
--- a/src/hotspot/share/runtime/mutexLocker.hpp
+++ b/src/hotspot/share/runtime/mutexLocker.hpp
@@ -136,10 +136,6 @@ extern Mutex* JfrBuffer_lock; // protects JFR buffer operatio
extern Monitor* JfrThreadSampler_lock; // used to suspend/resume JFR thread sampler
#endif
-#ifndef SUPPORTS_NATIVE_CX8
-extern Mutex* UnsafeJlong_lock; // provides Unsafe atomic updates to jlongs on platforms that don't support cx8
-#endif
-
extern Mutex* Metaspace_lock; // protects Metaspace virtualspace and chunk expansions
extern Monitor* MetaspaceCritical_lock; // synchronizes failed metaspace allocations that risk throwing metaspace OOM
extern Mutex* ClassLoaderDataGraph_lock; // protects CLDG list, needed for concurrent unloading
diff --git a/src/hotspot/share/runtime/vm_version.cpp b/src/hotspot/share/runtime/vm_version.cpp
index 33a5c792c87d5..e2a7aa565d6b8 100644
--- a/src/hotspot/share/runtime/vm_version.cpp
+++ b/src/hotspot/share/runtime/vm_version.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2020, 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
@@ -30,7 +30,7 @@
void VM_Version_init() {
VM_Version::initialize();
-
+ guarantee(VM_Version::supports_cx8(), "Support for 64-bit atomic operations is required");
if (log_is_enabled(Info, os, cpu)) {
char buf[1024];
ResourceMark rm;
diff --git a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java
index 926b773827ca8..e446df8fd3e0c 100644
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java
@@ -55,20 +55,6 @@
public class AtomicLong extends Number implements java.io.Serializable {
private static final long serialVersionUID = 1927816293512124184L;
- /**
- * Records whether the underlying JVM supports lockless
- * compareAndSet for longs. While the intrinsic compareAndSetLong
- * method works in either case, some constructions should be
- * handled at Java level to avoid locking user-visible locks.
- */
- static final boolean VM_SUPPORTS_LONG_CAS = VMSupportsCS8();
-
- /**
- * Returns whether underlying JVM supports lockless CompareAndSet
- * for longs. Called only once and cached in VM_SUPPORTS_LONG_CAS.
- */
- private static native boolean VMSupportsCS8();
-
/*
* This class intended to be implemented using VarHandles, but there
* are unresolved cyclic startup dependencies.
diff --git a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
index ae5440ef5f2a0..0e496dbd6a55d 100644
--- a/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
@@ -90,10 +90,7 @@ public abstract class AtomicLongFieldUpdater {
public static AtomicLongFieldUpdater newUpdater(Class tclass,
String fieldName) {
Class> caller = Reflection.getCallerClass();
- if (AtomicLong.VM_SUPPORTS_LONG_CAS)
- return new CASUpdater(tclass, fieldName, caller);
- else
- return new LockedUpdater(tclass, fieldName, caller);
+ return new CASUpdater(tclass, fieldName, caller);
}
/**
@@ -515,126 +512,6 @@ public final long addAndGet(T obj, long delta) {
}
}
- private static final class LockedUpdater extends AtomicLongFieldUpdater {
- private static final Unsafe U = Unsafe.getUnsafe();
- private final long offset;
- /**
- * if field is protected, the subclass constructing updater, else
- * the same as tclass
- */
- private final Class> cclass;
- /** class holding the field */
- private final Class tclass;
-
- @SuppressWarnings("removal")
- LockedUpdater(final Class tclass, final String fieldName,
- final Class> caller) {
- final Field field;
- final int modifiers;
- try {
- field = AccessController.doPrivileged(
- new PrivilegedExceptionAction() {
- public Field run() throws NoSuchFieldException {
- return tclass.getDeclaredField(fieldName);
- }
- });
- modifiers = field.getModifiers();
- sun.reflect.misc.ReflectUtil.ensureMemberAccess(
- caller, tclass, null, modifiers);
- ClassLoader cl = tclass.getClassLoader();
- ClassLoader ccl = caller.getClassLoader();
- if ((ccl != null) && (ccl != cl) &&
- ((cl == null) || !isAncestor(cl, ccl))) {
- sun.reflect.misc.ReflectUtil.checkPackageAccess(tclass);
- }
- } catch (PrivilegedActionException pae) {
- throw new RuntimeException(pae.getException());
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
-
- if (field.getType() != long.class)
- throw new IllegalArgumentException("Must be long type");
-
- if (!Modifier.isVolatile(modifiers))
- throw new IllegalArgumentException("Must be volatile type");
-
- // Access to protected field members is restricted to receivers only
- // of the accessing class, or one of its subclasses, and the
- // accessing class must in turn be a subclass (or package sibling)
- // of the protected member's defining class.
- // If the updater refers to a protected field of a declaring class
- // outside the current package, the receiver argument will be
- // narrowed to the type of the accessing class.
- this.cclass = (Modifier.isProtected(modifiers) &&
- tclass.isAssignableFrom(caller) &&
- !isSamePackage(tclass, caller))
- ? caller : tclass;
- this.tclass = tclass;
- this.offset = U.objectFieldOffset(field);
- }
-
- /**
- * Checks that target argument is instance of cclass. On
- * failure, throws cause.
- */
- private final void accessCheck(T obj) {
- if (!cclass.isInstance(obj))
- throw accessCheckException(obj);
- }
-
- /**
- * Returns access exception if accessCheck failed due to
- * protected access, else ClassCastException.
- */
- private final RuntimeException accessCheckException(T obj) {
- if (cclass == tclass)
- return new ClassCastException();
- else
- return new RuntimeException(
- new IllegalAccessException(
- "Class " +
- cclass.getName() +
- " can not access a protected member of class " +
- tclass.getName() +
- " using an instance of " +
- obj.getClass().getName()));
- }
-
- public final boolean compareAndSet(T obj, long expect, long update) {
- accessCheck(obj);
- synchronized (this) {
- long v = U.getLong(obj, offset);
- if (v != expect)
- return false;
- U.putLong(obj, offset, update);
- return true;
- }
- }
-
- public final boolean weakCompareAndSet(T obj, long expect, long update) {
- return compareAndSet(obj, expect, update);
- }
-
- public final void set(T obj, long newValue) {
- accessCheck(obj);
- synchronized (this) {
- U.putLong(obj, offset, newValue);
- }
- }
-
- public final void lazySet(T obj, long newValue) {
- set(obj, newValue);
- }
-
- public final long get(T obj) {
- accessCheck(obj);
- synchronized (this) {
- return U.getLong(obj, offset);
- }
- }
- }
-
/**
* Returns true if the second classloader can be found in the first
* classloader's delegation chain.
diff --git a/src/java.base/share/native/libjava/AtomicLong.c b/src/java.base/share/native/libjava/AtomicLong.c
deleted file mode 100644
index bc4fd5db9708a..0000000000000
--- a/src/java.base/share/native/libjava/AtomicLong.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2004, 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.
- */
-
-#include
-#include
-#include "java_util_concurrent_atomic_AtomicLong.h"
-
-JNIEXPORT jboolean JNICALL
-Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8(JNIEnv *env, jclass cls)
-{
- return JVM_SupportsCX8();
-}
diff --git a/test/hotspot/gtest/runtime/test_atomic.cpp b/test/hotspot/gtest/runtime/test_atomic.cpp
index 744714c6f7fa5..b99ec0f984dde 100644
--- a/test/hotspot/gtest/runtime/test_atomic.cpp
+++ b/test/hotspot/gtest/runtime/test_atomic.cpp
@@ -60,9 +60,6 @@ TEST_VM(AtomicAddTest, int32) {
}
TEST_VM(AtomicAddTest, int64) {
- // Check if 64-bit atomics are available on the machine.
- if (!VM_Version::supports_cx8()) return;
-
using Support = AtomicAddTestSupport;
Support().test_add();
Support().test_fetch_add();
@@ -109,9 +106,6 @@ TEST_VM(AtomicXchgTest, int32) {
}
TEST_VM(AtomicXchgTest, int64) {
- // Check if 64-bit atomics are available on the machine.
- if (!VM_Version::supports_cx8()) return;
-
using Support = AtomicXchgTestSupport;
Support().test();
}
@@ -349,15 +343,9 @@ TEST_VM(AtomicBitopsTest, uint32) {
}
TEST_VM(AtomicBitopsTest, int64) {
- // Check if 64-bit atomics are available on the machine.
- if (!VM_Version::supports_cx8()) return;
-
AtomicBitopsTestSupport()();
}
TEST_VM(AtomicBitopsTest, uint64) {
- // Check if 64-bit atomics are available on the machine.
- if (!VM_Version::supports_cx8()) return;
-
AtomicBitopsTestSupport()();
}
diff --git a/test/jdk/java/util/concurrent/atomic/VMSupportsCS8.java b/test/jdk/java/util/concurrent/atomic/VMSupportsCS8.java
deleted file mode 100644
index a485a490bb659..0000000000000
--- a/test/jdk/java/util/concurrent/atomic/VMSupportsCS8.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2004, 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 4992443 4994819
- * @modules java.base/java.util.concurrent.atomic:open
- * @run main VMSupportsCS8
- * @summary Checks that the value of VMSupportsCS8 matches system properties.
- */
-
-import java.lang.reflect.Field;
-
-public class VMSupportsCS8 {
- public static void main(String[] args) throws Exception {
- String isalist = System.getProperty("sun.cpu.isalist");
- if (isalist != null && isalist.matches
- (".*\\b(pentium_pro|ia64|amd64).*")
- ||
- System.getProperty("os.arch").matches
- (".*\\b(ia64|amd64).*")) {
-
- System.out.println("This system is known to have hardware CS8");
-
- Class klass = Class.forName("java.util.concurrent.atomic.AtomicLong");
- Field field = klass.getDeclaredField("VM_SUPPORTS_LONG_CAS");
- field.setAccessible(true);
- boolean VMSupportsCS8 = field.getBoolean(null);
- if (! VMSupportsCS8)
- throw new Exception("Unexpected value for VMSupportsCS8");
- }
- }
-}
From df1b896e01f4e7feeff90c1836aa395201fc4e4e Mon Sep 17 00:00:00 2001
From: Doug Simon
Date: Thu, 23 Nov 2023 23:36:08 +0000
Subject: [PATCH 051/250] 8320679: [JVMCI] invalid code in PushLocalFrame event
message
Reviewed-by: never
---
src/hotspot/share/jvmci/jvmciEnv.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hotspot/share/jvmci/jvmciEnv.cpp b/src/hotspot/share/jvmci/jvmciEnv.cpp
index 47db09d6922c7..b060bd8479fe4 100644
--- a/src/hotspot/share/jvmci/jvmciEnv.cpp
+++ b/src/hotspot/share/jvmci/jvmciEnv.cpp
@@ -189,7 +189,7 @@ void JVMCIEnv::init_env_mode_runtime(JavaThread* thread, JNIEnv* parent_env) {
JNIAccessMark jni(this, thread);
jint result = _env->PushLocalFrame(32);
if (result != JNI_OK) {
- JVMCI_event_1("[%s:%d] Error pushing local JNI frame (err: %d)", _file, _line, _init_error);
+ JVMCI_event_1("[%s:%d] Error pushing local JNI frame (err: %d)", _file, _line, result);
return;
}
_pop_frame_on_close = true;
From fc314740e947b2338ab9e4d4fce0c4f52de56c4b Mon Sep 17 00:00:00 2001
From: Jan Lahoda
Date: Fri, 24 Nov 2023 06:30:08 +0000
Subject: [PATCH 052/250] 8318913: The module-infos for --release data do not
contain pre-set versions
Co-authored-by: Erik Joelsson
Reviewed-by: vromero, ihse
---
make/Main.gmk | 21 +-
make/autoconf/boot-jdk.m4 | 4 +-
make/autoconf/spec.gmk.in | 3 +-
.../tools/symbolgenerator/CreateSymbols.java | 337 +++++++++++++++---
.../TransitiveDependencies.java | 123 -------
make/modules/jdk.compiler/Gendata.gmk | 53 ++-
.../javac/platform/JDKPlatformProvider.java | 37 --
.../platform/CanHandleClassFilesTest.java | 7 +-
.../javac/platform/ModuleVersionTest.java | 114 ++++++
.../platform/NonExportedPermittedTypes.java | 52 +++
.../platform/NonExportedPermittedTypes.out | 2 +
.../javac/platform/NonExportedSuperTypes.java | 3 +-
.../platform/ReleaseAndEnablePreview.java | 38 ++
.../createsymbols/CreateSymbolsTestImpl.java | 12 +-
14 files changed, 546 insertions(+), 260 deletions(-)
delete mode 100644 make/langtools/src/classes/build/tools/symbolgenerator/TransitiveDependencies.java
create mode 100644 test/langtools/tools/javac/platform/ModuleVersionTest.java
create mode 100644 test/langtools/tools/javac/platform/NonExportedPermittedTypes.java
create mode 100644 test/langtools/tools/javac/platform/NonExportedPermittedTypes.out
create mode 100644 test/langtools/tools/javac/platform/ReleaseAndEnablePreview.java
diff --git a/make/Main.gmk b/make/Main.gmk
index 8fdaf788c4dfe..1817416867738 100644
--- a/make/Main.gmk
+++ b/make/Main.gmk
@@ -608,11 +608,11 @@ endif
ifeq ($(CREATING_BUILDJDK), true)
# This target is only called by the recursive call below.
create-buildjdk-interim-image-helper: interim-image jdk.jlink-launchers \
- java.base-copy jdk.jdeps-launchers
+ java.base-copy jdk.jdeps-launchers jdk.compiler-launchers
endif
-BUILDJDK_MODULES := $(sort $(foreach m, jdk.jlink $(INTERIM_IMAGE_MODULES), \
- $(call FindTransitiveDepsForModule, $m) $m))
+BUILDJDK_MODULES := $(sort $(foreach m, jdk.jlink jdk.compiler \
+ $(INTERIM_IMAGE_MODULES), $(call FindTransitiveDepsForModule, $m) $m))
$(eval $(call SetupTarget, create-buildjdk-interim-image, \
MAKEFILE := Main, \
@@ -971,7 +971,20 @@ else
jdk.jdeps-gendata: java
# The ct.sym generation uses all the moduleinfos as input
- jdk.compiler-gendata: $(GENSRC_MODULEINFO_TARGETS)
+ jdk.compiler-gendata: $(GENSRC_MODULEINFO_TARGETS) $(JAVA_TARGETS)
+ # jdk.compiler-gendata needs the BUILD_JDK. If the BUILD_JDK was supplied
+ # externally, no extra prerequisites are needed.
+ ifeq ($(CREATE_BUILDJDK), true)
+ ifneq ($(CREATING_BUILDJDK), true)
+ # When cross compiling and an external BUILD_JDK wasn't supplied, it's
+ # produced by the create-buildjdk target.
+ jdk.compiler-gendata: create-buildjdk
+ endif
+ else ifeq ($(EXTERNAL_BUILDJDK), false)
+ # When not cross compiling, the BUILD_JDK is the interim jdk image, and
+ # the javac launcher is needed.
+ jdk.compiler-gendata: jdk.compiler-launchers
+ endif
# Declare dependencies between jmod targets.
# java.base jmod needs jrt-fs.jar and access to the jmods for all non
diff --git a/make/autoconf/boot-jdk.m4 b/make/autoconf/boot-jdk.m4
index 960a8ffce3a88..8d272c28ad54f 100644
--- a/make/autoconf/boot-jdk.m4
+++ b/make/autoconf/boot-jdk.m4
@@ -520,8 +520,8 @@ AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS],
# Don't presuppose SerialGC is present in the buildjdk. Also, we cannot test
# the buildjdk, but on the other hand we know what it will support.
- BUILDJDK_JAVA_FLAGS_SMALL="-Xms32M -Xmx512M -XX:TieredStopAtLevel=1"
- AC_SUBST(BUILDJDK_JAVA_FLAGS_SMALL)
+ BUILD_JAVA_FLAGS_SMALL="-Xms32M -Xmx512M -XX:TieredStopAtLevel=1"
+ AC_SUBST(BUILD_JAVA_FLAGS_SMALL)
JAVA_TOOL_FLAGS_SMALL=""
for f in $JAVA_FLAGS_SMALL; do
diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in
index 2b7a7b8d1afde..3ac1ea7427197 100644
--- a/make/autoconf/spec.gmk.in
+++ b/make/autoconf/spec.gmk.in
@@ -663,7 +663,7 @@ STRIPFLAGS:=@STRIPFLAGS@
JAVA_FLAGS:=@JAVA_FLAGS@
JAVA_FLAGS_BIG:=@JAVA_FLAGS_BIG@
JAVA_FLAGS_SMALL:=@JAVA_FLAGS_SMALL@
-BUILDJDK_JAVA_FLAGS_SMALL:=@BUILDJDK_JAVA_FLAGS_SMALL@
+BUILD_JAVA_FLAGS_SMALL:=@BUILD_JAVA_FLAGS_SMALL@
JAVA_TOOL_FLAGS_SMALL:=@JAVA_TOOL_FLAGS_SMALL@
# The *_CMD variables are defined separately to be easily overridden in bootcycle-spec.gmk
@@ -690,6 +690,7 @@ JTREG_JAVA = @FIXPATH@ $(JTREG_JDK)/bin/java $(JAVA_FLAGS_BIG) $(JAVA_FLAGS)
BUILD_JAVA_FLAGS := @BOOTCYCLE_JVM_ARGS_BIG@
BUILD_JAVA=@FIXPATH@ $(BUILD_JDK)/bin/java $(BUILD_JAVA_FLAGS)
+BUILD_JAVA_SMALL=@FIXPATH@ $(BUILD_JDK)/bin/java $(BUILD_JAVA_FLAGS_SMALL)
BUILD_JAVAC=@FIXPATH@ $(BUILD_JDK)/bin/javac
BUILD_JAR=@FIXPATH@ $(BUILD_JDK)/bin/jar
diff --git a/make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java b/make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java
index 76dcdb6273a2b..860a96f2b677d 100644
--- a/make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java
+++ b/make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java
@@ -150,7 +150,9 @@
import com.sun.tools.javac.util.Assert;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.Pair;
+import java.nio.file.DirectoryStream;
import java.util.Optional;
+import java.util.function.Consumer;
/**
* A tool for processing the .sym.txt files.
@@ -228,11 +230,25 @@ public class CreateSymbols {
*/
@SuppressWarnings("unchecked")
public void createSymbols(String ctDescriptionFileExtra, String ctDescriptionFile, String ctSymLocation,
- long timestamp, String currentVersion, String systemModules) throws IOException {
+ long timestamp, String currentVersion, String preReleaseTag, String moduleClasses) throws IOException {
LoadDescriptions data = load(ctDescriptionFileExtra != null ? Paths.get(ctDescriptionFileExtra)
: null,
Paths.get(ctDescriptionFile));
+ int currentVersionParsed = Integer.parseInt(currentVersion);
+
+ currentVersion = Integer.toString(currentVersionParsed, Character.MAX_RADIX);
+ currentVersion = currentVersion.toUpperCase(Locale.ROOT);
+
+ String previousVersion = Integer.toString(currentVersionParsed - 1, Character.MAX_RADIX);
+
+ previousVersion = previousVersion.toUpperCase(Locale.ROOT);
+
+ //load current version classes:
+ Path moduleClassPath = Paths.get(moduleClasses);
+
+ loadVersionClassesFromDirectory(data.classes, data.modules, moduleClassPath, currentVersion, previousVersion);
+
stripNonExistentAnnotations(data);
splitHeaders(data.classes);
@@ -241,12 +257,19 @@ public void createSymbols(String ctDescriptionFileExtra, String ctDescriptionFil
for (ModuleDescription md : data.modules.values()) {
for (ModuleHeaderDescription mhd : md.header) {
- List versionsList =
- Collections.singletonList(mhd.versions);
writeModulesForVersions(directory2FileData,
md,
mhd,
- versionsList);
+ mhd.versions,
+ version -> {
+ String versionString = Character.toString(version);
+ int versionNumber = Integer.parseInt(versionString, Character.MAX_RADIX);
+ versionString = Integer.toString(versionNumber);
+ if (versionNumber == currentVersionParsed && !preReleaseTag.isEmpty()) {
+ versionString = versionString + "-" + preReleaseTag;
+ }
+ return versionString;
+ });
List packages = new ArrayList<>();
mhd.exports.stream()
.map(ExportsDescription::packageName)
@@ -293,13 +316,6 @@ public void createSymbols(String ctDescriptionFileExtra, String ctDescriptionFil
}
}
- currentVersion = Integer.toString(Integer.parseInt(currentVersion), Character.MAX_RADIX);
- currentVersion = currentVersion.toUpperCase(Locale.ROOT);
-
- openDirectory(directory2FileData, currentVersion + "/")
- .add(new FileData(currentVersion + "/system-modules",
- Files.readAllBytes(Paths.get(systemModules))));
-
try (OutputStream fos = new FileOutputStream(ctSymLocation);
OutputStream bos = new BufferedOutputStream(fos);
ZipOutputStream jos = new ZipOutputStream(bos)) {
@@ -788,10 +804,14 @@ void writeClassesForVersions(Map> directory2FileData,
void writeModulesForVersions(Map> directory2FileData,
ModuleDescription moduleDescription,
ModuleHeaderDescription header,
- Iterable versions)
+ String versions,
+ Function version2ModuleVersion)
throws IOException {
- for (String ver : versions) {
- writeModule(directory2FileData, moduleDescription, header, ver);
+ //ensure every module-info.class is written separatelly,
+ //so that the correct version is used for it:
+ for (char ver : versions.toCharArray()) {
+ writeModule(directory2FileData, moduleDescription, header, ver,
+ version2ModuleVersion);
}
}
@@ -799,7 +819,8 @@ void writeModulesForVersions(Map> directory2FileData,
void writeModule(Map> directory2FileData,
ModuleDescription moduleDescription,
ModuleHeaderDescription header,
- String version) throws IOException {
+ char version,
+ Function version2ModuleVersion) throws IOException {
List constantPool = new ArrayList<>();
constantPool.add(null);
int currentClass = addClass(constantPool, "module-info");
@@ -807,7 +828,9 @@ void writeModule(Map> directory2FileData,
int[] interfaces = new int[0];
AccessFlags flags = new AccessFlags(header.flags);
Map attributesMap = new HashMap<>();
- addAttributes(moduleDescription, header, constantPool, attributesMap);
+ String versionString = Character.toString(version);
+ addAttributes(moduleDescription, header, constantPool, attributesMap,
+ version2ModuleVersion.apply(version));
Attributes attributes = new Attributes(attributesMap);
CPInfo[] cpData = constantPool.toArray(new CPInfo[constantPool.size()]);
ConstantPool cp = new ConstantPool(cpData);
@@ -823,7 +846,7 @@ void writeModule(Map> directory2FileData,
new Method[0],
attributes);
- doWrite(directory2FileData, version, moduleDescription.name, "module-info" + EXTENSION, classFile);
+ doWrite(directory2FileData, versionString, moduleDescription.name, "module-info" + EXTENSION, classFile);
}
void writeClass(Map> directory2FileData,
@@ -924,7 +947,8 @@ public FileData(String fileName, byte[] fileData) {
private void addAttributes(ModuleDescription md,
ModuleHeaderDescription header,
List cp,
- Map attributes) {
+ Map attributes,
+ String moduleVersion) {
addGenericAttributes(header, cp, attributes);
if (header.moduleResolution != null) {
int attrIdx = addString(cp, Attribute.ModuleResolution);
@@ -945,12 +969,13 @@ private void addAttributes(ModuleDescription md,
attributes.put(Attribute.ModuleMainClass,
new ModuleMainClass_attribute(attrIdx, targetIdx));
}
+ int versionIdx = addString(cp, moduleVersion);
int attrIdx = addString(cp, Attribute.Module);
attributes.put(Attribute.Module,
new Module_attribute(attrIdx,
addModuleName(cp, md.name),
0,
- 0,
+ versionIdx,
header.requires
.stream()
.map(r -> createRequiresEntry(cp, r))
@@ -1123,8 +1148,9 @@ private void addAttributes(MethodDescription desc, List constantPool, Ma
MethodParameters_attribute.Entry[] entries =
desc.methodParameters
.stream()
- .map(p -> new MethodParameters_attribute.Entry(addString(constantPool, p.name),
- p.flags))
+ .map(p -> new MethodParameters_attribute.Entry(p.name == null || p.name.isEmpty() ? 0
+ : addString(constantPool, p.name),
+ p.flags))
.toArray(s -> new MethodParameters_attribute.Entry[s]);
attributes.put(Attribute.MethodParameters,
new MethodParameters_attribute(attributeString, entries));
@@ -1492,7 +1518,7 @@ private void loadVersionClasses(ClassList classes,
}
}
- ExcludeIncludeList currentEIList = excludesIncludes;
+ ExcludeIncludeList currentEIList;
if (!currentVersionModules.isEmpty()) {
Set privateIncludes =
@@ -1509,19 +1535,182 @@ private void loadVersionClasses(ClassList classes,
currentEIList = new ExcludeIncludeList(includes,
privateIncludes,
Collections.emptySet());
+ } else {
+ currentEIList = excludesIncludes;
}
ClassList currentVersionClasses = new ClassList();
+ Map extraModulesPackagesToDerive = new HashMap<>();
for (byte[] classFileData : classData) {
try (InputStream in = new ByteArrayInputStream(classFileData)) {
inspectClassFile(in, currentVersionClasses,
- currentEIList, version);
+ currentEIList, version,
+ cf -> {
+ PermittedSubclasses_attribute permitted = (PermittedSubclasses_attribute) cf.getAttribute(Attribute.PermittedSubclasses);
+ if (permitted != null) {
+ try {
+ String currentPack = cf.getName().substring(0, cf.getName().lastIndexOf('/'));
+
+ for (int i = 0; i < permitted.subtypes.length; i++) {
+ String permittedClassName = cf.constant_pool.getClassInfo(permitted.subtypes[i]).getName();
+ if (!currentEIList.accepts(permittedClassName, false)) {
+ String permittedPack = permittedClassName.substring(0, permittedClassName.lastIndexOf('/'));
+
+ extraModulesPackagesToDerive.put(permittedPack, currentPack);
+ }
+ }
+ } catch (ConstantPoolException ex) {
+ throw new IllegalStateException(ex);
+ }
+ }
+ });
} catch (IOException | ConstantPoolException ex) {
throw new IllegalStateException(ex);
}
}
+ //derive extra module packages for permitted types based on on their supertypes:
+ boolean modified;
+
+ do {
+ modified = false;
+
+ for (Iterator> it = extraModulesPackagesToDerive.entrySet().iterator(); it.hasNext();) {
+ Entry e = it.next();
+ Optional module = currentVersionModules.values().stream().map(md -> md.header.get(0)).filter(d -> containsPackage(d, e.getValue())).findAny();
+ if (module.isPresent()) {
+ if (!module.get().extraModulePackages.contains(e.getKey())) {
+ module.get().extraModulePackages.add(e.getKey());
+ }
+ it.remove();
+ modified = true;
+ }
+ }
+ } while (modified);
+
+ if (!extraModulesPackagesToDerive.isEmpty()) {
+ throw new AssertionError("Cannot derive some owning modules: " + extraModulesPackagesToDerive);
+ }
+
+ finishClassLoading(classes, modules, currentVersionModules, currentVersionClasses, currentEIList, version, baseline);
+ }
+
+ private boolean containsPackage(ModuleHeaderDescription module, String pack) {
+ return module.exports.stream().filter(ed -> ed.packageName().equals(pack)).findAny().isPresent() ||
+ module.extraModulePackages.contains(pack);
+ }
+
+ private void loadVersionClassesFromDirectory(ClassList classes,
+ Map modules,
+ Path modulesDirectory,
+ String version,
+ String baseline) {
+ Map currentVersionModules =
+ new HashMap<>();
+ ClassList currentVersionClasses = new ClassList();
+ Set privateIncludes = new HashSet<>();
+ Set includes = new HashSet<>();
+ ExcludeIncludeList currentEIList = new ExcludeIncludeList(includes,
+ privateIncludes,
+ Collections.emptySet());
+
+ try {
+ Map modulePath2Header = new HashMap<>();
+ List pendingExportedDirectories = new ArrayList<>();
+
+ try (DirectoryStream ds = Files.newDirectoryStream(modulesDirectory)) {
+ for (Path p : ds) {
+ Path moduleInfo = p.resolve("module-info.class");
+
+ if (Files.isReadable(moduleInfo)) {
+ ModuleDescription md;
+
+ try (InputStream in = Files.newInputStream(moduleInfo)) {
+ md = inspectModuleInfoClassFile(in,
+ currentVersionModules, version);
+ }
+ if (md == null) {
+ continue;
+ }
+
+ modulePath2Header.put(p, md.header.get(0));
+
+ Set currentModuleExports =
+ md.header.get(0).exports.stream()
+ .filter(e -> !e.isQualified())
+ .map(e -> e.packageName + '/')
+ .collect(Collectors.toSet());
+
+ for (String dir : currentModuleExports) {
+ includes.add(dir);
+ pendingExportedDirectories.add(p.resolve(dir));
+ }
+ }
+ }
+ }
+
+ List pendingExtraClasses = new ArrayList<>();
+
+ for (Path exported : pendingExportedDirectories) {
+ try (DirectoryStream ds = Files.newDirectoryStream(exported)) {
+ for (Path p2 : ds) {
+ if (!Files.isRegularFile(p2) || !p2.getFileName().toString().endsWith(".class")) {
+ continue;
+ }
+
+ loadFromDirectoryHandleClassFile(p2, currentVersionClasses,
+ currentEIList, version,
+ pendingExtraClasses);
+ }
+ }
+ }
+
+ while (!pendingExtraClasses.isEmpty()) {
+ String current = pendingExtraClasses.remove(pendingExtraClasses.size() - 1);
+
+ if (currentVersionClasses.find(current, true) != null) {
+ continue;
+ }
+
+ for (Entry e : modulePath2Header.entrySet()) {
+ Path currentPath = e.getKey().resolve(current + ".class");
+
+ if (Files.isReadable(currentPath)) {
+ String pack = current.substring(0, current.lastIndexOf('/'));
+
+ e.getValue().extraModulePackages.add(pack);
+
+ loadFromDirectoryHandleClassFile(currentPath, currentVersionClasses,
+ currentEIList, version,
+ pendingExtraClasses);
+ }
+ }
+ }
+ } catch (IOException | ConstantPoolException ex) {
+ throw new IllegalStateException(ex);
+ }
+
+ finishClassLoading(classes, modules, currentVersionModules, currentVersionClasses, currentEIList, version, baseline);
+ }
+
+ private void loadFromDirectoryHandleClassFile(Path path, ClassList currentVersionClasses,
+ ExcludeIncludeList currentEIList, String version,
+ List todo) throws IOException, ConstantPoolException {
+ try (InputStream in = Files.newInputStream(path)) {
+ inspectClassFile(in, currentVersionClasses,
+ currentEIList, version,
+ cf -> {
+ Set superTypes = otherRelevantTypesWithOwners(cf);
+
+ currentEIList.privateIncludeList.addAll(superTypes);
+ todo.addAll(superTypes);
+ });
+ }
+ }
+
+ private void finishClassLoading(ClassList classes, Map modules, Map currentVersionModules, ClassList currentVersionClasses, ExcludeIncludeList currentEIList, String version,
+ String baseline) {
ModuleDescription unsupported =
currentVersionModules.get("jdk.unsupported");
@@ -1563,6 +1752,11 @@ private void loadVersionClasses(ClassList classes,
for (String i : header.implementsAttr) {
modified |= include(includedClasses, currentVersionClasses, i);
}
+ if (header.permittedSubclasses != null) {
+ for (String i : header.permittedSubclasses) {
+ modified |= include(includedClasses, currentVersionClasses, i);
+ }
+ }
modified |= includeOutputType(Collections.singleton(header),
h -> "",
@@ -1962,6 +2156,11 @@ private List dumpCurrentClasses() throws IOException {
public static boolean ALLOW_NON_EXISTING_CLASSES = false;
private void inspectClassFile(InputStream in, ClassList classes, ExcludeIncludeList excludesIncludes, String version) throws IOException, ConstantPoolException {
+ inspectClassFile(in, classes, excludesIncludes, version, cf -> {});
+ }
+
+ private void inspectClassFile(InputStream in, ClassList classes, ExcludeIncludeList excludesIncludes, String version,
+ Consumer extraTask) throws IOException, ConstantPoolException {
ClassFile cf = ClassFile.read(in);
if (cf.access_flags.is(AccessFlags.ACC_MODULE)) {
@@ -1972,6 +2171,8 @@ private void inspectClassFile(InputStream in, ClassList classes, ExcludeIncludeL
return ;
}
+ extraTask.accept(cf);
+
ClassHeaderDescription headerDesc = new ClassHeaderDescription();
headerDesc.flags = cf.access_flags.flags;
@@ -2032,13 +2233,13 @@ private void inspectClassFile(InputStream in, ClassList classes, ExcludeIncludeL
}
}
- private void inspectModuleInfoClassFile(InputStream in,
+ private ModuleDescription inspectModuleInfoClassFile(InputStream in,
Map modules,
String version) throws IOException, ConstantPoolException {
ClassFile cf = ClassFile.read(in);
if (!cf.access_flags.is(AccessFlags.ACC_MODULE)) {
- return ;
+ return null;
}
ModuleHeaderDescription headerDesc = new ModuleHeaderDescription();
@@ -2048,7 +2249,7 @@ private void inspectModuleInfoClassFile(InputStream in,
for (Attribute attr : cf.attributes) {
if (!readAttribute(cf, headerDesc, attr))
- return ;
+ return null;
}
String name = headerDesc.name;
@@ -2062,6 +2263,8 @@ private void inspectModuleInfoClassFile(InputStream in,
}
addModuleHeader(moduleDesc, headerDesc, version);
+
+ return moduleDesc;
}
private Set enhancedIncludesListBasedOnClassHeaders(ClassList classes,
@@ -2072,35 +2275,53 @@ private Set enhancedIncludesListBasedOnClassHeaders(ClassList classes,
try (InputStream in = new ByteArrayInputStream(classFileData)) {
ClassFile cf = ClassFile.read(in);
- if (cf.access_flags.is(AccessFlags.ACC_MODULE)) {
- continue;
- }
+ additionalIncludes.addAll(otherRelevantTypesWithOwners(cf));
+ } catch (IOException | ConstantPoolException ex) {
+ throw new IllegalStateException(ex);
+ }
+ }
- Set additionalClasses = new HashSet<>();
+ return additionalIncludes;
+ }
- if (cf.super_class != 0) {
- additionalClasses.add(cf.getSuperclassName());
- }
- for (int i = 0; i < cf.interfaces.length; i++) {
- additionalClasses.add(cf.getInterfaceName(i));
+ private Set otherRelevantTypesWithOwners(ClassFile cf) {
+ Set supertypes = new HashSet<>();
+
+ try {
+ if (cf.access_flags.is(AccessFlags.ACC_MODULE)) {
+ return supertypes;
+ }
+
+ Set additionalClasses = new HashSet<>();
+
+ if (cf.super_class != 0) {
+ additionalClasses.add(cf.getSuperclassName());
+ }
+ for (int i = 0; i < cf.interfaces.length; i++) {
+ additionalClasses.add(cf.getInterfaceName(i));
+ }
+ PermittedSubclasses_attribute permitted = (PermittedSubclasses_attribute) cf.getAttribute(Attribute.PermittedSubclasses);
+ if (permitted != null) {
+ for (int i = 0; i < permitted.subtypes.length; i++) {
+ additionalClasses.add(cf.constant_pool.getClassInfo(permitted.subtypes[i]).getName());
}
+ }
- for (String additional : additionalClasses) {
- int dollar;
+ for (String additional : additionalClasses) {
+ int dollar;
- additionalIncludes.add(additional);
+ supertypes.add(additional);
- while ((dollar = additional.lastIndexOf('$')) != (-1)) {
- additional = additional.substring(0, dollar);
- additionalIncludes.add(additional);
- }
+ while ((dollar = additional.lastIndexOf('$')) != (-1)) {
+ additional = additional.substring(0, dollar);
+ supertypes.add(additional);
}
- } catch (IOException | ConstantPoolException ex) {
- throw new IllegalStateException(ex);
}
- }
- return additionalIncludes;
+ return supertypes;
+ } catch (ConstantPoolException ex) {
+ throw new IllegalStateException(ex);
+ }
}
private void addModuleHeader(ModuleDescription moduleDesc,
@@ -2115,7 +2336,9 @@ private void addModuleHeader(ModuleDescription moduleDesc,
}
}
- headerDesc.versions += version;
+ if (!headerDesc.versions.contains(version)) {
+ headerDesc.versions += version;
+ }
if (!existed) {
moduleDesc.header.add(headerDesc);
@@ -2159,7 +2382,9 @@ private void addClassHeader(ClassDescription clazzDesc, ClassHeaderDescription h
}
}
- headerDesc.versions += version;
+ if (!headerDesc.versions.contains(version)) {
+ headerDesc.versions += version;
+ }
if (!existed) {
clazzDesc.header.add(headerDesc);
@@ -4415,22 +4640,25 @@ public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOExce
String ctSymLocation;
String timestampSpec;
String currentVersion;
- String systemModules;
+ String preReleaseTag;
+ String moduleClasses;
- if (args.length == 6) {
+ if (args.length == 7) {
ctDescriptionFileExtra = null;
ctDescriptionFile = args[1];
ctSymLocation = args[2];
timestampSpec = args[3];
currentVersion = args[4];
- systemModules = args[5];
- } else if (args.length == 7) {
+ preReleaseTag = args[5];
+ moduleClasses = args[6];
+ } else if (args.length == 8) {
ctDescriptionFileExtra = args[1];
ctDescriptionFile = args[2];
ctSymLocation = args[3];
timestampSpec = args[4];
currentVersion = args[5];
- systemModules = args[6];
+ preReleaseTag = args[6];
+ moduleClasses = args[7];
} else {
help();
return ;
@@ -4446,7 +4674,8 @@ public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOExce
ctSymLocation,
timestamp,
currentVersion,
- systemModules);
+ preReleaseTag,
+ moduleClasses);
break;
}
case "build-javadoc-data": {
diff --git a/make/langtools/src/classes/build/tools/symbolgenerator/TransitiveDependencies.java b/make/langtools/src/classes/build/tools/symbolgenerator/TransitiveDependencies.java
deleted file mode 100644
index a26f74b9e236e..0000000000000
--- a/make/langtools/src/classes/build/tools/symbolgenerator/TransitiveDependencies.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2017, 2018, 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 build.tools.symbolgenerator;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.nio.charset.Charset;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayDeque;
-import java.util.Arrays;
-import java.util.Deque;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import javax.lang.model.element.ModuleElement.RequiresDirective;
-import javax.lang.model.util.Elements;
-import javax.tools.JavaCompiler;
-
-import com.sun.tools.javac.api.JavacTaskImpl;
-import com.sun.tools.javac.api.JavacTool;
-import com.sun.tools.javac.code.Source;
-import com.sun.tools.javac.code.Symbol.ModuleSymbol;
-import com.sun.tools.javac.jvm.Target;
-
-/**
- * Write reflexive transitive closure of the given modules along their requires transitive edges into
- * file /system-modules in the specified directory.
- */
-public class TransitiveDependencies {
-
- private static void help() {
- System.err.println("java TransitiveDependencies