diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 index 87d147d4f07..dafac618c59 100644 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -103,8 +103,12 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS], AC_SUBST(ENABLE_HEADLESS_ONLY) # should we linktime gc unused code sections in the JDK build ? - if test "x$OPENJDK_TARGET_OS" = "xlinux" && test "x$OPENJDK_TARGET_CPU" = xs390x; then - LINKTIME_GC_DEFAULT=true + if test "x$OPENJDK_TARGET_OS" = "xlinux"; then + if test "x$OPENJDK_TARGET_CPU" = "xs390x" || test "x$OPENJDK_TARGET_CPU" = "xppc64le"; then + LINKTIME_GC_DEFAULT=true + else + LINKTIME_GC_DEFAULT=false + fi else LINKTIME_GC_DEFAULT=false fi diff --git a/src/hotspot/cpu/aarch64/assembler_aarch64.hpp b/src/hotspot/cpu/aarch64/assembler_aarch64.hpp index 19b3bb1a65b..67cf77989d2 100644 --- a/src/hotspot/cpu/aarch64/assembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/assembler_aarch64.hpp @@ -3814,8 +3814,8 @@ public: } private: - void sve_cpy(FloatRegister Zd, SIMD_RegVariant T, PRegister Pg, int imm8, - bool isMerge, bool isFloat) { + void _sve_cpy(FloatRegister Zd, SIMD_RegVariant T, PRegister Pg, int imm8, + bool isMerge, bool isFloat) { starti; assert(T != Q, "invalid size"); int sh = 0; @@ -3839,11 +3839,11 @@ private: public: // SVE copy signed integer immediate to vector elements (predicated) void sve_cpy(FloatRegister Zd, SIMD_RegVariant T, PRegister Pg, int imm8, bool isMerge) { - sve_cpy(Zd, T, Pg, imm8, isMerge, /*isFloat*/false); + _sve_cpy(Zd, T, Pg, imm8, isMerge, /*isFloat*/false); } // SVE copy floating-point immediate to vector elements (predicated) void sve_cpy(FloatRegister Zd, SIMD_RegVariant T, PRegister Pg, double d) { - sve_cpy(Zd, T, Pg, checked_cast(pack(d)), /*isMerge*/true, /*isFloat*/true); + _sve_cpy(Zd, T, Pg, checked_cast(pack(d)), /*isMerge*/true, /*isFloat*/true); } // SVE conditionally select elements from two vectors diff --git a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp index dc0b9eb9546..7aab7d389e1 100644 --- a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp @@ -2875,3 +2875,24 @@ void C2_MacroAssembler::vector_expand_sve(FloatRegister dst, FloatRegister src, // dst = 00 87 00 65 00 43 00 21 sve_tbl(dst, size, src, dst); } + +// Optimized SVE cpy (imm, zeroing) instruction. +// +// `movi; cpy(imm, merging)` and `cpy(imm, zeroing)` have the same +// functionality, but test results show that `movi; cpy(imm, merging)` has +// higher throughput on some microarchitectures. This would depend on +// microarchitecture and so may vary between implementations. +void C2_MacroAssembler::sve_cpy(FloatRegister dst, SIMD_RegVariant T, + PRegister pg, int imm8, bool isMerge) { + if (VM_Version::prefer_sve_merging_mode_cpy() && !isMerge) { + // Generates a NEON instruction `movi V.2d, #0`. + // On AArch64, Z and V registers alias in the low 128 bits, so V is + // the low 128 bits of Z. A write to V also clears all bits of + // Z above 128, so this `movi` instruction effectively zeroes the + // entire Z register. According to the Arm Software Optimization + // Guide, `movi` is zero latency. + movi(dst, T2D, 0); + isMerge = true; + } + Assembler::sve_cpy(dst, T, pg, imm8, isMerge); +} diff --git a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp index 4f3a41da402..5c05832afbe 100644 --- a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.hpp @@ -75,6 +75,8 @@ unsigned vector_length_in_bytes); public: + using Assembler::sve_cpy; + // jdk.internal.util.ArraysSupport.vectorizedHashCode address arrays_hashcode(Register ary, Register cnt, Register result, FloatRegister vdata0, FloatRegister vdata1, FloatRegister vdata2, FloatRegister vdata3, @@ -244,4 +246,7 @@ void vector_expand_sve(FloatRegister dst, FloatRegister src, PRegister pg, FloatRegister tmp1, FloatRegister tmp2, BasicType bt, int vector_length_in_bytes); + + void sve_cpy(FloatRegister dst, SIMD_RegVariant T, PRegister pg, int imm8, + bool isMerge); #endif // CPU_AARCH64_C2_MACROASSEMBLER_AARCH64_HPP diff --git a/src/hotspot/cpu/aarch64/globals_aarch64.hpp b/src/hotspot/cpu/aarch64/globals_aarch64.hpp index a59e83c4b69..e6de2c798b1 100644 --- a/src/hotspot/cpu/aarch64/globals_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/globals_aarch64.hpp @@ -95,7 +95,7 @@ define_pd_global(intx, InlineSmallCode, 1000); "Use simplest and shortest implementation for array equals") \ product(bool, UseSIMDForBigIntegerShiftIntrinsics, true, \ "Use SIMD instructions for left/right shift of BigInteger") \ - product(bool, UseSIMDForSHA3Intrinsic, true, \ + product(bool, UseSIMDForSHA3Intrinsic, false, \ "Use SIMD SHA3 instructions for SHA3 intrinsic") \ product(bool, AvoidUnalignedAccesses, false, \ "Avoid generating unaligned memory accesses") \ diff --git a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp index a459a28b09e..21a1124a8ec 100644 --- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp @@ -11876,16 +11876,13 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_sha512_implCompress = generate_sha512_implCompress(StubId::stubgen_sha512_implCompress_id); StubRoutines::_sha512_implCompressMB = generate_sha512_implCompress(StubId::stubgen_sha512_implCompressMB_id); } - if (UseSHA3Intrinsics) { - + if (UseSHA3Intrinsics && UseSIMDForSHA3Intrinsic) { StubRoutines::_double_keccak = generate_double_keccak(); - if (UseSIMDForSHA3Intrinsic) { - StubRoutines::_sha3_implCompress = generate_sha3_implCompress(StubId::stubgen_sha3_implCompress_id); - StubRoutines::_sha3_implCompressMB = generate_sha3_implCompress(StubId::stubgen_sha3_implCompressMB_id); - } else { - StubRoutines::_sha3_implCompress = generate_sha3_implCompress_gpr(StubId::stubgen_sha3_implCompress_id); - StubRoutines::_sha3_implCompressMB = generate_sha3_implCompress_gpr(StubId::stubgen_sha3_implCompressMB_id); - } + StubRoutines::_sha3_implCompress = generate_sha3_implCompress(StubId::stubgen_sha3_implCompress_id); + StubRoutines::_sha3_implCompressMB = generate_sha3_implCompress(StubId::stubgen_sha3_implCompressMB_id); + } else if (UseSHA3Intrinsics) { + StubRoutines::_sha3_implCompress = generate_sha3_implCompress_gpr(StubId::stubgen_sha3_implCompress_id); + StubRoutines::_sha3_implCompressMB = generate_sha3_implCompress_gpr(StubId::stubgen_sha3_implCompressMB_id); } if (UsePoly1305Intrinsics) { diff --git a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp index 9b85733ed08..4423d9c5b58 100644 --- a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp @@ -365,16 +365,28 @@ void VM_Version::initialize() { FLAG_SET_DEFAULT(UseSHA256Intrinsics, false); } - if (UseSHA && VM_Version::supports_sha3()) { - // Auto-enable UseSHA3Intrinsics on hardware with performance benefit. - // Note that the evaluation of UseSHA3Intrinsics shows better performance + if (UseSHA) { + // No need to check VM_Version::supports_sha3(), since a fallback GPR intrinsic implementation is provided. + if (FLAG_IS_DEFAULT(UseSHA3Intrinsics)) { + FLAG_SET_DEFAULT(UseSHA3Intrinsics, true); + } + } else if (UseSHA3Intrinsics) { + // Matches the documented and tested behavior: the -UseSHA option disables all SHA intrinsics. + warning("UseSHA3Intrinsics requires that UseSHA is enabled."); + FLAG_SET_DEFAULT(UseSHA3Intrinsics, false); + } + + if (UseSHA3Intrinsics && VM_Version::supports_sha3()) { + // Auto-enable UseSIMDForSHA3Intrinsic on hardware with performance benefit. + // Note that the evaluation of SHA3 extension Intrinsics shows better performance // on Apple and Qualcomm silicon but worse performance on Neoverse V1 and N2. if (_cpu == CPU_APPLE || _cpu == CPU_QUALCOMM) { // Apple or Qualcomm silicon - if (FLAG_IS_DEFAULT(UseSHA3Intrinsics)) { - FLAG_SET_DEFAULT(UseSHA3Intrinsics, true); + if (FLAG_IS_DEFAULT(UseSIMDForSHA3Intrinsic)) { + FLAG_SET_DEFAULT(UseSIMDForSHA3Intrinsic, true); } } - } else if (UseSHA3Intrinsics && UseSIMDForSHA3Intrinsic) { + } + if (UseSHA3Intrinsics && UseSIMDForSHA3Intrinsic && !VM_Version::supports_sha3()) { warning("Intrinsics for SHA3-224, SHA3-256, SHA3-384 and SHA3-512 crypto hash functions not available on this CPU."); FLAG_SET_DEFAULT(UseSHA3Intrinsics, false); } diff --git a/src/hotspot/cpu/aarch64/vm_version_aarch64.hpp b/src/hotspot/cpu/aarch64/vm_version_aarch64.hpp index 0213872852b..e8681611234 100644 --- a/src/hotspot/cpu/aarch64/vm_version_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.hpp @@ -55,6 +55,9 @@ protected: static int _max_supported_sve_vector_length; static bool _rop_protection; static uintptr_t _pac_mask; + // When _prefer_sve_merging_mode_cpy is true, `cpy (imm, zeroing)` is + // implemented as `movi; cpy(imm, merging)`. + static constexpr bool _prefer_sve_merging_mode_cpy = true; static SpinWait _spin_wait; @@ -242,6 +245,8 @@ public: static bool use_rop_protection() { return _rop_protection; } + static bool prefer_sve_merging_mode_cpy() { return _prefer_sve_merging_mode_cpy; } + // For common 64/128-bit unpredicated vector operations, we may prefer // emitting NEON instructions rather than the corresponding SVE instructions. static bool use_neon_for_vector(int vector_length_in_bytes) { diff --git a/src/hotspot/cpu/ppc/icache_ppc.cpp b/src/hotspot/cpu/ppc/icache_ppc.cpp index 05ad3c7a30d..f3d51bad18c 100644 --- a/src/hotspot/cpu/ppc/icache_ppc.cpp +++ b/src/hotspot/cpu/ppc/icache_ppc.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2018 SAP SE. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ */ #include "runtime/icache.hpp" +#include "runtime/vm_version.hpp" // Use inline assembler to implement icache flush. int ICache::ppc64_flush_icache(address start, int lines, int magic) { @@ -67,6 +68,9 @@ int ICache::ppc64_flush_icache(address start, int lines, int magic) { void ICacheStubGenerator::generate_icache_flush(ICache::flush_icache_stub_t* flush_icache_stub) { + guarantee(VM_Version::get_icache_line_size() >= ICache::line_size, + "processors with smaller cache line size are no longer supported"); + *flush_icache_stub = (ICache::flush_icache_stub_t)ICache::ppc64_flush_icache; // First call to flush itself. diff --git a/src/hotspot/cpu/ppc/icache_ppc.hpp b/src/hotspot/cpu/ppc/icache_ppc.hpp index d348cad1c72..024f706182a 100644 --- a/src/hotspot/cpu/ppc/icache_ppc.hpp +++ b/src/hotspot/cpu/ppc/icache_ppc.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2013 SAP SE. All rights reserved. + * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,9 +35,8 @@ class ICache : public AbstractICache { public: enum { - // Actually, cache line size is 64, but keeping it as it is to be - // on the safe side on ALL PPC64 implementations. - log2_line_size = 5, + // Cache line size is 128 on all supported PPC64 implementations. + log2_line_size = 7, line_size = 1 << log2_line_size }; diff --git a/src/hotspot/cpu/ppc/vm_version_ppc.cpp b/src/hotspot/cpu/ppc/vm_version_ppc.cpp index 75feb389298..e471f5a6e4f 100644 --- a/src/hotspot/cpu/ppc/vm_version_ppc.cpp +++ b/src/hotspot/cpu/ppc/vm_version_ppc.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2025 SAP SE. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -475,19 +475,12 @@ void VM_Version::print_features() { void VM_Version::determine_features() { #if defined(ABI_ELFv2) - // 1 InstWord per call for the blr instruction. - const int code_size = (num_features+1+2*1)*BytesPerInstWord; + const int code_size = (num_features + 1 /*blr*/) * BytesPerInstWord; #else - // 7 InstWords for each call (function descriptor + blr instruction). - const int code_size = (num_features+1+2*7)*BytesPerInstWord; + const int code_size = (num_features + 1 /*blr*/ + 6 /* fd */) * BytesPerInstWord; #endif int features = 0; - // create test area - enum { BUFFER_SIZE = 2*4*K }; // Needs to be >=2* max cache line size (cache line size can't exceed min page size). - char test_area[BUFFER_SIZE]; - char *mid_of_test_area = &test_area[BUFFER_SIZE>>1]; - // Allocate space for the code. ResourceMark rm; CodeBuffer cb("detect_cpu_features", code_size, 0); @@ -497,20 +490,13 @@ void VM_Version::determine_features() { _features = VM_Version::all_features_m; // Emit code. - void (*test)(address addr, uint64_t offset)=(void(*)(address addr, uint64_t offset))(void *)a->function_entry(); + void (*test)() = (void(*)())(void *)a->function_entry(); uint32_t *code = (uint32_t *)a->pc(); - // Keep R3_ARG1 unmodified, it contains &field (see below). - // Keep R4_ARG2 unmodified, it contains offset = 0 (see below). a->mfdscr(R0); a->darn(R7); a->brw(R5, R6); a->blr(); - // Emit function to set one cache line to zero. Emit function descriptor and get pointer to it. - void (*zero_cacheline_func_ptr)(char*) = (void(*)(char*))(void *)a->function_entry(); - a->dcbz(R3_ARG1); // R3_ARG1 = addr - a->blr(); - uint32_t *code_end = (uint32_t *)a->pc(); a->flush(); _features = VM_Version::unknown_m; @@ -522,18 +508,9 @@ void VM_Version::determine_features() { Disassembler::decode((u_char*)code, (u_char*)code_end, tty); } - // Measure cache line size. - memset(test_area, 0xFF, BUFFER_SIZE); // Fill test area with 0xFF. - (*zero_cacheline_func_ptr)(mid_of_test_area); // Call function which executes dcbz to the middle. - int count = 0; // count zeroed bytes - for (int i = 0; i < BUFFER_SIZE; i++) if (test_area[i] == 0) count++; - guarantee(is_power_of_2(count), "cache line size needs to be a power of 2"); - _L1_data_cache_line_size = count; - // Execute code. Illegal instructions will be replaced by 0 in the signal handler. VM_Version::_is_determine_features_test_running = true; - // We must align the first argument to 16 bytes because of the lqarx check. - (*test)(align_up((address)mid_of_test_area, 16), 0); + (*test)(); VM_Version::_is_determine_features_test_running = false; // determine which instructions are legal. @@ -550,6 +527,10 @@ void VM_Version::determine_features() { } _features = features; + + _L1_data_cache_line_size = VM_Version::get_dcache_line_size(); + assert(_L1_data_cache_line_size >= DEFAULT_CACHE_LINE_SIZE, + "processors with smaller cache line size are no longer supported"); } // Power 8: Configure Data Stream Control Register. diff --git a/src/hotspot/cpu/ppc/vm_version_ppc.hpp b/src/hotspot/cpu/ppc/vm_version_ppc.hpp index 11dce83bed0..0f4eb3593a3 100644 --- a/src/hotspot/cpu/ppc/vm_version_ppc.hpp +++ b/src/hotspot/cpu/ppc/vm_version_ppc.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2025 SAP SE. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,6 +81,9 @@ public: static uint64_t _dscr_val; static void initialize_cpu_information(void); + + static int get_dcache_line_size(); + static int get_icache_line_size(); }; #endif // CPU_PPC_VM_VERSION_PPC_HPP diff --git a/src/hotspot/cpu/x86/assembler_x86.cpp b/src/hotspot/cpu/x86/assembler_x86.cpp index 3c8defe62d9..38a28a6ec49 100644 --- a/src/hotspot/cpu/x86/assembler_x86.cpp +++ b/src/hotspot/cpu/x86/assembler_x86.cpp @@ -5442,6 +5442,13 @@ void Assembler::pmovsxwd(XMMRegister dst, XMMRegister src) { emit_int16(0x23, (0xC0 | encode)); } +void Assembler::pmovzxwd(XMMRegister dst, XMMRegister src) { + assert(VM_Version::supports_sse4_1(), ""); + InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int16(0x33, (0xC0 | encode)); +} + void Assembler::vpmovzxbw(XMMRegister dst, Address src, int vector_len) { assert(VM_Version::supports_avx(), ""); InstructionMark im(this); diff --git a/src/hotspot/cpu/x86/assembler_x86.hpp b/src/hotspot/cpu/x86/assembler_x86.hpp index 97854f712cf..57a5e25d7a6 100644 --- a/src/hotspot/cpu/x86/assembler_x86.hpp +++ b/src/hotspot/cpu/x86/assembler_x86.hpp @@ -1965,6 +1965,7 @@ private: void pmovsxbq(XMMRegister dst, XMMRegister src); void pmovsxbw(XMMRegister dst, XMMRegister src); void pmovsxwd(XMMRegister dst, XMMRegister src); + void pmovzxwd(XMMRegister dst, XMMRegister src); void vpmovsxbd(XMMRegister dst, XMMRegister src, int vector_len); void vpmovsxbq(XMMRegister dst, XMMRegister src, int vector_len); void vpmovsxbw(XMMRegister dst, XMMRegister src, int vector_len); diff --git a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp index a3ccc081b6b..5b5fb02967c 100644 --- a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp @@ -1729,6 +1729,24 @@ void C2_MacroAssembler::reduce_operation_128(BasicType typ, int opcode, XMMRegis default: assert(false, "wrong type"); } break; + case Op_UMinReductionV: + switch (typ) { + case T_BYTE: vpminub(dst, dst, src, Assembler::AVX_128bit); break; + case T_SHORT: vpminuw(dst, dst, src, Assembler::AVX_128bit); break; + case T_INT: vpminud(dst, dst, src, Assembler::AVX_128bit); break; + case T_LONG: evpminuq(dst, k0, dst, src, true, Assembler::AVX_128bit); break; + default: assert(false, "wrong type"); + } + break; + case Op_UMaxReductionV: + switch (typ) { + case T_BYTE: vpmaxub(dst, dst, src, Assembler::AVX_128bit); break; + case T_SHORT: vpmaxuw(dst, dst, src, Assembler::AVX_128bit); break; + case T_INT: vpmaxud(dst, dst, src, Assembler::AVX_128bit); break; + case T_LONG: evpmaxuq(dst, k0, dst, src, true, Assembler::AVX_128bit); break; + default: assert(false, "wrong type"); + } + break; case Op_AddReductionVF: addss(dst, src); break; case Op_AddReductionVD: addsd(dst, src); break; case Op_AddReductionVI: @@ -1792,6 +1810,24 @@ void C2_MacroAssembler::reduce_operation_256(BasicType typ, int opcode, XMMRegis default: assert(false, "wrong type"); } break; + case Op_UMinReductionV: + switch (typ) { + case T_BYTE: vpminub(dst, src1, src2, vector_len); break; + case T_SHORT: vpminuw(dst, src1, src2, vector_len); break; + case T_INT: vpminud(dst, src1, src2, vector_len); break; + case T_LONG: evpminuq(dst, k0, src1, src2, true, vector_len); break; + default: assert(false, "wrong type"); + } + break; + case Op_UMaxReductionV: + switch (typ) { + case T_BYTE: vpmaxub(dst, src1, src2, vector_len); break; + case T_SHORT: vpmaxuw(dst, src1, src2, vector_len); break; + case T_INT: vpmaxud(dst, src1, src2, vector_len); break; + case T_LONG: evpmaxuq(dst, k0, src1, src2, true, vector_len); break; + default: assert(false, "wrong type"); + } + break; case Op_AddReductionVI: switch (typ) { case T_BYTE: vpaddb(dst, src1, src2, vector_len); break; @@ -2058,7 +2094,11 @@ void C2_MacroAssembler::reduce8B(int opcode, Register dst, Register src1, XMMReg psrldq(vtmp2, 1); reduce_operation_128(T_BYTE, opcode, vtmp1, vtmp2); movdl(vtmp2, src1); - pmovsxbd(vtmp1, vtmp1); + if (opcode == Op_UMinReductionV || opcode == Op_UMaxReductionV) { + pmovzxbd(vtmp1, vtmp1); + } else { + pmovsxbd(vtmp1, vtmp1); + } reduce_operation_128(T_INT, opcode, vtmp1, vtmp2); pextrb(dst, vtmp1, 0x0); movsbl(dst, dst); @@ -2135,7 +2175,11 @@ void C2_MacroAssembler::reduce4S(int opcode, Register dst, Register src1, XMMReg reduce_operation_128(T_SHORT, opcode, vtmp1, vtmp2); } movdl(vtmp2, src1); - pmovsxwd(vtmp1, vtmp1); + if (opcode == Op_UMinReductionV || opcode == Op_UMaxReductionV) { + pmovzxwd(vtmp1, vtmp1); + } else { + pmovsxwd(vtmp1, vtmp1); + } reduce_operation_128(T_INT, opcode, vtmp1, vtmp2); pextrw(dst, vtmp1, 0x0); movswl(dst, dst); diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad index 0ffa4c2031c..b155355c827 100644 --- a/src/hotspot/cpu/x86/x86.ad +++ b/src/hotspot/cpu/x86/x86.ad @@ -3341,6 +3341,18 @@ bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType bt) { return false; } break; + case Op_UMinReductionV: + case Op_UMaxReductionV: + if (UseAVX == 0) { + return false; + } + if (bt == T_LONG && !VM_Version::supports_avx512vl()) { + return false; + } + if (UseAVX > 2 && size_in_bits == 512 && !VM_Version::supports_avx512vl()) { + return false; + } + break; case Op_MaxV: case Op_MinV: if (UseSSE < 4 && is_integral_type(bt)) { @@ -19371,6 +19383,8 @@ instruct reductionI(rRegI dst, rRegI src1, legVec src2, legVec vtmp1, legVec vtm match(Set dst (XorReductionV src1 src2)); match(Set dst (MinReductionV src1 src2)); match(Set dst (MaxReductionV src1 src2)); + match(Set dst (UMinReductionV src1 src2)); + match(Set dst (UMaxReductionV src1 src2)); effect(TEMP vtmp1, TEMP vtmp2); format %{ "vector_reduction_int $dst,$src1,$src2 ; using $vtmp1, $vtmp2 as TEMP" %} ins_encode %{ @@ -19392,6 +19406,8 @@ instruct reductionL(rRegL dst, rRegL src1, legVec src2, legVec vtmp1, legVec vtm match(Set dst (XorReductionV src1 src2)); match(Set dst (MinReductionV src1 src2)); match(Set dst (MaxReductionV src1 src2)); + match(Set dst (UMinReductionV src1 src2)); + match(Set dst (UMaxReductionV src1 src2)); effect(TEMP vtmp1, TEMP vtmp2); format %{ "vector_reduction_long $dst,$src1,$src2 ; using $vtmp1, $vtmp2 as TEMP" %} ins_encode %{ @@ -19411,6 +19427,8 @@ instruct reductionL_avx512dq(rRegL dst, rRegL src1, vec src2, vec vtmp1, vec vtm match(Set dst (XorReductionV src1 src2)); match(Set dst (MinReductionV src1 src2)); match(Set dst (MaxReductionV src1 src2)); + match(Set dst (UMinReductionV src1 src2)); + match(Set dst (UMaxReductionV src1 src2)); effect(TEMP vtmp1, TEMP vtmp2); format %{ "vector_reduction_long $dst,$src1,$src2 ; using $vtmp1, $vtmp2 as TEMP" %} ins_encode %{ @@ -19639,6 +19657,8 @@ instruct reductionB(rRegI dst, rRegI src1, legVec src2, legVec vtmp1, legVec vtm match(Set dst (XorReductionV src1 src2)); match(Set dst (MinReductionV src1 src2)); match(Set dst (MaxReductionV src1 src2)); + match(Set dst (UMinReductionV src1 src2)); + match(Set dst (UMaxReductionV src1 src2)); effect(TEMP vtmp1, TEMP vtmp2); format %{ "vector_reduction_byte $dst,$src1,$src2 ; using $vtmp1, $vtmp2 as TEMP" %} ins_encode %{ @@ -19657,6 +19677,8 @@ instruct reductionB_avx512bw(rRegI dst, rRegI src1, vec src2, vec vtmp1, vec vtm match(Set dst (XorReductionV src1 src2)); match(Set dst (MinReductionV src1 src2)); match(Set dst (MaxReductionV src1 src2)); + match(Set dst (UMinReductionV src1 src2)); + match(Set dst (UMaxReductionV src1 src2)); effect(TEMP vtmp1, TEMP vtmp2); format %{ "vector_reduction_byte $dst,$src1,$src2 ; using $vtmp1, $vtmp2 as TEMP" %} ins_encode %{ @@ -19678,6 +19700,8 @@ instruct reductionS(rRegI dst, rRegI src1, legVec src2, legVec vtmp1, legVec vtm match(Set dst (XorReductionV src1 src2)); match(Set dst (MinReductionV src1 src2)); match(Set dst (MaxReductionV src1 src2)); + match(Set dst (UMinReductionV src1 src2)); + match(Set dst (UMaxReductionV src1 src2)); effect(TEMP vtmp1, TEMP vtmp2); format %{ "vector_reduction_short $dst,$src1,$src2 ; using $vtmp1, $vtmp2 as TEMP" %} ins_encode %{ diff --git a/src/hotspot/os_cpu/aix_ppc/vm_version_aix_ppc.cpp b/src/hotspot/os_cpu/aix_ppc/vm_version_aix_ppc.cpp new file mode 100644 index 00000000000..8cc8b715201 --- /dev/null +++ b/src/hotspot/os_cpu/aix_ppc/vm_version_aix_ppc.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026 SAP SE. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 "runtime/vm_version.hpp" + +#include + +int VM_Version::get_dcache_line_size() { + return _system_configuration.dcache_line; +} + +int VM_Version::get_icache_line_size() { + return _system_configuration.icache_line; +} diff --git a/src/hotspot/os_cpu/linux_ppc/vm_version_linux_ppc.cpp b/src/hotspot/os_cpu/linux_ppc/vm_version_linux_ppc.cpp new file mode 100644 index 00000000000..d64340edf5c --- /dev/null +++ b/src/hotspot/os_cpu/linux_ppc/vm_version_linux_ppc.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2026 SAP SE. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 "runtime/vm_version.hpp" + +#include + +int VM_Version::get_dcache_line_size() { + // This should work on all modern linux versions: + int size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE); + // It may fail with very old linux / glibc versions. We use DEFAULT_CACHE_LINE_SIZE in this case. + // That is the correct value for all currently supported processors. + return (size <= 0) ? DEFAULT_CACHE_LINE_SIZE : size; +} + +int VM_Version::get_icache_line_size() { + // This should work on all modern linux versions: + int size = sysconf(_SC_LEVEL1_ICACHE_LINESIZE); + // It may fail with very old linux / glibc versions. We use DEFAULT_CACHE_LINE_SIZE in this case. + // That is the correct value for all currently supported processors. + return (size <= 0) ? DEFAULT_CACHE_LINE_SIZE : size; +} diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp index fd70796251d..7f0e5e86cd9 100644 --- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp +++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp @@ -73,8 +73,8 @@ void G1BlockOffsetTable::set_offset_array(Atomic* left, Atomic #ifdef ASSERT void G1BlockOffsetTable::check_address(Atomic* addr, const char* msg) const { - Atomic* start_addr = const_cast*>(_offset_base + (uintptr_t(_reserved.start()) >> CardTable::card_shift())); - Atomic* end_addr = const_cast*>(_offset_base + (uintptr_t(_reserved.end()) >> CardTable::card_shift())); + Atomic* start_addr = _offset_base + (uintptr_t(_reserved.start()) >> CardTable::card_shift()); + Atomic* end_addr = _offset_base + (uintptr_t(_reserved.end()) >> CardTable::card_shift()); assert(addr >= start_addr && addr <= end_addr, "%s - offset address: " PTR_FORMAT ", start address: " PTR_FORMAT ", end address: " PTR_FORMAT, msg, (p2i(addr)), (p2i(start_addr)), (p2i(end_addr))); diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp index b707e310781..1236d24bb03 100644 --- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp +++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp @@ -54,7 +54,7 @@ uint8_t G1BlockOffsetTable::offset_array(Atomic* addr) const { inline Atomic* G1BlockOffsetTable::entry_for_addr(const void* const p) const { assert(_reserved.contains(p), "out of bounds access to block offset table"); - Atomic* result = const_cast*>(&_offset_base[uintptr_t(p) >> CardTable::card_shift()]); + Atomic* result = &_offset_base[uintptr_t(p) >> CardTable::card_shift()]; return result; } diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp index ec5649f4fe2..074231a02d4 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp @@ -898,9 +898,26 @@ public: }; class G1PreConcurrentStartTask::NoteStartOfMarkTask : public G1AbstractSubTask { + + class NoteStartOfMarkHRClosure : public G1HeapRegionClosure { + G1ConcurrentMark* _cm; + + public: + NoteStartOfMarkHRClosure() : G1HeapRegionClosure(), _cm(G1CollectedHeap::heap()->concurrent_mark()) { } + + bool do_heap_region(G1HeapRegion* r) override { + if (r->is_old_or_humongous() && !r->is_collection_set_candidate() && !r->in_collection_set()) { + _cm->update_top_at_mark_start(r); + } else { + _cm->reset_top_at_mark_start(r); + } + return false; + } + } _region_cl; + G1HeapRegionClaimer _claimer; public: - NoteStartOfMarkTask() : G1AbstractSubTask(G1GCPhaseTimes::NoteStartOfMark), _claimer(0) { } + NoteStartOfMarkTask() : G1AbstractSubTask(G1GCPhaseTimes::NoteStartOfMark), _region_cl(), _claimer(0) { } double worker_cost() const override { // The work done per region is very small, therefore we choose this magic number to cap the number @@ -909,8 +926,13 @@ public: return _claimer.n_regions() / regions_per_thread; } - void set_max_workers(uint max_workers) override; - void do_work(uint worker_id) override; + void set_max_workers(uint max_workers) override { + _claimer.set_n_workers(max_workers); + } + + void do_work(uint worker_id) override { + G1CollectedHeap::heap()->heap_region_par_iterate_from_worker_offset(&_region_cl, &_claimer, worker_id); + } }; void G1PreConcurrentStartTask::ResetMarkingStateTask::do_work(uint worker_id) { @@ -918,31 +940,6 @@ void G1PreConcurrentStartTask::ResetMarkingStateTask::do_work(uint worker_id) { _cm->reset(); } -class NoteStartOfMarkHRClosure : public G1HeapRegionClosure { - G1ConcurrentMark* _cm; - -public: - NoteStartOfMarkHRClosure() : G1HeapRegionClosure(), _cm(G1CollectedHeap::heap()->concurrent_mark()) { } - - bool do_heap_region(G1HeapRegion* r) override { - if (r->is_old_or_humongous() && !r->is_collection_set_candidate() && !r->in_collection_set()) { - _cm->update_top_at_mark_start(r); - } else { - _cm->reset_top_at_mark_start(r); - } - return false; - } -}; - -void G1PreConcurrentStartTask::NoteStartOfMarkTask::do_work(uint worker_id) { - NoteStartOfMarkHRClosure start_cl; - G1CollectedHeap::heap()->heap_region_par_iterate_from_worker_offset(&start_cl, &_claimer, worker_id); -} - -void G1PreConcurrentStartTask::NoteStartOfMarkTask::set_max_workers(uint max_workers) { - _claimer.set_n_workers(max_workers); -} - G1PreConcurrentStartTask::G1PreConcurrentStartTask(GCCause::Cause cause, G1ConcurrentMark* cm) : G1BatchedTask("Pre Concurrent Start", G1CollectedHeap::heap()->phase_times()) { add_serial_task(new ResetMarkingStateTask(cm)); @@ -962,7 +959,6 @@ void G1ConcurrentMark::pre_concurrent_start(GCCause::Cause cause) { _gc_tracer_cm->set_gc_cause(cause); } - void G1ConcurrentMark::post_concurrent_mark_start() { // Start Concurrent Marking weak-reference discovery. ReferenceProcessor* rp = _g1h->ref_processor_cm(); diff --git a/src/hotspot/share/gc/g1/g1HeapRegion.inline.hpp b/src/hotspot/share/gc/g1/g1HeapRegion.inline.hpp index 4f242b7a537..f92e37fee3c 100644 --- a/src/hotspot/share/gc/g1/g1HeapRegion.inline.hpp +++ b/src/hotspot/share/gc/g1/g1HeapRegion.inline.hpp @@ -42,6 +42,11 @@ #include "utilities/globalDefinitions.hpp" inline HeapWord* G1HeapRegion::block_start(const void* addr) const { + if (is_young()) { + // We are here because of BlockLocationPrinter. + // Can be invoked in any context, so this region might not be parsable. + return nullptr; + } return block_start(addr, parsable_bottom_acquire()); } @@ -64,6 +69,7 @@ inline HeapWord* G1HeapRegion::advance_to_block_containing_addr(const void* addr inline HeapWord* G1HeapRegion::block_start(const void* addr, HeapWord* const pb) const { assert(addr >= bottom() && addr < top(), "invalid address"); + assert(!is_young(), "Only non-young regions have BOT"); HeapWord* first_block = _bot->block_start_reaching_into_card(addr); return advance_to_block_containing_addr(addr, pb, first_block); } diff --git a/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp b/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp index 4dd0a509bcd..1b9704e8ad3 100644 --- a/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp +++ b/src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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 @@ -366,6 +366,12 @@ static size_t target_heap_capacity(size_t used_bytes, uintx free_ratio) { } size_t G1HeapSizingPolicy::full_collection_resize_amount(bool& expand, size_t allocation_word_size) { + // User-requested Full GCs introduce GC load unrelated to heap size; reset CPU + // usage tracking so heap resizing heuristics are driven only by GC pressure. + if (GCCause::is_user_requested_gc(_g1h->gc_cause())) { + reset_cpu_usage_tracking_data(); + } + const size_t capacity_after_gc = _g1h->capacity(); // Capacity, free and used after the GC counted as full regions to // include the waste in the following calculations. diff --git a/src/hotspot/share/gc/shared/collectedHeap.hpp b/src/hotspot/share/gc/shared/collectedHeap.hpp index f13c3ab7b6e..100866bb528 100644 --- a/src/hotspot/share/gc/shared/collectedHeap.hpp +++ b/src/hotspot/share/gc/shared/collectedHeap.hpp @@ -289,7 +289,7 @@ protected: DEBUG_ONLY(bool is_in_or_null(const void* p) const { return p == nullptr || is_in(p); }) void set_gc_cause(GCCause::Cause v); - GCCause::Cause gc_cause() { return _gc_cause; } + GCCause::Cause gc_cause() const { return _gc_cause; } oop obj_allocate(Klass* klass, size_t size, TRAPS); virtual oop array_allocate(Klass* klass, size_t size, int length, bool do_zero, TRAPS); diff --git a/src/hotspot/share/oops/resolvedFieldEntry.cpp b/src/hotspot/share/oops/resolvedFieldEntry.cpp index 49e9115ca9a..122ecf092d8 100644 --- a/src/hotspot/share/oops/resolvedFieldEntry.cpp +++ b/src/hotspot/share/oops/resolvedFieldEntry.cpp @@ -77,10 +77,13 @@ void ResolvedFieldEntry::assert_is_valid() const { "field offset out of range %d >= %d", field_offset(), instanceOopDesc::base_offset_in_bytes()); assert(as_BasicType((TosState)tos_state()) != T_ILLEGAL, "tos_state is ILLEGAL"); assert(_flags < (1 << (max_flag_shift + 1)), "flags are too large %d", _flags); - assert((get_code() == 0 || get_code() == Bytecodes::_getstatic || get_code() == Bytecodes::_getfield), - "invalid get bytecode %d", get_code()); - assert((put_code() == 0 || put_code() == Bytecodes::_putstatic || put_code() == Bytecodes::_putfield), - "invalid put bytecode %d", put_code()); + + // Read each bytecode once. + volatile Bytecodes::Code g = (Bytecodes::Code)get_code(); + assert(g == 0 || g == Bytecodes::_getstatic || g == Bytecodes::_getfield, "invalid get bytecode %d", g); + + volatile Bytecodes::Code p = (Bytecodes::Code)put_code(); + assert(p == 0 || p == Bytecodes::_putstatic || p == Bytecodes::_putfield, "invalid put bytecode %d", p); } #endif diff --git a/src/hotspot/share/opto/mulnode.cpp b/src/hotspot/share/opto/mulnode.cpp index 9bdaa3b9f34..cac9f1dcc37 100644 --- a/src/hotspot/share/opto/mulnode.cpp +++ b/src/hotspot/share/opto/mulnode.cpp @@ -1539,15 +1539,20 @@ Node* URShiftINode::Ideal(PhaseGVN* phase, bool can_reshape) { Node *add = in(1); if (in1_op == Op_AddI) { Node *lshl = add->in(1); + Node *y = add->in(2); + if (lshl->Opcode() != Op_LShiftI) { + lshl = add->in(2); + y = add->in(1); + } // Compare shift counts by value, not by node pointer, to also match a not-yet-normalized // negative constant (e.g. -1 vs 31) int lshl_con = 0; if (lshl->Opcode() == Op_LShiftI && const_shift_count(phase, lshl, &lshl_con) && (lshl_con & (BitsPerJavaInteger - 1)) == con) { - Node *y_z = phase->transform( new URShiftINode(add->in(2),in(2)) ); - Node *sum = phase->transform( new AddINode( lshl->in(1), y_z ) ); - return new AndINode( sum, phase->intcon(mask) ); + Node *y_z = phase->transform(new URShiftINode(y, in(2))); + Node *sum = phase->transform(new AddINode(lshl->in(1), y_z)); + return new AndINode(sum, phase->intcon(mask)); } } @@ -1699,13 +1704,18 @@ Node* URShiftLNode::Ideal(PhaseGVN* phase, bool can_reshape) { const TypeInt *t2 = phase->type(in(2))->isa_int(); if (add->Opcode() == Op_AddL) { Node *lshl = add->in(1); + Node *y = add->in(2); + if (lshl->Opcode() != Op_LShiftL) { + lshl = add->in(2); + y = add->in(1); + } // Compare shift counts by value, not by node pointer, to also match a not-yet-normalized // negative constant (e.g. -1 vs 63) int lshl_con = 0; if (lshl->Opcode() == Op_LShiftL && const_shift_count(phase, lshl, &lshl_con) && (lshl_con & (BitsPerJavaLong - 1)) == con) { - Node* y_z = phase->transform(new URShiftLNode(add->in(2), in(2))); + Node* y_z = phase->transform(new URShiftLNode(y, in(2))); Node* sum = phase->transform(new AddLNode(lshl->in(1), y_z)); return new AndLNode(sum, phase->longcon(mask)); } diff --git a/src/hotspot/share/opto/parse2.cpp b/src/hotspot/share/opto/parse2.cpp index eac2b3e863a..7f41870ccea 100644 --- a/src/hotspot/share/opto/parse2.cpp +++ b/src/hotspot/share/opto/parse2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, 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 @@ -966,12 +966,28 @@ void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, _max_switch_depth = 0; _est_switch_depth = log2i_graceful((hi - lo + 1) - 1) + 1; } + SwitchRange* orig_lo = lo; + SwitchRange* orig_hi = hi; #endif - assert(lo <= hi, "must be a non-empty set of ranges"); - if (lo == hi) { - jump_if_always_fork(lo->dest(), trim_ranges && lo->cnt() == 0); - } else { + // The lower-range processing is done iteratively to avoid O(N) stack depth + // when the profiling-based pivot repeatedly selects mid==lo (JDK-8366138). + // The upper-range processing remains recursive but is only reached for + // balanced splits, bounding its depth to O(log N). + // Termination: every iteration either exits or strictly decreases hi-lo: + // lo == mid && mid < hi, increments lo + // lo < mid <= hi, sets hi = mid - 1. + for (int depth = switch_depth;; depth++) { +#ifndef PRODUCT + _max_switch_depth = MAX2(depth, _max_switch_depth); +#endif + + assert(lo <= hi, "must be a non-empty set of ranges"); + if (lo == hi) { + jump_if_always_fork(lo->dest(), trim_ranges && lo->cnt() == 0); + break; + } + assert(lo->hi() == (lo+1)->lo()-1, "contiguous ranges"); assert(hi->lo() == (hi-1)->hi()+1, "contiguous ranges"); @@ -981,7 +997,12 @@ void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, float total_cnt = sum_of_cnts(lo, hi); int nr = hi - lo + 1; - if (UseSwitchProfiling) { + // With total_cnt==0 the profiling pivot degenerates to mid==lo + // (0 >= 0/2), producing a linear chain of If nodes instead of a + // balanced tree. A balanced tree is strictly better here: all paths + // are cold, so a balanced split gives fewer comparisons at runtime + // and avoids pathological memory usage in the optimizer. + if (UseSwitchProfiling && total_cnt > 0) { // Don't keep the binary search tree balanced: pick up mid point // that split frequencies in half. float cnt = 0; @@ -1002,7 +1023,7 @@ void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, assert(nr != 2 || mid == hi, "should pick higher of 2"); assert(nr != 3 || mid == hi-1, "should pick middle of 3"); } - + assert(mid != nullptr, "mid must be set"); Node *test_val = _gvn.intcon(mid == lo ? mid->hi() : mid->lo()); @@ -1025,7 +1046,7 @@ void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, Node *iffalse = _gvn.transform( new IfFalseNode(iff_lt) ); { PreserveJVMState pjvms(this); set_control(iffalse); - jump_switch_ranges(key_val, mid+1, hi, switch_depth+1); + jump_switch_ranges(key_val, mid+1, hi, depth+1); } set_control(iftrue); } @@ -1043,21 +1064,22 @@ void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, Node *iffalse = _gvn.transform( new IfFalseNode(iff_ge) ); { PreserveJVMState pjvms(this); set_control(iftrue); - jump_switch_ranges(key_val, mid == lo ? mid+1 : mid, hi, switch_depth+1); + jump_switch_ranges(key_val, mid == lo ? mid+1 : mid, hi, depth+1); } set_control(iffalse); } } - // in any case, process the lower range + // Process the lower range: iterate instead of recursing. if (mid == lo) { if (mid->is_singleton()) { - jump_switch_ranges(key_val, lo+1, hi, switch_depth+1); + lo++; } else { jump_if_always_fork(lo->dest(), trim_ranges && lo->cnt() == 0); + break; } } else { - jump_switch_ranges(key_val, lo, mid-1, switch_depth+1); + hi = mid - 1; } } @@ -1072,23 +1094,22 @@ void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, } #ifndef PRODUCT - _max_switch_depth = MAX2(switch_depth, _max_switch_depth); if (TraceOptoParse && Verbose && WizardMode && switch_depth == 0) { SwitchRange* r; int nsing = 0; - for( r = lo; r <= hi; r++ ) { + for (r = orig_lo; r <= orig_hi; r++) { if( r->is_singleton() ) nsing++; } tty->print(">>> "); _method->print_short_name(); tty->print_cr(" switch decision tree"); tty->print_cr(" %d ranges (%d singletons), max_depth=%d, est_depth=%d", - (int) (hi-lo+1), nsing, _max_switch_depth, _est_switch_depth); + (int) (orig_hi-orig_lo+1), nsing, _max_switch_depth, _est_switch_depth); if (_max_switch_depth > _est_switch_depth) { tty->print_cr("******** BAD SWITCH DEPTH ********"); } tty->print(" "); - for( r = lo; r <= hi; r++ ) { + for (r = orig_lo; r <= orig_hi; r++) { r->print(); } tty->cr(); diff --git a/src/hotspot/share/opto/phaseX.cpp b/src/hotspot/share/opto/phaseX.cpp index 3cbbc114778..c77316e7d0b 100644 --- a/src/hotspot/share/opto/phaseX.cpp +++ b/src/hotspot/share/opto/phaseX.cpp @@ -360,6 +360,16 @@ NodeHash::~NodeHash() { } #endif +// Add users of 'n' that match 'predicate' to worklist +template +static void add_users_to_worklist_if(Unique_Node_List& worklist, const Node* n, Predicate predicate) { + for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { + Node* u = n->fast_out(i); + if (predicate(u)) { + worklist.push(u); + } + } +} //============================================================================= //------------------------------PhaseRemoveUseless----------------------------- @@ -2298,12 +2308,7 @@ void PhaseIterGVN::remove_globally_dead_node( Node *dead ) { // A Load that directly follows an InitializeNode is // going away. The Stores that follow are candidates // again to be captured by the InitializeNode. - for (DUIterator_Fast jmax, j = in->fast_outs(jmax); j < jmax; j++) { - Node *n = in->fast_out(j); - if (n->is_Store()) { - _worklist.push(n); - } - } + add_users_to_worklist_if(_worklist, in, [](Node* n) { return n->is_Store(); }); } } // if (in != nullptr && in != C->top()) } // for (uint i = 0; i < dead->req(); i++) @@ -2559,41 +2564,29 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_ // If changed LShift inputs, check RShift/URShift users for // "(X << C) >> C" sign-ext and "(X << C) >>> C" zero-ext optimizations. if (use_op == Op_LShiftI || use_op == Op_LShiftL) { - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->Opcode() == Op_RShiftI || u->Opcode() == Op_RShiftL || - u->Opcode() == Op_URShiftI || u->Opcode() == Op_URShiftL) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [](Node* u) { + return u->Opcode() == Op_RShiftI || u->Opcode() == Op_RShiftL || + u->Opcode() == Op_URShiftI || u->Opcode() == Op_URShiftL; + }); } // If changed LShift inputs, check And users for shift and mask (And) operation if (use_op == Op_LShiftI || use_op == Op_LShiftL) { - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->Opcode() == Op_AndI || u->Opcode() == Op_AndL) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [](Node* u) { + return u->Opcode() == Op_AndI || u->Opcode() == Op_AndL; + }); } // If changed AddI/SubI inputs, check CmpU for range check optimization. if (use_op == Op_AddI || use_op == Op_SubI) { - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->is_Cmp() && (u->Opcode() == Op_CmpU)) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [](Node* u) { + return u->Opcode() == Op_CmpU; + }); } // If changed AndI/AndL inputs, check RShift/URShift users for "(x & mask) >> shift" optimization opportunity if (use_op == Op_AndI || use_op == Op_AndL) { - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->Opcode() == Op_RShiftI || u->Opcode() == Op_RShiftL || - u->Opcode() == Op_URShiftI || u->Opcode() == Op_URShiftL) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [](Node* u) { + return u->Opcode() == Op_RShiftI || u->Opcode() == Op_RShiftL || + u->Opcode() == Op_URShiftI || u->Opcode() == Op_URShiftL; + }); } // Check for redundant conversion patterns: // ConvD2L->ConvL2D->ConvD2L @@ -2606,35 +2599,22 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_ use_op == Op_ConvI2F || use_op == Op_ConvL2F || use_op == Op_ConvF2I) { - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if ((use_op == Op_ConvL2D && u->Opcode() == Op_ConvD2L) || - (use_op == Op_ConvI2F && u->Opcode() == Op_ConvF2I) || - (use_op == Op_ConvL2F && u->Opcode() == Op_ConvF2L) || - (use_op == Op_ConvF2I && u->Opcode() == Op_ConvI2F)) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [=](Node* u) { + return (use_op == Op_ConvL2D && u->Opcode() == Op_ConvD2L) || + (use_op == Op_ConvI2F && u->Opcode() == Op_ConvF2I) || + (use_op == Op_ConvL2F && u->Opcode() == Op_ConvF2L) || + (use_op == Op_ConvF2I && u->Opcode() == Op_ConvI2F); + }); } // ConvD2F::Ideal matches ConvD2F(SqrtD(ConvF2D(x))) => SqrtF(x). // Notify ConvD2F users of SqrtD when any input of the SqrtD changes. if (use_op == Op_SqrtD) { - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->Opcode() == Op_ConvD2F) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [](Node* u) { return u->Opcode() == Op_ConvD2F; }); } // ConvF2HF::Ideal matches ConvF2HF(binopF(ConvHF2F(...))) => FP16BinOp(...). // Notify ConvF2HF users of float binary ops when any input changes. if (Float16NodeFactory::is_float32_binary_oper(use_op)) { - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->Opcode() == Op_ConvF2HF) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [](Node* u) { return u->Opcode() == Op_ConvF2HF; }); } // If changed AddP inputs: // - check Stores for loop invariant, and @@ -2642,33 +2622,21 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_ // address expression flattening. if (use_op == Op_AddP) { bool offset_changed = n == use->in(AddPNode::Offset); - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->is_Mem()) { - worklist.push(u); - } else if (offset_changed && u->is_AddP() && u->in(AddPNode::Offset)->is_Con()) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [=](Node* u) { + return u->is_Mem() || + (offset_changed && u->is_AddP() && u->in(AddPNode::Offset)->is_Con()); + }); } // Check for "abs(0-x)" into "abs(x)" conversion if (use->is_Sub()) { - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->Opcode() == Op_AbsD || u->Opcode() == Op_AbsF || - u->Opcode() == Op_AbsL || u->Opcode() == Op_AbsI) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [](Node* u) { + return u->Opcode() == Op_AbsD || u->Opcode() == Op_AbsF || + u->Opcode() == Op_AbsL || u->Opcode() == Op_AbsI; + }); } // Check for Max/Min(A, Max/Min(B, C)) where A == B or A == C if (use->is_MinMax()) { - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->is_MinMax()) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [](Node* u) { return u->is_MinMax(); }); } auto enqueue_init_mem_projs = [&](ProjNode* proj) { add_users_to_worklist0(proj, worklist); @@ -2707,12 +2675,9 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_ if (u->Opcode() == Op_LoadP && ut->isa_instptr()) { if (has_load_barrier_nodes) { // Search for load barriers behind the load - for (DUIterator_Fast i3max, i3 = u->fast_outs(i3max); i3 < i3max; i3++) { - Node* b = u->fast_out(i3); - if (bs->is_gc_barrier_node(b)) { - worklist.push(b); - } - } + add_users_to_worklist_if(worklist, u, [&](Node* b) { + return bs->is_gc_barrier_node(b); + }); } worklist.push(u); } @@ -2725,17 +2690,17 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_ worklist.push(cmp); } } + // VectorMaskToLongNode::Ideal_MaskAll looks through VectorStoreMask + // to fold constant masks. + if (use_op == Op_VectorStoreMask) { + add_users_to_worklist_if(worklist, use, [](Node* u) { return u->Opcode() == Op_VectorMaskToLong; }); + } // From CastX2PNode::Ideal // CastX2P(AddX(x, y)) // CastX2P(SubX(x, y)) if (use->Opcode() == Op_AddX || use->Opcode() == Op_SubX) { - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->Opcode() == Op_CastX2P) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [](Node* u) { return u->Opcode() == Op_CastX2P; }); } /* AndNode has a special handling when one of the operands is a LShiftNode: @@ -2770,12 +2735,7 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_ // e.g., (x - y) + y -> x; x + (y - x) -> y. if (use_op == Op_SubI || use_op == Op_SubL) { const int add_op = (use_op == Op_SubI) ? Op_AddI : Op_AddL; - for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { - Node* u = use->fast_out(i2); - if (u->Opcode() == add_op) { - worklist.push(u); - } - } + add_users_to_worklist_if(worklist, use, [=](Node* u) { return u->Opcode() == add_op; }); } } @@ -2960,6 +2920,10 @@ void PhaseCCP::dump_type_and_node(const Node* n, const Type* t) { } #endif +bool PhaseCCP::not_bottom_type(Node* n) const { + return n->bottom_type() != type(n); +} + // We need to propagate the type change of 'n' to all its uses. Depending on the kind of node, additional nodes // (grandchildren or even further down) need to be revisited as their types could also be improved as a result // of the new type of 'n'. Push these nodes to the worklist. @@ -2972,7 +2936,7 @@ void PhaseCCP::push_child_nodes_to_worklist(Unique_Node_List& worklist, Node* n) } void PhaseCCP::push_if_not_bottom_type(Unique_Node_List& worklist, Node* n) const { - if (n->bottom_type() != type(n)) { + if (not_bottom_type(n)) { worklist.push(n); } } @@ -2995,9 +2959,9 @@ void PhaseCCP::push_more_uses(Unique_Node_List& worklist, Node* parent, const No // We must recheck Phis too if use is a Region. void PhaseCCP::push_phis(Unique_Node_List& worklist, const Node* use) const { if (use->is_Region()) { - for (DUIterator_Fast imax, i = use->fast_outs(imax); i < imax; i++) { - push_if_not_bottom_type(worklist, use->fast_out(i)); - } + add_users_to_worklist_if(worklist, use, [&](Node* u) { + return not_bottom_type(u); + }); } } @@ -3024,14 +2988,11 @@ void PhaseCCP::push_catch(Unique_Node_List& worklist, const Node* use) { void PhaseCCP::push_cmpu(Unique_Node_List& worklist, const Node* use) const { uint use_op = use->Opcode(); if (use_op == Op_AddI || use_op == Op_SubI) { - for (DUIterator_Fast imax, i = use->fast_outs(imax); i < imax; i++) { - Node* cmpu = use->fast_out(i); - const uint cmpu_opcode = cmpu->Opcode(); - if (cmpu_opcode == Op_CmpU || cmpu_opcode == Op_CmpU3) { - // Got a CmpU or CmpU3 which might need the new type information from node n. - push_if_not_bottom_type(worklist, cmpu); - } - } + // Got a CmpU or CmpU3 which might need the new type information from node n. + add_users_to_worklist_if(worklist, use, [&](Node* u) { + uint op = u->Opcode(); + return (op == Op_CmpU || op == Op_CmpU3) && not_bottom_type(u); + }); } } @@ -3120,12 +3081,9 @@ void PhaseCCP::push_loadp(Unique_Node_List& worklist, const Node* use) const { } void PhaseCCP::push_load_barrier(Unique_Node_List& worklist, const BarrierSetC2* barrier_set, const Node* use) { - for (DUIterator_Fast imax, i = use->fast_outs(imax); i < imax; i++) { - Node* barrier_node = use->fast_out(i); - if (barrier_set->is_gc_barrier_node(barrier_node)) { - worklist.push(barrier_node); - } - } + add_users_to_worklist_if(worklist, use, [&](Node* u) { + return barrier_set->is_gc_barrier_node(u); + }); } // AndI/L::Value() optimizes patterns similar to (v << 2) & 3, or CON & 3 to zero if they are bitwise disjoint. @@ -3161,12 +3119,9 @@ void PhaseCCP::push_and(Unique_Node_List& worklist, const Node* parent, const No void PhaseCCP::push_cast_ii(Unique_Node_List& worklist, const Node* parent, const Node* use) const { if (use->Opcode() == Op_CmpI && use->in(2) == parent) { Node* other_cmp_input = use->in(1); - for (DUIterator_Fast imax, i = other_cmp_input->fast_outs(imax); i < imax; i++) { - Node* cast_ii = other_cmp_input->fast_out(i); - if (cast_ii->is_CastII()) { - push_if_not_bottom_type(worklist, cast_ii); - } - } + add_users_to_worklist_if(worklist, other_cmp_input, [&](Node* u) { + return u->is_CastII() && not_bottom_type(u); + }); } } diff --git a/src/hotspot/share/opto/phaseX.hpp b/src/hotspot/share/opto/phaseX.hpp index cd38f37ccf5..94890c250c4 100644 --- a/src/hotspot/share/opto/phaseX.hpp +++ b/src/hotspot/share/opto/phaseX.hpp @@ -652,6 +652,7 @@ class PhaseCCP : public PhaseIterGVN { Node* fetch_next_node(Unique_Node_List& worklist); static void dump_type_and_node(const Node* n, const Type* t) PRODUCT_RETURN; + bool not_bottom_type(Node* n) const; void push_child_nodes_to_worklist(Unique_Node_List& worklist, Node* n) const; void push_if_not_bottom_type(Unique_Node_List& worklist, Node* n) const; void push_more_uses(Unique_Node_List& worklist, Node* parent, const Node* use) const; diff --git a/src/hotspot/share/opto/phasetype.hpp b/src/hotspot/share/opto/phasetype.hpp index f388dc6cdc6..ce432fbfc01 100644 --- a/src/hotspot/share/opto/phasetype.hpp +++ b/src/hotspot/share/opto/phasetype.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ #ifndef SHARE_OPTO_PHASETYPE_HPP #define SHARE_OPTO_PHASETYPE_HPP +#include "memory/allocation.hpp" #include "utilities/bitMap.inline.hpp" #include "utilities/stringUtils.hpp" diff --git a/src/hotspot/share/runtime/atomicAccess.hpp b/src/hotspot/share/runtime/atomicAccess.hpp index c9a2dfb9383..46330cffdb2 100644 --- a/src/hotspot/share/runtime/atomicAccess.hpp +++ b/src/hotspot/share/runtime/atomicAccess.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ #define SHARE_RUNTIME_ATOMICACCESS_HPP #include "cppstdlib/type_traits.hpp" -#include "memory/allocation.hpp" +#include "memory/allStatic.hpp" #include "metaprogramming/enableIf.hpp" #include "metaprogramming/primitiveConversions.hpp" #include "runtime/orderAccess.hpp" @@ -829,7 +829,7 @@ class AtomicAccess::PlatformBitops {}; template -class ScopedFenceGeneral: public StackObj { +class ScopedFenceGeneral { public: void prefix() {} void postfix() {} diff --git a/src/hotspot/share/runtime/objectMonitor.cpp b/src/hotspot/share/runtime/objectMonitor.cpp index 8c6994c2152..91771772e2c 100644 --- a/src/hotspot/share/runtime/objectMonitor.cpp +++ b/src/hotspot/share/runtime/objectMonitor.cpp @@ -2541,19 +2541,19 @@ bool ObjectMonitor::try_spin(JavaThread* current) { // ----------------------------------------------------------------------------- // wait_set management ... -ObjectWaiter::ObjectWaiter(JavaThread* current) { - _next = nullptr; - _prev = nullptr; - _thread = current; - _monitor = nullptr; - _notifier_tid = 0; - _recursions = 0; - TState = TS_RUN; - _is_wait = false; - _at_reenter = false; - _interrupted = false; - _do_timed_park = false; - _active = false; +ObjectWaiter::ObjectWaiter(JavaThread* current) + : _next(nullptr), + _prev(nullptr), + _thread(current), + _monitor(nullptr), + _notifier_tid(0), + _recursions(0), + TState(TS_RUN), + _is_wait(false), + _at_reenter(false), + _interrupted(false), + _do_timed_park(false), + _active(false) { } const char* ObjectWaiter::getTStateName(ObjectWaiter::TStates state) { diff --git a/src/hotspot/share/utilities/bitMap.hpp b/src/hotspot/share/utilities/bitMap.hpp index 5ee462bbe47..17bf437ecae 100644 --- a/src/hotspot/share/utilities/bitMap.hpp +++ b/src/hotspot/share/utilities/bitMap.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ #include "utilities/globalDefinitions.hpp" // Forward decl; +class Arena; class BitMapClosure; // Operations for bitmaps represented as arrays of unsigned integers. diff --git a/src/java.base/share/classes/java/io/ObjectInputStream.java b/src/java.base/share/classes/java/io/ObjectInputStream.java index daed5f3cce5..cd6bd7683f7 100644 --- a/src/java.base/share/classes/java/io/ObjectInputStream.java +++ b/src/java.base/share/classes/java/io/ObjectInputStream.java @@ -2219,7 +2219,7 @@ public class ObjectInputStream * mechanism marks the record as having an exception. * Null is returned from readRecord and later the exception is thrown at * the exit of {@link #readObject(Class)}. - **/ + */ private Object readRecord(ObjectStreamClass desc) throws IOException { ObjectStreamClass.ClassDataSlot[] slots = desc.getClassDataLayout(); if (slots.length != 1) { diff --git a/src/java.base/share/classes/java/lang/Boolean.java b/src/java.base/share/classes/java/lang/Boolean.java index 4c24e98a549..49ab80edfea 100644 --- a/src/java.base/share/classes/java/lang/Boolean.java +++ b/src/java.base/share/classes/java/lang/Boolean.java @@ -28,14 +28,10 @@ package java.lang; import jdk.internal.vm.annotation.IntrinsicCandidate; import java.lang.constant.Constable; -import java.lang.constant.ConstantDesc; import java.lang.constant.ConstantDescs; import java.lang.constant.DynamicConstantDesc; import java.util.Optional; -import static java.lang.constant.ConstantDescs.BSM_GET_STATIC_FINAL; -import static java.lang.constant.ConstantDescs.CD_Boolean; - /** * The {@code Boolean} class is the {@linkplain * java.lang##wrapperClass wrapper class} for values of the primitive diff --git a/src/java.base/share/classes/java/lang/Byte.java b/src/java.base/share/classes/java/lang/Byte.java index 0f3f7f40d05..c2c03e7a3c2 100644 --- a/src/java.base/share/classes/java/lang/Byte.java +++ b/src/java.base/share/classes/java/lang/Byte.java @@ -36,7 +36,6 @@ import java.util.Optional; import static java.lang.constant.ConstantDescs.BSM_EXPLICIT_CAST; import static java.lang.constant.ConstantDescs.CD_byte; -import static java.lang.constant.ConstantDescs.CD_int; import static java.lang.constant.ConstantDescs.DEFAULT_NAME; /** diff --git a/src/java.base/share/classes/java/lang/Class.java b/src/java.base/share/classes/java/lang/Class.java index eab1993a2b4..8a2f722f3dd 100644 --- a/src/java.base/share/classes/java/lang/Class.java +++ b/src/java.base/share/classes/java/lang/Class.java @@ -224,9 +224,9 @@ public final class Class implements java.io.Serializable, AnnotatedElement, TypeDescriptor.OfField>, Constable { - private static final int ANNOTATION= 0x00002000; - private static final int ENUM = 0x00004000; - private static final int SYNTHETIC = 0x00001000; + private static final int ANNOTATION = 0x00002000; + private static final int ENUM = 0x00004000; + private static final int SYNTHETIC = 0x00001000; private static native void registerNatives(); static { @@ -1390,6 +1390,7 @@ public final class Class implements java.io.Serializable, // INNER_CLASS forbids. INNER_CLASS allows PRIVATE, PROTECTED, // and STATIC, which are not allowed on Location.CLASS. // Use getClassFileAccessFlags to expose SUPER status. + // Arrays need to use PRIVATE/PROTECTED from its component modifiers. var location = (isMemberClass() || isLocalClass() || isAnonymousClass() || isArray()) ? AccessFlag.Location.INNER_CLASS : @@ -3779,7 +3780,7 @@ public final class Class implements java.io.Serializable, * @since 1.8 */ public AnnotatedType[] getAnnotatedInterfaces() { - return TypeAnnotationParser.buildAnnotatedInterfaces(getRawTypeAnnotations(), getConstantPool(), this); + return TypeAnnotationParser.buildAnnotatedInterfaces(getRawTypeAnnotations(), getConstantPool(), this); } private native Class getNestHost0(); diff --git a/src/java.base/share/classes/java/lang/Short.java b/src/java.base/share/classes/java/lang/Short.java index 920500a7fa3..14f7a267165 100644 --- a/src/java.base/share/classes/java/lang/Short.java +++ b/src/java.base/share/classes/java/lang/Short.java @@ -35,7 +35,6 @@ import java.lang.constant.DynamicConstantDesc; import java.util.Optional; import static java.lang.constant.ConstantDescs.BSM_EXPLICIT_CAST; -import static java.lang.constant.ConstantDescs.CD_int; import static java.lang.constant.ConstantDescs.CD_short; import static java.lang.constant.ConstantDescs.DEFAULT_NAME; diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java index fc05febdb45..c6c08ed4473 100644 --- a/src/java.base/share/classes/java/lang/String.java +++ b/src/java.base/share/classes/java/lang/String.java @@ -1133,6 +1133,34 @@ public final class String return Arrays.copyOf(dst, dp); } + // This follows the implementation of encodeASCII and encode8859_1 + private static int encodedLengthASCIIor8859_1(byte coder, byte[] val) { + if (coder == LATIN1) { + return val.length; + } + int len = val.length >> 1; + int dp = 0; + int sp = 0; + int sl = len; + while (sp < sl) { + char c = StringUTF16.getChar(val, sp); + if (c >= Character.MIN_HIGH_SURROGATE) { + break; + } + dp++; + sp++; + } + while (sp < sl) { + char c = StringUTF16.getChar(val, sp++); + if (Character.isHighSurrogate(c) && sp < sl && + Character.isLowSurrogate(StringUTF16.getChar(val, sp))) { + sp++; + } + dp++; + } + return dp; + } + //------------------------------ utf8 ------------------------------------ /** @@ -1467,6 +1495,27 @@ public final class String return Arrays.copyOf(dst, dp); } + // This follows the implementation of encodeUTF8 + private static int encodedLengthUTF8(byte coder, byte[] val) { + if (coder == UTF16) { + return encodedLengthUTF8_UTF16(val, null); + } + int positives = StringCoding.countPositives(val, 0, val.length); + if (positives == val.length) { + return positives; + } + int dp = positives; + for (int i = dp; i < val.length; i++) { + byte c = val[i]; + if (c < 0) { + dp += 2; + } else { + dp++; + } + } + return dp; + } + /** * {@return the byte array obtained by first decoding {@code val} with * UTF-16, and then encoding the result with UTF-8} @@ -1484,11 +1533,8 @@ public final class String int sl = val.length >> 1; // UTF-8 encoded can be as much as 3 times the string length // For very large estimate, (as in overflow of 32 bit int), precompute the exact size - long allocLen = (sl * 3 < 0) ? computeSizeUTF8_UTF16(val, exClass) : sl * 3; - if (allocLen > (long)Integer.MAX_VALUE) { - throw new OutOfMemoryError("Required length exceeds implementation limit"); - } - byte[] dst = new byte[(int) allocLen]; + int allocLen = (sl * 3 < 0) ? encodedLengthUTF8_UTF16(val, exClass) : sl * 3; + byte[] dst = new byte[allocLen]; while (sp < sl) { // ascii fast loop; char c = StringUTF16.getChar(val, sp); @@ -1547,11 +1593,20 @@ public final class String * @param The exception type parameter to enable callers to avoid * having to declare the exception */ - private static long computeSizeUTF8_UTF16(byte[] val, Class exClass) throws E { + private static int encodedLengthUTF8_UTF16(byte[] val, Class exClass) throws E { long dp = 0L; int sp = 0; int sl = val.length >> 1; + while (sp < sl) { + // ascii fast loop; + char c = StringUTF16.getChar(val, sp); + if (c >= '\u0080') { + break; + } + dp++; + sp++; + } while (sp < sl) { char c = StringUTF16.getChar(val, sp++); if (c < 0x80) { @@ -1580,7 +1635,10 @@ public final class String dp += 3; } } - return dp; + if (dp > (long)Integer.MAX_VALUE) { + throw new OutOfMemoryError("Required length exceeds implementation limit"); + } + return (int) dp; } /** @@ -2045,6 +2103,29 @@ public final class String return encode(Charset.defaultCharset(), coder(), value); } + /** + * {@return the length in bytes of this {@code String} encoded with the given {@link Charset}} + * + *

The returned length accounts for the replacement of malformed-input and unmappable-character + * sequences with the charset's default replacement byte array. The result will be the same value + * as {@link #getBytes(Charset) getBytes(cs).length}. + * + * @apiNote This method provides equivalent or better performance than {@link #getBytes(Charset) + * getBytes(cs).length}. + * + * @param cs The {@link Charset} used to the compute the length + * @since 27 + */ + public int encodedLength(Charset cs) { + Objects.requireNonNull(cs); + if (cs == UTF_8.INSTANCE) { + return encodedLengthUTF8(coder, value); + } else if (cs == ISO_8859_1.INSTANCE || cs == US_ASCII.INSTANCE) { + return encodedLengthASCIIor8859_1(coder, value); + } + return getBytes(cs).length; + } + boolean bytesCompatible(Charset charset, int srcIndex, int numChars) { if (isLatin1()) { if (charset == ISO_8859_1.INSTANCE) { diff --git a/src/java.base/share/classes/java/lang/doc-files/ValueBased.html b/src/java.base/share/classes/java/lang/doc-files/ValueBased.html index 6a935afe04b..3b860ce0534 100644 --- a/src/java.base/share/classes/java/lang/doc-files/ValueBased.html +++ b/src/java.base/share/classes/java/lang/doc-files/ValueBased.html @@ -30,35 +30,35 @@

{@index "Value-based Classes"}

-Some classes, such as java.lang.Integer and -java.time.LocalDate, are value-based. +Some classes, such as {@code java.lang.Integer} and +{@code java.time.LocalDate}, are value-based. A value-based class has the following properties:
  • the class declares only final instance fields (though these may contain references to mutable objects);
  • -
  • the class's implementations of equals, hashCode, - and toString compute their results solely from the values +
  • the class's implementations of {@code equals}, {@code hashCode}, + and {@code toString} compute their results solely from the values of the class's instance fields (and the members of the objects they reference), not from the instance's identity;
  • the class's methods treat instances as freely substitutable - when equal, meaning that interchanging any two instances x and - y that are equal according to equals() produces no + when equal, meaning that interchanging any two instances {@code x} and + {@code y} that are equal according to {@code equals()} produces no visible change in the behavior of the class's methods;
  • the class performs no synchronization using an instance's monitor;
  • -
  • the class does not declare (or has deprecated any) accessible constructors;
  • +
  • the class does not declare (or discourages use of) accessible constructors;
  • the class does not provide any instance creation mechanism that promises a unique identity on each method call—in particular, any factory method's contract must allow for the possibility that if two independently-produced - instances are equal according to equals(), they may also be - equal according to ==;
  • -
  • the class is final, and extends either Object or a hierarchy of + instances are equal according to {@code equals()}, they may also be + equal according to {@code ==};
  • +
  • the class is final, and extends either {@code Object} or a hierarchy of abstract classes that declare no instance fields or instance initializers and whose constructors are empty.

When two instances of a value-based class are equal (according to `equals`), a program should not attempt to distinguish between their identities, whether directly via reference - equality or indirectly via an appeal to synchronization, identity hashing, + equality {@code ==} or indirectly via an appeal to synchronization, identity hashing, serialization, or any other identity-sensitive mechanism.

Synchronization on instances of value-based classes is strongly discouraged, diff --git a/src/java.base/share/classes/java/lang/invoke/MemberName.java b/src/java.base/share/classes/java/lang/invoke/MemberName.java index 918d1b10791..d320ad11ade 100644 --- a/src/java.base/share/classes/java/lang/invoke/MemberName.java +++ b/src/java.base/share/classes/java/lang/invoke/MemberName.java @@ -408,11 +408,12 @@ final class MemberName implements Member, Cloneable { // let the rest (native, volatile, transient, etc.) be tested via Modifier.isFoo // unofficial modifier flags, used by HotSpot: - static final int BRIDGE = 0x00000040; - static final int VARARGS = 0x00000080; - static final int SYNTHETIC = 0x00001000; - static final int ANNOTATION= 0x00002000; - static final int ENUM = 0x00004000; + static final int BRIDGE = 0x00000040; + static final int VARARGS = 0x00000080; + static final int SYNTHETIC = 0x00001000; + static final int ANNOTATION = 0x00002000; + static final int ENUM = 0x00004000; + /** Utility method to query the modifier flags of this member; returns false if the member is not a method. */ public boolean isBridge() { return allFlagsSet(IS_METHOD | BRIDGE); @@ -426,19 +427,19 @@ final class MemberName implements Member, Cloneable { return allFlagsSet(SYNTHETIC); } - static final String CONSTRUCTOR_NAME = ""; // the ever-popular + static final String CONSTRUCTOR_NAME = ""; // modifiers exported by the JVM: static final int RECOGNIZED_MODIFIERS = 0xFFFF; // private flags, not part of RECOGNIZED_MODIFIERS: static final int - IS_METHOD = MN_IS_METHOD, // method (not constructor) - IS_CONSTRUCTOR = MN_IS_CONSTRUCTOR, // constructor - IS_FIELD = MN_IS_FIELD, // field - IS_TYPE = MN_IS_TYPE, // nested type - CALLER_SENSITIVE = MN_CALLER_SENSITIVE, // @CallerSensitive annotation detected - TRUSTED_FINAL = MN_TRUSTED_FINAL; // trusted final field + IS_METHOD = MN_IS_METHOD, // method (not constructor) + IS_CONSTRUCTOR = MN_IS_CONSTRUCTOR, // constructor + IS_FIELD = MN_IS_FIELD, // field + IS_TYPE = MN_IS_TYPE, // nested type + CALLER_SENSITIVE = MN_CALLER_SENSITIVE, // @CallerSensitive annotation detected + TRUSTED_FINAL = MN_TRUSTED_FINAL; // trusted final field static final int ALL_ACCESS = Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED; static final int ALL_KINDS = IS_METHOD | IS_CONSTRUCTOR | IS_FIELD | IS_TYPE; diff --git a/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java b/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java index 16f5c7e59b8..8dac21c8968 100644 --- a/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java +++ b/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java @@ -344,7 +344,7 @@ public final class MethodHandleProxies { ClassLoaders.platformClassLoader() : loader))) .build(proxyDesc, clb -> { clb.withSuperclass(CD_Object) - .withFlags(ACC_FINAL | ACC_SYNTHETIC) + .withFlags(ACC_SUPER | ACC_FINAL | ACC_SYNTHETIC) .withInterfaceSymbols(ifaceDesc) // static and instance fields .withField(TYPE_NAME, CD_Class, ACC_PRIVATE | ACC_STATIC | ACC_FINAL) diff --git a/src/java.base/share/classes/java/lang/reflect/Proxy.java b/src/java.base/share/classes/java/lang/reflect/Proxy.java index b811deb863d..6ce8e80cdca 100644 --- a/src/java.base/share/classes/java/lang/reflect/Proxy.java +++ b/src/java.base/share/classes/java/lang/reflect/Proxy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package java.lang.reflect; +import java.lang.classfile.ClassFile; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; @@ -467,7 +468,7 @@ public class Proxy implements java.io.Serializable { * Generate the specified proxy class. */ byte[] proxyClassFile = ProxyGenerator.generateProxyClass(loader, proxyName, interfaces, - context.accessFlags() | Modifier.FINAL); + context.accessFlags() | Modifier.FINAL | ClassFile.ACC_SUPER); try { Class pc = JLA.defineClass(loader, proxyName, proxyClassFile, null, "__dynamic_proxy__"); diff --git a/src/java.base/share/classes/java/util/Base64.java b/src/java.base/share/classes/java/util/Base64.java index ed1a4a8d638..fd714050149 100644 --- a/src/java.base/share/classes/java/util/Base64.java +++ b/src/java.base/share/classes/java/util/Base64.java @@ -32,6 +32,8 @@ import java.io.OutputStream; import java.nio.ByteBuffer; import sun.nio.cs.ISO_8859_1; +import jdk.internal.access.JavaLangAccess; +import jdk.internal.access.SharedSecrets; import jdk.internal.util.Preconditions; import jdk.internal.vm.annotation.IntrinsicCandidate; @@ -201,6 +203,7 @@ public final class Base64 { * @since 1.8 */ public static class Encoder { + private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess(); private final byte[] newline; private final int linemax; @@ -344,10 +347,9 @@ public final class Base64 { * the byte array to encode * @return A String containing the resulting Base64 encoded characters */ - @SuppressWarnings("deprecation") public String encodeToString(byte[] src) { byte[] encoded = encode(src); - return new String(encoded, 0, 0, encoded.length); + return JLA.uncheckedNewStringWithLatin1Bytes(encoded); } /** diff --git a/src/java.base/share/classes/java/util/WeakHashMap.java b/src/java.base/share/classes/java/util/WeakHashMap.java index b5a27593840..1412d8f6ff9 100644 --- a/src/java.base/share/classes/java/util/WeakHashMap.java +++ b/src/java.base/share/classes/java/util/WeakHashMap.java @@ -25,8 +25,8 @@ package java.util; -import java.lang.ref.WeakReference; import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.Consumer; diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/DirectClassBuilder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/DirectClassBuilder.java index 0e82c545359..79c623bc31d 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/DirectClassBuilder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/DirectClassBuilder.java @@ -168,7 +168,6 @@ public final class DirectClassBuilder this.sizeHint = sizeHint; } - public byte[] build() { // The logic of this is very carefully ordered. We want to avoid diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerificationTable.java b/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerificationTable.java index 04276b8eeb8..eb3f5ee913d 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerificationTable.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerificationTable.java @@ -321,7 +321,7 @@ class VerificationTable { return frame; } int offset_delta = _stream.get_u2(); - if (frame_type < SAME_LOCALS_1_STACK_ITEM_EXTENDED) { + if (frame_type <= RESERVED_END) { _verifier.classError("reserved frame type"); } if (frame_type == SAME_LOCALS_1_STACK_ITEM_EXTENDED) { diff --git a/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java b/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java index c36e265ee2f..4c358820166 100644 --- a/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java +++ b/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java @@ -821,6 +821,7 @@ public final class ImageReader implements AutoCloseable { this.children = Collections.unmodifiableList(children); } } + /** * Resource node (e.g. a ".class" entry, or any other data resource). * diff --git a/src/java.base/share/classes/jdk/internal/lang/CaseFolding.java.template b/src/java.base/share/classes/jdk/internal/lang/CaseFolding.java.template index 24a183c8da0..24f48151f21 100644 --- a/src/java.base/share/classes/jdk/internal/lang/CaseFolding.java.template +++ b/src/java.base/share/classes/jdk/internal/lang/CaseFolding.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, 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 @@ -188,6 +188,12 @@ public final class CaseFolding { } private static long getDefined(int cp) { + // Exclude code point U+0000, which is guaranteed to have no + // case-folding mapping. + if (cp == 0) { + return -1; + } + var hashes = CASE_FOLDING_HASHES; var length = CASE_FOLDING_CPS.length; // hashed based on total defined. var hash = cp % length; diff --git a/src/java.base/share/classes/module-info.java b/src/java.base/share/classes/module-info.java index d20f6311bca..665b3a3b98d 100644 --- a/src/java.base/share/classes/module-info.java +++ b/src/java.base/share/classes/module-info.java @@ -135,7 +135,6 @@ module java.base { exports javax.security.auth.x500; exports javax.security.cert; - // additional qualified exports may be inserted at build time // see make/gensrc/GenModuleInfo.gmk @@ -147,11 +146,11 @@ module java.base { java.security.sasl; exports jdk.internal to jdk.incubator.vector; - // Note: all modules in the exported list participate in preview features - // and therefore if they use preview features they do not need to be - // compiled with "--enable-preview". + // Note: all modules in the exported list participate in preview features, + // normal or reflective. They do not need to be compiled with "--enable-preview" + // to use preview features and do not need to suppress "preview" warnings. // It is recommended for any modules that do participate that their - // module declaration be annotated with jdk.internal.javac.ParticipatesInPreview + // module declaration be annotated with jdk.internal.javac.ParticipatesInPreview. exports jdk.internal.javac to java.compiler, jdk.compiler; diff --git a/src/java.base/share/native/include/classfile_constants.h.template b/src/java.base/share/native/include/classfile_constants.h.template index fb022ec1fd4..4f96a0673ef 100644 --- a/src/java.base/share/native/include/classfile_constants.h.template +++ b/src/java.base/share/native/include/classfile_constants.h.template @@ -111,7 +111,7 @@ enum { JVM_CONSTANT_InvokeDynamic = 18, JVM_CONSTANT_Module = 19, JVM_CONSTANT_Package = 20, - JVM_CONSTANT_ExternalMax = 20 + JVM_CONSTANT_ExternalMax = 20 }; /* JVM_CONSTANT_MethodHandle subtypes */ diff --git a/src/java.base/unix/native/libjava/TimeZone_md.c b/src/java.base/unix/native/libjava/TimeZone_md.c index cd253edde60..39e7b726220 100644 --- a/src/java.base/unix/native/libjava/TimeZone_md.c +++ b/src/java.base/unix/native/libjava/TimeZone_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, 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 @@ -352,33 +352,15 @@ getPlatformTimeZoneID() } static char * -mapPlatformToJavaTimezone(const char *java_home_dir, const char *tz) { +getJavaTimezoneFromPlatform(const char *tz_buf, size_t tz_len, const char *mapfilename) { FILE *tzmapf; - char mapfilename[PATH_MAX + 1]; char line[256]; int linecount = 0; - char *tz_buf = NULL; - char *temp_tz = NULL; char *javatz = NULL; - size_t tz_len = 0; - /* On AIX, the TZ environment variable may end with a comma - * followed by modifier fields until early AIX6.1. - * This restriction has been removed from AIX7. */ - - tz_buf = strdup(tz); - tz_len = strlen(tz_buf); - - /* Open tzmappings file, with buffer overrun check */ - if ((strlen(java_home_dir) + 15) > PATH_MAX) { - jio_fprintf(stderr, "Path %s/lib/tzmappings exceeds maximum path length\n", java_home_dir); - goto tzerr; - } - strcpy(mapfilename, java_home_dir); - strcat(mapfilename, "/lib/tzmappings"); if ((tzmapf = fopen(mapfilename, "r")) == NULL) { jio_fprintf(stderr, "can't open %s\n", mapfilename); - goto tzerr; + return NULL; } while (fgets(line, sizeof(line), tzmapf) != NULL) { @@ -431,10 +413,50 @@ mapPlatformToJavaTimezone(const char *java_home_dir, const char *tz) { break; } } + (void) fclose(tzmapf); + return javatz; +} + +static char * +mapPlatformToJavaTimezone(const char *java_home_dir, const char *tz) { + char mapfilename[PATH_MAX + 1]; + char *tz_buf = NULL; + char *javatz = NULL; + char *temp_tz = NULL; + size_t tz_len = 0; + + /* On AIX, the TZ environment variable may end with a comma + * followed by modifier fields until early AIX6.1. + * This restriction has been removed from AIX7. */ + + tz_buf = strdup(tz); + tz_len = strlen(tz_buf); + + /* Open tzmappings file, with buffer overrun check */ + if ((strlen(java_home_dir) + 15) > PATH_MAX) { + jio_fprintf(stderr, "Path %s/lib/tzmappings exceeds maximum path length\n", java_home_dir); + goto tzerr; + } + strcpy(mapfilename, java_home_dir); + strcat(mapfilename, "/lib/tzmappings"); + + // First attempt to find the Java timezone for the full tz string + javatz = getJavaTimezoneFromPlatform(tz_buf, tz_len, mapfilename); + + // If no match was found, check for timezone with truncated value + if (javatz == NULL) { + temp_tz = strchr(tz, ','); + tz_len = (temp_tz == NULL) ? strlen(tz) : temp_tz - tz; + free((void *) tz_buf); + tz_buf = (char *)malloc(tz_len + 1); + memcpy(tz_buf, tz, tz_len); + tz_buf[tz_len] = '\0'; + javatz = getJavaTimezoneFromPlatform(tz_buf, tz_len, mapfilename); + } tzerr: - if (tz_buf != NULL ) { + if (tz_buf != NULL) { free((void *) tz_buf); } diff --git a/src/java.compiler/share/classes/javax/annotation/processing/Processor.java b/src/java.compiler/share/classes/javax/annotation/processing/Processor.java index 4be159868fa..2f2a9b285f6 100644 --- a/src/java.compiler/share/classes/javax/annotation/processing/Processor.java +++ b/src/java.compiler/share/classes/javax/annotation/processing/Processor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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 @@ -101,28 +101,29 @@ import javax.lang.model.SourceVersion; * supports, possibly an empty set. * * For a given round, the tool computes the set of annotation - * interfaces that are present on the elements enclosed within the - * root elements. If there is at least one annotation interface - * present, then as processors claim annotation interfaces, they are - * removed from the set of unmatched annotation interfaces. When the - * set is empty or no more processors are available, the round has run - * to completion. If there are no annotation interfaces present, - * annotation processing still occurs but only universal + * interfaces that are present on the elements {@linkplain + * RoundEnvironment#getElementsAnnotatedWith(TypeElement) included} + * within the root elements. If there is at least one annotation + * interface present, then as processors claim annotation interfaces, + * they are removed from the set of unmatched annotation interfaces. + * When the set is empty or no more processors are available, the + * round has run to completion. If there are no annotation interfaces + * present, annotation processing still occurs but only universal * processors which support processing all annotation interfaces, * {@code "*"}, can claim the (empty) set of annotation interfaces. * *

An annotation interface is considered present if there is at least - * one annotation of that interface present on an element enclosed within + * one annotation of that interface present on an element included within * the root elements of a round. For this purpose, a type parameter is - * considered to be enclosed by its {@linkplain + * considered to be included by its {@linkplain * TypeParameterElement#getGenericElement generic * element}. * For this purpose, a package element is not considered to - * enclose the top-level classes and interfaces within that + * include the top-level classes and interfaces within that * package. (A root element representing a package is created when a * {@code package-info} file is processed.) Likewise, for this - * purpose, a module element is not considered to enclose the + * purpose, a module element is not considered to include the * packages within that module. (A root element representing a module * is created when a {@code module-info} file is processed.) * diff --git a/src/java.desktop/share/classes/java/awt/AWTEvent.java b/src/java.desktop/share/classes/java/awt/AWTEvent.java index d48fae68cbe..f365393ffb1 100644 --- a/src/java.desktop/share/classes/java/awt/AWTEvent.java +++ b/src/java.desktop/share/classes/java/awt/AWTEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2026, 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,22 +554,9 @@ public abstract class AWTEvent extends EventObject { */ void copyPrivateDataInto(AWTEvent that) { that.bdata = this.bdata; - // Copy canAccessSystemClipboard value from this into that. - if (this instanceof InputEvent && that instanceof InputEvent) { - - AWTAccessor.InputEventAccessor accessor - = AWTAccessor.getInputEventAccessor(); - - boolean b = accessor.canAccessSystemClipboard((InputEvent) this); - accessor.setCanAccessSystemClipboard((InputEvent) that, b); - } that.isSystemGenerated = this.isSystemGenerated; } void dispatched() { - if (this instanceof InputEvent) { - AWTAccessor.getInputEventAccessor(). - setCanAccessSystemClipboard((InputEvent) this, false); - } } } // class AWTEvent diff --git a/src/java.desktop/share/classes/java/awt/event/InputEvent.java b/src/java.desktop/share/classes/java/awt/event/InputEvent.java index 9f1172916df..7517ea810e3 100644 --- a/src/java.desktop/share/classes/java/awt/event/InputEvent.java +++ b/src/java.desktop/share/classes/java/awt/event/InputEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2026, 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 @@ -309,13 +309,6 @@ public abstract sealed class InputEvent extends ComponentEvent */ int modifiers; - /* - * A flag that indicates that this instance can be used to access - * the system clipboard. - * This should be false in a headless environment, true in a headful one. - */ - private transient boolean canAccessSystemClipboard; - static { /* ensure that the necessary native libraries are loaded */ NativeLibLoader.loadLibraries(); @@ -328,15 +321,6 @@ public abstract sealed class InputEvent extends ComponentEvent return InputEvent.getButtonDownMasks(); } - public boolean canAccessSystemClipboard(InputEvent event) { - return event.canAccessSystemClipboard; - } - - @Override - public void setCanAccessSystemClipboard(InputEvent event, - boolean canAccessSystemClipboard) { - event.canAccessSystemClipboard = canAccessSystemClipboard; - } }); } @@ -381,11 +365,6 @@ public abstract sealed class InputEvent extends ComponentEvent super(source, id); this.when = when; this.modifiers = modifiers; - canAccessSystemClipboard = canAccessSystemClipboard(); - } - - private boolean canAccessSystemClipboard() { - return !GraphicsEnvironment.isHeadless(); } /** diff --git a/src/java.desktop/share/classes/sun/awt/AWTAccessor.java b/src/java.desktop/share/classes/sun/awt/AWTAccessor.java index c74219f7efa..f98118171b4 100644 --- a/src/java.desktop/share/classes/sun/awt/AWTAccessor.java +++ b/src/java.desktop/share/classes/sun/awt/AWTAccessor.java @@ -361,13 +361,6 @@ public final class AWTAccessor { * Accessor for InputEvent.getButtonDownMasks() */ int[] getButtonDownMasks(); - - /* - * Accessor for InputEvent.canAccessSystemClipboard field - */ - boolean canAccessSystemClipboard(InputEvent event); - void setCanAccessSystemClipboard(InputEvent event, - boolean canAccessSystemClipboard); } /** diff --git a/src/java.desktop/share/legal/freetype.md b/src/java.desktop/share/legal/freetype.md index cf2518df594..7259c27183f 100644 --- a/src/java.desktop/share/legal/freetype.md +++ b/src/java.desktop/share/legal/freetype.md @@ -1,4 +1,4 @@ -## The FreeType Project: Freetype v2.14.1 +## The FreeType Project: Freetype v2.14.2 ### FreeType Notice diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftoption.h b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftoption.h index be7a4c50dc3..a0a1a410b68 100644 --- a/src/java.desktop/share/native/libfreetype/include/freetype/config/ftoption.h +++ b/src/java.desktop/share/native/libfreetype/include/freetype/config/ftoption.h @@ -759,7 +759,13 @@ FT_BEGIN_HEADER /************************************************************************** * * Define `TT_CONFIG_OPTION_BDF` if you want to include support for an - * embedded 'BDF~' table within SFNT-based bitmap formats. + * embedded 'BDF~' table within an SFNT-based `.otb` font file. This table + * is an extension used by X11 to preserve BDF properties after conversion + * to SFNT containers. See + * + * https://fontforge.org/docs/techref/non-standard.html#non-standard-bdf + * + * for more details. */ /* #define TT_CONFIG_OPTION_BDF */ diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/config/mac-support.h b/src/java.desktop/share/native/libfreetype/include/freetype/config/mac-support.h index d1b6a9898fd..bd350851d56 100644 --- a/src/java.desktop/share/native/libfreetype/include/freetype/config/mac-support.h +++ b/src/java.desktop/share/native/libfreetype/include/freetype/config/mac-support.h @@ -24,6 +24,7 @@ * This is the only necessary change, so it is defined here instead * providing a new configuration file. */ +#ifdef FT_MACINTOSH #if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) ) /* No Carbon frameworks for 64bit 10.4.x. */ /* `AvailabilityMacros.h` is available since Mac OS X 10.2, */ @@ -36,6 +37,7 @@ ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 ) #undef FT_MACINTOSH #endif +#endif /* __APPLE__ ... */ #elif defined( __SC__ ) || defined( __MRC__ ) /* Classic MacOS compilers */ diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/freetype.h b/src/java.desktop/share/native/libfreetype/include/freetype/freetype.h index 1e249235882..e8a1b1e2f3e 100644 --- a/src/java.desktop/share/native/libfreetype/include/freetype/freetype.h +++ b/src/java.desktop/share/native/libfreetype/include/freetype/freetype.h @@ -4318,14 +4318,13 @@ FT_BEGIN_HEADER * property `no-stem-darkening` provided by the 'autofit', 'cff', * 'type1', and 't1cid' modules; see @no-stem-darkening). * - * * @FT_PARAM_TAG_LCD_FILTER_WEIGHTS (LCD filter weights, corresponding - * to function @FT_Library_SetLcdFilterWeights). - * * * @FT_PARAM_TAG_RANDOM_SEED (seed value for the CFF, Type~1, and CID * 'random' operator, corresponding to the `random-seed` property * provided by the 'cff', 'type1', and 't1cid' modules; see * @random-seed). * + * * @FT_PARAM_TAG_LCD_FILTER_WEIGHTS (no longer supported). + * * Pass `NULL` as `data` in @FT_Parameter for a given tag to reset the * option and use the library or module default again. * @@ -4352,25 +4351,17 @@ FT_BEGIN_HEADER * FT_Bool darken_stems = 1; * * FT_Parameter property2; - * FT_LcdFiveTapFilter custom_weight = - * { 0x11, 0x44, 0x56, 0x44, 0x11 }; - * - * FT_Parameter property3; * FT_Int32 random_seed = 314159265; * - * FT_Parameter properties[3] = { property1, - * property2, - * property3 }; + * FT_Parameter properties[2] = { property1, + * property2 }; * * * property1.tag = FT_PARAM_TAG_STEM_DARKENING; * property1.data = &darken_stems; * - * property2.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS; - * property2.data = custom_weight; - * - * property3.tag = FT_PARAM_TAG_RANDOM_SEED; - * property3.data = &random_seed; + * property2.tag = FT_PARAM_TAG_RANDOM_SEED; + * property2.data = &random_seed; * * FT_Face_Properties( face, 3, properties ); * ``` @@ -4381,7 +4372,7 @@ FT_BEGIN_HEADER * FT_Parameter property; * * - * property.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS; + * property.tag = FT_PARAM_TAG_STEM_DARKENING; * property.data = NULL; * * FT_Face_Properties( face, 1, &property ); @@ -5178,7 +5169,7 @@ FT_BEGIN_HEADER */ #define FREETYPE_MAJOR 2 #define FREETYPE_MINOR 14 -#define FREETYPE_PATCH 1 +#define FREETYPE_PATCH 2 /************************************************************************** diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftbdf.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftbdf.h index faad25689c9..ab142249217 100644 --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftbdf.h +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftbdf.h @@ -44,7 +44,8 @@ FT_BEGIN_HEADER * * @description: * This section contains the declaration of functions specific to BDF and - * PCF fonts. + * PCF fonts. They also work for SFNT bitmap fonts that contain a 'BDF~' + * table like X11's `.otb` fonts. * */ @@ -151,7 +152,9 @@ FT_BEGIN_HEADER * FreeType error code. 0~means success. * * @note: - * This function only works with BDF faces, returning an error otherwise. + * This function only works with BDF faces and SFNT fonts that have a + * 'BDF~' table, returning an error otherwise. For the latter, a bitmap + * strike size must be selected first. */ FT_EXPORT( FT_Error ) FT_Get_BDF_Charset_ID( FT_Face face, @@ -165,7 +168,7 @@ FT_BEGIN_HEADER * FT_Get_BDF_Property * * @description: - * Retrieve a BDF property from a BDF or PCF font file. + * Retrieve a BDF property from a BDF or PCF font. * * @input: * face :: @@ -196,6 +199,9 @@ FT_BEGIN_HEADER * * In case of error, `aproperty->type` is always set to * @BDF_PROPERTY_TYPE_NONE. + * + * This also works with SFNT fonts that have a 'BDF~' table, after a + * bitmap strike size has been selected. */ FT_EXPORT( FT_Error ) FT_Get_BDF_Property( FT_Face face, diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftimage.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftimage.h index b0a0172ef4f..a4dc724f349 100644 --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftimage.h +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftimage.h @@ -875,7 +875,7 @@ FT_BEGIN_HEADER */ typedef struct FT_Span_ { - short x; + unsigned short x; unsigned short len; unsigned char coverage; diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftlcdfil.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftlcdfil.h index a0a8e9da929..37bb5e1b8fb 100644 --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftlcdfil.h +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftlcdfil.h @@ -145,16 +145,10 @@ FT_BEGIN_HEADER * * FT_LCD_FILTER_LEGACY :: * FT_LCD_FILTER_LEGACY1 :: - * This filter corresponds to the original libXft color filter. It - * provides high contrast output but can exhibit really bad color - * fringes if glyphs are not extremely well hinted to the pixel grid. - * This filter is only provided for comparison purposes, and might be - * disabled or stay unsupported in the future. The second value is - * provided for compatibility with FontConfig, which historically used - * different enumeration, sometimes incorrectly forwarded to FreeType. + * The legacy libXft color filter is no longer supported and ignored. * * @since: - * 2.3.0 (`FT_LCD_FILTER_LEGACY1` since 2.6.2) + * 2.3.0 */ typedef enum FT_LcdFilter_ { diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/ftparams.h b/src/java.desktop/share/native/libfreetype/include/freetype/ftparams.h index 2c09db1683e..94dcd6399a6 100644 --- a/src/java.desktop/share/native/libfreetype/include/freetype/ftparams.h +++ b/src/java.desktop/share/native/libfreetype/include/freetype/ftparams.h @@ -133,11 +133,8 @@ FT_BEGIN_HEADER * FT_PARAM_TAG_LCD_FILTER_WEIGHTS * * @description: - * An @FT_Parameter tag to be used with @FT_Face_Properties. The - * corresponding argument specifies the five LCD filter weights for a - * given face (if using @FT_LOAD_TARGET_LCD, for example), overriding the - * global default values or the values set up with - * @FT_Library_SetLcdFilterWeights. + * Overriding global LCD filter weights with custom values for a given + * face is no longer supported and ignored. * * @since: * 2.8 diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/cfftypes.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/cfftypes.h index 62335db4834..754122fa646 100644 --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/cfftypes.h +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/cfftypes.h @@ -191,8 +191,8 @@ FT_BEGIN_HEADER FT_UInt weight; FT_Bool is_fixed_pitch; FT_Fixed italic_angle; - FT_Fixed underline_position; - FT_Fixed underline_thickness; + FT_Short underline_position; + FT_UShort underline_thickness; FT_Int paint_type; FT_Int charstring_type; FT_Matrix font_matrix; diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftobjs.h b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftobjs.h index 3db2fe28ffd..d4d7bc00fe9 100644 --- a/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftobjs.h +++ b/src/java.desktop/share/native/libfreetype/include/freetype/internal/ftobjs.h @@ -365,11 +365,6 @@ FT_BEGIN_HEADER * Value~0 means to use the font's value. Value~-1 means to use the * CFF driver's default. * - * lcd_weights :: - * lcd_filter_func :: - * These fields specify the LCD filtering weights and callback function - * for ClearType-style subpixel rendering. - * * refcount :: * A counter initialized to~1 at the time an @FT_Face structure is * created. @FT_Reference_Face increments this counter, and @@ -391,11 +386,6 @@ FT_BEGIN_HEADER FT_Char no_stem_darkening; FT_Int32 random_seed; -#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING - FT_LcdFiveTapFilter lcd_weights; /* filter weights, if any */ - FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */ -#endif - FT_Int refcount; } FT_Face_InternalRec; @@ -724,9 +714,9 @@ FT_BEGIN_HEADER const FT_Vector* origin ); /* Allocate a new bitmap buffer in a glyph slot. */ + /* Dimensions must be preset in advance. */ FT_BASE( FT_Error ) - ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot, - FT_ULong size ); + ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot ); /* Set the bitmap buffer in a glyph slot to a given pointer. The buffer */ @@ -889,10 +879,6 @@ FT_BEGIN_HEADER * lcd_weights :: * The LCD filter weights for ClearType-style subpixel rendering. * - * lcd_filter_func :: - * The LCD filtering callback function for for ClearType-style subpixel - * rendering. - * * lcd_geometry :: * This array specifies LCD subpixel geometry and controls Harmony LCD * rendering technique, alternative to ClearType. @@ -926,7 +912,6 @@ FT_BEGIN_HEADER #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING FT_LcdFiveTapFilter lcd_weights; /* filter weights, if any */ - FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */ #else FT_Vector lcd_geometry[3]; /* RGB subpixel positions */ #endif @@ -995,17 +980,6 @@ FT_BEGIN_HEADER #endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */ - /* Define default raster's interface. The default raster is located in */ - /* `src/base/ftraster.c'. */ - /* */ - /* Client applications can register new rasters through the */ - /* FT_Set_Raster() API. */ - -#ifndef FT_NO_DEFAULT_RASTER - FT_EXPORT_VAR( FT_Raster_Funcs ) ft_default_raster; -#endif - - /************************************************************************** * * @macro: diff --git a/src/java.desktop/share/native/libfreetype/include/freetype/t1tables.h b/src/java.desktop/share/native/libfreetype/include/freetype/t1tables.h index fc3c1706de5..fe769f607fa 100644 --- a/src/java.desktop/share/native/libfreetype/include/freetype/t1tables.h +++ b/src/java.desktop/share/native/libfreetype/include/freetype/t1tables.h @@ -92,7 +92,7 @@ FT_BEGIN_HEADER FT_String* full_name; FT_String* family_name; FT_String* weight; - FT_Long italic_angle; + FT_Fixed italic_angle; FT_Bool is_fixed_pitch; FT_Short underline_position; FT_UShort underline_thickness; @@ -645,7 +645,7 @@ FT_BEGIN_HEADER PS_DICT_UNDERLINE_POSITION, /* FT_Short */ PS_DICT_UNDERLINE_THICKNESS, /* FT_UShort */ PS_DICT_FS_TYPE, /* FT_UShort */ - PS_DICT_ITALIC_ANGLE, /* FT_Long */ + PS_DICT_ITALIC_ANGLE, /* FT_Fixed */ PS_DICT_MAX = PS_DICT_ITALIC_ANGLE diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afadjust.c b/src/java.desktop/share/native/libfreetype/src/autofit/afadjust.c index 6637cacfccf..a1aa45914d0 100644 --- a/src/java.desktop/share/native/libfreetype/src/autofit/afadjust.c +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afadjust.c @@ -1405,7 +1405,8 @@ FT_TRACE4(( " " )); idx = HB_SET_VALUE_INVALID; while ( hb( set_next )( gsub_lookups, &idx ) ) - if ( globals->gsub_lookups_single_alternate[idx] ) + if ( idx < globals->gsub_lookup_count && + globals->gsub_lookups_single_alternate[idx] ) { have_idx = TRUE; FT_TRACE4(( " %u", idx )); @@ -1428,9 +1429,17 @@ idx = HB_SET_VALUE_INVALID; while ( hb( set_next )( gsub_lookups, &idx ) ) { - FT_UInt32 offset = globals->gsub_lookups_single_alternate[idx]; + FT_UInt32 offset; + /* HarfBuzz only validates lookup indices while */ + /* processing lookups, not while collecting them, */ + /* so we have to do that by ourselves. */ + if ( idx < globals->gsub_lookup_count ) + offset = globals->gsub_lookups_single_alternate[idx]; + else + offset = 0; + /* Put all substitutions into a single hash table. Note that */ /* the hash values usually contain more than a single character */ /* code; this can happen if different 'SingleSubst' subtables */ diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.h b/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.h index 362f56e290b..dc061159492 100644 --- a/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.h +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afglobal.h @@ -116,7 +116,9 @@ FT_BEGIN_HEADER /* The GSUB table. */ FT_Byte* gsub; - /* Lookup offsets, with only SingleSubst and AlternateSubst non-NULL. */ + /* An array of lookup offsets (of `gsub_lookup_count` elements), */ + /* with only SingleSubst and AlternateSubst lookups non-NULL. */ + FT_UShort gsub_lookup_count; FT_UInt32* gsub_lookups_single_alternate; #endif diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.c b/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.c index cb5667ff793..4a42d919474 100644 --- a/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.c +++ b/src/java.desktop/share/native/libfreetype/src/autofit/aflatin.c @@ -3269,9 +3269,9 @@ next_on = next_on->next; if ( next_on->y > p->y && prev_on->y > p->y ) - measurement = p->y - min_y; + measurement = SUB_LONG( p->y, min_y ); else if ( next_on->y < p->y && prev_on->y < p->y ) - measurement = max_y - p->y; + measurement = SUB_LONG( max_y, p->y ); else continue; @@ -3309,11 +3309,14 @@ p = first_point; do { - p = p->next; - /* We adjust the height of the diacritic only, which means */ - /* we are never dealing with large numbers and can thus avoid */ - /* `FT_MulFix`. */ - p->y = ( ( p->y - min_y ) * target_height / height ) + min_y; + p = p->next; + /* We adjust the height of the diacritic only, which means */ + /* we are never dealing with (valid) large numbers and can */ + /* thus avoid `FT_MulFix`. */ + p->y = ADD_LONG( MUL_LONG( SUB_LONG( p->y, + min_y ), + target_height ) / height, + min_y ); } while ( p != first_point ); @@ -3370,9 +3373,9 @@ next_on = next_on->next; if ( next_on->y > p->y && prev_on->y > p->y ) - measurement = p->y - min_y; + measurement = SUB_LONG( p->y, min_y ); else if ( next_on->y < p->y && prev_on->y < p->y ) - measurement = max_y - p->y; + measurement = SUB_LONG( max_y, p->y ); else continue; @@ -3403,8 +3406,11 @@ p = first_point; do { - p = p->next; - p->y = ( ( p->y - max_y ) * target_height / height ) + max_y; + p = p->next; + p->y = ADD_LONG( MUL_LONG( SUB_LONG( p->y, + max_y ), + target_height ) / height, + max_y ); } while ( p != first_point ); @@ -3462,9 +3468,9 @@ } while ( p != first_point ); /* Align bottom of the tilde to the grid. */ - min_y_rounded = FT_PIX_ROUND( min_y ); - delta = min_y_rounded - min_y; - height = max_y - min_y; + min_y_rounded = FT_PIX_ROUND_LONG( min_y ); + delta = SUB_LONG( min_y_rounded, min_y ); + height = SUB_LONG( max_y, min_y ); /* If the tilde is less than 3 pixels tall, snap the center of it */ /* to the grid instead of the bottom to improve readability. */ @@ -3502,9 +3508,9 @@ } while ( p != first_point ); - max_y_rounded = FT_PIX_ROUND( max_y ); - delta = max_y_rounded - max_y; - height = max_y - min_y; + max_y_rounded = FT_PIX_ROUND_LONG( max_y ); + delta = SUB_LONG( max_y_rounded, max_y ); + height = SUB_LONG( max_y, min_y ); if ( height < 64 * 3 ) delta -= ( FT_PIX_ROUND( height ) - height ) / 2; @@ -3673,7 +3679,7 @@ high_min_y = hints->contour_y_minima[high_contour]; high_max_y = hints->contour_y_maxima[high_contour]; - high_height = high_max_y - high_min_y; + high_height = SUB_LONG( high_max_y, high_min_y ); if ( high_height > accent_height_limit ) { @@ -3705,7 +3711,7 @@ /* We also check that the y minimum of the 'other' contour */ /* is below the high contour to avoid potential false hits */ /* with contours enclosed in the high one. */ - distance = high_min_y - max_y; + distance = SUB_LONG( high_min_y, max_y ); if ( distance < 64 && distance < min_distance && min_y < high_min_y ) @@ -3724,14 +3730,14 @@ tilde_min_y = hints->contour_y_minima[tilde_contour]; tilde_max_y = hints->contour_y_maxima[tilde_contour]; - tilde_height = tilde_max_y - tilde_min_y; + tilde_height = SUB_LONG( tilde_max_y, tilde_min_y); /* The vertical separation adjustment potentially undoes a */ /* tilde center alignment. If it would grid-align a tilde */ /* less than 3 pixels in height, shift additionally to */ /* re-center the tilde. */ - pos = high_min_y + adjustment_amount; + pos = ADD_LONG( high_min_y, adjustment_amount ); if ( adjust_below_top && is_top_tilde ) pos += high_height; @@ -3764,7 +3770,7 @@ { /* Value 8 is heuristic. */ FT_Pos height_delta = high_height / 8; - FT_Pos min_y_limit = high_min_y - height_delta; + FT_Pos min_y_limit = SUB_LONG( high_min_y, height_delta ); FT_TRACE4(( " Pushing high contour %ld units up\n", @@ -3784,7 +3790,7 @@ centering_adjustment )); af_move_contours_up( hints, - min_y_limit + high_height, + ADD_LONG( min_y_limit, high_height ), centering_adjustment ); } } @@ -3838,7 +3844,7 @@ low_min_y = hints->contour_y_minima[low_contour]; low_max_y = hints->contour_y_maxima[low_contour]; - low_height = low_max_y - low_min_y; + low_height = SUB_LONG( low_max_y, low_min_y ); if ( low_height > accent_height_limit ) { @@ -3863,7 +3869,7 @@ min_y = hints->contour_y_minima[contour]; max_y = hints->contour_y_maxima[contour]; - distance = min_y - low_max_y; + distance = SUB_LONG( min_y, low_max_y ); if ( distance < 64 && distance < min_distance && max_y > low_max_y ) @@ -3882,9 +3888,9 @@ tilde_min_y = hints->contour_y_minima[tilde_contour]; tilde_max_y = hints->contour_y_maxima[tilde_contour]; - tilde_height = tilde_max_y - tilde_min_y; + tilde_height = SUB_LONG( tilde_max_y, tilde_min_y ); - pos = low_max_y - adjustment_amount; + pos = SUB_LONG( low_max_y, adjustment_amount ); if ( adjust_above_bottom && is_bottom_tilde ) pos -= low_height; @@ -3915,7 +3921,7 @@ ( calculated_amount <= 66 || adjustment_amount <= 66 ) ) { FT_Pos height_delta = low_height / 8; - FT_Pos max_y_limit = low_max_y + height_delta; + FT_Pos max_y_limit = ADD_LONG( low_max_y, height_delta ); FT_TRACE4(( " Pushing low contour %ld units down\n", @@ -3929,7 +3935,7 @@ centering_adjustment )); af_move_contours_down( hints, - max_y_limit - low_height, + SUB_LONG( max_y_limit, low_height ), centering_adjustment ); } } diff --git a/src/java.desktop/share/native/libfreetype/src/autofit/afloader.c b/src/java.desktop/share/native/libfreetype/src/autofit/afloader.c index d84adc09679..4e2ac1f1ce3 100644 --- a/src/java.desktop/share/native/libfreetype/src/autofit/afloader.c +++ b/src/java.desktop/share/native/libfreetype/src/autofit/afloader.c @@ -524,16 +524,18 @@ bbox.xMin = FT_PIX_FLOOR( bbox.xMin ); bbox.yMin = FT_PIX_FLOOR( bbox.yMin ); - bbox.xMax = FT_PIX_CEIL( bbox.xMax ); - bbox.yMax = FT_PIX_CEIL( bbox.yMax ); + bbox.xMax = FT_PIX_CEIL_LONG( bbox.xMax ); + bbox.yMax = FT_PIX_CEIL_LONG( bbox.yMax ); - slot->metrics.width = bbox.xMax - bbox.xMin; - slot->metrics.height = bbox.yMax - bbox.yMin; + slot->metrics.width = SUB_LONG( bbox.xMax, bbox.xMin ); + slot->metrics.height = SUB_LONG( bbox.yMax, bbox.yMin ); slot->metrics.horiBearingX = bbox.xMin; slot->metrics.horiBearingY = bbox.yMax; - slot->metrics.vertBearingX = FT_PIX_FLOOR( bbox.xMin + vvector.x ); - slot->metrics.vertBearingY = FT_PIX_FLOOR( bbox.yMax + vvector.y ); + slot->metrics.vertBearingX = FT_PIX_FLOOR( ADD_LONG( bbox.xMin, + vvector.x ) ); + slot->metrics.vertBearingY = FT_PIX_FLOOR( ADD_LONG( bbox.yMax, + vvector.y ) ); /* for mono-width fonts (like Andale, Courier, etc.) we need */ /* to keep the original rounded advance width; ditto for */ diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftadvanc.c b/src/java.desktop/share/native/libfreetype/src/base/ftadvanc.c index ff0fc510503..7b965c62d58 100644 --- a/src/java.desktop/share/native/libfreetype/src/base/ftadvanc.c +++ b/src/java.desktop/share/native/libfreetype/src/base/ftadvanc.c @@ -20,6 +20,7 @@ #include #include +#include static FT_Error @@ -47,11 +48,43 @@ /* (see `FT_Load_Glyph' implementation in src/base/ftobjs.c) */ for ( nn = 0; nn < count; nn++ ) - advances[nn] = FT_MulDiv( advances[nn], scale, 64 ); + advances[nn] = FT_MulFix( 1024 * advances[nn], scale ); return FT_Err_Ok; } + /* loading (and hinting) to calculate the advances is slow */ + /* unless TrueType hdmx table is provided as an accelerator */ + static FT_Error + ft_load_advances( FT_Face face, + FT_UInt gindex, + FT_UInt count, + FT_Int32 flags, + FT_Fixed *padvances ) + { + FT_UInt nn; + FT_Error error = FT_Err_Ok; + FT_Pos factor = flags & FT_LOAD_NO_SCALE ? 1 : 1024; + FT_Pos* advance = flags & FT_LOAD_VERTICAL_LAYOUT + ? &face->glyph->advance.y + : &face->glyph->advance.x; + + + flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY; + + for ( nn = 0; nn < count; nn++ ) + { + error = FT_Load_Glyph( face, gindex + nn, flags ); + if ( error ) + break; + + /* scale from 26.6 to 16.16, unless NO_SCALE was requested */ + padvances[nn] = *advance * factor; + } + + return error; + } + /* at the moment, we can perform fast advance retrieval only in */ /* the following cases: */ @@ -102,7 +135,10 @@ return error; } - return FT_Get_Advances( face, gindex, 1, flags, padvance ); + if ( flags & FT_ADVANCE_FLAG_FAST_ONLY ) + return FT_THROW( Unimplemented_Feature ); + + return ft_load_advances( face, gindex, 1, flags, padvance ); } @@ -115,12 +151,9 @@ FT_Int32 flags, FT_Fixed *padvances ) { - FT_Error error = FT_Err_Ok; - FT_Face_GetAdvancesFunc func; - FT_UInt num, end, nn; - FT_Int factor; + FT_UInt num, end; if ( !face ) @@ -140,6 +173,9 @@ func = face->driver->clazz->get_advances; if ( func && LOAD_ADVANCE_FAST_CHECK( face, flags ) ) { + FT_Error error; + + error = func( face, start, count, flags, padvances ); if ( !error ) return ft_face_scale_advances_( face, padvances, count, flags ); @@ -148,26 +184,10 @@ return error; } - error = FT_Err_Ok; - if ( flags & FT_ADVANCE_FLAG_FAST_ONLY ) return FT_THROW( Unimplemented_Feature ); - flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY; - factor = ( flags & FT_LOAD_NO_SCALE ) ? 1 : 1024; - for ( nn = 0; nn < count; nn++ ) - { - error = FT_Load_Glyph( face, start + nn, flags ); - if ( error ) - break; - - /* scale from 26.6 to 16.16, unless NO_SCALE was requested */ - padvances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT ) - ? face->glyph->advance.y * factor - : face->glyph->advance.x * factor; - } - - return error; + return ft_load_advances( face, start, count, flags, padvances ); } diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftbitmap.c b/src/java.desktop/share/native/libfreetype/src/base/ftbitmap.c index 2c8e44b905d..364f881e435 100644 --- a/src/java.desktop/share/native/libfreetype/src/base/ftbitmap.c +++ b/src/java.desktop/share/native/libfreetype/src/base/ftbitmap.c @@ -922,14 +922,7 @@ target->pitch = (int)final_width * 4; target->num_grays = 256; - if ( FT_LONG_MAX / target->pitch < (int)target->rows ) - { - FT_TRACE5(( "FT_Blend_Bitmap: target bitmap too large (%u x %u)\n", - final_width, final_rows )); - return FT_THROW( Invalid_Argument ); - } - - if ( FT_ALLOC( target->buffer, target->pitch * (int)target->rows ) ) + if ( FT_ALLOC_MULT( target->buffer, target->rows, target->pitch ) ) return error; free_target_bitmap_on_error = 1; @@ -950,16 +943,9 @@ new_pitch = (int)final_width * 4; - if ( FT_LONG_MAX / new_pitch < (int)final_rows ) - { - FT_TRACE5(( "FT_Blend_Bitmap: target bitmap too large (%u x %u)\n", - final_width, final_rows )); - return FT_THROW( Invalid_Argument ); - } - /* TODO: provide an in-buffer solution for large bitmaps */ /* to avoid allocation of a new buffer */ - if ( FT_ALLOC( buffer, new_pitch * (int)final_rows ) ) + if ( FT_ALLOC_MULT( buffer, final_rows, new_pitch ) ) goto Error; /* copy data to new buffer */ diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftglyph.c b/src/java.desktop/share/native/libfreetype/src/base/ftglyph.c index 75babb1aa56..6138cfeec2c 100644 --- a/src/java.desktop/share/native/libfreetype/src/base/ftglyph.c +++ b/src/java.desktop/share/native/libfreetype/src/base/ftglyph.c @@ -62,7 +62,7 @@ FT_GlyphSlot slot ) { FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph; - FT_Error error = FT_Err_Ok; + FT_Error error; FT_Library library = FT_GLYPH( glyph )->library; @@ -75,17 +75,8 @@ glyph->left = slot->bitmap_left; glyph->top = slot->bitmap_top; - /* do lazy copying whenever possible */ - if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) - { - glyph->bitmap = slot->bitmap; - slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; - } - else - { - FT_Bitmap_Init( &glyph->bitmap ); - error = FT_Bitmap_Copy( library, &slot->bitmap, &glyph->bitmap ); - } + FT_Bitmap_Init( &glyph->bitmap ); + error = FT_Bitmap_Copy( library, &slot->bitmap, &glyph->bitmap ); Exit: return error; diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftlcdfil.c b/src/java.desktop/share/native/libfreetype/src/base/ftlcdfil.c index d026da8b012..51c6fd48a1b 100644 --- a/src/java.desktop/share/native/libfreetype/src/base/ftlcdfil.c +++ b/src/java.desktop/share/native/libfreetype/src/base/ftlcdfil.c @@ -25,265 +25,28 @@ #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING -/* define USE_LEGACY to implement the legacy filter */ -#define USE_LEGACY - -#define FT_SHIFTCLAMP( x ) ( x >>= 8, (FT_Byte)( x > 255 ? 255 : x ) ) - - - /* add padding according to filter weights */ + /* add padding sufficient for a 5-tap filter, */ + /* which is 2/3 of a pixel */ FT_BASE_DEF( void ) ft_lcd_padding( FT_BBox* cbox, FT_GlyphSlot slot, FT_Render_Mode mode ) { - FT_Byte* lcd_weights; - FT_Bitmap_LcdFilterFunc lcd_filter_func; + FT_UNUSED( slot ); - - /* Per-face LCD filtering takes priority if set up. */ - if ( slot->face && slot->face->internal->lcd_filter_func ) + if ( mode == FT_RENDER_MODE_LCD ) { - lcd_weights = slot->face->internal->lcd_weights; - lcd_filter_func = slot->face->internal->lcd_filter_func; + cbox->xMin -= 43; + cbox->xMax += 43; } - else + else if ( mode == FT_RENDER_MODE_LCD_V ) { - lcd_weights = slot->library->lcd_weights; - lcd_filter_func = slot->library->lcd_filter_func; - } - - if ( lcd_filter_func == ft_lcd_filter_fir ) - { - if ( mode == FT_RENDER_MODE_LCD ) - { - cbox->xMin -= lcd_weights[0] ? 43 : - lcd_weights[1] ? 22 : 0; - cbox->xMax += lcd_weights[4] ? 43 : - lcd_weights[3] ? 22 : 0; - } - else if ( mode == FT_RENDER_MODE_LCD_V ) - { - cbox->yMin -= lcd_weights[0] ? 43 : - lcd_weights[1] ? 22 : 0; - cbox->yMax += lcd_weights[4] ? 43 : - lcd_weights[3] ? 22 : 0; - } + cbox->yMin -= 43; + cbox->yMax += 43; } } - /* FIR filter used by the default and light filters */ - FT_BASE_DEF( void ) - ft_lcd_filter_fir( FT_Bitmap* bitmap, - FT_LcdFiveTapFilter weights ) - { - FT_UInt width = (FT_UInt)bitmap->width; - FT_UInt height = (FT_UInt)bitmap->rows; - FT_Int pitch = bitmap->pitch; - FT_Byte* origin = bitmap->buffer; - FT_Byte mode = bitmap->pixel_mode; - - - /* take care of bitmap flow */ - if ( pitch > 0 && height > 0 ) - origin += pitch * (FT_Int)( height - 1 ); - - /* horizontal in-place FIR filter */ - if ( mode == FT_PIXEL_MODE_LCD && width >= 2 ) - { - FT_Byte* line = origin; - - - /* `fir' must be at least 32 bit wide, since the sum of */ - /* the values in `weights' can exceed 0xFF */ - - for ( ; height > 0; height--, line -= pitch ) - { - FT_UInt fir[5]; - FT_UInt val, xx; - - - val = line[0]; - fir[2] = weights[2] * val; - fir[3] = weights[3] * val; - fir[4] = weights[4] * val; - - val = line[1]; - fir[1] = fir[2] + weights[1] * val; - fir[2] = fir[3] + weights[2] * val; - fir[3] = fir[4] + weights[3] * val; - fir[4] = weights[4] * val; - - for ( xx = 2; xx < width; xx++ ) - { - val = line[xx]; - fir[0] = fir[1] + weights[0] * val; - fir[1] = fir[2] + weights[1] * val; - fir[2] = fir[3] + weights[2] * val; - fir[3] = fir[4] + weights[3] * val; - fir[4] = weights[4] * val; - - line[xx - 2] = FT_SHIFTCLAMP( fir[0] ); - } - - line[xx - 2] = FT_SHIFTCLAMP( fir[1] ); - line[xx - 1] = FT_SHIFTCLAMP( fir[2] ); - } - } - - /* vertical in-place FIR filter */ - else if ( mode == FT_PIXEL_MODE_LCD_V && height >= 2 ) - { - FT_Byte* column = origin; - - - for ( ; width > 0; width--, column++ ) - { - FT_Byte* col = column; - FT_UInt fir[5]; - FT_UInt val, yy; - - - val = col[0]; - fir[2] = weights[2] * val; - fir[3] = weights[3] * val; - fir[4] = weights[4] * val; - col -= pitch; - - val = col[0]; - fir[1] = fir[2] + weights[1] * val; - fir[2] = fir[3] + weights[2] * val; - fir[3] = fir[4] + weights[3] * val; - fir[4] = weights[4] * val; - col -= pitch; - - for ( yy = 2; yy < height; yy++, col -= pitch ) - { - val = col[0]; - fir[0] = fir[1] + weights[0] * val; - fir[1] = fir[2] + weights[1] * val; - fir[2] = fir[3] + weights[2] * val; - fir[3] = fir[4] + weights[3] * val; - fir[4] = weights[4] * val; - - col[pitch * 2] = FT_SHIFTCLAMP( fir[0] ); - } - - col[pitch * 2] = FT_SHIFTCLAMP( fir[1] ); - col[pitch] = FT_SHIFTCLAMP( fir[2] ); - } - } - } - - -#ifdef USE_LEGACY - - /* intra-pixel filter used by the legacy filter */ - static void - _ft_lcd_filter_legacy( FT_Bitmap* bitmap, - FT_Byte* weights ) - { - FT_UInt width = (FT_UInt)bitmap->width; - FT_UInt height = (FT_UInt)bitmap->rows; - FT_Int pitch = bitmap->pitch; - FT_Byte* origin = bitmap->buffer; - FT_Byte mode = bitmap->pixel_mode; - - static const unsigned int filters[3][3] = - { - { 65538 * 9/13, 65538 * 1/6, 65538 * 1/13 }, - { 65538 * 3/13, 65538 * 4/6, 65538 * 3/13 }, - { 65538 * 1/13, 65538 * 1/6, 65538 * 9/13 } - }; - - FT_UNUSED( weights ); - - - /* take care of bitmap flow */ - if ( pitch > 0 && height > 0 ) - origin += pitch * (FT_Int)( height - 1 ); - - /* horizontal in-place intra-pixel filter */ - if ( mode == FT_PIXEL_MODE_LCD && width >= 3 ) - { - FT_Byte* line = origin; - - - for ( ; height > 0; height--, line -= pitch ) - { - FT_UInt xx; - - - for ( xx = 0; xx < width; xx += 3 ) - { - FT_UInt r, g, b; - FT_UInt p; - - - p = line[xx]; - r = filters[0][0] * p; - g = filters[0][1] * p; - b = filters[0][2] * p; - - p = line[xx + 1]; - r += filters[1][0] * p; - g += filters[1][1] * p; - b += filters[1][2] * p; - - p = line[xx + 2]; - r += filters[2][0] * p; - g += filters[2][1] * p; - b += filters[2][2] * p; - - line[xx] = (FT_Byte)( r / 65536 ); - line[xx + 1] = (FT_Byte)( g / 65536 ); - line[xx + 2] = (FT_Byte)( b / 65536 ); - } - } - } - else if ( mode == FT_PIXEL_MODE_LCD_V && height >= 3 ) - { - FT_Byte* column = origin; - - - for ( ; width > 0; width--, column++ ) - { - FT_Byte* col = column - 2 * pitch; - - - for ( ; height > 0; height -= 3, col -= 3 * pitch ) - { - FT_UInt r, g, b; - FT_UInt p; - - - p = col[0]; - r = filters[0][0] * p; - g = filters[0][1] * p; - b = filters[0][2] * p; - - p = col[pitch]; - r += filters[1][0] * p; - g += filters[1][1] * p; - b += filters[1][2] * p; - - p = col[pitch * 2]; - r += filters[2][0] * p; - g += filters[2][1] * p; - b += filters[2][2] * p; - - col[0] = (FT_Byte)( r / 65536 ); - col[pitch] = (FT_Byte)( g / 65536 ); - col[pitch * 2] = (FT_Byte)( b / 65536 ); - } - } - } - } - -#endif /* USE_LEGACY */ - - /* documentation in ftlcdfil.h */ FT_EXPORT_DEF( FT_Error ) @@ -297,7 +60,6 @@ return FT_THROW( Invalid_Argument ); ft_memcpy( library->lcd_weights, weights, FT_LCD_FILTER_FIVE_TAPS ); - library->lcd_filter_func = ft_lcd_filter_fir; return FT_Err_Ok; } @@ -321,32 +83,23 @@ switch ( filter ) { case FT_LCD_FILTER_NONE: - library->lcd_filter_func = NULL; + ft_memset( library->lcd_weights, + 0, + FT_LCD_FILTER_FIVE_TAPS ); break; case FT_LCD_FILTER_DEFAULT: ft_memcpy( library->lcd_weights, default_weights, FT_LCD_FILTER_FIVE_TAPS ); - library->lcd_filter_func = ft_lcd_filter_fir; break; case FT_LCD_FILTER_LIGHT: ft_memcpy( library->lcd_weights, light_weights, FT_LCD_FILTER_FIVE_TAPS ); - library->lcd_filter_func = ft_lcd_filter_fir; break; -#ifdef USE_LEGACY - - case FT_LCD_FILTER_LEGACY: - case FT_LCD_FILTER_LEGACY1: - library->lcd_filter_func = _ft_lcd_filter_legacy; - break; - -#endif - default: return FT_THROW( Invalid_Argument ); } diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftobjs.c b/src/java.desktop/share/native/libfreetype/src/base/ftobjs.c index cced4fed06b..323dd5efac2 100644 --- a/src/java.desktop/share/native/libfreetype/src/base/ftobjs.c +++ b/src/java.desktop/share/native/libfreetype/src/base/ftobjs.c @@ -524,12 +524,28 @@ bitmap->rows = (unsigned int)height; bitmap->pitch = pitch; - if ( pbox.xMin < -0x8000 || pbox.xMax > 0x7FFF || - pbox.yMin < -0x8000 || pbox.yMax > 0x7FFF ) + /* Flag the bounding box size unsuitable for rendering. */ + /* FT_Renderer modules should check the return value. */ + /* The limit is based on the ppem value when available. */ { - FT_TRACE3(( "ft_glyphslot_preset_bitmap: [%ld %ld %ld %ld]\n", - pbox.xMin, pbox.yMin, pbox.xMax, pbox.yMax )); - return 1; + FT_Face face = slot->face; + FT_Pos xlim = 0x8000; + FT_Pos ylim = 0x8000; + + + if ( face ) + { + xlim = FT_MIN( xlim, 10 * face->size->metrics.x_ppem ); + ylim = FT_MIN( ylim, 10 * face->size->metrics.y_ppem ); + } + + if ( pbox.xMin < -xlim || pbox.xMax >= xlim || + pbox.yMin < -ylim || pbox.yMax >= ylim ) + { + FT_TRACE3(( "ft_glyphslot_preset_bitmap: [%ld %ld %ld %ld]\n", + pbox.xMin, pbox.yMin, pbox.xMax, pbox.yMax )); + return 1; + } } return 0; @@ -549,8 +565,7 @@ FT_BASE_DEF( FT_Error ) - ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot, - FT_ULong size ) + ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot ) { FT_Memory memory = FT_FACE_MEMORY( slot->face ); FT_Error error; @@ -561,7 +576,10 @@ else slot->internal->flags |= FT_GLYPH_OWN_BITMAP; - FT_MEM_ALLOC( slot->bitmap.buffer, size ); + /* dimensions must be preset */ + FT_MEM_ALLOC_MULT( slot->bitmap.buffer, + slot->bitmap.rows, + slot->bitmap.pitch ); return error; } @@ -1413,7 +1431,10 @@ if ( ( cur[0]->platform_id == TT_PLATFORM_MICROSOFT && cur[0]->encoding_id == TT_MS_ID_UCS_4 ) || ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE && - cur[0]->encoding_id == TT_APPLE_ID_UNICODE_32 ) ) + cur[0]->encoding_id == TT_APPLE_ID_UNICODE_32 ) || + ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE && + cur[0]->encoding_id == TT_APPLE_ID_FULL_UNICODE && + FT_Get_CMap_Format( cur[0] ) == 13 ) ) { face->charmap = cur[0]; return FT_Err_Ok; @@ -2798,11 +2819,6 @@ internal->refcount = 1; internal->no_stem_darkening = -1; - -#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING - /* Per-face filtering can only be set up by FT_Face_Properties */ - internal->lcd_filter_func = NULL; -#endif } if ( aface ) @@ -4032,18 +4048,8 @@ } else if ( properties->tag == FT_PARAM_TAG_LCD_FILTER_WEIGHTS ) { -#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING - if ( properties->data ) - { - ft_memcpy( face->internal->lcd_weights, - properties->data, - FT_LCD_FILTER_FIVE_TAPS ); - face->internal->lcd_filter_func = ft_lcd_filter_fir; - } -#else error = FT_THROW( Unimplemented_Feature ); goto Exit; -#endif } else if ( properties->tag == FT_PARAM_TAG_RANDOM_SEED ) { diff --git a/src/java.desktop/share/native/libfreetype/src/base/ftutil.c b/src/java.desktop/share/native/libfreetype/src/base/ftutil.c index 0b7382627c5..f83c4394893 100644 --- a/src/java.desktop/share/native/libfreetype/src/base/ftutil.c +++ b/src/java.desktop/share/native/libfreetype/src/base/ftutil.c @@ -424,11 +424,10 @@ while ( cur ) { FT_ListNode next = cur->next; - void* data = cur->data; if ( destroy ) - destroy( memory, data, user ); + destroy( memory, cur->data, user ); FT_FREE( cur ); cur = next; diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.c b/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.c index 0079ddd1950..44ff44aecbd 100644 --- a/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.c +++ b/src/java.desktop/share/native/libfreetype/src/cff/cffdrivr.c @@ -456,8 +456,8 @@ dict->weight ); font_info->italic_angle = dict->italic_angle; font_info->is_fixed_pitch = dict->is_fixed_pitch; - font_info->underline_position = (FT_Short)dict->underline_position; - font_info->underline_thickness = (FT_UShort)dict->underline_thickness; + font_info->underline_position = dict->underline_position; + font_info->underline_thickness = dict->underline_thickness; cff->font_info = font_info; } diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffload.c b/src/java.desktop/share/native/libfreetype/src/cff/cffload.c index 326f885056f..39d662eb434 100644 --- a/src/java.desktop/share/native/libfreetype/src/cff/cffload.c +++ b/src/java.desktop/share/native/libfreetype/src/cff/cffload.c @@ -2014,8 +2014,8 @@ /* set defaults */ FT_ZERO( top ); - top->underline_position = -( 100L << 16 ); - top->underline_thickness = 50L << 16; + top->underline_position = -100; + top->underline_thickness = 50; top->charstring_type = 2; top->font_matrix.xx = 0x10000L; top->font_matrix.yy = 0x10000L; diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.c b/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.c index 1aeb908f4a1..9e00943a95d 100644 --- a/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.c +++ b/src/java.desktop/share/native/libfreetype/src/cff/cffobjs.c @@ -846,10 +846,8 @@ cffface->height = (FT_Short)( cffface->ascender - cffface->descender ); - cffface->underline_position = - (FT_Short)( dict->underline_position >> 16 ); - cffface->underline_thickness = - (FT_Short)( dict->underline_thickness >> 16 ); + cffface->underline_position = (FT_Short)dict->underline_position; + cffface->underline_thickness = (FT_Short)dict->underline_thickness; /* retrieve font family & style name */ if ( dict->family_name ) diff --git a/src/java.desktop/share/native/libfreetype/src/cff/cfftoken.h b/src/java.desktop/share/native/libfreetype/src/cff/cfftoken.h index cc5aaa2867a..a7ee1cb3fe7 100644 --- a/src/java.desktop/share/native/libfreetype/src/cff/cfftoken.h +++ b/src/java.desktop/share/native/libfreetype/src/cff/cfftoken.h @@ -30,8 +30,8 @@ CFF_FIELD_STRING ( 4, weight, "Weight" ) CFF_FIELD_BOOL ( 0x101, is_fixed_pitch, "isFixedPitch" ) CFF_FIELD_FIXED ( 0x102, italic_angle, "ItalicAngle" ) - CFF_FIELD_FIXED ( 0x103, underline_position, "UnderlinePosition" ) - CFF_FIELD_FIXED ( 0x104, underline_thickness, "UnderlineThickness" ) + CFF_FIELD_NUM ( 0x103, underline_position, "UnderlinePosition" ) + CFF_FIELD_NUM ( 0x104, underline_thickness, "UnderlineThickness" ) CFF_FIELD_NUM ( 0x105, paint_type, "PaintType" ) CFF_FIELD_NUM ( 0x106, charstring_type, "CharstringType" ) CFF_FIELD_CALLBACK( 0x107, font_matrix, "FontMatrix" ) diff --git a/src/java.desktop/share/native/libfreetype/src/cid/cidtoken.h b/src/java.desktop/share/native/libfreetype/src/cid/cidtoken.h index 25ba74fed94..d40ebfab86d 100644 --- a/src/java.desktop/share/native/libfreetype/src/cid/cidtoken.h +++ b/src/java.desktop/share/native/libfreetype/src/cid/cidtoken.h @@ -47,7 +47,7 @@ T1_FIELD_STRING( "FullName", full_name, 0 ) T1_FIELD_STRING( "FamilyName", family_name, 0 ) T1_FIELD_STRING( "Weight", weight, 0 ) - T1_FIELD_NUM ( "ItalicAngle", italic_angle, 0 ) + T1_FIELD_FIXED ( "ItalicAngle", italic_angle, 0 ) T1_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch, 0 ) T1_FIELD_NUM ( "UnderlinePosition", underline_position, 0 ) T1_FIELD_NUM ( "UnderlineThickness", underline_thickness, 0 ) diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.c b/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.c index ca30702321d..e053dba17b2 100644 --- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.c +++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshalgo.c @@ -35,10 +35,6 @@ #endif -#define COMPUTE_INFLEXS /* compute inflection points to optimize `S' */ - /* and similar glyphs */ - - /*************************************************************************/ /*************************************************************************/ /***** *****/ @@ -920,117 +916,6 @@ #define psh_corner_orientation ft_corner_orientation -#ifdef COMPUTE_INFLEXS - - /* compute all inflex points in a given glyph */ - static void - psh_glyph_compute_inflections( PSH_Glyph glyph ) - { - FT_UInt n; - - - for ( n = 0; n < glyph->num_contours; n++ ) - { - PSH_Point first, start, end, before, after; - FT_Pos in_x, in_y, out_x, out_y; - FT_Int orient_prev, orient_cur; - FT_Int finished = 0; - - - /* we need at least 4 points to create an inflection point */ - if ( glyph->contours[n].count < 4 ) - continue; - - /* compute first segment in contour */ - first = glyph->contours[n].start; - - start = end = first; - do - { - end = end->next; - if ( end == first ) - goto Skip; - - in_x = end->org_u - start->org_u; - in_y = end->org_v - start->org_v; - - } while ( in_x == 0 && in_y == 0 ); - - /* extend the segment start whenever possible */ - before = start; - do - { - do - { - start = before; - before = before->prev; - if ( before == first ) - goto Skip; - - out_x = start->org_u - before->org_u; - out_y = start->org_v - before->org_v; - - } while ( out_x == 0 && out_y == 0 ); - - orient_prev = psh_corner_orientation( in_x, in_y, out_x, out_y ); - - } while ( orient_prev == 0 ); - - first = start; - in_x = out_x; - in_y = out_y; - - /* now, process all segments in the contour */ - do - { - /* first, extend current segment's end whenever possible */ - after = end; - do - { - do - { - end = after; - after = after->next; - if ( after == first ) - finished = 1; - - out_x = after->org_u - end->org_u; - out_y = after->org_v - end->org_v; - - } while ( out_x == 0 && out_y == 0 ); - - orient_cur = psh_corner_orientation( in_x, in_y, out_x, out_y ); - - } while ( orient_cur == 0 ); - - if ( ( orient_cur ^ orient_prev ) < 0 ) - { - do - { - psh_point_set_inflex( start ); - start = start->next; - } - while ( start != end ); - - psh_point_set_inflex( start ); - } - - start = end; - end = after; - orient_prev = orient_cur; - in_x = out_x; - in_y = out_y; - - } while ( !finished ); - - Skip: - ; - } - } - -#endif /* COMPUTE_INFLEXS */ - - static void psh_glyph_done( PSH_Glyph glyph ) { @@ -1258,11 +1143,6 @@ glyph->outline = outline; glyph->globals = globals; -#ifdef COMPUTE_INFLEXS - psh_glyph_load_points( glyph, 0 ); - psh_glyph_compute_inflections( glyph ); -#endif /* COMPUTE_INFLEXS */ - /* now deal with hints tables */ error = psh_hint_table_init( &glyph->hint_tables [0], &ps_hints->dimension[0].hints, @@ -1285,122 +1165,47 @@ } - /* compute all extrema in a glyph for a given dimension */ + /* compute all extreme and inflection points */ + /* in a glyph for a given dimension */ static void psh_glyph_compute_extrema( PSH_Glyph glyph ) { FT_UInt n; - /* first of all, compute all local extrema */ for ( n = 0; n < glyph->num_contours; n++ ) { - PSH_Point first = glyph->contours[n].start; - PSH_Point point, before, after; + PSH_Point first, point, before, after; - if ( glyph->contours[n].count == 0 ) + /* we need at least 3 points to create an extremum */ + if ( glyph->contours[n].count < 3 ) continue; - point = first; - before = point; + first = glyph->contours[n].start; + point = first->prev; + after = first; do { - before = before->prev; - if ( before == first ) - goto Skip; - - } while ( before->org_u == point->org_u ); - - first = point = before->next; - - for (;;) - { - after = point; - do - { - after = after->next; - if ( after == first ) - goto Next; - - } while ( after->org_u == point->org_u ); - - if ( before->org_u < point->org_u ) - { - if ( after->org_u < point->org_u ) - { - /* local maximum */ - goto Extremum; - } - } - else /* before->org_u > point->org_u */ - { - if ( after->org_u > point->org_u ) - { - /* local minimum */ - Extremum: - do - { - psh_point_set_extremum( point ); - point = point->next; - - } while ( point != after ); - } - } - - before = after->prev; + before = point; point = after; + after = point->next; - } /* for */ + if ( ( before->org_u < point->org_u && point->org_u < after->org_u ) || + ( before->org_u > point->org_u && point->org_u > after->org_u ) ) + continue; - Next: - ; - } + /* otherwise this is either extremum or inflection point */ + psh_point_set_extremum( point ); - /* for each extremum, determine its direction along the */ - /* orthogonal axis */ - for ( n = 0; n < glyph->num_points; n++ ) - { - PSH_Point point, before, after; + /* also note its direction */ + if ( before->org_v < after->org_v ) + psh_point_set_positive( point ); + else if ( before->org_v > after->org_v ) + psh_point_set_negative( point ); - - point = &glyph->points[n]; - before = point; - after = point; - - if ( psh_point_is_extremum( point ) ) - { - do - { - before = before->prev; - if ( before == point ) - goto Skip; - - } while ( before->org_v == point->org_v ); - - do - { - after = after->next; - if ( after == point ) - goto Skip; - - } while ( after->org_v == point->org_v ); - } - - if ( before->org_v < point->org_v && - after->org_v > point->org_v ) - { - psh_point_set_positive( point ); - } - else if ( before->org_v > point->org_v && - after->org_v < point->org_v ) - { - psh_point_set_negative( point ); - } - - Skip: - ; + } while ( after != first ); } } @@ -1836,8 +1641,7 @@ point->dir_in != point->dir_out ) continue; - if ( !psh_point_is_extremum( point ) && - !psh_point_is_inflex( point ) ) + if ( !psh_point_is_extremum( point ) ) continue; point->flags &= ~PSH_POINT_SMOOTH; diff --git a/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.c b/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.c index 521a5ff6c5c..a772b66f309 100644 --- a/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.c +++ b/src/java.desktop/share/native/libfreetype/src/pshinter/pshglob.c @@ -376,36 +376,24 @@ /* not. We simply need to compare the vertical scale */ /* parameter to the raw bluescale value. Here is why: */ /* */ - /* We need to suppress overshoots for all pointsizes. */ - /* At 300dpi that satisfies: */ + /* The specs explain how the bluescale is calculated */ + /* from the desired maximum rounded pointsize at 300 dpi */ + /* and assuming upem of 1000. */ /* */ - /* pointsize < 240*bluescale + 0.49 */ + /* bluescale = ( pointsize - 0.49 ) / 240 */ /* */ - /* This corresponds to: */ + /* For unrounded pointsize in general terms */ /* */ - /* pixelsize < 1000*bluescale + 49/24 */ + /* bluescale = ( pointsize * dpi / 72 ) / upem */ /* */ - /* scale*EM_Size < 1000*bluescale + 49/24 */ + /* which is */ /* */ - /* However, for normal Type 1 fonts, EM_Size is 1000! */ - /* We thus only check: */ + /* bluescale = pixelsize / upem */ /* */ - /* scale < bluescale + 49/24000 */ + /* Therefore, the bluescale value can be used directly */ + /* as a scale limit, now that it is in comparable units */ /* */ - /* which we shorten to */ - /* */ - /* "scale < bluescale" */ - /* */ - /* Note that `blue_scale' is stored 1000 times its real */ - /* value, and that `scale' converts from font units to */ - /* fractional pixels. */ - /* */ - - /* 1000 / 64 = 125 / 8 */ - if ( scale >= 0x20C49BAL ) - blues->no_overshoots = FT_BOOL( scale < blues->blue_scale * 8 / 125 ); - else - blues->no_overshoots = FT_BOOL( scale * 125 < blues->blue_scale * 8 ); + blues->no_overshoots = FT_BOOL( scale < blues->blue_scale ); /* */ /* The blue threshold is the font units distance under */ @@ -420,8 +408,8 @@ FT_Int threshold = blues->blue_shift; - while ( threshold > 0 && FT_MulFix( threshold, scale ) > 32 ) - threshold--; + if ( threshold > 0 && FT_MulFix( threshold, scale ) > 32 ) + threshold = 32 * 0x10000L / scale; blues->blue_threshold = threshold; } @@ -708,7 +696,6 @@ /* limit the BlueScale value to `1 / max_of_blue_zone_heights' */ { - FT_Fixed max_scale; FT_Short max_height = 1; @@ -725,11 +712,12 @@ priv->family_other_blues, max_height ); - /* BlueScale is scaled 1000 times */ - max_scale = FT_DivFix( 1000, max_height ); - globals->blues.blue_scale = priv->blue_scale < max_scale - ? priv->blue_scale - : max_scale; + /* restrict BlueScale value that is amplified 1000-fold and */ + /* rescale it to be comparable to the metrics scale */ + if ( FT_MulFix( max_height, priv->blue_scale ) < 1000 ) + globals->blues.blue_scale = priv->blue_scale * 8 / 125; + else + globals->blues.blue_scale = 64 * 0x10000L / max_height; } globals->blues.blue_shift = priv->blue_shift; diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.c b/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.c index 9df75dc3acc..24fb3455598 100644 --- a/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.c +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/pngshim.c @@ -420,10 +420,7 @@ if ( populate_map_and_metrics ) { /* this doesn't overflow: 0x7FFF * 0x7FFF * 4 < 2^32 */ - FT_ULong size = map->rows * (FT_ULong)map->pitch; - - - error = ft_glyphslot_alloc_bitmap( slot, size ); + error = ft_glyphslot_alloc_bitmap( slot ); if ( error ) goto DestroyExit; } diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.c b/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.c index ec78247aa56..32291e23e36 100644 --- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.c +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfdriver.c @@ -1142,12 +1142,7 @@ FT_Error error; - /* XXX: I don't know whether this is correct, since - * tt_face_find_bdf_prop only returns something correct if we have - * previously selected a size that is listed in the BDF table. - * Should we change the BDF table format to include single offsets - * for `CHARSET_REGISTRY' and `CHARSET_ENCODING'? - */ + /* We expect that a bitmap strike has been selected. */ error = tt_face_find_bdf_prop( face, "CHARSET_REGISTRY", ®istry ); if ( !error ) { diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.c b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.c index 5acbbaa2a77..41c233597b8 100644 --- a/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.c +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/sfwoff2.c @@ -1043,7 +1043,6 @@ FT_ULong total_n_points = 0; FT_UShort n_points_contour; FT_UInt j; - FT_ULong flag_size; FT_ULong triplet_size; FT_ULong triplet_bytes_used; FT_Bool have_overlap = FALSE; @@ -1088,8 +1087,8 @@ } substreams[N_POINTS_STREAM].offset = FT_STREAM_POS(); - flag_size = total_n_points; - if ( flag_size > substreams[FLAG_STREAM].size ) + points_size += total_n_points; + if ( points_size > substreams[FLAG_STREAM].size ) goto Fail; flags_buf = stream->base + substreams[FLAG_STREAM].offset; @@ -1106,8 +1105,7 @@ triplet_bytes_used = 0; /* Create array to store point information. */ - points_size = total_n_points; - if ( FT_QNEW_ARRAY( points, points_size ) ) + if ( FT_QNEW_ARRAY( points, total_n_points ) ) goto Fail; if ( triplet_decode( flags_buf, @@ -1118,7 +1116,7 @@ &triplet_bytes_used ) ) goto Fail; - substreams[FLAG_STREAM].offset += flag_size; + substreams[FLAG_STREAM].offset += total_n_points; substreams[GLYPH_STREAM].offset += triplet_bytes_used; if ( FT_STREAM_SEEK( substreams[GLYPH_STREAM].offset ) || diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.c index ad9ad6f2710..7929b7aaf4c 100644 --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.c +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttcolr.c @@ -1749,7 +1749,6 @@ FT_UInt x, y; FT_Byte b, g, r, alpha; - FT_ULong size; FT_Byte* src; FT_Byte* dst; @@ -1767,13 +1766,9 @@ dstSlot->bitmap.pitch = (int)dstSlot->bitmap.width * 4; dstSlot->bitmap.num_grays = 256; - size = dstSlot->bitmap.rows * (unsigned int)dstSlot->bitmap.pitch; - - error = ft_glyphslot_alloc_bitmap( dstSlot, size ); + error = ft_glyphslot_alloc_bitmap( dstSlot ); if ( error ) return error; - - FT_MEM_ZERO( dstSlot->bitmap.buffer, size ); } else { @@ -1805,8 +1800,7 @@ FT_Byte* q; - size = rows * pitch; - if ( FT_ALLOC( buf, size ) ) + if ( FT_ALLOC_MULT( buf, rows, pitch ) ) return error; p = dstSlot->bitmap.buffer; diff --git a/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.c b/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.c index 9f9013bf39b..34e45619817 100644 --- a/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.c +++ b/src/java.desktop/share/native/libfreetype/src/sfnt/ttsbit.c @@ -547,7 +547,6 @@ FT_Error error = FT_Err_Ok; FT_UInt width, height; FT_Bitmap* map = decoder->bitmap; - FT_ULong size; if ( !decoder->metrics_loaded ) @@ -599,17 +598,11 @@ goto Exit; } - size = map->rows * (FT_ULong)map->pitch; - - /* check that there is no empty image */ - if ( size == 0 ) - goto Exit; /* exit successfully! */ - if ( metrics_only ) goto Exit; /* only metrics are requested */ - error = ft_glyphslot_alloc_bitmap( decoder->face->root.glyph, size ); - if ( error ) + error = ft_glyphslot_alloc_bitmap( decoder->face->root.glyph ); + if ( error || !map->buffer ) goto Exit; decoder->bitmap_allocated = 1; diff --git a/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.c b/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.c index 365fbad42ad..3c387aea0ac 100644 --- a/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.c +++ b/src/java.desktop/share/native/libfreetype/src/smooth/ftgrays.c @@ -1804,7 +1804,7 @@ typedef ptrdiff_t FT_PtrDist; FT_FILL_RULE( coverage, cover, fill ); span[n].coverage = (unsigned char)coverage; - span[n].x = (short)x; + span[n].x = (unsigned short)x; span[n].len = (unsigned short)( cell->x - x ); if ( ++n == FT_MAX_GRAY_SPANS ) @@ -1823,7 +1823,7 @@ typedef ptrdiff_t FT_PtrDist; FT_FILL_RULE( coverage, area, fill ); span[n].coverage = (unsigned char)coverage; - span[n].x = (short)cell->x; + span[n].x = (unsigned short)cell->x; span[n].len = 1; if ( ++n == FT_MAX_GRAY_SPANS ) diff --git a/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.c b/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.c index 21a6eca00ba..5a7a852a619 100644 --- a/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.c +++ b/src/java.desktop/share/native/libfreetype/src/smooth/ftsmooth.c @@ -80,6 +80,7 @@ { unsigned char* origin; /* pixmap origin at the bottom-left */ int pitch; /* pitch to go down one row */ + unsigned char wght[5]; /* filtering weights */ } TOrigin; @@ -274,6 +275,32 @@ } + /* This function applies a horizontal filter in direct rendering mode */ + static void + ft_smooth_lcd_spans( int y, + int count, + const FT_Span* spans, + void* target_ ) /* TOrigin* */ + { + TOrigin* target = (TOrigin*)target_; + + unsigned char* dst_line = target->origin - y * target->pitch - 2; + unsigned char* dst; + unsigned short w; + + + for ( ; count--; spans++ ) + for ( dst = dst_line + spans->x, w = spans->len; w--; dst++ ) + { + dst[0] += ( spans->coverage * target->wght[0] + 85 ) >> 8; + dst[1] += ( spans->coverage * target->wght[1] + 85 ) >> 8; + dst[2] += ( spans->coverage * target->wght[2] + 85 ) >> 8; + dst[3] += ( spans->coverage * target->wght[3] + 85 ) >> 8; + dst[4] += ( spans->coverage * target->wght[4] + 85 ) >> 8; + } + } + + static FT_Error ft_smooth_raster_lcd( FT_Renderer render, FT_Outline* outline, @@ -285,11 +312,47 @@ FT_Vector* vec; FT_Raster_Params params; + TOrigin target; - params.target = bitmap; - params.source = outline; - params.flags = FT_RASTER_FLAG_AA; + if ( render->root.library->lcd_weights[2] ) + { + /* Reject outlines that are too wide for 16-bit FT_Span. */ + /* Other limits are applied upstream with the same error code. */ + if ( bitmap->width > 0x7FFF ) + return FT_THROW( Raster_Overflow ); + + /* Set up direct rendering for instant filtering. */ + params.source = outline; + params.flags = FT_RASTER_FLAG_AA | FT_RASTER_FLAG_DIRECT; + params.gray_spans = ft_smooth_lcd_spans; + params.user = ⌖ + + params.clip_box.xMin = 0; + params.clip_box.yMin = 0; + params.clip_box.xMax = bitmap->width; + params.clip_box.yMax = bitmap->rows; + + if ( bitmap->pitch < 0 ) + target.origin = bitmap->buffer; + else + target.origin = bitmap->buffer + + ( bitmap->rows - 1 ) * (unsigned int)bitmap->pitch; + + target.pitch = bitmap->pitch; + + target.wght[0] = render->root.library->lcd_weights[0]; + target.wght[1] = render->root.library->lcd_weights[1]; + target.wght[2] = render->root.library->lcd_weights[2]; + target.wght[3] = render->root.library->lcd_weights[3]; + target.wght[4] = render->root.library->lcd_weights[4]; + } + else + { + params.target = bitmap; + params.source = outline; + params.flags = FT_RASTER_FLAG_AA; + } /* implode outline */ for ( vec = points; vec < points_end; vec++ ) @@ -306,6 +369,32 @@ } + /* This function applies a vertical filter in direct rendering mode */ + static void + ft_smooth_lcdv_spans( int y, + int count, + const FT_Span* spans, + void* target_ ) /* TOrigin* */ + { + TOrigin* target = (TOrigin*)target_; + + int pitch = target->pitch; + unsigned char* dst_line = target->origin - ( y + 2 ) * pitch; + unsigned char* dst; + unsigned short w; + + + for ( ; count--; spans++ ) + for ( dst = dst_line + spans->x, w = spans->len; w--; dst++ ) + { + dst[ 0] += ( spans->coverage * target->wght[0] + 85 ) >> 8; + dst[ pitch] += ( spans->coverage * target->wght[1] + 85 ) >> 8; + dst[2 * pitch] += ( spans->coverage * target->wght[2] + 85 ) >> 8; + dst[3 * pitch] += ( spans->coverage * target->wght[3] + 85 ) >> 8; + dst[4 * pitch] += ( spans->coverage * target->wght[4] + 85 ) >> 8; + } + } + static FT_Error ft_smooth_raster_lcdv( FT_Renderer render, FT_Outline* outline, @@ -317,11 +406,42 @@ FT_Vector* vec; FT_Raster_Params params; + TOrigin target; - params.target = bitmap; - params.source = outline; - params.flags = FT_RASTER_FLAG_AA; + if ( render->root.library->lcd_weights[2] ) + { + /* Set up direct rendering for instant filtering. */ + params.source = outline; + params.flags = FT_RASTER_FLAG_AA | FT_RASTER_FLAG_DIRECT; + params.gray_spans = ft_smooth_lcdv_spans; + params.user = ⌖ + + params.clip_box.xMin = 0; + params.clip_box.yMin = 0; + params.clip_box.xMax = bitmap->width; + params.clip_box.yMax = bitmap->rows; + + if ( bitmap->pitch < 0 ) + target.origin = bitmap->buffer; + else + target.origin = bitmap->buffer + + ( bitmap->rows - 1 ) * (unsigned int)bitmap->pitch; + + target.pitch = bitmap->pitch; + + target.wght[0] = render->root.library->lcd_weights[0]; + target.wght[1] = render->root.library->lcd_weights[1]; + target.wght[2] = render->root.library->lcd_weights[2]; + target.wght[3] = render->root.library->lcd_weights[3]; + target.wght[4] = render->root.library->lcd_weights[4]; + } + else + { + params.target = bitmap; + params.source = outline; + params.flags = FT_RASTER_FLAG_AA; + } /* implode outline */ for ( vec = points; vec < points_end; vec++ ) @@ -494,12 +614,6 @@ else y_shift += 64 * (FT_Int)bitmap->rows; - if ( origin ) - { - x_shift += origin->x; - y_shift += origin->y; - } - /* translate outline to render it into the bitmap */ if ( x_shift || y_shift ) FT_Outline_Translate( outline, x_shift, y_shift ); @@ -527,33 +641,6 @@ error = ft_smooth_raster_lcd ( render, outline, bitmap ); else if ( mode == FT_RENDER_MODE_LCD_V ) error = ft_smooth_raster_lcdv( render, outline, bitmap ); - -#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING - - /* finally apply filtering */ - { - FT_Byte* lcd_weights; - FT_Bitmap_LcdFilterFunc lcd_filter_func; - - - /* Per-face LCD filtering takes priority if set up. */ - if ( slot->face && slot->face->internal->lcd_filter_func ) - { - lcd_weights = slot->face->internal->lcd_weights; - lcd_filter_func = slot->face->internal->lcd_filter_func; - } - else - { - lcd_weights = slot->library->lcd_weights; - lcd_filter_func = slot->library->lcd_filter_func; - } - - if ( lcd_filter_func ) - lcd_filter_func( bitmap, lcd_weights ); - } - -#endif /* FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ - } Exit: diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.c b/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.c index e810ebfd550..4dd68ab1019 100644 --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.c +++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttgload.c @@ -2217,6 +2217,10 @@ exec = size->context; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL + /* reset backward compatibility; note that */ + /* the CVT program always runs without it */ + exec->backward_compatibility = 0; + if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 ) { grayscale = FALSE; @@ -2253,9 +2257,7 @@ return error; } - error = TT_Load_Context( exec, face, size ); - if ( error ) - return error; + TT_Load_Context( exec, face, size ); /* check whether the cvt program has disabled hinting */ if ( size->GS.instruct_control & 1 ) @@ -2283,8 +2285,7 @@ mode != FT_RENDER_MODE_MONO && !FT_IS_TRICKY( glyph->face ) ) exec->backward_compatibility = ( size->GS.instruct_control & 4 ) ^ 4; - else - exec->backward_compatibility = 0; + #endif /* TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL */ loader->exec = exec; diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.c b/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.c index 0732fcbae36..f8842795f14 100644 --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.c +++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttgxvar.c @@ -697,11 +697,9 @@ if ( long_words ) per_region_size *= 2; - if ( FT_NEW_ARRAY( varData->deltaSet, per_region_size * item_count ) ) + if ( FT_QALLOC_MULT( varData->deltaSet, item_count, per_region_size ) ) goto Exit; - if ( FT_Stream_Read( stream, - varData->deltaSet, - per_region_size * item_count ) ) + if ( FT_STREAM_READ( varData->deltaSet, item_count * per_region_size ) ) { FT_TRACE2(( "deltaSet read failed." )); error = FT_THROW( Invalid_Table ); diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.c b/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.c index 7b26c9a9df2..f46cc77fe5f 100644 --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.c +++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.c @@ -272,7 +272,7 @@ * * Note that not all members of `TT_ExecContext` get initialized. */ - FT_LOCAL_DEF( FT_Error ) + FT_LOCAL_DEF( void ) TT_Load_Context( TT_ExecContext exec, TT_Face face, TT_Size size ) @@ -284,7 +284,7 @@ exec->size = size; /* CVT and storage are not persistent in FreeType */ - /* reset them after they might have been modifief */ + /* reset them after they might have been modified */ exec->storage = exec->stack + exec->stackSize; exec->cvt = exec->storage + exec->storeSize; @@ -297,8 +297,6 @@ exec->metrics = *size->metrics; exec->twilight = size->twilight; - - return FT_Err_Ok; } @@ -5457,11 +5455,11 @@ /* single width cut-in test */ /* |org_dist - single_width_value| < single_width_cutin */ - if ( exc->GS.single_width_cutin > 0 && - org_dist < exc->GS.single_width_value + - exc->GS.single_width_cutin && - org_dist > exc->GS.single_width_value - - exc->GS.single_width_cutin ) + if ( exc->GS.single_width_cutin > 0 && + org_dist < ADD_LONG( exc->GS.single_width_value, + exc->GS.single_width_cutin ) && + org_dist > SUB_LONG( exc->GS.single_width_value, + exc->GS.single_width_cutin ) ) { if ( org_dist >= 0 ) org_dist = exc->GS.single_width_value; diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.h b/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.h index 2e69d191890..5cdc8f59f1a 100644 --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.h +++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttinterp.h @@ -439,7 +439,7 @@ FT_BEGIN_HEADER FT_LOCAL( void ) TT_Done_Context( TT_ExecContext exec ); - FT_LOCAL( FT_Error ) + FT_LOCAL( void ) TT_Load_Context( TT_ExecContext exec, TT_Face face, TT_Size size ); diff --git a/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.c b/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.c index fd0c0ad14f6..2aedbd842c1 100644 --- a/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.c +++ b/src/java.desktop/share/native/libfreetype/src/truetype/ttobjs.c @@ -884,9 +884,7 @@ FT_Error error; - error = TT_Load_Context( exec, face, size ); - if ( error ) - return error; + TT_Load_Context( exec, face, size ); /* disable CVT and glyph programs coderange */ TT_Clear_CodeRange( exec, tt_coderange_cvt ); @@ -952,9 +950,7 @@ FT_ARRAY_ZERO( size->twilight.org, size->twilight.n_points ); FT_ARRAY_ZERO( size->twilight.cur, size->twilight.n_points ); - error = TT_Load_Context( exec, face, size ); - if ( error ) - return error; + TT_Load_Context( exec, face, size ); /* clear storage area */ FT_ARRAY_ZERO( exec->storage, exec->storeSize ); @@ -1043,13 +1039,15 @@ if ( !exec ) return FT_THROW( Could_Not_Find_Context ); + size->context = exec; + exec->pedantic_hinting = pedantic; exec->maxFDefs = maxp->maxFunctionDefs; exec->maxIDefs = maxp->maxInstructionDefs; if ( FT_NEW_ARRAY( exec->FDefs, exec->maxFDefs + exec->maxIDefs ) ) - goto Exit; + goto Fail; exec->IDefs = exec->FDefs + exec->maxFDefs; @@ -1068,7 +1066,7 @@ if ( FT_NEW_ARRAY( exec->stack, exec->stackSize + (FT_Long)( exec->storeSize + exec->cvtSize ) ) ) - goto Exit; + goto Fail; /* reserve twilight zone and set GS before fpgm is executed, */ /* just in case, even though fpgm should not touch them */ @@ -1079,11 +1077,10 @@ error = tt_glyphzone_new( memory, n_twilight, 0, &size->twilight ); if ( error ) - goto Exit; + goto Fail; size->GS = tt_default_graphics_state; size->cvt_ready = -1; - size->context = exec; size->ttmetrics.rotated = FALSE; size->ttmetrics.stretched = FALSE; @@ -1099,10 +1096,8 @@ error = tt_size_run_fpgm( size ); return error; - Exit: - if ( error ) - tt_size_done_bytecode( size ); - + Fail: + tt_size_done_bytecode( size ); return error; } diff --git a/src/java.desktop/share/native/libfreetype/src/type1/t1tokens.h b/src/java.desktop/share/native/libfreetype/src/type1/t1tokens.h index c3736cd42c0..a526406a411 100644 --- a/src/java.desktop/share/native/libfreetype/src/type1/t1tokens.h +++ b/src/java.desktop/share/native/libfreetype/src/type1/t1tokens.h @@ -33,7 +33,7 @@ T1_FIELD_DICT_FONTDICT ) /* we use pointers to detect modifications made by synthetic fonts */ - T1_FIELD_NUM ( "ItalicAngle", italic_angle, + T1_FIELD_FIXED ( "ItalicAngle", italic_angle, T1_FIELD_DICT_FONTDICT ) T1_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch, T1_FIELD_DICT_FONTDICT ) diff --git a/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java b/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java index 45a452bd0dd..44d9bd89917 100644 --- a/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java +++ b/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2026, 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 @@ -195,23 +195,30 @@ public abstract class DocTrees extends Trees { /** * Returns the language model element referred to by the leaf node of the given - * {@link DocTreePath}, or {@code null} if unknown. + * {@link DocTreePath}, or {@code null} if the leaf node of {@code path} does + * not refer to an element. + * * @param path the path for the tree node - * @return the element + * @return the referenced element, or null + * @see #getType(DocTreePath) */ public abstract Element getElement(DocTreePath path); /** * Returns the language model type referred to by the leaf node of the given - * {@link DocTreePath}, or {@code null} if unknown. This method usually - * returns the same value as {@code getElement(path).asType()} for a - * {@code path} argument for which {@link #getElement(DocTreePath)} returns - * a non-null value, but may return a type that includes additional - * information, such as a parameterized generic type instead of a raw type. + * {@link DocTreePath}, or {@code null} if the leaf node of {@code path} does + * not refer to a type. + * + *

If {@link #getElement(DocTreePath)} returns a non-null value for a given {@code path} + * argument, this method usally returns the same value as {@code getElement(path).asType()}. + * However, there are cases where the returned type includes additional information, + * such as a parameterized generic type instead of a raw type. In other cases, such as with + * primitive or array types, the returned type may not have a corresponding element returned + * by {@code getElement(DocTreePath)}.

* * @param path the path for the tree node * @return the referenced type, or null - * + * @see #getElement(DocTreePath) * @since 15 */ public abstract TypeMirror getType(DocTreePath path); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java index 6bc5d358b6f..ecd7f5b101a 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, 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 @@ -354,22 +354,28 @@ public class JavacTrees extends DocTrees { DocTree tree = path.getLeaf(); if (tree instanceof DCReference dcReference) { JCTree qexpr = dcReference.qualifierExpression; - if (qexpr != null) { + + // Forward references with explicit module name to getElement + if (qexpr != null && dcReference.moduleName == null) { + + Env env = getAttrContext(path.getTreePath()); Log.DeferredDiagnosticHandler deferredDiagnosticHandler = log.new DeferredDiagnosticHandler(); + JavaFileObject prevSource = log.useSource(env.toplevel.sourcefile); + try { - Env env = getAttrContext(path.getTreePath()); - JavaFileObject prevSource = log.useSource(env.toplevel.sourcefile); - try { - Type t = attr.attribType(dcReference.qualifierExpression, env); - if (t != null && !t.isErroneous()) { + Type t = attr.attribType(dcReference.qualifierExpression, env); + if (t != null && !t.isErroneous()) { + if (dcReference.memberName != null) { + Symbol sym = resolveMember(t, (Name) dcReference.memberName, dcReference, env); + return sym == null ? null : sym.type; + } else { return t; } - } finally { - log.useSource(prevSource); } } catch (Abort e) { // may be thrown by Check.completionError in case of bad class file return null; } finally { + log.useSource(prevSource); log.popDiagnosticHandler(deferredDiagnosticHandler); } } @@ -426,14 +432,12 @@ public class JavacTrees extends DocTrees { memberName = (Name) ref.memberName; } else { // Check if qualifierExpression is a type or package, using the methods javac provides. - // If no module name is given we check if qualifierExpression identifies a type. - // If that fails or we have a module name, use that to resolve qualifierExpression to - // a package or type. - Type t = ref.moduleName == null ? attr.attribType(ref.qualifierExpression, env) : null; + Type t = attr.attribType(ref.qualifierExpression, env); - if (t == null || t.isErroneous()) { - JCCompilationUnit toplevel = - treeMaker.TopLevel(List.nil()); + if (t == null || t.isErroneous() || + (ref.moduleName != null && !mdlsym.equals(elements.getModuleOf(t.asElement())))) { + + JCCompilationUnit toplevel = treeMaker.TopLevel(List.nil()); toplevel.modle = mdlsym; toplevel.packge = mdlsym.unnamedPackage; Symbol sym = attr.attribIdent(ref.qualifierExpression, toplevel); @@ -447,10 +451,6 @@ public class JavacTrees extends DocTrees { if ((sym.kind == PCK || sym.kind == TYP) && sym.exists()) { tsym = (TypeSymbol) sym; memberName = (Name) ref.memberName; - if (sym.kind == PCK && memberName != null) { - //cannot refer to a package "member" - return null; - } } else { if (modules.modulesInitialized() && ref.moduleName == null && ref.memberName == null) { // package/type does not exist, check if there is a matching module @@ -470,64 +470,22 @@ public class JavacTrees extends DocTrees { } } } else { - Type e = t; - // If this is an array type convert to element type - while (e instanceof ArrayType arrayType) - e = arrayType.elemtype; - tsym = e.tsym; + tsym = switch (t.getKind()) { + case DECLARED, TYPEVAR, PACKAGE, MODULE -> t.tsym; + default -> null; + }; memberName = (Name) ref.memberName; } } if (memberName == null) { return tsym; - } else if (tsym == null || tsym.getKind() == ElementKind.PACKAGE || tsym.getKind() == ElementKind.MODULE) { - return null; // Non-null member name in non-class context - } - - if (tsym.type.isPrimitive()) { + } else if (tsym == null) { return null; } - final List paramTypes; - if (ref.paramTypes == null) - paramTypes = null; - else { - ListBuffer lb = new ListBuffer<>(); - for (List l = (List) ref.paramTypes; l.nonEmpty(); l = l.tail) { - JCTree tree = l.head; - Type t = attr.attribType(tree, env); - lb.add(t); - } - paramTypes = lb.toList(); - } + return resolveMember(tsym.type, memberName, ref, env); - ClassSymbol sym = (ClassSymbol) types.skipTypeVars(tsym.type, false).tsym; - boolean explicitType = ref.qualifierExpression != null; - Symbol msym = (memberName == sym.name) - ? findConstructor(sym, paramTypes, true) - : findMethod(sym, memberName, paramTypes, true, explicitType); - - if (msym == null) { - msym = (memberName == sym.name) - ? findConstructor(sym, paramTypes, false) - : findMethod(sym, memberName, paramTypes, false, explicitType); - } - - if (paramTypes != null) { - // explicit (possibly empty) arg list given, so cannot be a field - return msym; - } - - VarSymbol vsym = (ref.paramTypes != null) ? null : findField(sym, memberName, explicitType); - // prefer a field over a method with no parameters - if (vsym != null && - (msym == null || - types.isSubtypeUnchecked(vsym.enclClass().asType(), msym.enclClass().asType()))) { - return vsym; - } else { - return msym; - } } catch (Abort e) { // may be thrown by Check.completionError in case of bad class file return null; } finally { @@ -536,6 +494,54 @@ public class JavacTrees extends DocTrees { } } + private Symbol resolveMember(Type type, Name memberName, DCReference ref, Env env) { + + if (type.isPrimitive() || type.getKind() == TypeKind.PACKAGE || type.getKind() == TypeKind.MODULE) { + return null; + } + + final List paramTypes; + if (ref.paramTypes == null) + paramTypes = null; + else { + ListBuffer lb = new ListBuffer<>(); + for (List l = (List) ref.paramTypes; l.nonEmpty(); l = l.tail) { + JCTree tree = l.head; + Type t = attr.attribType(tree, env); + lb.add(t); + } + paramTypes = lb.toList(); + } + + // skipTypeVars conversion below is needed if type is itself a type variable + ClassSymbol sym = (ClassSymbol) types.skipTypeVars(type, false).tsym; + boolean explicitType = ref.qualifierExpression != null; + Symbol msym = (memberName == sym.name) + ? findConstructor(sym, paramTypes, true) + : findMethod(sym, memberName, paramTypes, true, explicitType); + + if (msym == null) { + msym = (memberName == sym.name) + ? findConstructor(sym, paramTypes, false) + : findMethod(sym, memberName, paramTypes, false, explicitType); + } + + if (paramTypes != null) { + // explicit (possibly empty) arg list given, so cannot be a field + return msym; + } + + VarSymbol vsym = (ref.paramTypes != null) ? null : findField(sym, memberName, explicitType); + // prefer a field over a method with no parameters + if (vsym != null && + (msym == null || + types.isSubtypeUnchecked(vsym.enclClass().asType(), msym.enclClass().asType()))) { + return vsym; + } else { + return msym; + } + } + private Symbol attributeParamIdentifier(TreePath path, DCParam paramTag) { Symbol javadocSymbol = getElement(path); if (javadocSymbol == null) diff --git a/src/jdk.httpserver/share/classes/sun/net/httpserver/ContextList.java b/src/jdk.httpserver/share/classes/sun/net/httpserver/ContextList.java index 6393ca34798..14a07b3a677 100644 --- a/src/jdk.httpserver/share/classes/sun/net/httpserver/ContextList.java +++ b/src/jdk.httpserver/share/classes/sun/net/httpserver/ContextList.java @@ -186,38 +186,31 @@ class ContextList { */ PATH_PREFIX((contextPath, requestPath) -> { - // Fast-path for `/` - if ("/".equals(contextPath)) { + // Does the request path prefix match? + if (!requestPath.startsWith(contextPath)) { + return false; + } + + // Is it an exact match? + int contextPathLength = contextPath.length(); + if (requestPath.length() == contextPathLength) { return true; } - // Does the request path prefix match? - if (requestPath.startsWith(contextPath)) { - - // Is it an exact match? - int contextPathLength = contextPath.length(); - if (requestPath.length() == contextPathLength) { - return true; - } - - // Is it a path-prefix match? - assert contextPathLength > 0; - return - // Case 1: The request path starts with the context - // path, but the context path has an extra path - // separator suffix. For instance, the context path is - // `/foo/` and the request path is `/foo/bar`. - contextPath.charAt(contextPathLength - 1) == '/' || - // Case 2: The request path starts with the - // context path, but the request path has an - // extra path separator suffix. For instance, - // context path is `/foo` and the request path - // is `/foo/` or `/foo/bar`. - requestPath.charAt(contextPathLength) == '/'; - - } - - return false; + // Is it a path-prefix match? + assert contextPathLength > 0; + return + // Case 1: The request path starts with the context + // path, but the context path has an extra path + // separator suffix. For instance, the context path is + // `/foo/` and the request path is `/foo/bar`. + contextPath.charAt(contextPathLength - 1) == '/' || + // Case 2: The request path starts with the + // context path, but the request path has an + // extra path separator suffix. For instance, + // context path is `/foo` and the request path + // is `/foo/` or `/foo/bar`. + requestPath.charAt(contextPathLength) == '/'; }); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java index 30aa86aea71..3d300b77073 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 @@ -136,10 +136,7 @@ public class CommentHelper { return null; } DocTrees doctrees = configuration.docEnv.getDocTrees(); - // Workaround for JDK-8284193 - // DocTrees.getElement(DocTreePath) returns javac-internal Symbols - var e = doctrees.getElement(docTreePath); - return e == null || e.getKind() == ElementKind.CLASS && e.asType().getKind() != TypeKind.DECLARED ? null : e; + return doctrees.getElement(docTreePath); } public TypeMirror getType(ReferenceTree rtree) { 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 b5399d0fef9..90b371a8a15 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, 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 @@ -1006,11 +1006,11 @@ public class Checker extends DocTreePathScanner { public Void visitReference(ReferenceTree tree, Void ignore) { // Exclude same-file anchor links from reference checks if (!tree.getSignature().startsWith("##")) { - Element e = env.trees.getElement(getCurrentPath()); - if (e == null) { - reportBadReference(tree); - } else if ((inLink || inSee) - && e.getKind() == ElementKind.CLASS && e.asType().getKind() != TypeKind.DECLARED) { + if (inLink || inSee) { + if (env.trees.getElement(getCurrentPath()) == null) { + reportBadReference(tree); + } + } else if (env.trees.getType(getCurrentPath()) == null) { reportBadReference(tree); } } diff --git a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxBundlingEnvironment.java b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxBundlingEnvironment.java index d6d9def9407..724aeabb4b3 100644 --- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxBundlingEnvironment.java +++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxBundlingEnvironment.java @@ -33,6 +33,7 @@ import static jdk.jpackage.internal.cli.StandardBundlingOperation.CREATE_LINUX_R import static jdk.jpackage.internal.util.MemoizingSupplier.runOnce; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.function.Supplier; import java.util.stream.Stream; @@ -41,6 +42,7 @@ import jdk.jpackage.internal.cli.StandardBundlingOperation; import jdk.jpackage.internal.model.BundlingOperationDescriptor; import jdk.jpackage.internal.model.LinuxPackage; import jdk.jpackage.internal.model.PackageType; +import jdk.jpackage.internal.model.StandardPackageType; import jdk.jpackage.internal.util.Result; public class LinuxBundlingEnvironment extends DefaultBundlingEnvironment { @@ -55,11 +57,15 @@ public class LinuxBundlingEnvironment extends DefaultBundlingEnvironment { }); Supplier> debSysEnv = () -> { - return LinuxDebSystemEnvironment.create(sysEnv.get()); + return LinuxDebSystemEnvironment.create(sysEnv.get().flatMap(v -> { + return adjustPackageArch(v, StandardPackageType.LINUX_DEB); + })); }; Supplier> rpmSysEnv = () -> { - return LinuxRpmSystemEnvironment.create(sysEnv.get()); + return LinuxRpmSystemEnvironment.create(sysEnv.get().flatMap(v -> { + return adjustPackageArch(v, StandardPackageType.LINUX_RPM); + })); }; builder.defaultOperation(() -> { @@ -107,6 +113,20 @@ public class LinuxBundlingEnvironment extends DefaultBundlingEnvironment { return new BuildEnvFromOptions().predefinedAppImageLayout(APPLICATION_LAYOUT); } + private static Result adjustPackageArch(LinuxSystemEnvironment sysEnv, StandardPackageType type) { + Objects.requireNonNull(sysEnv); + Objects.requireNonNull(type); + if (sysEnv.nativePackageType().equals(type)) { + return Result.of(() -> { + return sysEnv; + }); + } else { + return LinuxPackageArch.create(type).map(arch -> { + return new LinuxSystemEnvironment.Stub(sysEnv.soLookupAvailable(), sysEnv.nativePackageType(), arch); + }); + } + } + private static final Map DESCRIPTORS = Stream.of( CREATE_LINUX_DEB, CREATE_LINUX_RPM diff --git a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebPackager.java b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebPackager.java index 7c1f06f54a3..d46ec8865c8 100644 --- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebPackager.java +++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebPackager.java @@ -104,7 +104,7 @@ final class LinuxDebPackager extends LinuxPackager { List cmdline = new ArrayList<>(List.of( sysEnv.dpkgdeb().toString(), "-f", outputPackageFile().toString())); - properties.forEach(property -> cmdline.add(property.name)); + properties.forEach(property -> cmdline.add(property.name())); Map actualValues = Executor.of(cmdline) .saveOutput(true) @@ -116,7 +116,7 @@ final class LinuxDebPackager extends LinuxPackager { components -> components[1])); for (var property : properties) { - Optional.ofNullable(property.verifyValue(actualValues.get(property.name))).ifPresent(errors::add); + Optional.ofNullable(property.verifyValue(actualValues.get(property.name()))).ifPresent(errors::add); } return errors; diff --git a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmPackager.java b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmPackager.java index e22b9c24fdd..8c3e8125e9b 100644 --- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmPackager.java +++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxRpmPackager.java @@ -112,12 +112,12 @@ final class LinuxRpmPackager extends LinuxPackager { "APPLICATION_VERSION", specFileName), new PackageProperty("Release", pkg.release().orElseThrow(), "APPLICATION_RELEASE", specFileName), - new PackageProperty("Arch", pkg.arch(), null, specFileName)); + new PackageProperty("Arch", pkg.arch(), specFileName)); var actualValues = Executor.of( sysEnv.rpm().toString(), "-qp", - "--queryformat", properties.stream().map(e -> String.format("%%{%s}", e.name)).collect(joining("\\n")), + "--queryformat", properties.stream().map(e -> String.format("%%{%s}", e.name())).collect(joining("\\n")), outputPackageFile().toString() ).saveOutput(true).executeExpectSuccess().getOutput(); diff --git a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/PackageProperty.java b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/PackageProperty.java index 6b06190f891..e19e45cb5d4 100644 --- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/PackageProperty.java +++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/PackageProperty.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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,52 +25,61 @@ package jdk.jpackage.internal; -import java.text.MessageFormat; +import java.util.Objects; +import java.util.Optional; import jdk.jpackage.internal.model.ConfigException; -final class PackageProperty { - /** - * Constructor - * - * @param name property name - * @param expectedValue expected property value - * @param substString substitution string to be placed in resource file to - * be replaced with the expected property value by jpackage at package build - * time - * @param customResource name of custom resource from resource directory in - * which this package property can be set - */ - PackageProperty(String name, String expectedValue, String substString, - String customResource) { - this.name = name; - this.expectedValue = expectedValue; - this.substString = substString; - this.customResource = customResource; +/** + * Linux package property. + * + * @param name the property name (e.g.: "Architecture", "Version") + * @param expectedValue the expected value of the property + * @param subtrituteString the substitute string in the jpackage resource if + * applicable (e.g.: "APPLICATION_PACKAGE", + * "APPLICATION_VERSION") + * @param resourceName the name of the custom resource file from the + * resource directory in which this package property can + * be set + */ +record PackageProperty(String name, String expectedValue, Optional subtrituteString, String customResource) { + + PackageProperty { + Objects.requireNonNull(name); + Objects.requireNonNull(expectedValue); + Objects.requireNonNull(subtrituteString); + Objects.requireNonNull(customResource); + } + + PackageProperty(String name, String expectedValue, String subtrituteString, String resourceName) { + this(name, expectedValue, Optional.of(subtrituteString), resourceName); + } + + PackageProperty(String name, String expectedValue, String resourceName) { + this(name, expectedValue, Optional.empty(), resourceName); + } + + private String formatErrorMessage(String actualValue) { + Objects.requireNonNull(actualValue); + return I18N.format("error.unexpected-package-property", + name, expectedValue, actualValue, customResource); + } + + private String formatAdvice(String actualValue) { + Objects.requireNonNull(actualValue); + return subtrituteString.map(ss -> { + return I18N.format("error.unexpected-package-property.advice", ss, actualValue, name, customResource); + }).orElseGet(() -> { + return I18N.format("error.unexpected-default-package-property.advice", name, customResource); + }); } ConfigException verifyValue(String actualValue) { + Objects.requireNonNull(actualValue); + if (expectedValue.equals(actualValue)) { return null; } - final String advice; - if (substString != null) { - advice = MessageFormat.format(I18N.getString( - "error.unexpected-package-property.advice"), substString, - actualValue, name, customResource); - } else { - advice = MessageFormat.format(I18N.getString( - "error.unexpected-default-package-property.advice"), name, - customResource); - } - - return new ConfigException(MessageFormat.format(I18N.getString( - "error.unexpected-package-property"), name, - expectedValue, actualValue, customResource, substString), advice); + return new ConfigException(formatErrorMessage(actualValue), formatAdvice(actualValue)); } - - final String name; - private final String expectedValue; - private final String substString; - private final String customResource; } diff --git a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/LinuxResources.properties b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/LinuxResources.properties index 3aa0e0e92a0..1ab45d26a4c 100644 --- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/LinuxResources.properties +++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/LinuxResources.properties @@ -58,6 +58,6 @@ message.rpm-ldd-not-available.advice=Install "glibc-common" RPM package to get l warning.foreign-app-image=Warning: app-image dir not generated by jpackage. message.not-default-bundler-no-dependencies-lookup={0} is not the default package type. Package dependencies will not be generated. -error.unexpected-package-property=Expected value of "{0}" property is [{1}]. Actual value in output package is [{2}]. Looks like custom "{3}" file from resource directory contained hard coded value of "{0}" property +error.unexpected-package-property=Expected value of "{0}" property is [{1}]. Actual value in output package is [{2}]. Looks like the value of "{0}" property is hardcoded in "{3}" file in the resource directory error.unexpected-package-property.advice=Use [{0}] pattern string instead of hard coded value [{1}] of {2} property in custom "{3}" file -error.unexpected-default-package-property.advice=Don't explicitly set value of {0} property in custom "{1}" file +error.unexpected-default-package-property.advice=Don''t explicitly set value of "{0}" property in custom "{1}" file diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/model/DottedVersion.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/model/DottedVersion.java index b49cbb025e9..8071f182801 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/model/DottedVersion.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/model/DottedVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,12 +37,11 @@ import java.util.stream.Stream; public final class DottedVersion { private DottedVersion(String version, boolean greedy) { - this.value = version; if (version.isEmpty()) { if (greedy) { throw new IllegalArgumentException(I18N.getString("error.version-string-empty")); } else { - this.components = new BigInteger[0]; + this.components = new Component[0]; this.suffix = ""; } } else { @@ -53,12 +52,12 @@ public final class DottedVersion { if (!greedy) { return null; } else { - ds.throwException(); + throw ds.createException(); } } try { - return new BigInteger(digits); + return new Component(digits); } catch (NumberFormatException ex) { if (!greedy) { return null; @@ -68,17 +67,25 @@ public final class DottedVersion { digits)); } } - }).takeWhile(Objects::nonNull).toArray(BigInteger[]::new); + }).takeWhile(Objects::nonNull).toArray(Component[]::new); suffix = ds.getUnprocessedString(); if (!suffix.isEmpty() && greedy) { - ds.throwException(); + throw ds.createException(); } } } + private DottedVersion(Component[] components, String suffix) { + this.components = components; + this.suffix = suffix; + } + private static class DigitsSupplier { DigitsSupplier(String input) { + if (input.isEmpty()) { + throw new IllegalArgumentException(); + } this.input = input; } @@ -95,7 +102,7 @@ public final class DottedVersion { } else { var curStopAtDot = (chr == '.'); if (!curStopAtDot) { - if (lastDotPos >= 0) { + if (sb.isEmpty() && lastDotPos >= 0) { cursor = lastDotPos; } else { cursor--; @@ -112,11 +119,7 @@ public final class DottedVersion { } if (sb.isEmpty()) { - if (lastDotPos >= 0) { - cursor = lastDotPos; - } else { - cursor--; - } + cursor = lastDotPos; } stoped = true; @@ -127,7 +130,7 @@ public final class DottedVersion { return input.substring(cursor); } - void throwException() { + IllegalArgumentException createException() { final String tail; if (lastDotPos >= 0) { tail = input.substring(lastDotPos + 1); @@ -143,7 +146,7 @@ public final class DottedVersion { errMessage = MessageFormat.format(I18N.getString( "error.version-string-invalid-component"), input, tail); } - throw new IllegalArgumentException(errMessage); + return new IllegalArgumentException(errMessage); } private int cursor; @@ -211,9 +214,31 @@ public final class DottedVersion { return Arrays.deepEquals(this.components, other.components); } + public DottedVersion trim(int limit) { + if (limit < 0) { + throw new IllegalArgumentException(); + } else if (limit >= components.length) { + return this; + } else { + return new DottedVersion(Arrays.copyOf(components, limit), suffix); + } + } + + public DottedVersion pad(int limit) { + if (limit < 0) { + throw new IllegalArgumentException(); + } else if (limit <= components.length) { + return this; + } else { + var newComponents = Arrays.copyOf(components, limit); + Arrays.fill(newComponents, components.length, newComponents.length, Component.ZERO); + return new DottedVersion(newComponents, suffix); + } + } + @Override public String toString() { - return value; + return Stream.of(components).map(Component::toString).collect(Collectors.joining(".")) + suffix; } public String getUnprocessedSuffix() { @@ -221,14 +246,35 @@ public final class DottedVersion { } public String toComponentsString() { - return Stream.of(components).map(BigInteger::toString).collect(Collectors.joining(".")); + return Stream.of(components).map(Component::parsedValue).map(BigInteger::toString).collect(Collectors.joining(".")); + } + + public int getComponentsCount() { + return components.length; } public BigInteger[] getComponents() { - return components; + return Stream.of(components).map(Component::parsedValue).toArray(BigInteger[]::new); } - private final BigInteger[] components; - private final String value; + private record Component(BigInteger parsedValue, String strValue) { + Component { + Objects.requireNonNull(parsedValue); + Objects.requireNonNull(strValue); + } + + Component(String strValue) { + this(new BigInteger(strValue), strValue); + } + + @Override + public String toString() { + return strValue; + } + + static final Component ZERO = new Component(BigInteger.ZERO, "0"); + } + + private final Component[] components; private final String suffix; } diff --git a/test/hotspot/jtreg/ProblemList-zgc.txt b/test/hotspot/jtreg/ProblemList-zgc.txt index 3e52b7169df..8514ffce11c 100644 --- a/test/hotspot/jtreg/ProblemList-zgc.txt +++ b/test/hotspot/jtreg/ProblemList-zgc.txt @@ -27,82 +27,6 @@ # ############################################################################# -# Quiet the majority of SA tests -# We run serviceability/sa/TestUniverse.java as a sanity check for minimal functionality - -resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java 8307393 generic-all -serviceability/sa/CDSJMapClstats.java 8307393 generic-all -serviceability/sa/ClhsdbAttach.java 8307393 generic-all -serviceability/sa/ClhsdbAttachDifferentJVMs.java 8307393 generic-all -serviceability/sa/ClhsdbCDSCore.java 8307393 generic-all -serviceability/sa/ClhsdbCDSJstackPrintAll.java 8307393 generic-all -serviceability/sa/ClhsdbClasses.java 8307393 generic-all -serviceability/sa/ClhsdbDumpclass.java 8307393 generic-all -serviceability/sa/ClhsdbDumpheap.java 8307393 generic-all -serviceability/sa/ClhsdbField.java 8307393 generic-all -serviceability/sa/ClhsdbFindPC.java#no-xcomp-core 8307393 generic-all -serviceability/sa/ClhsdbFindPC.java#no-xcomp-process 8307393 generic-all -serviceability/sa/ClhsdbFindPC.java#xcomp-core 8307393 generic-all -serviceability/sa/ClhsdbFindPC.java#xcomp-process 8307393 generic-all -serviceability/sa/ClhsdbFlags.java 8307393 generic-all -serviceability/sa/ClhsdbHistory.java 8307393 generic-all -serviceability/sa/ClhsdbInspect.java 8307393 generic-all -serviceability/sa/ClhsdbJdis.java 8307393 generic-all -serviceability/sa/ClhsdbJhisto.java 8307393 generic-all -serviceability/sa/ClhsdbJstack.java#id0 8307393 generic-all -serviceability/sa/ClhsdbJstack.java#id1 8307393 generic-all -serviceability/sa/ClhsdbJstackWithConcurrentLock.java 8307393 generic-all -serviceability/sa/ClhsdbJstackXcompStress.java 8307393 generic-all -serviceability/sa/ClhsdbLongConstant.java 8307393 generic-all -serviceability/sa/ClhsdbPmap.java#core 8307393 generic-all -serviceability/sa/ClhsdbPmap.java#process 8307393 generic-all -serviceability/sa/ClhsdbPrintAll.java 8307393 generic-all -serviceability/sa/ClhsdbPrintAs.java 8307393 generic-all -serviceability/sa/ClhsdbPrintStatics.java 8307393 generic-all -serviceability/sa/ClhsdbPstack.java#core 8307393 generic-all -serviceability/sa/ClhsdbPstack.java#process 8307393 generic-all -serviceability/sa/ClhsdbScanOops.java#parallel 8307393 generic-all -serviceability/sa/ClhsdbScanOops.java#serial 8307393 generic-all -serviceability/sa/ClhsdbSource.java 8307393 generic-all -serviceability/sa/ClhsdbSymbol.java 8307393 generic-all -serviceability/sa/ClhsdbThread.java 8307393 generic-all -serviceability/sa/ClhsdbThreadContext.java 8307393 generic-all -serviceability/sa/ClhsdbVmStructsDump.java 8307393 generic-all -serviceability/sa/ClhsdbWhere.java 8307393 generic-all -serviceability/sa/DeadlockDetectionTest.java 8307393 generic-all -serviceability/sa/JhsdbThreadInfoTest.java 8307393 generic-all -serviceability/sa/TestClassDump.java 8307393 generic-all -serviceability/sa/TestClhsdbJstackLock.java 8307393 generic-all -serviceability/sa/TestCpoolForInvokeDynamic.java 8307393 generic-all -serviceability/sa/TestDefaultMethods.java 8307393 generic-all -serviceability/sa/TestG1HeapRegion.java 8307393 generic-all -serviceability/sa/TestHeapDumpForInvokeDynamic.java 8307393 generic-all -serviceability/sa/TestInstanceKlassSize.java 8307393 generic-all -serviceability/sa/TestInstanceKlassSizeForInterface.java 8307393 generic-all -serviceability/sa/TestIntConstant.java 8307393 generic-all -serviceability/sa/TestJhsdbJstackLineNumbers.java 8307393 generic-all -serviceability/sa/TestJhsdbJstackLock.java 8307393 generic-all -serviceability/sa/TestJhsdbJstackMixed.java 8307393 generic-all -serviceability/sa/TestJhsdbJstackPrintVMLocks.java 8307393 generic-all -serviceability/sa/TestJhsdbJstackUpcall.java 8307393 generic-all -serviceability/sa/TestJmapCore.java 8307393 generic-all -serviceability/sa/TestJmapCoreMetaspace.java 8307393 generic-all -serviceability/sa/TestObjectAlignment.java 8307393 generic-all -serviceability/sa/TestObjectMonitorIterate.java 8307393 generic-all -serviceability/sa/TestPrintMdo.java 8307393 generic-all -serviceability/sa/TestRevPtrsForInvokeDynamic.java 8307393 generic-all -serviceability/sa/TestSysProps.java 8307393 generic-all -serviceability/sa/TestType.java 8307393 generic-all -serviceability/sa/UniqueVtableTest.java 8307393 generic-all -serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java 8307393 generic-all -serviceability/sa/sadebugd/ClhsdbAttachToDebugServer.java 8307393 generic-all -serviceability/sa/sadebugd/ClhsdbTestConnectArgument.java 8307393 generic-all -serviceability/sa/ClhsdbTestAllocationMerge.java 8307393 generic-all -serviceability/sa/sadebugd/DebugdConnectTest.java 8307393 generic-all -serviceability/sa/sadebugd/DisableRegistryTest.java 8307393 generic-all -serviceability/sa/sadebugd/PmapOnDebugdTest.java 8307393 generic-all -serviceability/sa/sadebugd/RunCommandOnServerTest.java 8307393 generic-all -serviceability/sa/sadebugd/SADebugDTest.java 8307393 generic-all vmTestbase/gc/gctests/MemoryEaterMT/MemoryEaterMT.java 8289582 windows-x64 diff --git a/test/hotspot/jtreg/compiler/arguments/TestUseSHA3IntrinsicsWithUseSHADisabledOnSupportedCPU.java b/test/hotspot/jtreg/compiler/arguments/TestUseSHA3IntrinsicsWithUseSHADisabledOnSupportedCPU.java index cf8000b7a21..10be61e98ec 100644 --- a/test/hotspot/jtreg/compiler/arguments/TestUseSHA3IntrinsicsWithUseSHADisabledOnSupportedCPU.java +++ b/test/hotspot/jtreg/compiler/arguments/TestUseSHA3IntrinsicsWithUseSHADisabledOnSupportedCPU.java @@ -52,7 +52,7 @@ public class TestUseSHA3IntrinsicsWithUseSHADisabledOnSupportedCPU { private static final String UNLOCK_DIAGNOSTIC = "-XX:+UnlockDiagnosticVMOptions"; public static void main(String[] args) throws Throwable { - if (!IntrinsicPredicates.SHA3_INSTRUCTION_AVAILABLE.getAsBoolean()) { + if (!IntrinsicPredicates.SHA3_INTRINSIC_AVAILABLE.getAsBoolean()) { throw new SkippedException("Skipping... SHA3 intrinsics are not available on this platform."); } @@ -111,7 +111,7 @@ public class TestUseSHA3IntrinsicsWithUseSHADisabledOnSupportedCPU { private static void testWarningWhenEnablingWithUseSHADisabled() throws Throwable { // A warning should be printed when trying to enable UseSHA3Intrinsics with -UseSHA CommandLineOptionTest.verifySameJVMStartup( - new String[] { WARNING_MESSAGE }, // Warning should appear + new String[] { "warning" }, // Warning should appear null, // No unexpected output "JVM should start successfully", String.format("A warning should be printed when trying to enable %s while %s is disabled", diff --git a/test/hotspot/jtreg/compiler/arguments/TestUseSHA3IntrinsicsWithUseSHADisabledOnUnsupportedCPU.java b/test/hotspot/jtreg/compiler/arguments/TestUseSHA3IntrinsicsWithUseSHADisabledOnUnsupportedCPU.java index 1e0df1874b6..ebada79c877 100644 --- a/test/hotspot/jtreg/compiler/arguments/TestUseSHA3IntrinsicsWithUseSHADisabledOnUnsupportedCPU.java +++ b/test/hotspot/jtreg/compiler/arguments/TestUseSHA3IntrinsicsWithUseSHADisabledOnUnsupportedCPU.java @@ -51,7 +51,7 @@ public class TestUseSHA3IntrinsicsWithUseSHADisabledOnUnsupportedCPU { private static final String UNLOCK_DIAGNOSTIC = "-XX:+UnlockDiagnosticVMOptions"; public static void main(String[] args) throws Throwable { - if (IntrinsicPredicates.SHA3_INSTRUCTION_AVAILABLE.getAsBoolean()) { + if (IntrinsicPredicates.SHA3_INTRINSIC_AVAILABLE.getAsBoolean()) { throw new SkippedException("Skipping... SHA3 intrinsics are available on this platform."); } diff --git a/test/hotspot/jtreg/compiler/c2/TestSwitchStackOverflow.java b/test/hotspot/jtreg/compiler/c2/TestSwitchStackOverflow.java new file mode 100644 index 00000000000..adbfa537aed --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/TestSwitchStackOverflow.java @@ -0,0 +1,99 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 2026, 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 8366138 + * @summary C2: jump_switch_ranges could cause stack overflow when compiling + * huge switch statement with zero-count profiling data. + * @library /test/lib / + * @run main/othervm ${test.main.class} + * @run main/othervm -Xbatch -XX:CompileOnly=Test::test -XX:-DontCompileHugeMethods -XX:CompilerThreadStackSize=512 ${test.main.class} + * @run main/othervm -Xbatch -XX:CompileOnly=Test::test -XX:+DontCompileHugeMethods -XX:CompilerThreadStackSize=512 ${test.main.class} + */ + +package compiler.c2; + +import java.util.stream.Stream; + +import compiler.lib.compile_framework.CompileFramework; +import compiler.lib.template_framework.Template; +import static compiler.lib.template_framework.Template.scope; + +public class TestSwitchStackOverflow { + // Template method exceeds HugeMethodLimit, hence -XX:-DontCompileHugeMethods. + // 5000 cases + CompilerThreadStackSize=512 reliably overflows without the fix. + static final int NUM_CASES = 5000; + + // Generate a class with a large tableswitch method and a main that + // triggers recompilation with zero-count profiling data: + // Phase 1: warm up with default-only path -> C2 compiles + // Phase 2: hit a case -> triggers unstable_if deopt + // Phase 3: recompile with all counts zero (except the default case) + static String generate() { + var caseTemplate = Template.make("i", (Integer i) -> scope( + """ + case #i: + return #i; + """ + )); + var test = Template.make(() -> scope( + """ + public class Test { + static int test(int x) { + switch (x) { + """, + Stream.iterate(0, i -> i + 1) + .limit(NUM_CASES) + .map(i -> caseTemplate.asToken(i)) + .toList(), + """ + default: return -1; + } + } + + public static void main(String[] args) { + for (int i = 0; i < 10_000; i++) { + test(-1); + } + test(42); + for (int i = 0; i < 10_000; i++) { + test(-1); + } + System.out.println("Done"); + } + } + """ + )); + + return test.render(); + } + + public static void main(String[] args) { + CompileFramework comp = new CompileFramework(); + comp.addJavaSourceCode("Test", generate()); + comp.compile(); + comp.invoke("Test", "main", new Object[] { new String[0] }); + } +} diff --git a/test/hotspot/jtreg/compiler/c2/gvn/MissedURShiftIAddILShiftIdeal.java b/test/hotspot/jtreg/compiler/c2/gvn/MissedURShiftIAddILShiftIdeal.java new file mode 100644 index 00000000000..a1f4f011466 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/gvn/MissedURShiftIAddILShiftIdeal.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package compiler.c2.gvn; + +import compiler.lib.ir_framework.*; +import jdk.test.lib.Asserts; +import jdk.test.lib.Utils; +import java.util.Random; + +/* + * @test + * @bug 8378413 + * @key randomness + * @summary Verify that URShift{I,L}Node::Ideal optimizes ((x << C) + y) >>> C + * regardless of Add input order, i.e. it is commutative w.r.t. the addition. + * @library /test/lib / + * @run driver ${test.main.class} + * @run driver ${test.main.class} -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions + * -XX:VerifyIterativeGVN=1110 -Xbatch -XX:CompileCommand=compileonly,${test.main.class}::* + */ +public class MissedURShiftIAddILShiftIdeal { + + private static final Random RANDOM = Utils.getRandomInstance(); + + public static void main(String[] args) { + TestFramework.run(); + } + + @Run(test = {"testI", "testICommuted", "testIComputedY", + "testL", "testLCommuted", "testLComputedY"}) + public void runMethod() { + int xi = RANDOM.nextInt(); + int yi = RANDOM.nextInt(); + int ai = RANDOM.nextInt(); + int bi = RANDOM.nextInt(); + long xl = RANDOM.nextLong(); + long yl = RANDOM.nextLong(); + long al = RANDOM.nextLong(); + long bl = RANDOM.nextLong(); + + assertResultI(xi, yi, ai, bi); + assertResultL(xl, yl, al, bl); + } + + @DontCompile + public void assertResultI(int x, int y, int a, int b) { + Asserts.assertEQ(((x << 3) + y) >>> 3, testI(x, y)); + Asserts.assertEQ((y + (x << 5)) >>> 5, testICommuted(x, y)); + Asserts.assertEQ(((x << 7) + (a ^ b)) >>> 7, testIComputedY(x, a, b)); + } + + @DontCompile + public void assertResultL(long x, long y, long a, long b) { + Asserts.assertEQ(((x << 9) + y) >>> 9, testL(x, y)); + Asserts.assertEQ((y + (x << 11)) >>> 11, testLCommuted(x, y)); + Asserts.assertEQ(((x << 13) + (a ^ b)) >>> 13, testLComputedY(x, a, b)); + } + + @Test + // ((x << 3) + y) >>> 3 => (x + (y >>> 3)) & mask + @IR(counts = {IRNode.LSHIFT_I, "0", + IRNode.URSHIFT_I, "1", + IRNode.AND_I, "1"}) + static int testI(int x, int y) { + return ((x << 3) + y) >>> 3; + } + + @Test + // (y + (x << 5)) >>> 5 => (x + (y >>> 5)) & mask (commuted Add) + @IR(counts = {IRNode.LSHIFT_I, "0", + IRNode.URSHIFT_I, "1", + IRNode.AND_I, "1"}) + static int testICommuted(int x, int y) { + return (y + (x << 5)) >>> 5; + } + + @Test + // ((x << 7) + (a ^ b)) >>> 7 => (x + ((a ^ b) >>> 7)) & mask + // Computed y (a ^ b) has higher _idx than LShift, so LShift stays in Add's in(1). + @IR(counts = {IRNode.LSHIFT_I, "0", + IRNode.URSHIFT_I, "1", + IRNode.AND_I, "1"}) + static int testIComputedY(int x, int a, int b) { + return ((x << 7) + (a ^ b)) >>> 7; + } + + @Test + // ((x << 9) + y) >>> 9 => (x + (y >>> 9)) & mask + @IR(counts = {IRNode.LSHIFT_L, "0", + IRNode.URSHIFT_L, "1", + IRNode.AND_L, "1"}) + static long testL(long x, long y) { + return ((x << 9) + y) >>> 9; + } + + @Test + // (y + (x << 11)) >>> 11 => (x + (y >>> 11)) & mask (commuted Add) + @IR(counts = {IRNode.LSHIFT_L, "0", + IRNode.URSHIFT_L, "1", + IRNode.AND_L, "1"}) + static long testLCommuted(long x, long y) { + return (y + (x << 11)) >>> 11; + } + + @Test + // ((x << 13) + (a ^ b)) >>> 13 => (x + ((a ^ b) >>> 13)) & mask + // Computed y (a ^ b) has higher _idx than LShift, so LShift stays in Add's in(1). + @IR(counts = {IRNode.LSHIFT_L, "0", + IRNode.URSHIFT_L, "1", + IRNode.AND_L, "1"}) + static long testLComputedY(long x, long a, long b) { + return ((x << 13) + (a ^ b)) >>> 13; + } +} diff --git a/test/hotspot/jtreg/compiler/intrinsics/sha/cli/DigestOptionsBase.java b/test/hotspot/jtreg/compiler/intrinsics/sha/cli/DigestOptionsBase.java index 22b3bba854c..b8a3896294b 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/sha/cli/DigestOptionsBase.java +++ b/test/hotspot/jtreg/compiler/intrinsics/sha/cli/DigestOptionsBase.java @@ -122,7 +122,7 @@ public class DigestOptionsBase extends CommandLineOptionTest { case DigestOptionsBase.USE_SHA512_INTRINSICS_OPTION: return IntrinsicPredicates.isSHA512IntrinsicAvailable(); case DigestOptionsBase.USE_SHA3_INTRINSICS_OPTION: - return IntrinsicPredicates.SHA3_INSTRUCTION_AVAILABLE; + return IntrinsicPredicates.SHA3_INTRINSIC_AVAILABLE; default: throw new Error("Unexpected option " + optionName); } diff --git a/test/hotspot/jtreg/compiler/intrinsics/sha/cli/TestUseSHA3IntrinsicsOptionOnSupportedCPU.java b/test/hotspot/jtreg/compiler/intrinsics/sha/cli/TestUseSHA3IntrinsicsOptionOnSupportedCPU.java index d3c0a4a8da7..c47591d75da 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/sha/cli/TestUseSHA3IntrinsicsOptionOnSupportedCPU.java +++ b/test/hotspot/jtreg/compiler/intrinsics/sha/cli/TestUseSHA3IntrinsicsOptionOnSupportedCPU.java @@ -28,10 +28,7 @@ * @summary Verify UseSHA3Intrinsics option processing on supported CPU. * @library /test/lib / * @requires vm.flagless - * @requires os.arch == "aarch64" & os.family == "mac" - * @comment sha3 is only implemented on AArch64 for now. - * UseSHA3Intrinsics is only auto-enabled on Apple silicon, because it - * may introduce performance regression on others. See JDK-8297092. + * @requires (os.arch == "aarch64" | os.arch == "amd64" | os.arch == "x86_64") * * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java b/test/hotspot/jtreg/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java index 4b3914e75fd..f1c7069c317 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java +++ b/test/hotspot/jtreg/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java @@ -80,7 +80,8 @@ public class GenericTestCaseForSupportedCPU extends // Verify that if -XX:-UseSHA is passed to the JVM, it is not possible // to enable the tested option and a warning is printed. CommandLineOptionTest.verifySameJVMStartup( - new String[] { DigestOptionsBase.getWarningForUnsupportedCPU(optionName) }, + new String[] { "warning: " }, // Accept any warning message, e.g. "requires that UseSHA is enabled" + // or the common "not available on this CPU" message. null, shouldPassMessage, String.format("Enabling option '%s' should not be possible and should result in a warning if %s was passed to JVM", diff --git a/test/hotspot/jtreg/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedCPU.java b/test/hotspot/jtreg/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedCPU.java index 85f6f280ccb..b2a0720e6e8 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedCPU.java +++ b/test/hotspot/jtreg/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedCPU.java @@ -71,7 +71,8 @@ public class GenericTestCaseForUnsupportedCPU extends // a warning will occur in VM output if UseSHA is disabled. if (!optionName.equals(DigestOptionsBase.USE_SHA_OPTION)) { CommandLineOptionTest.verifySameJVMStartup( - new String[] { DigestOptionsBase.getWarningForUnsupportedCPU(optionName) }, + new String[] { "warning: " }, // Accept any warning message, e.g. "requires that UseSHA is enabled" + // or the common "not available on this CPU" message. null, shouldPassMessage, shouldPassMessage, diff --git a/test/hotspot/jtreg/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java b/test/hotspot/jtreg/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java index 0c53c36af1d..b088f58bb5b 100644 --- a/test/hotspot/jtreg/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java +++ b/test/hotspot/jtreg/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java @@ -109,6 +109,12 @@ public class IntrinsicPredicates { new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] {"avx512f", "avx512bw"}, null), new CPUSpecificPredicate("x86_64", new String[] {"avx512f", "avx512bw"}, null))); + public static final BooleanSupplier SHA3_INTRINSIC_AVAILABLE + // AArch64 has both SHA3-based and GPR-based implementations of the SHA3 intrinsic. No need for the SHA3 capability. + = new OrPredicate(new CPUSpecificPredicate("aarch64.*", null, null), + new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] {"avx512f", "avx512bw"}, null), + new CPUSpecificPredicate("x86_64", new String[] {"avx512f", "avx512bw"}, null))); + public static final BooleanSupplier ANY_SHA_INSTRUCTION_AVAILABLE = new OrPredicate(IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE, new OrPredicate(IntrinsicPredicates.SHA256_INSTRUCTION_AVAILABLE, diff --git a/test/hotspot/jtreg/compiler/vectorapi/TestVectorMaskToLongStress.java b/test/hotspot/jtreg/compiler/vectorapi/TestVectorMaskToLongStress.java new file mode 100644 index 00000000000..f9807754539 --- /dev/null +++ b/test/hotspot/jtreg/compiler/vectorapi/TestVectorMaskToLongStress.java @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2026, 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 8375688 + * @key randomness + * @library /test/lib / + * @summary VectorMaskToLong constant folding through VectorStoreMask must work under StressIncrementalInlining + * @modules jdk.incubator.vector + * + * @run driver ${test.main.class} + */ + +package compiler.vectorapi; + +import compiler.lib.ir_framework.*; +import jdk.incubator.vector.*; +import jdk.test.lib.Asserts; + +/** + * Tests that VectorMaskToLongNode::Ideal_MaskAll folds constant masks even + * when StressIncrementalInlining randomizes the IGVN worklist order. + * + * Each test method does {@code VectorMask.fromLong(SPECIES, constant).toLong()} + * and asserts that VectorMaskToLong is folded away entirely (count = 0). + * + * Ideal_MaskAll looks through VectorStoreMask to inspect its input. Without the worklist + * propagation fix in PhaseIterGVN::add_users_of_use_to_worklist (JDK-8375688), VectorMaskToLong + * is not re-visited after VectorStoreMask's input becomes a recognized constant, + * leaving the fold opportunity missed. + * + * IR rules cover three hardware paths: + * - AVX-512/SVE/RVV: masks fold through MaskAll (correctness check only, VectorStoreMask + * is not involved on these platforms) + * - AVX2 without AVX-512: masks go through VectorStoreMask, directly exercising the worklist fix + * - ASIMD without SVE: same VectorStoreMask path, on AArch64 + * + * {@code @Check} methods verify correctness on all platforms, including those where no IR rule applies. + * Float/Double species are excluded because VectorMaskToLong fails to fold their masks + * due to an intervening VectorMaskCast (JDK-8377588). + */ +public class TestVectorMaskToLongStress { + static final VectorSpecies B_SPECIES = ByteVector.SPECIES_MAX; + static final VectorSpecies S_SPECIES = ShortVector.SPECIES_MAX; + static final VectorSpecies I_SPECIES = IntVector.SPECIES_MAX; + static final VectorSpecies L_SPECIES = LongVector.SPECIES_MAX; + + // --- All-ones mask: fromLong(-1).toLong() should fold to a constant --- + + @Test + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureOr = { "avx512", "true", "sve", "true", "rvv", "true" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "avx2", "true", "avx512", "false" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "asimd", "true", "sve", "false" }) + public static long testAllOnesByte() { + return VectorMask.fromLong(B_SPECIES, -1L).toLong(); + } + + @Test + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureOr = { "avx512", "true", "sve", "true", "rvv", "true" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "avx2", "true", "avx512", "false" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "asimd", "true", "sve", "false" }) + public static long testAllOnesShort() { + return VectorMask.fromLong(S_SPECIES, -1L).toLong(); + } + + @Test + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureOr = { "avx512", "true", "sve", "true", "rvv", "true" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "avx2", "true", "avx512", "false" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "asimd", "true", "sve", "false" }) + public static long testAllOnesInt() { + return VectorMask.fromLong(I_SPECIES, -1L).toLong(); + } + + @Test + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureOr = { "avx512", "true", "sve", "true", "rvv", "true" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "avx2", "true", "avx512", "false" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "asimd", "true", "sve", "false" }) + public static long testAllOnesLong() { + return VectorMask.fromLong(L_SPECIES, -1L).toLong(); + } + + // --- All-zeros mask: fromLong(0).toLong() should fold to a constant --- + + @Test + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureOr = { "avx512", "true", "sve", "true", "rvv", "true" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "avx2", "true", "avx512", "false" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "asimd", "true", "sve", "false" }) + public static long testAllZerosByte() { + return VectorMask.fromLong(B_SPECIES, 0L).toLong(); + } + + @Test + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureOr = { "avx512", "true", "sve", "true", "rvv", "true" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "avx2", "true", "avx512", "false" }) + @IR(counts = { IRNode.VECTOR_MASK_TO_LONG, "= 0" }, + applyIfCPUFeatureAnd = { "asimd", "true", "sve", "false" }) + public static long testAllZerosInt() { + return VectorMask.fromLong(I_SPECIES, 0L).toLong(); + } + + // --- Verification --- + + @Check(test = "testAllOnesByte") + public static void checkAllOnesByte(long result) { + Asserts.assertEquals(-1L >>> (64 - B_SPECIES.length()), result); + } + + @Check(test = "testAllOnesShort") + public static void checkAllOnesShort(long result) { + Asserts.assertEquals(-1L >>> (64 - S_SPECIES.length()), result); + } + + @Check(test = "testAllOnesInt") + public static void checkAllOnesInt(long result) { + Asserts.assertEquals(-1L >>> (64 - I_SPECIES.length()), result); + } + + @Check(test = "testAllOnesLong") + public static void checkAllOnesLong(long result) { + Asserts.assertEquals(-1L >>> (64 - L_SPECIES.length()), result); + } + + @Check(test = "testAllZerosByte") + public static void checkAllZerosByte(long result) { + Asserts.assertEquals(0L, result); + } + + @Check(test = "testAllZerosInt") + public static void checkAllZerosInt(long result) { + Asserts.assertEquals(0L, result); + } + + public static void main(String[] args) { + TestFramework testFramework = new TestFramework(); + testFramework.addFlags("--add-modules=jdk.incubator.vector", + "-XX:+IgnoreUnrecognizedVMOptions", + "-XX:+StressIncrementalInlining", + "-XX:CompileCommand=compileonly,compiler.vectorapi.TestVectorMaskToLongStress::*", + "-XX:VerifyIterativeGVN=1110") + .start(); + } +} diff --git a/test/hotspot/jtreg/compiler/vectorapi/VectorUMinMaxReductionTest.java b/test/hotspot/jtreg/compiler/vectorapi/VectorUMinMaxReductionTest.java index 1c8cc34170e..4c753d91afd 100644 --- a/test/hotspot/jtreg/compiler/vectorapi/VectorUMinMaxReductionTest.java +++ b/test/hotspot/jtreg/compiler/vectorapi/VectorUMinMaxReductionTest.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -140,7 +141,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMIN_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testByteUMin() { byte got = ByteVector.fromArray(B_SPECIES, ba, 0).reduceLanes(VectorOperators.UMIN); verifyByte(B_SPECIES, got, BYTE_UMIN_IDENTITY, VectorMath::minUnsigned, false); @@ -148,7 +149,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMAX_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testByteUMax() { byte got = ByteVector.fromArray(B_SPECIES, ba, 0).reduceLanes(VectorOperators.UMAX); verifyByte(B_SPECIES, got, BYTE_UMAX_IDENTITY, VectorMath::maxUnsigned, false); @@ -156,7 +157,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMIN_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testByteUMinMasked() { byte got = ByteVector.fromArray(B_SPECIES, ba, 0) .reduceLanes(VectorOperators.UMIN, @@ -166,7 +167,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMAX_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testByteUMaxMasked() { byte got = ByteVector.fromArray(B_SPECIES, ba, 0) .reduceLanes(VectorOperators.UMAX, @@ -178,7 +179,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMIN_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testShortUMin() { short got = ShortVector.fromArray(S_SPECIES, sa, 0).reduceLanes(VectorOperators.UMIN); verifyShort(S_SPECIES, got, SHORT_UMIN_IDENTITY, VectorMath::minUnsigned, false); @@ -186,7 +187,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMAX_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testShortUMax() { short got = ShortVector.fromArray(S_SPECIES, sa, 0).reduceLanes(VectorOperators.UMAX); verifyShort(S_SPECIES, got, SHORT_UMAX_IDENTITY, VectorMath::maxUnsigned, false); @@ -194,7 +195,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMIN_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testShortUMinMasked() { short got = ShortVector.fromArray(S_SPECIES, sa, 0) .reduceLanes(VectorOperators.UMIN, @@ -204,7 +205,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMAX_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testShortUMaxMasked() { short got = ShortVector.fromArray(S_SPECIES, sa, 0) .reduceLanes(VectorOperators.UMAX, @@ -216,7 +217,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMIN_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testIntUMin() { int got = IntVector.fromArray(I_SPECIES, ia, 0).reduceLanes(VectorOperators.UMIN); verifyInt(I_SPECIES, got, INT_UMIN_IDENTITY, VectorMath::minUnsigned, false); @@ -224,7 +225,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMAX_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testIntUMax() { int got = IntVector.fromArray(I_SPECIES, ia, 0).reduceLanes(VectorOperators.UMAX); verifyInt(I_SPECIES, got, INT_UMAX_IDENTITY, VectorMath::maxUnsigned, false); @@ -232,7 +233,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMIN_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testIntUMinMasked() { int got = IntVector.fromArray(I_SPECIES, ia, 0) .reduceLanes(VectorOperators.UMIN, @@ -242,7 +243,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMAX_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"}) public static void testIntUMaxMasked() { int got = IntVector.fromArray(I_SPECIES, ia, 0) .reduceLanes(VectorOperators.UMAX, @@ -254,7 +255,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMIN_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx512vl", "true"}) public static void testLongUMin() { long got = LongVector.fromArray(L_SPECIES, la, 0).reduceLanes(VectorOperators.UMIN); verifyLong(L_SPECIES, got, LONG_UMIN_IDENTITY, VectorMath::minUnsigned, false); @@ -262,7 +263,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMAX_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx512vl", "true"}) public static void testLongUMax() { long got = LongVector.fromArray(L_SPECIES, la, 0).reduceLanes(VectorOperators.UMAX); verifyLong(L_SPECIES, got, LONG_UMAX_IDENTITY, VectorMath::maxUnsigned, false); @@ -270,7 +271,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMIN_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx512vl", "true"}) public static void testLongUMinMasked() { long got = LongVector.fromArray(L_SPECIES, la, 0) .reduceLanes(VectorOperators.UMIN, @@ -280,7 +281,7 @@ public class VectorUMinMaxReductionTest { @Test @IR(counts = {IRNode.UMAX_REDUCTION_V, "= 1"}, - applyIfCPUFeature = {"asimd", "true"}) + applyIfCPUFeatureOr = {"asimd", "true", "avx512vl", "true"}) public static void testLongUMaxMasked() { long got = LongVector.fromArray(L_SPECIES, la, 0) .reduceLanes(VectorOperators.UMAX, diff --git a/test/hotspot/jtreg/compiler/vectorization/TestVectorAlgorithms.java b/test/hotspot/jtreg/compiler/vectorization/TestVectorAlgorithms.java index e02563c2fc2..785a6de30a0 100644 --- a/test/hotspot/jtreg/compiler/vectorization/TestVectorAlgorithms.java +++ b/test/hotspot/jtreg/compiler/vectorization/TestVectorAlgorithms.java @@ -272,8 +272,10 @@ public class TestVectorAlgorithms { @Test @IR(counts = {IRNode.ADD_VI, "> 0", IRNode.STORE_VECTOR, "> 0"}, - applyIfCPUFeature = {"sse4.1", "true"}) - // Note: also works with NEON/asimd, but only with TieredCompilation. + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, + applyIf = {"TieredCompilation", "true"}) + // IR check only works with TieredCompilation. Needs to make it + // work with -XX:-TieredCompilation in future (see JDK-8378640). public Object iotaI_VectorAPI(int[] r) { return VectorAlgorithmsImpl.iotaI_VectorAPI(r); } @@ -360,7 +362,7 @@ public class TestVectorAlgorithms { @IR(counts = {IRNode.LOAD_VECTOR_F, "> 0", IRNode.ADD_REDUCTION_V, "> 0", IRNode.MUL_VF, "> 0"}, - applyIfCPUFeature = {"sse4.1", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, applyIf = {"UseSuperWord", "true"}) public float dotProductF_VectorAPI_naive(float[] a, float[] b) { return VectorAlgorithmsImpl.dotProductF_VectorAPI_naive(a, b); @@ -370,7 +372,7 @@ public class TestVectorAlgorithms { @IR(counts = {IRNode.LOAD_VECTOR_F, "> 0", IRNode.ADD_REDUCTION_V, "> 0", IRNode.MUL_VF, "> 0"}, - applyIfCPUFeature = {"sse4.1", "true"}, + applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"}, applyIf = {"UseSuperWord", "true"}) public float dotProductF_VectorAPI_reduction_after_loop(float[] a, float[] b) { return VectorAlgorithmsImpl.dotProductF_VectorAPI_reduction_after_loop(a, b); @@ -392,7 +394,8 @@ public class TestVectorAlgorithms { IRNode.MUL_VI, IRNode.VECTOR_SIZE_8, "> 0", IRNode.ADD_VI, IRNode.VECTOR_SIZE_8, "> 0", IRNode.ADD_REDUCTION_VI, "> 0"}, - applyIfCPUFeature = {"avx2", "true"}) + applyIfCPUFeatureOr = {"avx2", "true", "sve", "true"}, + applyIf = {"MaxVectorSize", ">=32"}) public int hashCodeB_VectorAPI_v1(byte[] a) { return VectorAlgorithmsImpl.hashCodeB_VectorAPI_v1(a); } @@ -402,7 +405,7 @@ public class TestVectorAlgorithms { IRNode.MUL_VI, "> 0", IRNode.ADD_VI, "> 0", IRNode.ADD_REDUCTION_VI, "> 0"}, - applyIfCPUFeature = {"avx2", "true"}) + applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"}) public int hashCodeB_VectorAPI_v2(byte[] a) { return VectorAlgorithmsImpl.hashCodeB_VectorAPI_v2(a); } @@ -506,7 +509,7 @@ public class TestVectorAlgorithms { IRNode.VECTOR_TEST, "> 0", IRNode.COMPRESS_VI, "> 0", IRNode.STORE_VECTOR_MASKED, "> 0"}, - applyIfCPUFeature = {"avx2", "true"}) + applyIfCPUFeatureOr = {"avx2", "true", "sve", "true"}) public Object filterI_VectorAPI(int[] a, int[] r, int threshold) { return VectorAlgorithmsImpl.filterI_VectorAPI(a, r, threshold); } @@ -526,7 +529,10 @@ public class TestVectorAlgorithms { IRNode.OR_V_MASK, "> 0", IRNode.ADD_VI, "> 0", IRNode.ADD_REDUCTION_VI, "> 0"}, - applyIfCPUFeatureOr = {"avx512", "true", "sve", "true"}) + applyIfCPUFeatureOr = {"avx512", "true", "sve", "true"}, + applyIf = {"TieredCompilation", "true"}) + // IR check only works with TieredCompilation. Needs to make it + // work with -XX:-TieredCompilation in future (see JDK-8378640). public int reduceAddIFieldsX4_VectorAPI(int[] oops, int[] mem) { return VectorAlgorithmsImpl.reduceAddIFieldsX4_VectorAPI(oops, mem); } diff --git a/test/hotspot/jtreg/resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java b/test/hotspot/jtreg/resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java index 553b8fbac35..cf32880c182 100644 --- a/test/hotspot/jtreg/resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java +++ b/test/hotspot/jtreg/resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,9 @@ import jdk.test.lib.Utils; * @test * @library /test/lib * @bug 8171084 - * @requires vm.hasSA & (vm.bits == "64" & os.maxMemory > 8g) + * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires vm.bits == "64" & os.maxMemory > 8g * @modules java.base/jdk.internal.misc * jdk.hotspot.agent/sun.jvm.hotspot * jdk.hotspot.agent/sun.jvm.hotspot.utilities diff --git a/test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java b/test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java index 4fd202a18da..8a9f148b3be 100644 --- a/test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java +++ b/test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +25,9 @@ * @test * @bug 8204308 * @summary Test the jhsdb jmap -clstats command with CDS enabled - * @requires vm.hasSA & vm.cds + * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires vm.cds * @library /test/lib * @run driver/timeout=2400 CDSJMapClstats */ diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbAttach.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbAttach.java index 57cd535a430..6493a803e90 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbAttach.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbAttach.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @bug 8191658 * @summary Test clhsdb attach, detach, reattach commands * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbAttach diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbAttachDifferentJVMs.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbAttachDifferentJVMs.java index 09f90355e67..f6833d5379a 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbAttachDifferentJVMs.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbAttachDifferentJVMs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @bug 8314679 * @summary Test clhsdb attach, detach, and then attach to different JVM * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbAttachDifferentJVMs diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java index aa3b19c4fcf..ab5b73bf720 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java @@ -25,8 +25,9 @@ * @test * @bug 8174994 8200613 * @summary Test the clhsdb commands 'printall', 'jstack' on a CDS enabled corefile. - * @requires vm.cds * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires vm.cds * @requires vm.flavor == "server" * @library /test/lib * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java index 4d01f9a26c8..c1e632782e2 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +25,9 @@ * @test * @bug 8174994 * @summary Test the clhsdb commands 'jstack', 'printall', 'where' with CDS enabled - * @requires vm.hasSA & vm.cds + * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires vm.cds * @library /test/lib * @run main/othervm/timeout=2400 -Xmx1g ClhsdbCDSJstackPrintAll */ diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbClasses.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbClasses.java index 3193f03bbc7..c4d11d29ec1 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbClasses.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbClasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @bug 8242142 * @summary Test clhsdb class and classes commands * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbClasses diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpclass.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpclass.java index e45318e201d..49a3eb5615c 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpclass.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpclass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, 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 jtreg.SkippedException; * @bug 8240990 * @summary Test clhsdb dumpclass command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run driver ClhsdbDumpclass diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpheap.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpheap.java index d9f856ab0a3..92ec1c5d160 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpheap.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpheap.java @@ -43,6 +43,7 @@ import jtreg.SkippedException; * @bug 8240989 * @summary Test clhsdb dumpheap command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires vm.compMode != "Xcomp" * @comment Running this test with -Xcomp is slow and therefore tends to cause diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbField.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbField.java index 7dc676f1f3a..1df35dccce3 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbField.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbField.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ import jtreg.SkippedException; * @bug 8191538 * @summary Test clhsdb 'field' command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbField diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java index 7ced4c9515b..1997e497af8 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,8 +35,9 @@ import jtreg.SkippedException; * @test id=xcomp-process * @bug 8193124 * @summary Test the clhsdb 'findpc' command with Xcomp on live process - * @requires vm.compMode != "Xcomp" * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires vm.compMode != "Xcomp" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires vm.compiler1.enabled * @requires vm.opt.DeoptimizeALot != true @@ -48,8 +49,9 @@ import jtreg.SkippedException; * @test id=xcomp-core * @bug 8193124 * @summary Test the clhsdb 'findpc' command with Xcomp on core file - * @requires vm.compMode != "Xcomp" * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires vm.compMode != "Xcomp" * @requires vm.compiler1.enabled * @requires vm.opt.DeoptimizeALot != true * @library /test/lib @@ -61,6 +63,7 @@ import jtreg.SkippedException; * @bug 8193124 * @summary Test the clhsdb 'findpc' command w/o Xcomp on live process * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires vm.compiler1.enabled * @library /test/lib @@ -72,6 +75,7 @@ import jtreg.SkippedException; * @bug 8193124 * @summary Test the clhsdb 'findpc' command w/o Xcomp on core file * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires vm.compiler1.enabled * @library /test/lib * @run main/othervm/timeout=1920 ClhsdbFindPC false true diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java index a19f3e1ca16..1c8cf7191dd 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,7 @@ import jtreg.SkippedException; * @bug 8217845 * @summary Test clhsdb flags command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run driver ClhsdbFlags diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbHistory.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbHistory.java index e8416cbadd8..5dabb898936 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbHistory.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbHistory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,7 @@ import jtreg.SkippedException; * @bug 8217845 * @summary Test clhsdb command line history support * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbHistory diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java index 553706e502d..c0c062223d4 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java @@ -26,6 +26,7 @@ * @bug 8192985 * @summary Test the clhsdb 'inspect' command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm/timeout=480 ClhsdbInspect diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbJdis.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbJdis.java index 756e45f68aa..6c0ff0e3dbe 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJdis.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJdis.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 8193124 * @summary Test the clhsdb 'jdis' command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbJdis diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbJhisto.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbJhisto.java index ef30a97a026..a582b01e832 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJhisto.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJhisto.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 @@ import jtreg.SkippedException; * @bug 8191658 * @summary Test clhsdb jhisto command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbJhisto diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java index 411664f195d..f066950cfc3 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @bug 8190198 * @summary Test clhsdb Jstack command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm/timeout=480 ClhsdbJstack true @@ -44,6 +45,7 @@ import jtreg.SkippedException; * @requires vm.compMode != "Xcomp" * @summary Test clhsdb Jstack command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm/timeout=480 ClhsdbJstack false diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackWithConcurrentLock.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackWithConcurrentLock.java index 64080b252c5..e3d586c9d8a 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackWithConcurrentLock.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackWithConcurrentLock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 8324066 * @summary Test the clhsdb 'jstack -l' command for printing concurrent lock information * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbJstackWithConcurrentLock diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackXcompStress.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackXcompStress.java index 4b02c01119d..a24b401dc47 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackXcompStress.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackXcompStress.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,6 +36,7 @@ import jdk.test.lib.process.OutputAnalyzer; * @test * @bug 8196969 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires vm.opt.DeoptimizeALot != true * @library /test/lib diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java index fceb2097e46..7fd3eb23d02 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 8190198 * @summary Test clhsdb longConstant command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbLongConstant diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java index 5c0aa9457ae..885694f7abb 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 @@ import jtreg.SkippedException; * @bug 8190198 * @summary Test clhsdb pmap command on a live process * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbPmap false @@ -45,6 +46,7 @@ import jtreg.SkippedException; * @bug 8190198 * @summary Test clhsdb pmap command on a core file * @requires vm.hasSA + * @requires vm.gc != "Z" * @library /test/lib * @run main/othervm/timeout=480 ClhsdbPmap true */ diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAll.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAll.java index ac5ddf774e1..a62142c2c5c 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAll.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAll.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ import jtreg.SkippedException; * @bug 8175384 * @summary Test clhsdb 'printall' command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm/timeout=2400 -Xmx2g ClhsdbPrintAll diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAs.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAs.java index 03ce8cd3048..c7e7e979b6d 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAs.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 8192985 * @summary Test the clhsdb 'printas' command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbPrintAs diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintStatics.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintStatics.java index c6f83c06845..e68e3ca4c47 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintStatics.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintStatics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @bug 8190198 * @summary Test clhsdb printstatics command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbPrintStatics diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java index 15d88400917..51738be3554 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 @@ import jtreg.SkippedException; * @bug 8190198 * @summary Test clhsdb pstack command on a live process * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbPstack false @@ -45,6 +46,7 @@ import jtreg.SkippedException; * @bug 8190198 * @summary Test clhsdb pstack command on a core file * @requires vm.hasSA + * @requires vm.gc != "Z" * @library /test/lib * @run main/othervm/timeout=480 ClhsdbPstack true */ diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java index 3b2aefec664..89c033f333a 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,8 +25,8 @@ * @test id=parallel * @bug 8192985 * @summary Test the clhsdb 'scanoops' command - * @requires vm.gc.Parallel * @requires vm.hasSA + * @requires vm.gc.Parallel * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm/timeout=1200 ClhsdbScanOops UseParallelGC @@ -36,8 +36,8 @@ * @test id=serial * @bug 8192985 * @summary Test the clhsdb 'scanoops' command - * @requires vm.gc.Serial * @requires vm.hasSA + * @requires vm.gc.Serial * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm/timeout=1200 ClhsdbScanOops UseSerialGC diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbSource.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbSource.java index c66e44aa213..8ec946e3ea1 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbSource.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,7 @@ import jtreg.SkippedException; * @bug 8192823 * @summary Test clhsdb source command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbSource diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbSymbol.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbSymbol.java index fe26427d6ce..ca05ba1d33e 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbSymbol.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbSymbol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import java.util.Map; * @bug 8261095 * @summary Test the clhsdb 'symbol' command on live process * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbSymbol diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbTestAllocationMerge.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbTestAllocationMerge.java index d076e648d90..05054f31c51 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbTestAllocationMerge.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbTestAllocationMerge.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ import jtreg.SkippedException; * @bug 8318682 * @summary Test clhsdb that decoding of AllocationMerge objects in debug info works correctly * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbTestAllocationMerge diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbThread.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbThread.java index f72b51585f5..e9a0b611134 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbThread.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbThread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @bug 8193352 * @summary Test clhsdb 'thread' and 'threads' commands * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbThread diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbThreadContext.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbThreadContext.java index 5c3092a139d..c452575b782 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbThreadContext.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbThreadContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @test * @summary Test clhsdb where command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm/timeout=480 ClhsdbThreadContext diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbVmStructsDump.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbVmStructsDump.java index 21db0e867a4..b00138e0c39 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbVmStructsDump.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbVmStructsDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ import jtreg.SkippedException; * @bug 8191538 * @summary Test clhsdb 'vmstructsdump' command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbVmStructsDump diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbWhere.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbWhere.java index 4536d568212..971f30fd94f 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbWhere.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbWhere.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @bug 8190198 * @summary Test clhsdb where command * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm ClhsdbWhere diff --git a/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java b/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java index cf9c4dfc5a1..ada0003fba5 100644 --- a/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java +++ b/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @summary Test deadlock detection * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.java b/test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.java index 75942f7113a..a13106b1401 100644 --- a/test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.java +++ b/test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ import jdk.test.lib.Utils; /** * @test * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run driver JhsdbThreadInfoTest diff --git a/test/hotspot/jtreg/serviceability/sa/TestClassDump.java b/test/hotspot/jtreg/serviceability/sa/TestClassDump.java index c163d45e0ba..c415332291e 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestClassDump.java +++ b/test/hotspot/jtreg/serviceability/sa/TestClassDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,7 @@ import jtreg.SkippedException; * @bug 8184982 * @summary Test ClassDump tool * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run driver TestClassDump diff --git a/test/hotspot/jtreg/serviceability/sa/TestClhsdbJstackLock.java b/test/hotspot/jtreg/serviceability/sa/TestClhsdbJstackLock.java index a0a1051beca..8524b4cd489 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestClhsdbJstackLock.java +++ b/test/hotspot/jtreg/serviceability/sa/TestClhsdbJstackLock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import jtreg.SkippedException; * @test * @bug 8185796 8335743 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm TestClhsdbJstackLock diff --git a/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java b/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java index b1f2148954c..2d6c208164a 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java +++ b/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,6 +46,7 @@ import jdk.test.lib.Utils; * @test * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @modules java.base/jdk.internal.misc * jdk.hotspot.agent/sun.jvm.hotspot diff --git a/test/hotspot/jtreg/serviceability/sa/TestDebugInfoDecode.java b/test/hotspot/jtreg/serviceability/sa/TestDebugInfoDecode.java index eb59f6f9487..3d808da683d 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestDebugInfoDecode.java +++ b/test/hotspot/jtreg/serviceability/sa/TestDebugInfoDecode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, 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 @@ -38,6 +38,7 @@ import jdk.test.lib.SA.SATestUtils; * @bug 8318682 * @summary Test decoding debug info for all nmethods in the code cache * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @modules jdk.hotspot.agent/sun.jvm.hotspot diff --git a/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java b/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java index 3bbb6fcdf35..c8efec888ca 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java +++ b/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,7 @@ import jdk.test.lib.Utils; * @test * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @modules java.base/jdk.internal.misc * jdk.hotspot.agent/sun.jvm.hotspot diff --git a/test/hotspot/jtreg/serviceability/sa/TestHeapDumpForInvokeDynamic.java b/test/hotspot/jtreg/serviceability/sa/TestHeapDumpForInvokeDynamic.java index 418dc5ec5a0..8ed476a0a1f 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestHeapDumpForInvokeDynamic.java +++ b/test/hotspot/jtreg/serviceability/sa/TestHeapDumpForInvokeDynamic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,7 @@ import jdk.test.lib.hprof.HprofParser; * @test * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @modules java.base/jdk.internal.misc * jdk.hotspot.agent/sun.jvm.hotspot diff --git a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java index 3dbfbecda73..d1ed4729d39 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java +++ b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,6 +46,7 @@ import java.util.*; * @test * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @modules java.base/jdk.internal.misc * jdk.hotspot.agent/sun.jvm.hotspot diff --git a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java index a462ee30fb2..fd192212bc4 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java +++ b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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,7 @@ import jdk.test.lib.Utils; * @test * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @modules java.base/jdk.internal.misc * jdk.hotspot.agent/sun.jvm.hotspot diff --git a/test/hotspot/jtreg/serviceability/sa/TestIntConstant.java b/test/hotspot/jtreg/serviceability/sa/TestIntConstant.java index 2b41394b7a5..23e64452652 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestIntConstant.java +++ b/test/hotspot/jtreg/serviceability/sa/TestIntConstant.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 @@ import jtreg.SkippedException; * @summary Test the 'intConstant' command of jhsdb clhsdb. * @bug 8190307 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm TestIntConstant diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLineNumbers.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLineNumbers.java index 15b9aa9ccae..936532527d4 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLineNumbers.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLineNumbers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,7 @@ import jdk.test.lib.SA.SATestUtils; * @test * @bug 8214226 8243500 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires os.arch=="amd64" | os.arch=="x86_64" * @requires os.family=="windows" | os.family == "linux" | os.family == "mac" * @requires vm.flagless diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.java index ac536523815..c9c85b3d25f 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import jdk.test.lib.Utils; * @test * @bug 8185796 8335743 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run driver TestJhsdbJstackLock diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixed.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixed.java index e90418b1030..e3808aa6706 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixed.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixed.java @@ -37,7 +37,9 @@ import jdk.test.lib.process.OutputAnalyzer; * @test * @key randomness * @bug 8208091 8374469 8377710 - * @requires (os.family == "linux" | os.family == "windows") & (vm.hasSA) + * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires (os.family == "linux" | os.family == "windows") * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run driver TestJhsdbJstackMixed diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedCore.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedCore.java index 84a62eb65e5..99232ed9813 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedCore.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedCore.java @@ -38,7 +38,9 @@ import jtreg.SkippedException; /** * @test * @bug 8374482 8376264 8376284 8377395 - * @requires (os.family == "linux") & (vm.hasSA) + * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires os.family == "linux" * @requires os.arch == "amd64" * @library /test/lib * @run driver TestJhsdbJstackMixedCore diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithVDSOCallCore.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithVDSOCallCore.java index 84da46e272f..de512b93121 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithVDSOCallCore.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithVDSOCallCore.java @@ -38,7 +38,9 @@ import jdk.test.lib.util.CoreUtils; /** * @test * @bug 8376269 - * @requires (os.family == "linux") & (vm.hasSA) + * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires os.family == "linux" * @requires os.arch == "amd64" * @library /test/lib * @run driver TestJhsdbJstackMixedWithVDSOCallCore diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithXComp.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithXComp.java index a26fc4532df..1ebf6c21a70 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithXComp.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixedWithXComp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2025, NTT DATA * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,6 +36,7 @@ import jdk.test.lib.process.OutputAnalyzer; * @test id=xcomp * @bug 8370176 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires os.family == "linux" * @requires os.arch == "amd64" * @library /test/lib @@ -46,6 +47,7 @@ import jdk.test.lib.process.OutputAnalyzer; * @test id=xcomp-preserve-frame-pointer * @bug 8370176 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires os.family == "linux" * @requires os.arch == "amd64" * @library /test/lib @@ -56,6 +58,7 @@ import jdk.test.lib.process.OutputAnalyzer; * @test id=xcomp-disable-tiered-compilation * @bug 8370176 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires os.family == "linux" * @requires os.arch == "amd64" * @library /test/lib diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackPrintVMLocks.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackPrintVMLocks.java index b7b3c956441..f6580d71e05 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackPrintVMLocks.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackPrintVMLocks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import jtreg.SkippedException; * @test * @summary Test verifies that jstack --mixed prints information about VM locks * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @build jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackUpcall.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackUpcall.java index 1873672d2ce..e91910c3411 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackUpcall.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackUpcall.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import jdk.test.lib.process.OutputAnalyzer; * @test * @bug 8339307 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run driver TestJhsdbJstackUpcall diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackWithVirtualThread.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackWithVirtualThread.java index 39b6e1ed609..55751c330b5 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackWithVirtualThread.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackWithVirtualThread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2025, NTT DATA * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -37,6 +37,7 @@ import jdk.test.lib.process.OutputAnalyzer; * @test * @bug 8369505 * @requires vm.hasSA + * @requires vm.gc != "Z" * @library /test/lib * @run driver TestJhsdbJstackWithVirtualThread */ diff --git a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java index 77258bd45b7..024b5e03c98 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test TestJmapCore * @summary Test verifies that jhsdb jmap could generate heap dump from core when heap is full * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires !vm.asan * @library /test/lib * @run driver/timeout=480 TestJmapCore run heap diff --git a/test/hotspot/jtreg/serviceability/sa/TestJmapCoreMetaspace.java b/test/hotspot/jtreg/serviceability/sa/TestJmapCoreMetaspace.java index ec3c66476a6..372cd0246ac 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJmapCoreMetaspace.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJmapCoreMetaspace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test TestJmapCoreMetaspace * @summary Test verifies that jhsdb jmap could generate heap dump from core when metaspace is full * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires !vm.asan * @library /test/lib * @run driver/timeout=480 TestJmapCore run metaspace diff --git a/test/hotspot/jtreg/serviceability/sa/TestObjectAlignment.java b/test/hotspot/jtreg/serviceability/sa/TestObjectAlignment.java index 62fe2f5d7aa..081dbe1206c 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestObjectAlignment.java +++ b/test/hotspot/jtreg/serviceability/sa/TestObjectAlignment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, 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 @@ -38,7 +38,9 @@ import jdk.test.lib.Utils; /** * @test * @library /test/lib - * @requires vm.hasSA & vm.bits == "64" + * @requires vm.hasSA + * @requires vm.gc != "Z" + * @requires vm.bits == "64" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @modules jdk.hotspot.agent/sun.jvm.hotspot * jdk.hotspot.agent/sun.jvm.hotspot.runtime diff --git a/test/hotspot/jtreg/serviceability/sa/TestObjectMonitorIterate.java b/test/hotspot/jtreg/serviceability/sa/TestObjectMonitorIterate.java index 86a00285ee4..0448cc0788a 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestObjectMonitorIterate.java +++ b/test/hotspot/jtreg/serviceability/sa/TestObjectMonitorIterate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, NTT DATA. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -38,6 +38,7 @@ import jdk.test.lib.SA.SATestUtils; * @bug 8259008 * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @modules jdk.hotspot.agent/sun.jvm.hotspot * jdk.hotspot.agent/sun.jvm.hotspot.oops diff --git a/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java b/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java index 315c931d49e..8c5ce3ae3cd 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java +++ b/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,6 +41,7 @@ import jdk.test.lib.Utils; * @test * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @modules java.base/jdk.internal.misc * jdk.hotspot.agent/sun.jvm.hotspot * jdk.hotspot.agent/sun.jvm.hotspot.utilities diff --git a/test/hotspot/jtreg/serviceability/sa/TestSysProps.java b/test/hotspot/jtreg/serviceability/sa/TestSysProps.java index a591d009ecf..a2617f7f268 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestSysProps.java +++ b/test/hotspot/jtreg/serviceability/sa/TestSysProps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,7 @@ import jdk.test.lib.SA.SATestUtils; * @bug 8242165 8242162 * @summary Test "jhsdb jinfo --sysprops", "jinfo -sysprops", and clhsdb "sysprops" commands * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run driver TestSysProps diff --git a/test/hotspot/jtreg/serviceability/sa/TestType.java b/test/hotspot/jtreg/serviceability/sa/TestType.java index c3326032b90..e5b90a3c2a9 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestType.java +++ b/test/hotspot/jtreg/serviceability/sa/TestType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 @@ import jtreg.SkippedException; * @summary Test the 'type' command of jhsdb clhsdb. * @bug 8190307 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @library /test/lib * @run main/othervm TestType diff --git a/test/hotspot/jtreg/serviceability/sa/UniqueVtableTest.java b/test/hotspot/jtreg/serviceability/sa/UniqueVtableTest.java index 774fcee50ed..7792ec1a003 100644 --- a/test/hotspot/jtreg/serviceability/sa/UniqueVtableTest.java +++ b/test/hotspot/jtreg/serviceability/sa/UniqueVtableTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @modules jdk.hotspot.agent/sun.jvm.hotspot * jdk.hotspot.agent/sun.jvm.hotspot.debugger diff --git a/test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java b/test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java index a41ab71f4fa..6a7c519fedf 100644 --- a/test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java +++ b/test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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,7 @@ import jdk.test.lib.SA.SATestUtils; * @test * @bug 6313383 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @summary Regression test for hprof export issue due to large heaps (>2G) * @library /test/lib diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbAttachToDebugServer.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbAttachToDebugServer.java index 57962e72c5c..ab211b70691 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbAttachToDebugServer.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbAttachToDebugServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021 NTT DATA. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,6 +36,7 @@ import jtreg.SkippedException; * @bug 8262520 * @summary Test clhsdb connect, detach, reattach commands * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires os.family != "windows" * @library /test/lib diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbTestConnectArgument.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbTestConnectArgument.java index 109afa21841..2e07dfa63f0 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbTestConnectArgument.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbTestConnectArgument.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021 NTT DATA. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,6 +35,7 @@ import jtreg.SkippedException; * @test * @bug 8263342 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires os.family != "windows" * @library /test/lib diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/DebugdConnectTest.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/DebugdConnectTest.java index 285f57f8115..7576aa54bf0 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/DebugdConnectTest.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/DebugdConnectTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 8209790 * @summary Checks ability for connecting to debug server (jstack, jmap, jinfo, jsnap) * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires os.family != "windows" * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/DisableRegistryTest.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/DisableRegistryTest.java index ae0774988a8..312e99c172c 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/DisableRegistryTest.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/DisableRegistryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021 NTT DATA. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,6 +36,7 @@ import jtreg.SkippedException; * @bug 8263636 8263635 * @summary Test to use already started RMI registry * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires os.family != "windows" * @library /test/lib diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/PmapOnDebugdTest.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/PmapOnDebugdTest.java index b1665634fb0..c27989e20ca 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/PmapOnDebugdTest.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/PmapOnDebugdTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021 NTT DATA. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -34,6 +34,7 @@ import jtreg.SkippedException; * @test * @bug 8263670 * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires (os.family != "windows") & (os.family != "mac") * @library /test/lib diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/RunCommandOnServerTest.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/RunCommandOnServerTest.java index 9e725561341..5905d558c55 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/RunCommandOnServerTest.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/RunCommandOnServerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021 NTT DATA. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -37,6 +37,7 @@ import jtreg.SkippedException; * @bug 8265505 * @summary Test clhsdb command which should be run on debugd server * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires os.family != "windows" * @library /test/lib diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java index 69f4c9eb454..166e45cc3b7 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ * @summary Checks that the jshdb debugd utility successfully starts * and tries to attach to a running process * @requires vm.hasSA + * @requires vm.gc != "Z" * @requires (os.arch != "riscv64" | !(vm.cpu.features ~= ".*qemu.*")) * @requires os.family != "windows" * @modules java.base/jdk.internal.misc diff --git a/test/jdk/ProblemList-zgc.txt b/test/jdk/ProblemList-zgc.txt index 065a52f9a83..a669f3e3abf 100644 --- a/test/jdk/ProblemList-zgc.txt +++ b/test/jdk/ProblemList-zgc.txt @@ -27,16 +27,6 @@ # ############################################################################# -# Quiet all SA tests - -sun/tools/jhsdb/HeapDumpTest.java 8307393 generic-all -sun/tools/jhsdb/BasicLauncherTest.java 8307393 generic-all -sun/tools/jhsdb/JStackStressTest.java 8307393 generic-all -sun/tools/jhsdb/JShellHeapDumpTest.java 8307393 generic-all -sun/tools/jhsdb/SAGetoptTest.java 8307393 generic-all -sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java 8307393 generic-all -sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java 8307393 generic-all - com/sun/jdi/ThreadMemoryLeakTest.java 8307402 generic-all ############################################################################# diff --git a/test/jdk/com/sun/net/httpserver/ContextPathMatcherPathPrefixTest.java b/test/jdk/com/sun/net/httpserver/ContextPathMatcherPathPrefixTest.java index e1cff62a45f..6b260636585 100644 --- a/test/jdk/com/sun/net/httpserver/ContextPathMatcherPathPrefixTest.java +++ b/test/jdk/com/sun/net/httpserver/ContextPathMatcherPathPrefixTest.java @@ -23,21 +23,30 @@ import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; + +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; import java.net.InetAddress; import java.net.InetSocketAddress; -import java.net.URI; +import java.net.Socket; import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import static java.net.http.HttpClient.Builder.NO_PROXY; import org.junit.jupiter.api.AfterAll; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -89,29 +98,88 @@ public class ContextPathMatcherPathPrefixTest { @Test void testContextPathAtRoot() throws Exception { + // Repeating all cases with both known (GET) and unknown (DOH) request methods to stress both paths try (var infra = new Infra("/")) { - infra.expect(200, "/foo", "/foo/", "/foo/bar", "/foobar"); + // 200 + infra.expect(200, "GET /foo"); + infra.expect(200, "GET /foo/"); + infra.expect(200, "GET /foo/bar"); + infra.expect(200, "GET /foobar"); + infra.expect(200, "DOH /foo"); + infra.expect(200, "DOH /foo/"); + infra.expect(200, "DOH /foo/bar"); + infra.expect(200, "DOH /foobar"); + // 404 + infra.expect(404, "GET foo"); + infra.expect(404, "GET *"); + infra.expect(404, "GET "); + infra.expect(404, "DOH foo"); + infra.expect(404, "DOH *"); + infra.expect(404, "DOH "); + // 400 + infra.expect(400, "GET"); + infra.expect(400, "DOH"); } } @Test void testContextPathAtSubDir() throws Exception { + // Repeating all cases with both known (GET) and unknown (DOH) request methods to stress both paths try (var infra = new Infra("/foo")) { - infra.expect(200, "/foo", "/foo/", "/foo/bar"); - infra.expect(404, "/foobar"); + // 200 + infra.expect(200, "GET /foo"); + infra.expect(200, "GET /foo/"); + infra.expect(200, "GET /foo/bar"); + infra.expect(200, "DOH /foo"); + infra.expect(200, "DOH /foo/"); + infra.expect(200, "DOH /foo/bar"); + // 404 + infra.expect(404, "GET /foobar"); // Differs from string prefix matching! + infra.expect(404, "GET foo"); + infra.expect(404, "GET *"); + infra.expect(404, "GET "); + infra.expect(404, "DOH /foobar"); // Differs from string prefix matching! + infra.expect(404, "DOH foo"); + infra.expect(404, "DOH *"); + infra.expect(404, "DOH "); + // 400 + infra.expect(400, "GET"); + infra.expect(400, "DOH"); } } @Test void testContextPathAtSubDirWithTrailingSlash() throws Exception { + // Repeating all cases with both known (GET) and unknown (DOH) request methods to stress both paths try (var infra = new Infra("/foo/")) { - infra.expect(200, "/foo/", "/foo/bar"); - infra.expect(404, "/foo", "/foobar"); + // 200 + infra.expect(200, "GET /foo/"); + infra.expect(200, "GET /foo/bar"); + infra.expect(200, "DOH /foo/"); + infra.expect(200, "DOH /foo/bar"); + // 404 + infra.expect(404, "GET /foo"); + infra.expect(404, "GET /foobar"); + infra.expect(404, "GET foo"); + infra.expect(404, "GET *"); + infra.expect(404, "GET "); + infra.expect(404, "DOH /foo"); + infra.expect(404, "DOH /foobar"); + infra.expect(404, "DOH foo"); + infra.expect(404, "DOH *"); + infra.expect(404, "DOH "); + // 400 + infra.expect(400, "GET"); + infra.expect(400, "DOH"); } } protected static final class Infra implements AutoCloseable { + /** Charset used for network and file I/O. */ + private static final Charset CHARSET = StandardCharsets.US_ASCII; + + /** Socket address the server will bind to. */ private static final InetSocketAddress LO_SA_0 = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); @@ -128,22 +196,51 @@ public class ContextPathMatcherPathPrefixTest { this.contextPath = contextPath; } - protected void expect(int statusCode, String... requestPaths) throws Exception { - for (String requestPath : requestPaths) { - var requestURI = URI.create("http://%s:%s%s".formatted( - server.getAddress().getHostString(), - server.getAddress().getPort(), - requestPath)); - var request = HttpRequest.newBuilder(requestURI).build(); - var response = CLIENT.send(request, HttpResponse.BodyHandlers.discarding()); - assertEquals( - statusCode, response.statusCode(), - "unexpected status code " + Map.of( - "contextPath", contextPath, - "requestPath", requestPath)); + protected void expect(int statusCode, String requestLinePrefix) { + try { + expect0(statusCode, requestLinePrefix); + } catch (Throwable exception) { + var extendedMessage = exception.getMessage() + " " + Map.of( + "contextPath", contextPath, + "requestLinePrefix", requestLinePrefix); + var extendedException = new RuntimeException(extendedMessage); + extendedException.setStackTrace(exception.getStackTrace()); + throw extendedException; } } + private void expect0(int statusCode, String requestLinePrefix) throws IOException { + + // Connect to the server + try (Socket socket = new Socket()) { + socket.connect(server.getAddress()); + + // Obtain the I/O streams + try (OutputStream outputStream = socket.getOutputStream(); + InputStream inputStream = socket.getInputStream(); + BufferedReader inputReader = new BufferedReader(new InputStreamReader(inputStream, CHARSET))) { + + // Write the request + byte[] requestBytes = String + // `Connection: close` is required for `BufferedReader::readLine` to work. + .format("%s HTTP/1.1\r\nConnection: close\r\n\r\n", requestLinePrefix) + .getBytes(CHARSET); + outputStream.write(requestBytes); + outputStream.flush(); + + // Read the response status code + String statusLine = inputReader.readLine(); + assertNotNull(statusLine, "Unexpected EOF while reading status line"); + Matcher statusLineMatcher = Pattern.compile("^HTTP/1\\.1 (\\d+) .+$").matcher(statusLine); + assertTrue(statusLineMatcher.matches(), "Couldn't match status line: \"" + statusLine + "\""); + assertEquals(statusCode, Integer.parseInt(statusLineMatcher.group(1))); + + } + + } + + } + @Override public void close() { server.stop(0); diff --git a/test/jdk/com/sun/net/httpserver/ContextPathMatcherStringPrefixTest.java b/test/jdk/com/sun/net/httpserver/ContextPathMatcherStringPrefixTest.java index 3f3008a8531..4faa1463e1b 100644 --- a/test/jdk/com/sun/net/httpserver/ContextPathMatcherStringPrefixTest.java +++ b/test/jdk/com/sun/net/httpserver/ContextPathMatcherStringPrefixTest.java @@ -36,28 +36,32 @@ import org.junit.jupiter.api.Test; class ContextPathMatcherStringPrefixTest extends ContextPathMatcherPathPrefixTest { - @Test - @Override - void testContextPathAtRoot() throws Exception { - try (var infra = new Infra("/")) { - infra.expect(200, "/foo", "/foo/", "/foo/bar", "/foobar"); - } - } - @Test @Override void testContextPathAtSubDir() throws Exception { + // Repeating all cases with both known (GET) and unknown (DOH) request methods to stress both paths try (var infra = new Infra("/foo")) { - infra.expect(200, "/foo", "/foo/", "/foo/bar", "/foobar"); - } - } - - @Test - @Override - void testContextPathAtSubDirWithTrailingSlash() throws Exception { - try (var infra = new Infra("/foo/")) { - infra.expect(200, "/foo/", "/foo/bar"); - infra.expect(404, "/foo", "/foobar"); + // 200 + infra.expect(200, "GET /foo"); + infra.expect(200, "GET /foo/"); + infra.expect(200, "GET /foo/bar"); + infra.expect(200, "GET /foobar"); // Differs from path prefix matching! + infra.expect(200, "DOH /foo"); + infra.expect(200, "DOH /foo/"); + infra.expect(200, "DOH /foo/bar"); + infra.expect(200, "DOH /foobar"); // Differs from path prefix matching! + // 404 + infra.expect(404, "GET /"); + infra.expect(404, "GET foo"); + infra.expect(404, "GET *"); + infra.expect(404, "GET "); + infra.expect(404, "DOH /"); + infra.expect(404, "DOH foo"); + infra.expect(404, "DOH *"); + infra.expect(404, "DOH "); + // 400 + infra.expect(400, "GET"); + infra.expect(400, "DOH"); } } diff --git a/test/jdk/java/lang/String/Encodings.java b/test/jdk/java/lang/String/Encodings.java index 4714815026e..7974157ede0 100644 --- a/test/jdk/java/lang/String/Encodings.java +++ b/test/jdk/java/lang/String/Encodings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ /* @test - * @bug 4085160 4139951 5005831 + * @bug 4085160 4139951 5005831 8372353 * @summary Test that required character encodings are supported */ @@ -106,6 +106,10 @@ public class Encodings { if (!equals(bs, bytes)) throw new Exception(charset + ": String.getBytes failed"); + /* String.encodedLength(Charset charset) */ + if (bs.length != str.encodedLength(charset)) + throw new Exception(charset + ": String.encodedLength failed"); + // Calls to String.getBytes(Charset) shouldn't automatically // use the cached thread-local encoder. if (charset.name().equals("UTF-16BE")) { diff --git a/test/jdk/java/lang/String/Exceptions.java b/test/jdk/java/lang/String/Exceptions.java index 3ba7792f424..15ffe3eac20 100644 --- a/test/jdk/java/lang/String/Exceptions.java +++ b/test/jdk/java/lang/String/Exceptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /** * @test - * @bug 4472841 4703640 4705681 4705683 4833095 5005831 + * @bug 4472841 4703640 4705681 4705683 4833095 5005831 8372353 * @summary Verify that constructor exceptions are thrown as expected. */ @@ -397,6 +397,14 @@ public class Exceptions { }}); } + private static void encodedLength() { + System.out.println("encodedLength(Charset charset)"); + tryCatch(" null", NullPointerException.class, new Runnable() { + public void run() { + "foo".encodedLength((Charset)null); + }}); + } + private static void contentEquals() { System.out.println("contentEquals(StringBuffer sb)"); tryCatch(" null", NullPointerException.class, new Runnable() { @@ -640,6 +648,7 @@ public class Exceptions { // getBytes(Locale) // getBytes(String) // getBytes(Charset) + encodedLength(); // encodedLength(Charset) contentEquals(); // contentEquals(StringBuffer) compareTo(); // compareTo(String), compareTo(Object) compareToIgnoreCase();// compareToIgnoreCase(String) diff --git a/test/jdk/java/net/httpclient/AggregateRequestBodyTest.java b/test/jdk/java/net/httpclient/AggregateRequestBodyTest.java index 175e860c229..fb67cf02566 100644 --- a/test/jdk/java/net/httpclient/AggregateRequestBodyTest.java +++ b/test/jdk/java/net/httpclient/AggregateRequestBodyTest.java @@ -74,6 +74,7 @@ import static java.lang.System.out; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Version.HTTP_3; +import static java.net.http.HttpOption.H3_DISCOVERY; import static java.net.http.HttpOption.Http3DiscoveryMode.HTTP_3_URI_ONLY; import org.junit.jupiter.api.AfterAll; @@ -81,7 +82,6 @@ import org.junit.jupiter.api.Assertions; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeAll; @@ -219,7 +219,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { int i = 0; for (boolean sameClient : List.of(false, true)) { for (URI uri : uris()) { - HttpClient.Version version = null; + final HttpClient.Version version; if (uri.equals(http1URI) || uri.equals(https1URI)) version = HttpClient.Version.HTTP_1_1; else if (uri.equals(http2URI) || uri.equals(https2URI)) version = HttpClient.Version.HTTP_2; else if (uri.equals(http3URI)) version = HTTP_3; @@ -295,7 +295,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { static List lengths(long... lengths) { return LongStream.of(lengths) - .mapToObj(Long::valueOf) + .boxed() .collect(Collectors.toList()); } @@ -446,7 +446,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { @Override public void onComplete() { - resultCF.complete(items.stream().collect(Collectors.toUnmodifiableList())); + resultCF.complete(items.stream().toList()); } public ByteBuffer take() { @@ -552,7 +552,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { subscriber.subscriptionCF.thenAccept(s -> s.request(Long.MAX_VALUE)); if (errorPublisher.hasErrors()) { CompletionException ce = Assertions.assertThrows(CompletionException.class, - () -> subscriber.resultCF.join()); + subscriber.resultCF::join); out.println(description + ": got expected " + ce); assertEquals(Exception.class, ce.getCause().getClass()); assertEquals(result, stringFromBytes(subscriber.items.stream()) + ""); @@ -600,7 +600,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { description.replace("null", "length(-1)")); } - private static final Throwable completionCause(CompletionException x) { + private static Throwable completionCause(CompletionException x) { while (x.getCause() instanceof CompletionException) { x = (CompletionException)x.getCause(); } @@ -618,7 +618,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { publisher.subscribe(subscriber); Subscription subscription = subscriber.subscriptionCF.join(); subscription.request(n); - CompletionException expected = Assertions.assertThrows(CE, () -> subscriber.resultCF.join()); + CompletionException expected = Assertions.assertThrows(CE, subscriber.resultCF::join); Throwable cause = completionCause(expected); if (cause instanceof IllegalArgumentException) { System.out.printf("Got expected IAE for %d: %s%n", n, cause); @@ -655,7 +655,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { assertTrue(requestSubscriber1.resultCF().isDone()); String result1 = stringFromBytes(list1.stream()); assertEquals("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", result1); - System.out.println("Got expected sentence with one request: \"%s\"".formatted(result1)); + System.out.printf("Got expected sentence with one request: \"%s\"%n", result1); // Test that we can split our requests call any which way we want // (whether in the 'middle of a publisher' or at the boundaries. @@ -824,7 +824,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { .toArray(HttpRequest.BodyPublisher[]::new) ); - HttpRequest request = HttpRequest.newBuilder(uri) + HttpRequest request = newRequestBuilder(uri) .version(version) .POST(publisher) .build(); @@ -835,13 +835,21 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { HttpResponse response = client.send(request, BodyHandlers.ofString()); int expectedResponse = RESPONSE_CODE; if (response.statusCode() != expectedResponse) - throw new RuntimeException("wrong response code " + Integer.toString(response.statusCode())); + throw new RuntimeException("wrong response code " + response.statusCode()); assertEquals(BODIES.stream().collect(Collectors.joining()), response.body()); } if (!sameClient) client.close(); System.out.println("test: DONE"); } + private static HttpRequest.Builder newRequestBuilder(URI uri) { + var builder = HttpRequest.newBuilder(uri); + if (uri.getPath().contains("/http3/")) { + builder.setOption(H3_DISCOVERY, HTTP_3_URI_ONLY); + } + return builder; + } + private static URI buildURI(String scheme, String path, int port) { return URIBuilder.newBuilder() .scheme(scheme) @@ -882,11 +890,17 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { http3TestServer.start(); } + private static void close(AutoCloseable closeable) throws Exception { + if (closeable == null) return; + out.println("Closing shared client " + closeable); + closeable.close(); + } + @AfterAll public static void teardown() throws Exception { String sharedClientName = sharedClient == null ? null : sharedClient.toString(); - sharedClient.close(); + close(sharedClient); sharedClient = null; Thread.sleep(100); AssertionError fail = TRACKER.check(500); diff --git a/test/jdk/java/net/httpclient/http2/ErrorTest.java b/test/jdk/java/net/httpclient/http2/ErrorTest.java index 6b36529b38f..0f3bafa571d 100644 --- a/test/jdk/java/net/httpclient/http2/ErrorTest.java +++ b/test/jdk/java/net/httpclient/http2/ErrorTest.java @@ -45,7 +45,7 @@ * java.net.http/jdk.internal.net.http.qpack.writers * java.security.jgss * @modules java.base/jdk.internal.util - * @run testng/othervm/timeout=60 -Djavax.net.debug=ssl -Djdk.httpclient.HttpClient.log=all ErrorTest + * @run junit/othervm/timeout=60 -Djavax.net.debug=ssl -Djdk.httpclient.HttpClient.log=all ErrorTest * @summary check exception thrown when bad TLS parameters selected */ @@ -67,7 +67,7 @@ import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.test.lib.net.SimpleSSLContext; import static java.net.http.HttpClient.Version.HTTP_2; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** * When selecting an unacceptable cipher suite the TLS handshake will fail. diff --git a/test/jdk/java/net/httpclient/http2/FixedThreadPoolTest.java b/test/jdk/java/net/httpclient/http2/FixedThreadPoolTest.java index 2378b0b6982..d788d39b441 100644 --- a/test/jdk/java/net/httpclient/http2/FixedThreadPoolTest.java +++ b/test/jdk/java/net/httpclient/http2/FixedThreadPoolTest.java @@ -30,7 +30,7 @@ * jdk.test.lib.Asserts * jdk.test.lib.Utils * jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors FixedThreadPoolTest + * @run junit/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors FixedThreadPoolTest */ import java.net.*; @@ -51,7 +51,7 @@ import static jdk.test.lib.Asserts.assertFileContentsEqual; import static jdk.test.lib.Utils.createTempFile; import static jdk.test.lib.Utils.createTempFileOfSize; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; public class FixedThreadPoolTest implements HttpServerAdapters { @@ -92,7 +92,7 @@ public class FixedThreadPoolTest implements HttpServerAdapters { } @Test - public static void test() throws Exception { + public void test() throws Exception { try { initialize(); simpleTest(false); diff --git a/test/jdk/java/net/httpclient/http2/H2SelectorVTTest.java b/test/jdk/java/net/httpclient/http2/H2SelectorVTTest.java index 85d4012494a..7adfd57319c 100644 --- a/test/jdk/java/net/httpclient/http2/H2SelectorVTTest.java +++ b/test/jdk/java/net/httpclient/http2/H2SelectorVTTest.java @@ -38,7 +38,7 @@ import jdk.test.lib.net.SimpleSSLContext; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Assertions; +import static org.junit.jupiter.api.Assertions.assertEquals; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpClient.Version.HTTP_2; @@ -166,21 +166,21 @@ class H2SelectorVTTest implements HttpServerAdapters { final HttpRequest req1 = reqBuilder.copy().GET().build(); System.out.println("\nIssuing request: " + req1); final HttpResponse resp1 = client.send(req1, BodyHandlers.ofString()); - Assertions.assertEquals(200, resp1.statusCode(), "unexpected response code for GET request"); + assertEquals(200, resp1.statusCode(), "unexpected response code for GET request"); assertSelectorThread(client); // POST final HttpRequest req2 = reqBuilder.copy().POST(BodyPublishers.ofString("foo")).build(); System.out.println("\nIssuing request: " + req2); final HttpResponse resp2 = client.send(req2, BodyHandlers.ofString()); - Assertions.assertEquals(200, resp2.statusCode(), "unexpected response code for POST request"); + assertEquals(200, resp2.statusCode(), "unexpected response code for POST request"); assertSelectorThread(client); // HEAD final HttpRequest req3 = reqBuilder.copy().HEAD().build(); System.out.println("\nIssuing request: " + req3); final HttpResponse resp3 = client.send(req3, BodyHandlers.ofString()); - Assertions.assertEquals(200, resp3.statusCode(), "unexpected response code for HEAD request"); + assertEquals(200, resp3.statusCode(), "unexpected response code for HEAD request"); assertSelectorThread(client); } } @@ -219,6 +219,6 @@ class H2SelectorVTTest implements HttpServerAdapters { msg = "%s not found in %s".formatted(name, threads); System.out.printf("%s: %s%n", status, msg); } - Assertions.assertEquals(!isTCPSelectorThreadVirtual(), found, msg); + assertEquals(!isTCPSelectorThreadVirtual(), found, msg); } } diff --git a/test/jdk/java/net/httpclient/http2/ImplicitPushCancel.java b/test/jdk/java/net/httpclient/http2/ImplicitPushCancel.java index c75a62d0f42..5bcaf95c6fc 100644 --- a/test/jdk/java/net/httpclient/http2/ImplicitPushCancel.java +++ b/test/jdk/java/net/httpclient/http2/ImplicitPushCancel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +25,7 @@ * @test * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=errors,requests,responses,trace * ImplicitPushCancel @@ -51,15 +51,16 @@ import java.util.concurrent.ConcurrentMap; import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http2.Http2TestExchange; import jdk.httpclient.test.lib.http2.Http2Handler; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ImplicitPushCancel { - static Map PUSH_PROMISES = Map.of( + static final Map PUSH_PROMISES = Map.of( "/x/y/z/1", "the first push promise body", "/x/y/z/2", "the second push promise body", "/x/y/z/3", "the third push promise body", @@ -72,11 +73,11 @@ public class ImplicitPushCancel { ); static final String MAIN_RESPONSE_BODY = "the main response body"; - Http2TestServer server; - URI uri; + private static Http2TestServer server; + private static URI uri; - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { server = new Http2TestServer(false, 0); Http2Handler handler = new ServerPushHandler(MAIN_RESPONSE_BODY, PUSH_PROMISES); @@ -87,13 +88,13 @@ public class ImplicitPushCancel { uri = new URI("http://localhost:" + port + "/foo/a/b/c"); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { server.stop(); } static final HttpResponse assert200ResponseCode(HttpResponse response) { - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); return response; } @@ -128,11 +129,11 @@ public class ImplicitPushCancel { promises.entrySet().stream().forEach(entry -> { HttpRequest request = entry.getKey(); HttpResponse response = entry.getValue().join(); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); if (PUSH_PROMISES.containsKey(request.uri().getPath())) { - assertEquals(response.body(), PUSH_PROMISES.get(request.uri().getPath())); + assertEquals(PUSH_PROMISES.get(request.uri().getPath()), response.body()); } else { - assertEquals(response.body(), MAIN_RESPONSE_BODY); + assertEquals(MAIN_RESPONSE_BODY, response.body()); } } ); diff --git a/test/jdk/java/net/httpclient/http2/NoBodyTest.java b/test/jdk/java/net/httpclient/http2/NoBodyTest.java index 3d30c54654a..2459c8eba4b 100644 --- a/test/jdk/java/net/httpclient/http2/NoBodyTest.java +++ b/test/jdk/java/net/httpclient/http2/NoBodyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @bug 8087112 * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors + * @run junit/othervm -Djdk.httpclient.HttpClient.log=ssl,requests,responses,errors * -Djdk.internal.httpclient.debug=true * NoBodyTest */ @@ -47,10 +47,10 @@ import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http2.Http2TestExchange; import jdk.httpclient.test.lib.http2.Http2Handler; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_2; -@Test +import org.junit.jupiter.api.Test; + public class NoBodyTest { static int httpPort, httpsPort; static Http2TestServer httpServer, httpsServer; @@ -86,7 +86,7 @@ public class NoBodyTest { } @Test - public static void runtest() throws Exception { + public void runtest() throws Exception { try { initialize(); warmup(false); diff --git a/test/jdk/java/net/httpclient/http2/PostPutTest.java b/test/jdk/java/net/httpclient/http2/PostPutTest.java index 89b192f6171..84e86b556ca 100644 --- a/test/jdk/java/net/httpclient/http2/PostPutTest.java +++ b/test/jdk/java/net/httpclient/http2/PostPutTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ * does not process any data. The client should read all data from the server and close the connection. * @library /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm/timeout=50 -Djdk.httpclient.HttpClient.log=all + * @run junit/othervm/timeout=50 -Djdk.httpclient.HttpClient.log=all * PostPutTest */ @@ -36,11 +36,6 @@ import jdk.httpclient.test.lib.http2.Http2Handler; import jdk.httpclient.test.lib.http2.Http2TestExchange; import jdk.httpclient.test.lib.http2.Http2TestServer; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import java.io.IOException; import java.io.PrintStream; import java.net.URI; @@ -51,19 +46,24 @@ import java.net.http.HttpResponse; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpRequest.BodyPublishers.ofByteArray; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PostPutTest { - Http2TestServer http2TestServer; - URI warmupURI, testHandlerBasicURI, testHandlerCloseBosURI, testHandleNegativeContentLengthURI; + private static Http2TestServer http2TestServer; + private static URI warmupURI, testHandlerBasicURI, testHandlerCloseBosURI, testHandleNegativeContentLengthURI; static PrintStream testLog = System.err; // As per jdk.internal.net.http.WindowController.DEFAULT_INITIAL_WINDOW_SIZE - final int DEFAULT_INITIAL_WINDOW_SIZE = (64 * 1024) - 1; + private static final int DEFAULT_INITIAL_WINDOW_SIZE = (64 * 1024) - 1; // Add on a small amount of arbitrary bytes to see if client hangs when receiving RST_STREAM - byte[] data = new byte[DEFAULT_INITIAL_WINDOW_SIZE + 10]; + private static byte[] data = new byte[DEFAULT_INITIAL_WINDOW_SIZE + 10]; - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { http2TestServer = new Http2TestServer(false, 0); http2TestServer.addHandler(new WarmupHandler(), "/Warmup"); http2TestServer.addHandler(new TestHandlerBasic(), "/TestHandlerBasic"); @@ -81,15 +81,14 @@ public class PostPutTest { testLog.println("PostPutTest.setup(): testHandleNegativeContentLengthURI: " + testHandleNegativeContentLengthURI); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { testLog.println("PostPutTest.teardown(): Stopping server"); http2TestServer.stop(); data = null; } - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { HttpRequest over64kPost, over64kPut, over64kPostCloseBos, over64kPutCloseBos, over64kPostNegativeContentLength, over64kPutNegativeContentLength; over64kPost = HttpRequest.newBuilder().version(HTTP_2).POST(ofByteArray(data)).uri(testHandlerBasicURI).build(); over64kPut = HttpRequest.newBuilder().version(HTTP_2).PUT(ofByteArray(data)).uri(testHandlerBasicURI).build(); @@ -117,7 +116,8 @@ public class PostPutTest { .build(); } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void testOver64kPUT(HttpRequest req, String testMessage) { testLog.println("PostPutTest: Performing test: " + testMessage); HttpClient hc = HttpClient.newBuilder().version(HTTP_2).build(); diff --git a/test/jdk/java/net/httpclient/http2/PushPromiseContinuation.java b/test/jdk/java/net/httpclient/http2/PushPromiseContinuation.java index e9c6447e600..2d5b5dd4f4e 100644 --- a/test/jdk/java/net/httpclient/http2/PushPromiseContinuation.java +++ b/test/jdk/java/net/httpclient/http2/PushPromiseContinuation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,10 +31,9 @@ * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer * jdk.httpclient.test.lib.http2.BodyOutputStream * jdk.httpclient.test.lib.http2.OutgoingPushPromise - * @run testng/othervm PushPromiseContinuation + * @run junit/othervm PushPromiseContinuation */ - import javax.net.ssl.SSLSession; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -68,14 +67,13 @@ import jdk.internal.net.http.common.HttpHeadersBuilder; import jdk.internal.net.http.frame.ContinuationFrame; import jdk.internal.net.http.frame.HeaderFrame; -import org.testng.TestException; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; public class PushPromiseContinuation { @@ -85,8 +83,8 @@ public class PushPromiseContinuation { static volatile int continuationCount; static final String mainPromiseBody = "Main Promise Body"; static final String mainResponseBody = "Main Response Body"; - Http2TestServer server; - URI uri; + private static Http2TestServer server; + private static URI uri; // Set up simple client-side push promise handler ConcurrentMap>> pushPromiseMap = new ConcurrentHashMap<>(); @@ -95,13 +93,13 @@ public class PushPromiseContinuation { pushPromiseMap.put(pushRequest, acceptor.apply(s)); }; - @BeforeMethod + @BeforeEach public void beforeMethod() { pushPromiseMap = new ConcurrentHashMap<>(); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { server = new Http2TestServer(false, 0); server.addHandler(new ServerPushHandler(), "/"); @@ -115,9 +113,8 @@ public class PushPromiseContinuation { uri = new URI("http://localhost:" + port + "/"); } - @AfterTest - public void teardown() { - pushPromiseMap = null; + @AfterAll + public static void teardown() { server.stop(); } @@ -195,29 +192,29 @@ public class PushPromiseContinuation { CompletableFuture> cf = client.sendAsync(hreq, HttpResponse.BodyHandlers.ofString(UTF_8), pph); - CompletionException t = expectThrows(CompletionException.class, () -> cf.join()); - assertEquals(t.getCause().getClass(), ProtocolException.class, + CompletionException t = assertThrows(CompletionException.class, () -> cf.join()); + assertEquals(ProtocolException.class, t.getCause().getClass(), "Expected a ProtocolException but got " + t.getCause()); System.err.println("Client received the following expected exception: " + t.getCause()); faultyServer.stop(); } private void verify(HttpResponse resp) { - assertEquals(resp.statusCode(), 200); - assertEquals(resp.body(), mainResponseBody); + assertEquals(200, resp.statusCode()); + assertEquals(mainResponseBody, resp.body()); if (pushPromiseMap.size() > 1) { System.err.println(pushPromiseMap.entrySet()); - throw new TestException("Results map size is greater than 1"); + fail("Results map size is greater than 1"); } else { // This will only iterate once for (HttpRequest r : pushPromiseMap.keySet()) { HttpResponse serverPushResp = pushPromiseMap.get(r).join(); // Received headers should be the same as the combined PushPromise // frame headers combined with the Continuation frame headers - assertEquals(testHeaders, r.headers()); + assertEquals(r.headers(), testHeaders); // Check status code and push promise body are as expected - assertEquals(serverPushResp.statusCode(), 200); - assertEquals(serverPushResp.body(), mainPromiseBody); + assertEquals(200, serverPushResp.statusCode()); + assertEquals(mainPromiseBody, serverPushResp.body()); } } } diff --git a/test/jdk/java/net/httpclient/http2/RedirectTest.java b/test/jdk/java/net/httpclient/http2/RedirectTest.java index e2acd807bd5..201b56513f6 100644 --- a/test/jdk/java/net/httpclient/http2/RedirectTest.java +++ b/test/jdk/java/net/httpclient/http2/RedirectTest.java @@ -30,7 +30,7 @@ * jdk.httpclient.test.lib.http2.Http2RedirectHandler * jdk.test.lib.Asserts * jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.HttpClient.log=frames,ssl,requests,responses,errors * -Djdk.internal.httpclient.debug=true * RedirectTest @@ -52,9 +52,10 @@ import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http2.Http2TestExchange; import jdk.httpclient.test.lib.http2.Http2RedirectHandler; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_2; +import org.junit.jupiter.api.Test; + public class RedirectTest implements HttpServerAdapters { static int httpPort; static HttpTestServer httpServer; @@ -135,7 +136,7 @@ public class RedirectTest implements HttpServerAdapters { } @Test - public static void test() throws Exception { + public void test() throws Exception { try { initialize(); simpleTest(); diff --git a/test/jdk/java/net/httpclient/http2/ServerPush.java b/test/jdk/java/net/httpclient/http2/ServerPush.java index 7f9c82fb28b..d38b867132b 100644 --- a/test/jdk/java/net/httpclient/http2/ServerPush.java +++ b/test/jdk/java/net/httpclient/http2/ServerPush.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ * @build jdk.httpclient.test.lib.http2.Http2TestServer * jdk.httpclient.test.lib.http2.PushHandler * jdk.test.lib.Utils - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.HttpClient.log=errors,requests,responses * ServerPush */ @@ -48,13 +48,14 @@ import java.util.concurrent.*; import java.util.function.Consumer; import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http2.PushHandler; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import static java.nio.charset.StandardCharsets.UTF_8; import static jdk.test.lib.Utils.createTempFileOfSize; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; public class ServerPush { @@ -66,11 +67,11 @@ public class ServerPush { static Path tempFile; - Http2TestServer server; - URI uri; + private static Http2TestServer server; + private static URI uri; - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { tempFile = createTempFileOfSize(TEMP_FILE_PREFIX, null, FILE_SIZE); server = new Http2TestServer(false, 0); server.addHandler(new PushHandler(tempFile, LOOPS), "/"); @@ -82,8 +83,8 @@ public class ServerPush { uri = new URI("http://localhost:" + port + "/foo/a/b/c"); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { server.stop(); } @@ -109,10 +110,10 @@ public class ServerPush { System.err.println("results.size: " + resultMap.size()); for (HttpRequest r : resultMap.keySet()) { HttpResponse response = resultMap.get(r).join(); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), tempFileAsString); + assertEquals(200, response.statusCode()); + assertEquals(tempFileAsString, response.body()); } - assertEquals(resultMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultMap.size()); } // Test 2 - of(...) populating the given Map, everything as a String @@ -135,10 +136,10 @@ public class ServerPush { System.err.println("results.size: " + resultMap.size()); for (HttpRequest r : resultMap.keySet()) { HttpResponse response = resultMap.get(r).join(); - assertEquals(response.statusCode(), 200); - assertEquals(response.body(), tempFileAsString); + assertEquals(200, response.statusCode()); + assertEquals(tempFileAsString, response.body()); } - assertEquals(resultMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultMap.size()); } // --- Path --- @@ -177,11 +178,11 @@ public class ServerPush { for (HttpRequest r : resultsMap.keySet()) { HttpResponse response = resultsMap.get(r).join(); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); String fileAsString = new String(Files.readAllBytes(response.body()), UTF_8); - assertEquals(fileAsString, tempFileAsString); + assertEquals(tempFileAsString, fileAsString); } - assertEquals(resultsMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultsMap.size()); } // Test 4 - of(...) populating the given Map, everything as a Path @@ -204,11 +205,11 @@ public class ServerPush { for (HttpRequest r : resultsMap.keySet()) { HttpResponse response = resultsMap.get(r).join(); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); String fileAsString = new String(Files.readAllBytes(response.body()), UTF_8); - assertEquals(fileAsString, tempFileAsString); + assertEquals(tempFileAsString, fileAsString); } - assertEquals(resultsMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultsMap.size()); } // --- Consumer --- @@ -263,12 +264,12 @@ public class ServerPush { for (HttpRequest r : resultsMap.keySet()) { HttpResponse response = resultsMap.get(r).join(); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); byte[] ba = byteArrayConsumerMap.get(r).getAccumulatedBytes(); String result = new String(ba, UTF_8); - assertEquals(result, tempFileAsString); + assertEquals(tempFileAsString, result); } - assertEquals(resultsMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultsMap.size()); } // Test 6 - of(...) populating the given Map, everything as a consumer of optional byte[] @@ -301,11 +302,11 @@ public class ServerPush { for (HttpRequest r : resultsMap.keySet()) { HttpResponse response = resultsMap.get(r).join(); - assertEquals(response.statusCode(), 200); + assertEquals(200, response.statusCode()); byte[] ba = byteArrayConsumerMap.get(r).getAccumulatedBytes(); String result = new String(ba, UTF_8); - assertEquals(result, tempFileAsString); + assertEquals(tempFileAsString, result); } - assertEquals(resultsMap.size(), LOOPS + 1); + assertEquals(LOOPS + 1, resultsMap.size()); } } diff --git a/test/jdk/java/net/httpclient/http2/ServerPushWithDiffTypes.java b/test/jdk/java/net/httpclient/http2/ServerPushWithDiffTypes.java index 3e12a20c15e..9cf2a3f7ae2 100644 --- a/test/jdk/java/net/httpclient/http2/ServerPushWithDiffTypes.java +++ b/test/jdk/java/net/httpclient/http2/ServerPushWithDiffTypes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +25,7 @@ * @test * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=errors,requests,responses * ServerPushWithDiffTypes @@ -47,9 +47,10 @@ import jdk.httpclient.test.lib.http2.Http2TestServer; import jdk.httpclient.test.lib.http2.Http2TestExchange; import jdk.httpclient.test.lib.http2.Http2Handler; -import org.testng.annotations.Test; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ServerPushWithDiffTypes { @@ -66,7 +67,7 @@ public class ServerPushWithDiffTypes { ); @Test - public static void test() throws Exception { + public void test() throws Exception { Http2TestServer server = null; try { server = new Http2TestServer(false, 0); @@ -93,7 +94,7 @@ public class ServerPushWithDiffTypes { results.put(request, cf); cf.join(); - assertEquals(results.size(), PUSH_PROMISES.size() + 1); + assertEquals(PUSH_PROMISES.size() + 1, results.size()); for (HttpRequest r : results.keySet()) { URI u = r.uri(); @@ -116,7 +117,7 @@ public class ServerPushWithDiffTypes { String expected = PUSH_PROMISES.get(r.uri().getPath()); if (expected == null) expected = "the main response body"; - assertEquals(result, expected); + assertEquals(expected, result); } } finally { server.stop(); diff --git a/test/jdk/java/net/httpclient/http2/SimpleGet.java b/test/jdk/java/net/httpclient/http2/SimpleGet.java index 692a6583b63..5df3174f820 100644 --- a/test/jdk/java/net/httpclient/http2/SimpleGet.java +++ b/test/jdk/java/net/httpclient/http2/SimpleGet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,11 +27,11 @@ * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.TestUtil * jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm -XX:+CrashOnOutOfMemoryError SimpleGet - * @run testng/othervm -XX:+CrashOnOutOfMemoryError + * @run junit/othervm -XX:+CrashOnOutOfMemoryError SimpleGet + * @run junit/othervm -XX:+CrashOnOutOfMemoryError * -Dsimpleget.repeat=1 -Dsimpleget.chunks=1 -Dsimpleget.requests=1000 * SimpleGet - * @run testng/othervm -Dsimpleget.requests=150 + * @run junit/othervm -Dsimpleget.requests=150 * -Dsimpleget.chunks=16384 * -Djdk.httpclient.redirects.retrylimit=5 * -Djdk.httpclient.HttpClient.log=errors @@ -62,11 +62,12 @@ import javax.net.ssl.SSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.Assert; -import org.testng.annotations.Test; import static java.net.http.HttpClient.Version.HTTP_2; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class SimpleGet implements HttpServerAdapters { static HttpTestServer httpsServer; static HttpClient client = null; @@ -117,11 +118,11 @@ public class SimpleGet implements HttpServerAdapters { } public static void main(String[] args) throws Exception { - test(); + new SimpleGet().test(); } @Test - public static void test() throws Exception { + public void test() throws Exception { try { long prestart = System.nanoTime(); initialize(); @@ -132,7 +133,7 @@ public class SimpleGet implements HttpServerAdapters { .GET().build(); long start = System.nanoTime(); var resp = client.send(request, BodyHandlers.ofByteArrayConsumer(b -> {})); - Assert.assertEquals(resp.statusCode(), 200); + assertEquals(200, resp.statusCode()); long elapsed = System.nanoTime() - start; System.out.println("Stat: First request took: " + elapsed + " nanos (" + TimeUnit.NANOSECONDS.toMillis(elapsed) + " ms)"); final int max = property("simpleget.requests", 50); @@ -163,7 +164,7 @@ public class SimpleGet implements HttpServerAdapters { + connections.size() + " connections"); } } - list.forEach((cf) -> Assert.assertEquals(cf.join().statusCode(), 200)); + list.forEach((cf) -> assertEquals(200, cf.join().statusCode())); } catch (Throwable tt) { System.err.println("tt caught"); tt.printStackTrace(); diff --git a/test/jdk/java/net/httpclient/http2/StreamFlowControlTest.java b/test/jdk/java/net/httpclient/http2/StreamFlowControlTest.java index 3edf0b71305..a36fe29813c 100644 --- a/test/jdk/java/net/httpclient/http2/StreamFlowControlTest.java +++ b/test/jdk/java/net/httpclient/http2/StreamFlowControlTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @bug 8342075 8343855 * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer jdk.test.lib.net.SimpleSSLContext - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.connectionWindowSize=65535 * -Djdk.httpclient.windowsize=16384 * StreamFlowControlTest @@ -65,30 +65,30 @@ import jdk.internal.net.http.common.HttpHeadersBuilder; import jdk.internal.net.http.frame.SettingsFrame; import jdk.test.lib.Utils; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import static java.util.concurrent.TimeUnit.NANOSECONDS; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class StreamFlowControlTest { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpTestServer http2TestServer; // HTTP/2 ( h2c ) - HttpTestServer https2TestServer; // HTTP/2 ( h2 ) - String http2URI; - String https2URI; - final AtomicInteger reqid = new AtomicInteger(); + private static HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + private static HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + private static String http2URI; + private static String https2URI; + private static final AtomicInteger reqid = new AtomicInteger(); final static int WINDOW = Integer.getInteger("jdk.httpclient.windowsize", 2 * 16 * 1024); - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][] { { http2URI, false }, { https2URI, false }, @@ -111,7 +111,8 @@ public class StreamFlowControlTest { } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") void test(String uri, boolean sameClient) throws Exception @@ -142,7 +143,7 @@ public class StreamFlowControlTest { if (sameClient) { String key = response.headers().firstValue("X-Connection-Key").get(); if (label == null) label = key; - assertEquals(key, label, "Unexpected key for " + query); + assertEquals(label, key, "Unexpected key for " + query); } sent.join(); // we have to pull to get the exception, but slow enough @@ -175,7 +176,8 @@ public class StreamFlowControlTest { } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") void testAsync(String uri, boolean sameClient) { @@ -207,7 +209,7 @@ public class StreamFlowControlTest { if (sameClient) { String key = response.headers().firstValue("X-Connection-Key").get(); if (label == null) label = key; - assertEquals(key, label, "Unexpected key for " + query); + assertEquals(label, key, "Unexpected key for " + query); } sent.join(); long wait = uri.startsWith("https://") ? 800 : 350; @@ -264,38 +266,38 @@ public class StreamFlowControlTest { } } - @BeforeTest - public void setup() throws Exception { - var http2TestServer = new Http2TestServer("localhost", false, 0); - http2TestServer.addHandler(new Http2TestHandler(), "/http2/"); - this.http2TestServer = HttpTestServer.of(http2TestServer); - http2URI = "http://" + this.http2TestServer.serverAuthority() + "/http2/x"; + @BeforeAll + public static void setup() throws Exception { + var http2TestServerImpl = new Http2TestServer("localhost", false, 0); + http2TestServerImpl.addHandler(new Http2TestHandler(), "/http2/"); + http2TestServer = HttpTestServer.of(http2TestServerImpl); + http2URI = "http://" + http2TestServer.serverAuthority() + "/http2/x"; - var https2TestServer = new Http2TestServer("localhost", true, sslContext); - https2TestServer.addHandler(new Http2TestHandler(), "/https2/"); - this.https2TestServer = HttpTestServer.of(https2TestServer); - this.https2TestServer.addHandler(new HttpHeadOrGetHandler(), "/https2/head/"); - https2URI = "https://" + this.https2TestServer.serverAuthority() + "/https2/x"; - String h2Head = "https://" + this.https2TestServer.serverAuthority() + "/https2/head/z"; + var https2TestServerImpl = new Http2TestServer("localhost", true, sslContext); + https2TestServerImpl.addHandler(new Http2TestHandler(), "/https2/"); + https2TestServer = HttpTestServer.of(https2TestServerImpl); + https2TestServer.addHandler(new HttpHeadOrGetHandler(), "/https2/head/"); + https2URI = "https://" + https2TestServer.serverAuthority() + "/https2/x"; + String h2Head = "https://" + https2TestServer.serverAuthority() + "/https2/head/z"; // Override the default exchange supplier with a custom one to enable // particular test scenarios - http2TestServer.setExchangeSupplier(FCHttp2TestExchange::new); - https2TestServer.setExchangeSupplier(FCHttp2TestExchange::new); + http2TestServerImpl.setExchangeSupplier(FCHttp2TestExchange::new); + https2TestServerImpl.setExchangeSupplier(FCHttp2TestExchange::new); - this.http2TestServer.start(); - this.https2TestServer.start(); + http2TestServer.start(); + https2TestServer.start(); // warmup to eliminate delay due to SSL class loading and initialization. try (var client = HttpClient.newBuilder().sslContext(sslContext).build()) { var request = HttpRequest.newBuilder(URI.create(h2Head)).HEAD().build(); var resp = client.send(request, BodyHandlers.discarding()); - assertEquals(resp.statusCode(), 200); + assertEquals(200, resp.statusCode()); } } - @AfterTest - public void teardown() throws Exception { + @AfterAll + public static void teardown() throws Exception { http2TestServer.stop(); https2TestServer.stop(); } diff --git a/test/jdk/java/net/httpclient/http2/TrailingHeadersTest.java b/test/jdk/java/net/httpclient/http2/TrailingHeadersTest.java index 9fa6f8b728e..9ea331d2d84 100644 --- a/test/jdk/java/net/httpclient/http2/TrailingHeadersTest.java +++ b/test/jdk/java/net/httpclient/http2/TrailingHeadersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ * @bug 8296410 * @library /test/jdk/java/net/httpclient/lib * @build jdk.httpclient.test.lib.http2.Http2TestServer - * @run testng/othervm -Djdk.httpclient.HttpClient.log=all TrailingHeadersTest + * @run junit/othervm -Djdk.httpclient.HttpClient.log=all TrailingHeadersTest */ import jdk.httpclient.test.lib.http2.OutgoingPushPromise; @@ -36,11 +36,6 @@ import jdk.internal.net.http.common.HttpHeadersBuilder; import jdk.internal.net.http.frame.DataFrame; import jdk.internal.net.http.frame.HeaderFrame; import jdk.internal.net.http.frame.HeadersFrame; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLSession; import java.io.ByteArrayInputStream; @@ -74,24 +69,30 @@ import jdk.httpclient.test.lib.http2.BodyOutputStream; import static java.net.http.HttpClient.Version.HTTP_2; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; public class TrailingHeadersTest { - Http2TestServer http2TestServer; - URI trailingURI, trailng1xxURI, trailingPushPromiseURI, warmupURI; + private static Http2TestServer http2TestServer; + private static URI trailingURI, trailng1xxURI, trailingPushPromiseURI, warmupURI; static PrintStream testLog = System.err; // Set up simple client-side push promise handler - ConcurrentMap>> pushPromiseMap = new ConcurrentHashMap<>(); + private static ConcurrentMap>> pushPromiseMap = new ConcurrentHashMap<>(); - @BeforeMethod + @BeforeEach public void beforeMethod() { pushPromiseMap = new ConcurrentHashMap<>(); } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { Properties props = new Properties(); // For triggering trailing headers to send after Push Promise Response headers are sent props.setProperty("sendTrailingHeadersAfterPushPromise", "1"); @@ -119,12 +120,13 @@ public class TrailingHeadersTest { warmupURI = URI.create("http://" + http2TestServer.serverAuthority() + "/WarmupHandler"); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { http2TestServer.stop(); } - @Test(dataProvider = "httpRequests") + @ParameterizedTest + @MethodSource("uris") public void testTrailingHeaders(String description, HttpRequest hRequest, HttpResponse.PushPromiseHandler pph) { testLog.println("testTrailingHeaders(): " + description); HttpClient httpClient = HttpClient.newBuilder().build(); @@ -134,7 +136,7 @@ public class TrailingHeadersTest { testLog.println("testTrailingHeaders(): Performing request: " + hRequest); HttpResponse resp = cf.join(); - assertEquals(resp.statusCode(), 200, "Status code of response should be 200"); + assertEquals(200, resp.statusCode(), "Status code of response should be 200"); // Verify Push Promise was successful if necessary if (pph != null) @@ -144,14 +146,14 @@ public class TrailingHeadersTest { } private void verifyPushPromise() { - assertEquals(pushPromiseMap.size(), 1, "Push Promise should not be greater than 1"); + assertEquals(1, pushPromiseMap.size(), "Push Promise should not be greater than 1"); // This will only iterate once for (HttpRequest r : pushPromiseMap.keySet()) { CompletableFuture> serverPushResp = pushPromiseMap.get(r); // Get the push promise HttpResponse result if present HttpResponse resp = serverPushResp.join(); - assertEquals(resp.body(), "Sample_Push_Data", "Unexpected Push Promise response body"); - assertEquals(resp.statusCode(), 200, "Status code of Push Promise response should be 200"); + assertEquals("Sample_Push_Data", resp.body(), "Unexpected Push Promise response body"); + assertEquals(200, resp.statusCode(), "Status code of Push Promise response should be 200"); } } @@ -162,11 +164,10 @@ public class TrailingHeadersTest { httpClient.sendAsync(warmupReq, BodyHandlers.discarding()).join(); } - @DataProvider(name = "httpRequests") - public Object[][] uris() { + public static Object[][] uris() { HttpResponse.PushPromiseHandler pph = (initial, pushRequest, acceptor) -> { HttpResponse.BodyHandler s = HttpResponse.BodyHandlers.ofString(UTF_8); - pushPromiseMap.put(pushRequest, acceptor.apply(s)); + TrailingHeadersTest.pushPromiseMap.put(pushRequest, acceptor.apply(s)); }; HttpRequest httpGetTrailing = HttpRequest.newBuilder(trailingURI).version(HTTP_2) diff --git a/test/jdk/java/net/httpclient/http2/java.net.http/jdk/internal/net/http/hpack/HeaderTableTest.java b/test/jdk/java/net/httpclient/http2/java.net.http/jdk/internal/net/http/hpack/HeaderTableTest.java index 0eb1714da35..07e27a7f2fa 100644 --- a/test/jdk/java/net/httpclient/http2/java.net.http/jdk/internal/net/http/hpack/HeaderTableTest.java +++ b/test/jdk/java/net/httpclient/http2/java.net.http/jdk/internal/net/http/hpack/HeaderTableTest.java @@ -29,9 +29,9 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import org.junit.jupiter.api.Assertions; -import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; public class HeaderTableTest extends SimpleHeaderTableTest { @@ -76,7 +76,7 @@ public class HeaderTableTest extends SimpleHeaderTableTest { Set expectedIndexes = indexes.get(hName); int actualMinimalIndex = table.indexOf(hName, "blah-blah"); - Assertions.assertTrue(expectedIndexes.contains(-actualMinimalIndex)); + assertTrue(expectedIndexes.contains(-actualMinimalIndex)); }); } diff --git a/test/jdk/java/net/httpclient/http3/H3MultipleConnectionsToSameHost.java b/test/jdk/java/net/httpclient/http3/H3MultipleConnectionsToSameHost.java index 67ac821b6f7..f9ba35359bc 100644 --- a/test/jdk/java/net/httpclient/http3/H3MultipleConnectionsToSameHost.java +++ b/test/jdk/java/net/httpclient/http3/H3MultipleConnectionsToSameHost.java @@ -30,6 +30,9 @@ * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.http2.Http2TestServer * @run junit/othervm/timeout=360 -XX:+CrashOnOutOfMemoryError + * -Djdk.httpclient.quic.idleTimeout=100000 + * -Djdk.httpclient.keepalive.timeout.h3=100000 + * -Djdk.test.server.quic.idleTimeout=100000 * -Djdk.httpclient.quic.minPtoBackoffTime=60 * -Djdk.httpclient.quic.maxPtoBackoffTime=90 * -Djdk.httpclient.quic.maxPtoBackoff=10 @@ -53,6 +56,9 @@ * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.http2.Http2TestServer * @run junit/othervm/timeout=360 -XX:+CrashOnOutOfMemoryError + * -Djdk.httpclient.quic.idleTimeout=100000 + * -Djdk.httpclient.keepalive.timeout.h3=100000 + * -Djdk.test.server.quic.idleTimeout=100000 * -Djdk.httpclient.quic.minPtoBackoffTime=45 * -Djdk.httpclient.quic.maxPtoBackoffTime=60 * -Djdk.httpclient.quic.maxPtoBackoff=9 @@ -76,9 +82,9 @@ * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.http2.Http2TestServer * @run junit/othervm/timeout=360 -XX:+CrashOnOutOfMemoryError - * -Djdk.httpclient.quic.idleTimeout=120 - * -Djdk.httpclient.keepalive.timeout.h3=120 - * -Djdk.test.server.quic.idleTimeout=90 + * -Djdk.httpclient.quic.idleTimeout=100000 + * -Djdk.httpclient.keepalive.timeout.h3=100000 + * -Djdk.test.server.quic.idleTimeout=100000 * -Djdk.httpclient.quic.minPtoBackoffTime=60 * -Djdk.httpclient.quic.maxPtoBackoffTime=120 * -Djdk.httpclient.quic.maxPtoBackoff=9 @@ -101,9 +107,9 @@ * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.http2.Http2TestServer * @run junit/othervm/timeout=360 -XX:+CrashOnOutOfMemoryError - * -Djdk.httpclient.quic.idleTimeout=120 - * -Djdk.httpclient.keepalive.timeout.h3=120 - * -Djdk.test.server.quic.idleTimeout=90 + * -Djdk.httpclient.quic.idleTimeout=100000 + * -Djdk.httpclient.keepalive.timeout.h3=100000 + * -Djdk.test.server.quic.idleTimeout=100000 * -Djdk.httpclient.quic.minPtoBackoffTime=60 * -Djdk.httpclient.quic.maxPtoBackoffTime=120 * -Djdk.httpclient.quic.maxPtoBackoff=9 diff --git a/test/jdk/java/net/httpclient/websocket/Abort.java b/test/jdk/java/net/httpclient/websocket/Abort.java index 99c94de83f0..a6088f8cce2 100644 --- a/test/jdk/java/net/httpclient/websocket/Abort.java +++ b/test/jdk/java/net/httpclient/websocket/Abort.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,12 +24,11 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.websocket.debug=true * Abort */ -import org.testng.annotations.Test; import java.io.IOException; import java.net.ProtocolException; @@ -44,10 +43,12 @@ import java.util.concurrent.TimeoutException; import static java.net.http.HttpClient.newHttpClient; import static java.net.http.WebSocket.NORMAL_CLOSURE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; public class Abort { @@ -79,7 +80,7 @@ public class Abort { TimeUnit.SECONDS.sleep(5); List inv = listener.invocationsSoFar(); // no more invocations after onOpen as WebSocket was aborted - assertEquals(inv, List.of(MockListener.Invocation.onOpen(webSocket))); + assertEquals(List.of(MockListener.Invocation.onOpen(webSocket)), inv); } finally { webSocket.abort(); } @@ -119,7 +120,7 @@ public class Abort { List expected = List.of( MockListener.Invocation.onOpen(webSocket), MockListener.Invocation.onText(webSocket, "", true)); - assertEquals(inv, expected); + assertEquals(expected, inv); } finally { webSocket.abort(); } @@ -159,7 +160,7 @@ public class Abort { List expected = List.of( MockListener.Invocation.onOpen(webSocket), MockListener.Invocation.onBinary(webSocket, ByteBuffer.allocate(0), true)); - assertEquals(inv, expected); + assertEquals(expected, inv); } finally { webSocket.abort(); } @@ -198,7 +199,7 @@ public class Abort { List expected = List.of( MockListener.Invocation.onOpen(webSocket), MockListener.Invocation.onPing(webSocket, ByteBuffer.allocate(0))); - assertEquals(inv, expected); + assertEquals(expected, inv); } finally { webSocket.abort(); } @@ -237,7 +238,7 @@ public class Abort { List expected = List.of( MockListener.Invocation.onOpen(webSocket), MockListener.Invocation.onPong(webSocket, ByteBuffer.allocate(0))); - assertEquals(inv, expected); + assertEquals(expected, inv); } finally { webSocket.abort(); } @@ -277,7 +278,7 @@ public class Abort { List expected = List.of( MockListener.Invocation.onOpen(webSocket), MockListener.Invocation.onClose(webSocket, 1005, "")); - assertEquals(inv, expected); + assertEquals(expected, inv); } finally { webSocket.abort(); } @@ -318,7 +319,7 @@ public class Abort { MockListener.Invocation.onOpen(webSocket), MockListener.Invocation.onError(webSocket, ProtocolException.class)); System.out.println("actual invocations:" + Arrays.toString(inv.toArray())); - assertEquals(inv, expected); + assertEquals(expected, inv); } finally { webSocket.abort(); } @@ -396,7 +397,7 @@ public class Abort { ws.abort(); assertTrue(ws.isInputClosed()); assertTrue(ws.isOutputClosed()); - assertEquals(ws.getSubprotocol(), ""); + assertEquals("", ws.getSubprotocol()); } // at this point valid requests MUST be a no-op: for (int j = 0; j < 3; j++) { diff --git a/test/jdk/java/net/httpclient/websocket/AutomaticPong.java b/test/jdk/java/net/httpclient/websocket/AutomaticPong.java index 1999781b82f..b438cb8e728 100644 --- a/test/jdk/java/net/httpclient/websocket/AutomaticPong.java +++ b/test/jdk/java/net/httpclient/websocket/AutomaticPong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,13 +24,11 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.websocket.debug=true * AutomaticPong */ import jdk.internal.net.http.websocket.Frame; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; import java.net.http.WebSocket; @@ -39,10 +37,14 @@ import java.nio.charset.StandardCharsets; import java.util.List; import static java.net.http.HttpClient.newHttpClient; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class AutomaticPong { /* @@ -86,7 +88,7 @@ public class AutomaticPong { MockListener.Invocation.onPing(webSocket, hello), MockListener.Invocation.onClose(webSocket, 1005, "") ); - assertEquals(actual, expected); + assertEquals(expected, actual); } finally { webSocket.abort(); } @@ -104,7 +106,8 @@ public class AutomaticPong { * b) the last Pong corresponds to the last Ping * c) there are no unrelated Pongs */ - @Test(dataProvider = "nPings") + @ParameterizedTest + @MethodSource("nPings") public void automaticPongs(int nPings) throws Exception { // big enough to not bother with resize ByteBuffer buffer = ByteBuffer.allocate(65536); @@ -133,7 +136,7 @@ public class AutomaticPong { .join(); try { List inv = listener.invocations(); - assertEquals(inv.size(), nPings + 2); // n * onPing + onOpen + onClose + assertEquals(nPings + 2, inv.size()); // n * onPing + onOpen + onClose ByteBuffer data = server.read(); Frame.Reader reader = new Frame.Reader(); @@ -171,7 +174,7 @@ public class AutomaticPong { closed = true; return; } - assertEquals(value, Frame.Opcode.PONG); + assertEquals(Frame.Opcode.PONG, value); } @Override @@ -182,7 +185,7 @@ public class AutomaticPong { @Override public void payloadLen(long value) { if (!closed) - assertEquals(value, 4); + assertEquals(4, value); } @Override @@ -222,8 +225,7 @@ public class AutomaticPong { } - @DataProvider(name = "nPings") - public Object[][] nPings() { + public static Object[][] nPings() { return new Object[][]{{1}, {2}, {4}, {8}, {9}, {256}}; } } diff --git a/test/jdk/java/net/httpclient/websocket/BlowupOutputQueue.java b/test/jdk/java/net/httpclient/websocket/BlowupOutputQueue.java index 7bf2564a04f..1865ca05e4f 100644 --- a/test/jdk/java/net/httpclient/websocket/BlowupOutputQueue.java +++ b/test/jdk/java/net/httpclient/websocket/BlowupOutputQueue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,14 +24,12 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.internal.httpclient.websocket.debug=true * BlowupOutputQueue */ -import org.testng.annotations.Test; - import java.io.IOException; import java.net.http.WebSocket; import java.nio.ByteBuffer; @@ -43,7 +41,8 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import static org.testng.Assert.assertFalse; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; public class BlowupOutputQueue extends PendingOperations { diff --git a/test/jdk/java/net/httpclient/websocket/HandshakeUrlEncodingTest.java b/test/jdk/java/net/httpclient/websocket/HandshakeUrlEncodingTest.java index 25a6893ff13..6854cacbcc2 100644 --- a/test/jdk/java/net/httpclient/websocket/HandshakeUrlEncodingTest.java +++ b/test/jdk/java/net/httpclient/websocket/HandshakeUrlEncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.TestServerConfigurator * @modules java.net.http/jdk.internal.net.http.common * jdk.httpserver - * @run testng/othervm -Djdk.internal.httpclient.debug=true HandshakeUrlEncodingTest + * @run junit/othervm -Djdk.internal.httpclient.debug=true HandshakeUrlEncodingTest */ import com.sun.net.httpserver.HttpHandler; @@ -39,10 +39,6 @@ import com.sun.net.httpserver.HttpExchange; import jdk.httpclient.test.lib.common.TestServerConfigurator; import jdk.test.lib.net.SimpleSSLContext; import jdk.test.lib.net.URIBuilder; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -58,20 +54,25 @@ import java.util.concurrent.CompletionException; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; - import static java.net.http.HttpClient.Builder.NO_PROXY; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; import static java.lang.System.out; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; + + public class HandshakeUrlEncodingTest { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpServer httpTestServer; - HttpsServer httpsTestServer; - String httpURI; - String httpsURI; + private static HttpServer httpTestServer; + private static HttpsServer httpsTestServer; + private static String httpURI; + private static String httpsURI; static String queryPart; @@ -79,8 +80,7 @@ public class HandshakeUrlEncodingTest { // a shared executor helps reduce the amount of threads created by the test static final ExecutorService executor = Executors.newCachedThreadPool(); - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][]{ { httpURI, false }, { httpsURI, false }, @@ -97,7 +97,8 @@ public class HandshakeUrlEncodingTest { .build(); } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void test(String uri, boolean sameClient) { HttpClient client = null; out.println("The url is " + uri); @@ -119,22 +120,21 @@ public class HandshakeUrlEncodingTest { final WebSocketHandshakeException wse = (WebSocketHandshakeException) t; assertNotNull(wse.getResponse()); assertNotNull(wse.getResponse().uri()); - assertNotNull(wse.getResponse().statusCode()); final String rawQuery = wse.getResponse().uri().getRawQuery(); final String expectedRawQuery = "&raw=abc+def/ghi=xyz&encoded=abc%2Bdef%2Fghi%3Dxyz"; - assertEquals(rawQuery, expectedRawQuery); + assertEquals(expectedRawQuery, rawQuery); final String body = (String) wse.getResponse().body(); final String expectedBody = "/?" + expectedRawQuery; - assertEquals(body, expectedBody); + assertEquals(expectedBody, body); out.println("Status code is " + wse.getResponse().statusCode()); out.println("Response is " + wse.getResponse()); - assertEquals(wse.getResponse().statusCode(), 400); + assertEquals(400, wse.getResponse().statusCode()); } } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); queryPart = "?&raw=abc+def/ghi=xyz&encoded=abc%2Bdef%2Fghi%3Dxyz"; httpTestServer = HttpServer.create(sa, 10); @@ -164,8 +164,8 @@ public class HandshakeUrlEncodingTest { httpsTestServer.start(); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { httpTestServer.stop(0); httpsTestServer.stop(0); executor.shutdownNow(); diff --git a/test/jdk/java/net/httpclient/websocket/HeaderWriterDriver.java b/test/jdk/java/net/httpclient/websocket/HeaderWriterDriver.java index 6293b1b6c71..75ae5423f00 100644 --- a/test/jdk/java/net/httpclient/websocket/HeaderWriterDriver.java +++ b/test/jdk/java/net/httpclient/websocket/HeaderWriterDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,7 +25,7 @@ * @test * @bug 8159053 * @modules java.net.http/jdk.internal.net.http.websocket:open - * @run testng/othervm + * @run junit/othervm * --add-reads java.net.http=ALL-UNNAMED * java.net.http/jdk.internal.net.http.websocket.HeaderWriterTest */ diff --git a/test/jdk/java/net/httpclient/websocket/MaskerDriver.java b/test/jdk/java/net/httpclient/websocket/MaskerDriver.java index b84ea1fff5c..e81417c25ef 100644 --- a/test/jdk/java/net/httpclient/websocket/MaskerDriver.java +++ b/test/jdk/java/net/httpclient/websocket/MaskerDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,7 +25,7 @@ * @test * @bug 8159053 * @modules java.net.http/jdk.internal.net.http.websocket:open - * @run testng/othervm + * @run junit/othervm * --add-reads java.net.http=ALL-UNNAMED * java.net.http/jdk.internal.net.http.websocket.MaskerTest */ diff --git a/test/jdk/java/net/httpclient/websocket/MessageQueueDriver.java b/test/jdk/java/net/httpclient/websocket/MessageQueueDriver.java index 9831bb59297..68a23d0be88 100644 --- a/test/jdk/java/net/httpclient/websocket/MessageQueueDriver.java +++ b/test/jdk/java/net/httpclient/websocket/MessageQueueDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +25,7 @@ * @test * @bug 8159053 * @modules java.net.http/jdk.internal.net.http.websocket:open - * @run testng/othervm + * @run junit/othervm * --add-reads java.net.http=ALL-UNNAMED * java.net.http/jdk.internal.net.http.websocket.MessageQueueTest */ diff --git a/test/jdk/java/net/httpclient/websocket/PendingBinaryPingClose.java b/test/jdk/java/net/httpclient/websocket/PendingBinaryPingClose.java index 5a410251593..4a5ae315e91 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingBinaryPingClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingBinaryPingClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,28 +24,30 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.sendBufferSize=8192 * -Djdk.internal.httpclient.debug=true * -Djdk.internal.httpclient.websocket.debug=true * PendingBinaryPingClose */ -import org.testng.annotations.Test; - import java.net.http.WebSocket; import java.nio.ByteBuffer; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PendingBinaryPingClose extends PendingOperations { CompletableFuture cfBinary; CompletableFuture cfPing; CompletableFuture cfClose; - @Test(dataProvider = "booleans") + @ParameterizedTest + @MethodSource("booleans") public void pendingBinaryPingClose(boolean last) throws Exception { repeatable(() -> { server = Support.notReadingServer(); diff --git a/test/jdk/java/net/httpclient/websocket/PendingBinaryPongClose.java b/test/jdk/java/net/httpclient/websocket/PendingBinaryPongClose.java index bef3d258850..a8330faeb3f 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingBinaryPongClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingBinaryPongClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,28 +24,30 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.sendBufferSize=8192 * -Djdk.internal.httpclient.debug=true * -Djdk.internal.httpclient.websocket.debug=true * PendingBinaryPongClose */ -import org.testng.annotations.Test; - import java.net.http.WebSocket; import java.nio.ByteBuffer; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PendingBinaryPongClose extends PendingOperations { CompletableFuture cfBinary; CompletableFuture cfPong; CompletableFuture cfClose; - @Test(dataProvider = "booleans") + @ParameterizedTest + @MethodSource("booleans") public void pendingBinaryPongClose(boolean last) throws Exception { repeatable(() -> { server = Support.notReadingServer(); diff --git a/test/jdk/java/net/httpclient/websocket/PendingOperations.java b/test/jdk/java/net/httpclient/websocket/PendingOperations.java index b4d7d7e2222..32350a1ab41 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingOperations.java +++ b/test/jdk/java/net/httpclient/websocket/PendingOperations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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 @@ -21,9 +21,6 @@ * questions. */ -import org.testng.annotations.AfterMethod; -import org.testng.annotations.DataProvider; - import java.io.IOException; import java.net.http.HttpClient; import java.net.http.WebSocket; @@ -35,6 +32,8 @@ import java.util.function.BooleanSupplier; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpClient.newBuilder; +import org.junit.jupiter.api.AfterEach; + /* Common infrastructure for tests that check pending operations */ public class PendingOperations { @@ -54,7 +53,7 @@ public class PendingOperations { return newBuilder().proxy(NO_PROXY).build(); } - @AfterMethod + @AfterEach public void cleanup() { // make sure we have a trace both on System.out and System.err // to help with diagnosis. @@ -85,8 +84,7 @@ public class PendingOperations { Support.assertNotDone(future); } - @DataProvider(name = "booleans") - public Object[][] booleans() { + public static Object[][] booleans() { return new Object[][]{{Boolean.TRUE}, {Boolean.FALSE}}; } diff --git a/test/jdk/java/net/httpclient/websocket/PendingPingBinaryClose.java b/test/jdk/java/net/httpclient/websocket/PendingPingBinaryClose.java index c1c314395e8..e07ebe0d03a 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingPingBinaryClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingPingBinaryClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.sendBufferSize=8192 * PendingPingBinaryClose */ @@ -33,21 +33,23 @@ // * -Djdk.internal.httpclient.debug=true // * -Djdk.internal.httpclient.websocket.debug=true -import org.testng.annotations.Test; - import java.net.http.WebSocket; import java.nio.ByteBuffer; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PendingPingBinaryClose extends PendingOperations { CompletableFuture cfBinary; CompletableFuture cfPing; CompletableFuture cfClose; - @Test(dataProvider = "booleans") + @ParameterizedTest + @MethodSource("booleans") public void pendingPingBinaryClose(boolean last) throws Exception { repeatable( () -> { server = Support.notReadingServer(); diff --git a/test/jdk/java/net/httpclient/websocket/PendingPingTextClose.java b/test/jdk/java/net/httpclient/websocket/PendingPingTextClose.java index 82666fafe67..eae01f804a4 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingPingTextClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingPingTextClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.sendBufferSize=8192 * PendingPingTextClose */ @@ -33,14 +33,15 @@ // * -Djdk.internal.httpclient.debug=true // * -Djdk.internal.httpclient.websocket.debug=true -import org.testng.annotations.Test; - import java.net.http.WebSocket; import java.nio.ByteBuffer; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PendingPingTextClose extends PendingOperations { static boolean debug = false; // avoid too verbose output @@ -48,7 +49,8 @@ public class PendingPingTextClose extends PendingOperations { CompletableFuture cfPing; CompletableFuture cfClose; - @Test(dataProvider = "booleans") + @ParameterizedTest + @MethodSource("booleans") public void pendingPingTextClose(boolean last) throws Exception { try { repeatable(() -> { diff --git a/test/jdk/java/net/httpclient/websocket/PendingPongBinaryClose.java b/test/jdk/java/net/httpclient/websocket/PendingPongBinaryClose.java index 0aa2f24c660..32640853b00 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingPongBinaryClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingPongBinaryClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.sendBufferSize=8192 * PendingPongBinaryClose */ @@ -33,21 +33,23 @@ // * -Djdk.internal.httpclient.debug=true // * -Djdk.internal.httpclient.websocket.debug=true -import org.testng.annotations.Test; - import java.net.http.WebSocket; import java.nio.ByteBuffer; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PendingPongBinaryClose extends PendingOperations { CompletableFuture cfBinary; CompletableFuture cfPong; CompletableFuture cfClose; - @Test(dataProvider = "booleans") + @ParameterizedTest + @MethodSource("booleans") public void pendingPongBinaryClose(boolean last) throws Exception { repeatable( () -> { server = Support.notReadingServer(); diff --git a/test/jdk/java/net/httpclient/websocket/PendingPongTextClose.java b/test/jdk/java/net/httpclient/websocket/PendingPongTextClose.java index f919a6706ad..f4d6c84c2f5 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingPongTextClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingPongTextClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.httpclient.sendBufferSize=8192 * PendingPongTextClose */ @@ -33,21 +33,23 @@ // * -Djdk.internal.httpclient.debug=true // * -Djdk.internal.httpclient.websocket.debug=true -import org.testng.annotations.Test; - import java.net.http.WebSocket; import java.nio.ByteBuffer; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PendingPongTextClose extends PendingOperations { CompletableFuture cfText; CompletableFuture cfPong; CompletableFuture cfClose; - @Test(dataProvider = "booleans") + @ParameterizedTest + @MethodSource("booleans") public void pendingPongTextClose(boolean last) throws Exception { repeatable( () -> { server = Support.notReadingServer(); diff --git a/test/jdk/java/net/httpclient/websocket/PendingTextPingClose.java b/test/jdk/java/net/httpclient/websocket/PendingTextPingClose.java index 39c8bbdc444..76f12430804 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingTextPingClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingTextPingClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,15 +24,13 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.internal.httpclient.websocket.debug=true * -Djdk.httpclient.sendBufferSize=8192 * PendingTextPingClose */ -import org.testng.annotations.Test; - import java.net.http.WebSocket; import java.nio.ByteBuffer; import java.nio.CharBuffer; @@ -40,13 +38,17 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PendingTextPingClose extends PendingOperations { CompletableFuture cfText; CompletableFuture cfPing; CompletableFuture cfClose; - @Test(dataProvider = "booleans") + @ParameterizedTest + @MethodSource("booleans") public void pendingTextPingClose(boolean last) throws Exception { repeatable(() -> { server = Support.notReadingServer(); diff --git a/test/jdk/java/net/httpclient/websocket/PendingTextPongClose.java b/test/jdk/java/net/httpclient/websocket/PendingTextPongClose.java index 8fa90400760..a2a41a73d7b 100644 --- a/test/jdk/java/net/httpclient/websocket/PendingTextPongClose.java +++ b/test/jdk/java/net/httpclient/websocket/PendingTextPongClose.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,15 +24,13 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.internal.httpclient.websocket.debug=true * -Djdk.httpclient.sendBufferSize=8192 * PendingTextPongClose */ -import org.testng.annotations.Test; - import java.net.http.WebSocket; import java.nio.ByteBuffer; import java.nio.CharBuffer; @@ -40,13 +38,17 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + public class PendingTextPongClose extends PendingOperations { CompletableFuture cfText; CompletableFuture cfPong; CompletableFuture cfClose; - @Test(dataProvider = "booleans") + @ParameterizedTest + @MethodSource("booleans") public void pendingTextPongClose(boolean last) throws Exception { repeatable(() -> { server = Support.notReadingServer(); diff --git a/test/jdk/java/net/httpclient/websocket/ReaderDriver.java b/test/jdk/java/net/httpclient/websocket/ReaderDriver.java index 0b874792b4f..3e195be046d 100644 --- a/test/jdk/java/net/httpclient/websocket/ReaderDriver.java +++ b/test/jdk/java/net/httpclient/websocket/ReaderDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ * @test * @bug 8159053 * @modules java.net.http/jdk.internal.net.http.websocket:open - * @run testng/othervm/timeout=240 --add-reads java.net.http=ALL-UNNAMED java.net.http/jdk.internal.net.http.websocket.ReaderTest + * @run junit/othervm/timeout=240 + * --add-reads java.net.http=ALL-UNNAMED + * java.net.http/jdk.internal.net.http.websocket.ReaderTest */ public final class ReaderDriver { } diff --git a/test/jdk/java/net/httpclient/websocket/SecureSupport.java b/test/jdk/java/net/httpclient/websocket/SecureSupport.java index 8b565768c29..41709d2fedb 100644 --- a/test/jdk/java/net/httpclient/websocket/SecureSupport.java +++ b/test/jdk/java/net/httpclient/websocket/SecureSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,18 +22,9 @@ */ import java.io.IOException; -import java.net.Socket; import java.nio.ByteBuffer; -import java.nio.channels.SocketChannel; import java.nio.charset.StandardCharsets; import java.util.Arrays; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionException; -import java.util.concurrent.CompletionStage; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import static org.testng.Assert.assertThrows; /** * Helper class to create instances of DummySecureWebSocketServer which diff --git a/test/jdk/java/net/httpclient/websocket/SendTest.java b/test/jdk/java/net/httpclient/websocket/SendTest.java index 39021131156..b3a433b5c29 100644 --- a/test/jdk/java/net/httpclient/websocket/SendTest.java +++ b/test/jdk/java/net/httpclient/websocket/SendTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,22 +24,22 @@ /* * @test * @build DummyWebSocketServer - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.websocket.debug=true * SendTest */ -import org.testng.annotations.Test; - import java.io.IOException; import java.net.http.WebSocket; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpClient.newBuilder; import static java.net.http.WebSocket.NORMAL_CLOSURE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SendTest { @@ -90,7 +90,7 @@ public class SendTest { try { webSocket.sendClose(NORMAL_CLOSURE, "").join(); assertTrue(webSocket.isOutputClosed()); - assertEquals(webSocket.getSubprotocol(), ""); + assertEquals("", webSocket.getSubprotocol()); webSocket.request(1); // No exceptions must be thrown } finally { webSocket.abort(); diff --git a/test/jdk/java/net/httpclient/websocket/Support.java b/test/jdk/java/net/httpclient/websocket/Support.java index 1323ae35105..73f840ff7eb 100644 --- a/test/jdk/java/net/httpclient/websocket/Support.java +++ b/test/jdk/java/net/httpclient/websocket/Support.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,8 +32,8 @@ import java.util.concurrent.CompletionStage; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertFalse; public class Support { diff --git a/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java b/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java index 90db79dc8ef..f28d84b2f20 100644 --- a/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java +++ b/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ * @build jdk.test.lib.net.SimpleSSLContext jdk.httpclient.test.lib.common.TestServerConfigurator * @modules java.net.http/jdk.internal.net.http.common * jdk.httpserver - * @run testng/othervm -Djdk.internal.httpclient.debug=true WSHandshakeExceptionTest + * @run junit/othervm -Djdk.internal.httpclient.debug=true WSHandshakeExceptionTest */ import com.sun.net.httpserver.HttpHandler; @@ -37,8 +37,6 @@ import com.sun.net.httpserver.HttpServer; import com.sun.net.httpserver.HttpsServer; import com.sun.net.httpserver.HttpExchange; - - import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -49,10 +47,6 @@ import java.net.http.WebSocketHandshakeException; import jdk.httpclient.test.lib.common.TestServerConfigurator; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.net.InetSocketAddress; import java.net.URI; @@ -62,29 +56,33 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import static java.net.http.HttpClient.Builder.NO_PROXY; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; import static java.lang.System.out; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + public class WSHandshakeExceptionTest { private static final SSLContext sslContext = SimpleSSLContext.findSSLContext(); - HttpServer httpTestServer; // HTTP/1.1 [ 2 servers ] - HttpsServer httpsTestServer; // HTTPS/1.1 - String httpURI; - String httpsURI; - String httpNonUtf8URI; - String httpsNonUtf8URI; - HttpClient sharedClient; + private static HttpServer httpTestServer; // HTTP/1.1 [ 2 servers ] + private static HttpsServer httpsTestServer; // HTTPS/1.1 + private static String httpURI; + private static String httpsURI; + private static String httpNonUtf8URI; + private static String httpsNonUtf8URI; + private static HttpClient sharedClient; static final int ITERATION_COUNT = 4; // a shared executor helps reduce the amount of threads created by the test static final ExecutorService executor = Executors.newCachedThreadPool(); - @DataProvider(name = "variants") - public Object[][] variants() { + public static Object[][] variants() { return new Object[][]{ { httpURI, false }, { httpsURI, false }, @@ -106,7 +104,8 @@ public class WSHandshakeExceptionTest { .build(); } - @Test(dataProvider = "variants") + @ParameterizedTest + @MethodSource("variants") public void test(String uri, boolean sameClient) { HttpClient client = sharedClient; boolean pause; @@ -132,7 +131,7 @@ public class WSHandshakeExceptionTest { WebSocketHandshakeException wse = (WebSocketHandshakeException) t; assertNotNull(wse.getResponse()); assertNotNull(wse.getResponse().body()); - assertEquals(wse.getResponse().body().getClass(), String.class); + assertEquals(String.class, wse.getResponse().body().getClass()); String body = (String)wse.getResponse().body(); out.println("Status code is " + wse.getResponse().statusCode()); out.println("Response is " + body); @@ -145,7 +144,7 @@ public class WSHandshakeExceptionTest { // default HttpServer 404 body expected assertTrue(body.contains("404")); } - assertEquals(wse.getResponse().statusCode(), 404); + assertEquals(404, wse.getResponse().statusCode()); } } } @@ -159,8 +158,8 @@ public class WSHandshakeExceptionTest { } } - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { // HTTP/1.1 InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); httpTestServer = HttpServer.create(sa, 0); @@ -178,8 +177,8 @@ public class WSHandshakeExceptionTest { httpsTestServer.start(); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { sharedClient = null; gc(100); httpTestServer.stop(0); diff --git a/test/jdk/java/net/httpclient/websocket/WebSocketBuilderTest.java b/test/jdk/java/net/httpclient/websocket/WebSocketBuilderTest.java index b28b8f59875..beef8cb42a4 100644 --- a/test/jdk/java/net/httpclient/websocket/WebSocketBuilderTest.java +++ b/test/jdk/java/net/httpclient/websocket/WebSocketBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,12 +26,9 @@ * @bug 8159053 * @build DummyWebSocketServer * Support - * @run testng/othervm WebSocketBuilderTest + * @run junit/othervm WebSocketBuilderTest */ -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import java.net.URI; import java.net.http.HttpClient; import java.net.http.WebSocket; @@ -42,7 +39,10 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; -import static org.testng.Assert.assertThrows; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertThrows; /* * In some places in this test a new String is created out of a string literal. @@ -98,7 +98,8 @@ public final class WebSocketBuilderTest { .connectTimeout(null)); } - @Test(dataProvider = "badURIs") + @ParameterizedTest + @MethodSource("badURIs") void illegalURI(URI uri) { WebSocket.Builder b = HttpClient.newHttpClient().newWebSocketBuilder(); assertFails(IllegalArgumentException.class, @@ -129,7 +130,8 @@ public final class WebSocketBuilderTest { // TODO: test for bad syntax headers // TODO: test for overwrites (subprotocols) and additions (headers) - @Test(dataProvider = "badSubprotocols") + @ParameterizedTest + @MethodSource("badSubprotocols") public void illegalSubprotocolsSyntax(String s) { WebSocket.Builder b = HttpClient.newHttpClient() .newWebSocketBuilder() @@ -138,7 +140,8 @@ public final class WebSocketBuilderTest { b.buildAsync(VALID_URI, listener())); } - @Test(dataProvider = "duplicatingSubprotocols") + @ParameterizedTest + @MethodSource("duplicatingSubprotocols") public void illegalSubprotocolsDuplicates(String mostPreferred, String[] lesserPreferred) { WebSocket.Builder b = HttpClient.newHttpClient() @@ -148,7 +151,8 @@ public final class WebSocketBuilderTest { b.buildAsync(VALID_URI, listener())); } - @Test(dataProvider = "badConnectTimeouts") + @ParameterizedTest + @MethodSource("badConnectTimeouts") public void illegalConnectTimeout(Duration d) { WebSocket.Builder b = HttpClient.newHttpClient() .newWebSocketBuilder() @@ -157,8 +161,7 @@ public final class WebSocketBuilderTest { b.buildAsync(VALID_URI, listener())); } - @DataProvider - public Object[][] badURIs() { + public static Object[][] badURIs() { return new Object[][]{ {URI.create("http://example.com")}, {URI.create("ftp://example.com")}, @@ -167,8 +170,7 @@ public final class WebSocketBuilderTest { }; } - @DataProvider - public Object[][] badConnectTimeouts() { + public static Object[][] badConnectTimeouts() { return new Object[][]{ {Duration.ofDays(0)}, {Duration.ofDays(-1)}, @@ -188,7 +190,6 @@ public final class WebSocketBuilderTest { // https://tools.ietf.org/html/rfc7230#section-3.2.6 // https://tools.ietf.org/html/rfc20 - @DataProvider public static Object[][] badSubprotocols() { return new Object[][]{ {""}, @@ -215,7 +216,6 @@ public final class WebSocketBuilderTest { }; } - @DataProvider public static Object[][] duplicatingSubprotocols() { return new Object[][]{ {"a.b.c", new String[]{"a.b.c"}}, diff --git a/test/jdk/java/net/httpclient/websocket/WebSocketExtendedTest.java b/test/jdk/java/net/httpclient/websocket/WebSocketExtendedTest.java index 0099104e872..56474555235 100644 --- a/test/jdk/java/net/httpclient/websocket/WebSocketExtendedTest.java +++ b/test/jdk/java/net/httpclient/websocket/WebSocketExtendedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8159053 - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.websocket.debug=true * -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.websocket.writeBufferSize=1024 @@ -32,8 +32,6 @@ */ import jdk.internal.net.http.websocket.Frame; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; import java.net.http.WebSocket; @@ -43,8 +41,11 @@ import java.util.List; import java.util.Random; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpClient.newBuilder; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /* @@ -52,7 +53,7 @@ import static org.testng.Assert.assertTrue; * possible fragmentation. */ public class WebSocketExtendedTest { -// * run testng/othervm +// * run junit/othervm // * -Djdk.httpclient.websocket.writeBufferSize=16 // * -Djdk.httpclient.sendBufferSize=32 WebSocketTextTest @@ -65,7 +66,8 @@ public class WebSocketExtendedTest { // FIXME ensure subsequent (sendText/Binary, false) only CONTINUATIONs - @Test(dataProvider = "binary") + @ParameterizedTest + @MethodSource("binary") public void binary(ByteBuffer expected) throws IOException, InterruptedException { try (DummyWebSocketServer server = new DummyWebSocketServer()) { server.open(); @@ -76,15 +78,16 @@ public class WebSocketExtendedTest { ws.sendBinary(expected.duplicate(), true).join(); ws.abort(); List frames = server.readFrames(); - assertEquals(frames.size(), 1); + assertEquals(1, frames.size()); DummyWebSocketServer.DecodedFrame f = frames.get(0); assertTrue(f.last()); - assertEquals(f.opcode(), Frame.Opcode.BINARY); - assertEquals(f.data(), expected); + assertEquals(Frame.Opcode.BINARY, f.opcode()); + assertEquals(expected, f.data()); } } - @Test(dataProvider = "pingPong") + @ParameterizedTest + @MethodSource("pingPongSizes") public void ping(ByteBuffer expected) throws Exception { try (DummyWebSocketServer server = new DummyWebSocketServer()) { server.open(); @@ -95,17 +98,18 @@ public class WebSocketExtendedTest { ws.sendPing(expected.duplicate()).join(); ws.abort(); List frames = server.readFrames(); - assertEquals(frames.size(), 1); + assertEquals(1, frames.size()); DummyWebSocketServer.DecodedFrame f = frames.get(0); - assertEquals(f.opcode(), Frame.Opcode.PING); + assertEquals(Frame.Opcode.PING, f.opcode()); ByteBuffer actual = ByteBuffer.allocate(expected.remaining()); actual.put(f.data()); actual.flip(); - assertEquals(actual, expected); + assertEquals(expected, actual); } } - @Test(dataProvider = "pingPong") + @ParameterizedTest + @MethodSource("pingPongSizes") public void pong(ByteBuffer expected) throws Exception { try (DummyWebSocketServer server = new DummyWebSocketServer()) { server.open(); @@ -116,17 +120,18 @@ public class WebSocketExtendedTest { ws.sendPong(expected.duplicate()).join(); ws.abort(); List frames = server.readFrames(); - assertEquals(frames.size(), 1); + assertEquals(1, frames.size()); DummyWebSocketServer.DecodedFrame f = frames.get(0); - assertEquals(f.opcode(), Frame.Opcode.PONG); + assertEquals(Frame.Opcode.PONG, f.opcode()); ByteBuffer actual = ByteBuffer.allocate(expected.remaining()); actual.put(f.data()); actual.flip(); - assertEquals(actual, expected); + assertEquals(expected, actual); } } - @Test(dataProvider = "close") + @ParameterizedTest + @MethodSource("closeArguments") public void close(int statusCode, String reason) throws Exception { try (DummyWebSocketServer server = new DummyWebSocketServer()) { server.open(); @@ -137,18 +142,19 @@ public class WebSocketExtendedTest { ws.sendClose(statusCode, reason).join(); ws.abort(); List frames = server.readFrames(); - assertEquals(frames.size(), 1); + assertEquals(1, frames.size()); DummyWebSocketServer.DecodedFrame f = frames.get(0); - assertEquals(f.opcode(), Frame.Opcode.CLOSE); + assertEquals(Frame.Opcode.CLOSE, f.opcode()); ByteBuffer actual = ByteBuffer.allocate(Frame.MAX_CONTROL_FRAME_PAYLOAD_LENGTH); actual.put(f.data()); actual.flip(); - assertEquals(actual.getChar(), statusCode); - assertEquals(StandardCharsets.UTF_8.decode(actual).toString(), reason); + assertEquals(statusCode, actual.getChar()); + assertEquals(reason, StandardCharsets.UTF_8.decode(actual).toString()); } } - @Test(dataProvider = "text") + @ParameterizedTest + @MethodSource("texts") public void text(String expected) throws Exception { try (DummyWebSocketServer server = new DummyWebSocketServer()) { server.open(); @@ -163,12 +169,11 @@ public class WebSocketExtendedTest { ByteBuffer actual = ByteBuffer.allocate(maxBytes); frames.stream().forEachOrdered(f -> actual.put(f.data())); actual.flip(); - assertEquals(StandardCharsets.UTF_8.decode(actual).toString(), expected); + assertEquals(expected, StandardCharsets.UTF_8.decode(actual).toString()); } } - @DataProvider(name = "pingPong") - public Object[][] pingPongSizes() { + public static Object[][] pingPongSizes() { return new Object[][]{ {bytes( 0)}, {bytes( 1)}, @@ -177,8 +182,7 @@ public class WebSocketExtendedTest { }; } - @DataProvider(name = "close") - public Object[][] closeArguments() { + public static Object[][] closeArguments() { return new Object[][]{ {WebSocket.NORMAL_CLOSURE, utf8String( 0)}, {WebSocket.NORMAL_CLOSURE, utf8String( 1)}, @@ -216,16 +220,14 @@ public class WebSocketExtendedTest { return str.toString(); } - @DataProvider(name = "text") - public Object[][] texts() { + public static Object[][] texts() { return new Object[][]{ {utf8String( 0)}, {utf8String(1024)}, }; } - @DataProvider(name = "binary") - public Object[][] binary() { + public static Object[][] binary() { return new Object[][]{ {bytes( 0)}, {bytes(1024)}, diff --git a/test/jdk/java/net/httpclient/websocket/WebSocketProxyTest.java b/test/jdk/java/net/httpclient/websocket/WebSocketProxyTest.java index 46758b2fe6e..a410aa9fe75 100644 --- a/test/jdk/java/net/httpclient/websocket/WebSocketProxyTest.java +++ b/test/jdk/java/net/httpclient/websocket/WebSocketProxyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ * @library /test/lib * @compile SecureSupport.java DummySecureWebSocketServer.java ../ProxyServer.java * @build jdk.test.lib.net.SimpleSSLContext WebSocketProxyTest - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * -Djdk.internal.httpclient.websocket.debug=true * -Djdk.httpclient.HttpClient.log=errors,requests,headers @@ -61,16 +61,18 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import static java.net.http.HttpClient.newBuilder; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.assertEquals; -import static org.testng.FileAssert.fail; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class WebSocketProxyTest { @@ -132,8 +134,7 @@ public class WebSocketProxyTest { @Override public String toString() { return "AUTH_TUNNELING_PROXY_SERVER"; } }; - @DataProvider(name = "servers") - public Object[][] servers() { + public static Object[][] servers() { return new Object[][] { { SERVER_WITH_CANNED_DATA, TUNNELING_PROXY_SERVER }, { SERVER_WITH_CANNED_DATA, AUTH_TUNNELING_PROXY_SERVER }, @@ -175,7 +176,8 @@ public class WebSocketProxyTest { return "%s and %s %s".formatted(actual, expected, message); } - @Test(dataProvider = "servers") + @ParameterizedTest + @MethodSource("servers") public void simpleAggregatingBinaryMessages (Function serverSupplier, Supplier proxyServerSupplier) @@ -263,7 +265,7 @@ public class WebSocketProxyTest { .join(); List a = actual.join(); - assertEquals(ofBytes(a), ofBytes(expected), diagnose(a, expected)); + assertEquals(ofBytes(expected), ofBytes(a), diagnose(a, expected)); } } @@ -359,7 +361,7 @@ public class WebSocketProxyTest { } catch (CompletionException expected) { WebSocketHandshakeException e = (WebSocketHandshakeException)expected.getCause(); HttpResponse response = e.getResponse(); - assertEquals(response.statusCode(), 407); + assertEquals(407, response.statusCode()); } } } @@ -398,7 +400,7 @@ public class WebSocketProxyTest { } } - @BeforeMethod + @BeforeEach public void breakBetweenTests() { System.gc(); try {Thread.sleep(100); } catch (InterruptedException x) { /* OK */ } diff --git a/test/jdk/java/net/httpclient/websocket/WebSocketTest.java b/test/jdk/java/net/httpclient/websocket/WebSocketTest.java index 43bcb054b7d..2b1df3d7e87 100644 --- a/test/jdk/java/net/httpclient/websocket/WebSocketTest.java +++ b/test/jdk/java/net/httpclient/websocket/WebSocketTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,12 +27,10 @@ * @library ../access * @build DummyWebSocketServer * java.net.http/jdk.internal.net.http.HttpClientTimerAccess - * @run testng/othervm + * @run junit/othervm * WebSocketTest */ -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import java.io.IOException; import java.net.Authenticator; @@ -63,9 +61,13 @@ import static java.net.http.HttpClient.newBuilder; import static java.net.http.WebSocket.NORMAL_CLOSURE; import static java.nio.charset.StandardCharsets.UTF_8; import static jdk.internal.net.http.HttpClientTimerAccess.assertNoResponseTimerEventRegistrations; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.fail; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; public class WebSocketTest { @@ -264,8 +266,7 @@ public class WebSocketTest { } } - @DataProvider(name = "sequence") - public Object[][] data1() { + public static Object[][] data1() { int[] CLOSE = { 0x81, 0x00, // "" 0x82, 0x00, // [] @@ -292,7 +293,8 @@ public class WebSocketTest { }; } - @Test(dataProvider = "sequence") + @ParameterizedTest + @MethodSource("data1") public void listenerSequentialOrder(int[] binary, long requestSize) throws IOException { @@ -470,8 +472,7 @@ public class WebSocketTest { @Override public String toString() { return "AUTH_SERVER_WITH_CANNED_DATA"; } }; - @DataProvider(name = "servers") - public Object[][] servers() { + public static Object[][] servers() { return new Object[][] { { SERVER_WITH_CANNED_DATA }, { AUTH_SERVER_WITH_CANNED_DATA }, @@ -507,7 +508,8 @@ public class WebSocketTest { return "%s and %s %s".formatted(actual, expected, message); } - @Test(dataProvider = "servers") + @ParameterizedTest + @MethodSource("servers") public void simpleAggregatingBinaryMessages (Function serverSupplier) throws IOException @@ -600,14 +602,15 @@ public class WebSocketTest { .join(); try { List a = actual.join(); - assertEquals(ofBytes(a), ofBytes(expected), diagnose(a, expected)); + assertEquals(ofBytes(expected), ofBytes(a), diagnose(a, expected)); } finally { webSocket.abort(); } } } - @Test(dataProvider = "servers") + @ParameterizedTest + @MethodSource("servers") public void simpleAggregatingTextMessages (Function serverSupplier) throws IOException @@ -683,7 +686,7 @@ public class WebSocketTest { .join(); try { List a = actual.join(); - assertEquals(a, expected); + assertEquals(expected, a); } finally { webSocket.abort(); } @@ -694,7 +697,8 @@ public class WebSocketTest { * Exercises the scenario where requests for more messages are made prior to * completing the returned CompletionStage instances. */ - @Test(dataProvider = "servers") + @ParameterizedTest + @MethodSource("servers") public void aggregatingTextMessages (Function serverSupplier) throws IOException @@ -784,7 +788,7 @@ public class WebSocketTest { .join(); try { List a = actual.join(); - assertEquals(a, expected); + assertEquals(expected, a); } finally { webSocket.abort(); } @@ -853,7 +857,7 @@ public class WebSocketTest { } catch (CompletionException expected) { WebSocketHandshakeException e = (WebSocketHandshakeException)expected.getCause(); HttpResponse response = e.getResponse(); - assertEquals(response.statusCode(), 401); + assertEquals(401, response.statusCode()); } } } diff --git a/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/HeaderWriterTest.java b/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/HeaderWriterTest.java index 0e55eaf521f..59a66591c93 100644 --- a/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/HeaderWriterTest.java +++ b/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/HeaderWriterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ package jdk.internal.net.http.websocket; -import org.testng.annotations.Test; import jdk.internal.net.http.websocket.Frame.HeaderWriter; import jdk.internal.net.http.websocket.Frame.Opcode; @@ -32,10 +31,12 @@ import java.util.OptionalInt; import static java.util.OptionalInt.empty; import static java.util.OptionalInt.of; -import static org.testng.Assert.assertEquals; import static jdk.internal.net.http.websocket.TestSupport.assertThrows; import static jdk.internal.net.http.websocket.TestSupport.forEachPermutation; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class HeaderWriterTest { private long cases, frames; @@ -109,7 +110,7 @@ public class HeaderWriterTest { ByteBuffer actual = ByteBuffer.allocate(Frame.MAX_HEADER_SIZE_BYTES + 2); writer.write(actual); actual.flip(); - assertEquals(actual, expected); + assertEquals(expected, actual); }); } } diff --git a/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/MaskerTest.java b/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/MaskerTest.java index 7eb892f12ea..cb59b9f7213 100644 --- a/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/MaskerTest.java +++ b/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/MaskerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,17 +23,17 @@ package jdk.internal.net.http.websocket; -import org.testng.annotations.Test; - import java.nio.ByteBuffer; import java.security.SecureRandom; import java.util.stream.IntStream; -import static org.testng.Assert.assertEquals; import static jdk.internal.net.http.websocket.Frame.Masker.applyMask; import static jdk.internal.net.http.websocket.TestSupport.forEachBufferPartition; import static jdk.internal.net.http.websocket.TestSupport.fullCopy; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class MaskerTest { private static final SecureRandom random = new SecureRandom(); @@ -98,14 +98,14 @@ public class MaskerTest { int dstRemaining = dstCopy.remaining(); int masked = Math.min(srcRemaining, dstRemaining); // 1. position check - assertEquals(src.position(), srcCopy.position() + masked); - assertEquals(dst.position(), dstCopy.position() + masked); + assertEquals(srcCopy.position() + masked, src.position()); + assertEquals(dstCopy.position() + masked, dst.position()); // 2. masking check src.position(srcCopy.position()); dst.position(dstCopy.position()); for (; src.hasRemaining() && dst.hasRemaining(); offset = (offset + 1) & 3) { - assertEquals(dst.get(), src.get() ^ maskBytes[offset]); + assertEquals(src.get() ^ maskBytes[offset], dst.get()); } // 3. corruption check // 3.1 src contents haven't changed @@ -113,7 +113,7 @@ public class MaskerTest { int srcLimit = src.limit(); src.clear(); srcCopy.clear(); - assertEquals(src, srcCopy); + assertEquals(srcCopy, src); src.limit(srcLimit).position(srcPosition); // restore src // 3.2 dst leading and trailing regions' contents haven't changed int dstPosition = dst.position(); @@ -122,11 +122,11 @@ public class MaskerTest { // leading dst.position(0).limit(dstInitialPosition); dstCopy.position(0).limit(dstInitialPosition); - assertEquals(dst, dstCopy); + assertEquals(dstCopy, dst); // trailing dst.limit(dst.capacity()).position(dstLimit); dstCopy.limit(dst.capacity()).position(dstLimit); - assertEquals(dst, dstCopy); + assertEquals(dstCopy, dst); // restore dst dst.position(dstPosition).limit(dstLimit); return offset; diff --git a/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/MessageQueueTest.java b/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/MessageQueueTest.java index 61503f0e235..73cab76df28 100644 --- a/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/MessageQueueTest.java +++ b/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/MessageQueueTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,9 +23,6 @@ package jdk.internal.net.http.websocket; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import java.io.IOException; import java.nio.ByteBuffer; import java.nio.CharBuffer; @@ -46,10 +43,14 @@ import java.util.function.BiConsumer; import java.util.function.Supplier; import static jdk.internal.net.http.websocket.MessageQueue.effectiveCapacityOf; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /* * A unit test for MessageQueue. The test is aware of the details of the queue @@ -59,7 +60,6 @@ public class MessageQueueTest { private static final Random r = new SecureRandom(); - @DataProvider(name = "illegalCapacities") public static Object[][] illegalCapacities() { return new Object[][]{ new Object[]{Integer.MIN_VALUE}, @@ -69,17 +69,20 @@ public class MessageQueueTest { }; } - @Test(dataProvider = "illegalCapacities") + @ParameterizedTest + @MethodSource("illegalCapacities") public void illegalCapacity(int n) { assertThrows(IllegalArgumentException.class, () -> new MessageQueue(n)); } - @Test(dataProvider = "capacities") + @ParameterizedTest + @MethodSource("capacities") public void emptiness(int n) { assertTrue(new MessageQueue(n).isEmpty()); } - @Test(dataProvider = "capacities") + @ParameterizedTest + @MethodSource("capacities") public void fullness(int n) throws IOException { MessageQueue q = new MessageQueue(n); int cap = effectiveCapacityOf(n); @@ -97,7 +100,7 @@ public class MessageQueueTest { for (int i = 0; i < cap; i++) { Message expected = referenceQueue.remove(); Message actual = new Remover().removeFrom(q); - assertEquals(actual, expected); + assertEquals(expected, actual); } } @@ -144,7 +147,8 @@ public class MessageQueueTest { action, future); } - @Test(dataProvider = "capacities") + @ParameterizedTest + @MethodSource("capacities") public void caterpillarWalk(int n) throws IOException { // System.out.println("n: " + n); int cap = effectiveCapacityOf(n); @@ -164,7 +168,7 @@ public class MessageQueueTest { for (int i = 0; i < p; i++) { Message expected = referenceQueue.remove(); Message actual = remover.removeFrom(q); - assertEquals(actual, expected); + assertEquals(expected, actual); } assertTrue(q.isEmpty()); } @@ -243,7 +247,7 @@ public class MessageQueueTest { f.get(); // Just to check for exceptions } consumer.get(); // Waiting for consumer to collect all the messages - assertEquals(actualList.size(), expectedList.size()); + assertEquals(expectedList.size(), actualList.size()); for (Message m : expectedList) { assertTrue(actualList.remove(m)); } @@ -257,7 +261,8 @@ public class MessageQueueTest { } } - @Test(dataProvider = "capacities") + @ParameterizedTest + @MethodSource("capacities") public void testSingleThreaded(int n) throws IOException { Queue referenceQueue = new LinkedList<>(); MessageQueue q = new MessageQueue(n); @@ -271,13 +276,12 @@ public class MessageQueueTest { for (int i = 0; i < cap; i++) { Message expected = referenceQueue.remove(); Message actual = new Remover().removeFrom(q); - assertEquals(actual, expected); + assertEquals(expected, actual); } assertTrue(q.isEmpty()); } - @DataProvider(name = "capacities") - public Object[][] capacities() { + public static Object[][] capacities() { return new Object[][]{ new Object[]{ 1}, new Object[]{ 2}, diff --git a/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/ReaderTest.java b/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/ReaderTest.java index c53ac88f69c..c7b1ab80fbd 100644 --- a/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/ReaderTest.java +++ b/test/jdk/java/net/httpclient/websocket/java.net.http/jdk/internal/net/http/websocket/ReaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ package jdk.internal.net.http.websocket; -import org.testng.annotations.Test; import jdk.internal.net.http.websocket.Frame.Opcode; import java.nio.ByteBuffer; @@ -35,10 +34,12 @@ import java.util.function.IntUnaryOperator; import static java.util.OptionalInt.empty; import static java.util.OptionalInt.of; -import static org.testng.Assert.assertEquals; import static jdk.internal.net.http.websocket.TestSupport.assertThrows; import static jdk.internal.net.http.websocket.TestSupport.forEachBufferPartition; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class ReaderTest { private long cases, frames; @@ -128,15 +129,15 @@ public class ReaderTest { for (ByteBuffer b : buffers) { r.readFrame(b, c); } - assertEquals(fin, c.fin()); - assertEquals(rsv1, c.rsv1()); - assertEquals(rsv2, c.rsv2()); - assertEquals(rsv3, c.rsv3()); - assertEquals(opcode, c.opcode()); - assertEquals(mask.isPresent(), c.mask()); - assertEquals(payloadLen, c.payloadLen()); - assertEquals(mask, c.maskingKey()); - assertEquals(payloadLen == 0, c.isEndFrame()); + assertEquals(c.fin(), fin); + assertEquals(c.rsv1(), rsv1); + assertEquals(c.rsv2(), rsv2); + assertEquals(c.rsv3(), rsv3); + assertEquals(c.opcode(), opcode); + assertEquals(c.mask(), mask.isPresent()); + assertEquals(c.payloadLen(), payloadLen); + assertEquals(c.maskingKey(), mask); + assertEquals(c.isEndFrame(), payloadLen == 0); }); } diff --git a/test/jdk/java/net/httpclient/websocket/security/WSSanityTest.java b/test/jdk/java/net/httpclient/websocket/security/WSSanityTest.java index 787486dbd84..c8e4faa1ad3 100644 --- a/test/jdk/java/net/httpclient/websocket/security/WSSanityTest.java +++ b/test/jdk/java/net/httpclient/websocket/security/WSSanityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 +25,7 @@ * @test * @summary Basic sanity checks for WebSocket URI from the Builder * @compile ../DummyWebSocketServer.java ../../ProxyServer.java - * @run testng/othervm WSSanityTest + * @run junit/othervm WSSanityTest */ import java.io.IOException; @@ -38,20 +38,21 @@ import java.net.URI; import java.util.List; import java.net.http.HttpClient; import java.net.http.WebSocket; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.*; public class WSSanityTest { - URI wsURI; - DummyWebSocketServer webSocketServer; - InetSocketAddress proxyAddress; + private static URI wsURI; + private static DummyWebSocketServer webSocketServer; + private static InetSocketAddress proxyAddress; - @BeforeTest - public void setup() throws Exception { + @BeforeAll + public static void setup() throws Exception { ProxyServer proxyServer = new ProxyServer(0, true); proxyAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), proxyServer.getPort()); @@ -63,8 +64,8 @@ public class WSSanityTest { System.out.println("DummyWebSocketServer: " + wsURI); } - @AfterTest - public void teardown() { + @AfterAll + public static void teardown() { webSocketServer.close(); } @@ -75,8 +76,7 @@ public class WSSanityTest { T run() throws Exception; } - @DataProvider(name = "passingScenarios") - public Object[][] passingScenarios() { + public static Object[][] passingScenarios() { HttpClient noProxyClient = HttpClient.newHttpClient(); return new Object[][]{ { (ExceptionAction)() -> { @@ -146,14 +146,15 @@ public class WSSanityTest { HttpClient client = HttpClient.newBuilder().proxy(ps).build(); client.newWebSocketBuilder() .buildAsync(wsURI, noOpListener).get().abort(); - assertEquals(ps.count(), 1); // ps.select only invoked once + assertEquals(1, ps.count()); // ps.select only invoked once return null; }, "7" }, }; } - @Test(dataProvider = "passingScenarios") + @ParameterizedTest + @MethodSource("passingScenarios") public void testScenarios(ExceptionAction action, String dataProviderId) throws Exception { diff --git a/test/jdk/java/net/httpclient/whitebox/AltSvcFrameTest.java b/test/jdk/java/net/httpclient/whitebox/AltSvcFrameTest.java index 589e5409044..b9e5f2d58fe 100644 --- a/test/jdk/java/net/httpclient/whitebox/AltSvcFrameTest.java +++ b/test/jdk/java/net/httpclient/whitebox/AltSvcFrameTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,17 +48,19 @@ import jdk.internal.net.http.HttpClientAccess; import jdk.internal.net.http.common.HttpHeadersBuilder; import jdk.internal.net.http.frame.AltSvcFrame; import jdk.test.lib.net.SimpleSSLContext; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import static java.net.http.HttpResponse.BodyHandlers.ofString; import static jdk.internal.net.http.AltServicesRegistry.AltService; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /* * @test - * @summary This test verifies alt-svc registry updation for frames + * @summary This test verifies alt-svc registry updating for frames * @library /test/lib /test/jdk/java/net/httpclient/lib * @build java.net.http/jdk.internal.net.http.HttpClientAccess * jdk.httpclient.test.lib.http2.Http2TestServer @@ -82,7 +84,7 @@ import static org.testng.Assert.assertTrue; * java.base/sun.net.www.http * java.base/sun.net.www * java.base/sun.net - * @run testng/othervm + * @run junit/othervm * -Dtest.requiresHost=true * -Djdk.httpclient.HttpClient.log=headers * -Djdk.internal.httpclient.disableHostnameVerification @@ -90,7 +92,6 @@ import static org.testng.Assert.assertTrue; * AltSvcFrameTest */ - public class AltSvcFrameTest { private static final String IGNORED_HOST = "www.should-be-ignored.com"; @@ -109,18 +110,23 @@ public class AltSvcFrameTest { static HttpClient client; private static final SSLContext server = SimpleSSLContext.findSSLContext(); - @BeforeTest - public void setUp() throws Exception { + @BeforeAll + public static void setUp() throws Exception { getRegistry(); https2Server = new Http2TestServer("localhost", true, server); https2Server.addHandler(new AltSvcFrameTestHandler(), "/"); https2Server.setExchangeSupplier(AltSvcFrameTest.CFTHttp2TestExchange::new); https2Server.start(); https2URI = "https://" + https2Server.serverAuthority() + "/"; - - } + @AfterAll + public static void tearDown() { + if (client != null) client.close(); + if (https2Server != null) https2Server.stop(); + } + + static AltServicesRegistry getRegistry() { client = HttpClient.newBuilder() .sslContext(server) @@ -139,7 +145,7 @@ public class AltSvcFrameTest { .GET() .build(); HttpResponse response = client.send(request, ofString()); - assertEquals(response.statusCode(), 200, "unexpected response code"); + assertEquals(200, response.statusCode(), "unexpected response code"); final List services = registry.lookup(URI.create(https2URI), "h3").toList(); System.out.println("Alt services in registry for " + https2URI + " = " + services); final boolean hasExpectedAltSvc = services.stream().anyMatch( @@ -158,7 +164,7 @@ public class AltSvcFrameTest { .GET() .build(); HttpResponse response = client.send(request, ofString()); - assertEquals(response.statusCode(), 200, "unexpected response code"); + assertEquals(200, response.statusCode(), "unexpected response code"); final List services = registry.lookup( URI.create(FOO_BAR_ORIGIN), "h3").toList(); System.out.println("Alt services in registry for " + FOO_BAR_ORIGIN + " = " + services); diff --git a/test/jdk/java/net/httpclient/whitebox/AltSvcRegistryTest.java b/test/jdk/java/net/httpclient/whitebox/AltSvcRegistryTest.java index b853f715415..682082ba9f8 100644 --- a/test/jdk/java/net/httpclient/whitebox/AltSvcRegistryTest.java +++ b/test/jdk/java/net/httpclient/whitebox/AltSvcRegistryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,8 +26,6 @@ import jdk.internal.net.http.AltServicesRegistry; import jdk.test.lib.net.SimpleSSLContext; import jdk.httpclient.test.lib.common.HttpServerAdapters; import jdk.httpclient.test.lib.http2.Http2TestServer; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import java.io.IOException; @@ -46,6 +44,10 @@ import java.util.concurrent.Executors; import static jdk.internal.net.http.AltServicesRegistry.AltService; import static java.net.http.HttpResponse.BodyHandlers.ofString; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Test; + /* * @test * @summary This test verifies alt-svc registry updates @@ -73,7 +75,7 @@ import static java.net.http.HttpResponse.BodyHandlers.ofString; * java.base/sun.net.www * java.base/sun.net * java.base/jdk.internal.util - * @run testng/othervm + * @run junit/othervm * -Dtest.requiresHost=true * -Djdk.httpclient.HttpClient.log=headers * -Djdk.internal.httpclient.disableHostnameVerification @@ -81,7 +83,6 @@ import static java.net.http.HttpResponse.BodyHandlers.ofString; * AltSvcRegistryTest */ - public class AltSvcRegistryTest implements HttpServerAdapters { static HttpTestServer https2Server; @@ -89,8 +90,8 @@ public class AltSvcRegistryTest implements HttpServerAdapters { static HttpClient client; private static final SSLContext server = SimpleSSLContext.findSSLContext(); - @BeforeTest - public void setUp() throws Exception { + @BeforeAll + public static void setUp() throws Exception { getRegistry(); final ExecutorService executor = Executors.newCachedThreadPool(); https2Server = HttpServerAdapters.HttpTestServer.of( @@ -98,8 +99,12 @@ public class AltSvcRegistryTest implements HttpServerAdapters { https2Server.addHandler(new AltSvcRegistryTestHandler("https", https2Server), "/"); https2Server.start(); https2URI = "https://" + https2Server.serverAuthority() + "/"; + } - + @AfterAll + public static void tearDown() { + if (client != null) client.close(); + if (https2Server != null) https2Server.stop(); } static AltServicesRegistry getRegistry() { diff --git a/test/jdk/java/net/httpclient/whitebox/AuthenticationFilterTestDriver.java b/test/jdk/java/net/httpclient/whitebox/AuthenticationFilterTestDriver.java index e932455e409..5808c380593 100644 --- a/test/jdk/java/net/httpclient/whitebox/AuthenticationFilterTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/AuthenticationFilterTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,5 +24,5 @@ /* * @test * @modules java.net.http/jdk.internal.net.http - * @run testng java.net.http/jdk.internal.net.http.AuthenticationFilterTest + * @run junit java.net.http/jdk.internal.net.http.AuthenticationFilterTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/DefaultProxyDriver.java b/test/jdk/java/net/httpclient/whitebox/DefaultProxyDriver.java index 5c18fd84a0f..54127855386 100644 --- a/test/jdk/java/net/httpclient/whitebox/DefaultProxyDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/DefaultProxyDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ * @summary Verifies that the HTTP Client, by default, uses the system-wide * proxy selector, and that that selector supports the standard HTTP proxy * system properties. - * @run testng/othervm + * @run junit/othervm * -Dhttp.proxyHost=foo.proxy.com * -Dhttp.proxyPort=9876 * -Dhttp.nonProxyHosts=*.direct.com diff --git a/test/jdk/java/net/httpclient/whitebox/DemandTestDriver.java b/test/jdk/java/net/httpclient/whitebox/DemandTestDriver.java index ea442878261..c8b793a289c 100644 --- a/test/jdk/java/net/httpclient/whitebox/DemandTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/DemandTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,5 +24,5 @@ /* * @test * @modules java.net.http/jdk.internal.net.http.common - * @run testng java.net.http/jdk.internal.net.http.common.DemandTest + * @run junit java.net.http/jdk.internal.net.http.common.DemandTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/FlowTestDriver.java b/test/jdk/java/net/httpclient/whitebox/FlowTestDriver.java index c24a733db3b..4468b5d6eb6 100644 --- a/test/jdk/java/net/httpclient/whitebox/FlowTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/FlowTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,5 +25,5 @@ * @test * @compile/module=java.net.http ../../../../../../lib/jdk/test/lib/net/SimpleSSLContext.java * @modules java.net.http/jdk.internal.net.http - * @run testng/timeout=480 java.net.http/jdk.internal.net.http.FlowTest + * @run junit/timeout=480 java.net.http/jdk.internal.net.http.FlowTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/FramesDecoderTestDriver.java b/test/jdk/java/net/httpclient/whitebox/FramesDecoderTestDriver.java index 9b3c8878669..7edc555d8a6 100644 --- a/test/jdk/java/net/httpclient/whitebox/FramesDecoderTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/FramesDecoderTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,7 +25,7 @@ * @test * @bug 8195823 * @modules java.net.http/jdk.internal.net.http.frame - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * java.net.http/jdk.internal.net.http.frame.FramesDecoderTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/Http1HeaderParserTestDriver.java b/test/jdk/java/net/httpclient/whitebox/Http1HeaderParserTestDriver.java index b18142601a5..f3b9d410b51 100644 --- a/test/jdk/java/net/httpclient/whitebox/Http1HeaderParserTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/Http1HeaderParserTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,5 +25,5 @@ * @test * @bug 8195138 * @modules java.net.http/jdk.internal.net.http - * @run testng java.net.http/jdk.internal.net.http.Http1HeaderParserTest + * @run junit java.net.http/jdk.internal.net.http.Http1HeaderParserTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/MinimalFutureTestDriver.java b/test/jdk/java/net/httpclient/whitebox/MinimalFutureTestDriver.java index 316ca29e2a6..90fe6816adc 100644 --- a/test/jdk/java/net/httpclient/whitebox/MinimalFutureTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/MinimalFutureTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,5 +24,5 @@ /* * @test * @modules java.net.http/jdk.internal.net.http.common - * @run testng java.net.http/jdk.internal.net.http.common.MinimalFutureTest + * @run junit java.net.http/jdk.internal.net.http.common.MinimalFutureTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/RawChannelTestDriver.java b/test/jdk/java/net/httpclient/whitebox/RawChannelTestDriver.java index ab44fba5ecd..7ca448b7892 100644 --- a/test/jdk/java/net/httpclient/whitebox/RawChannelTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/RawChannelTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,10 +25,10 @@ * @test * @bug 8151299 8164704 * @modules java.net.http/jdk.internal.net.http - * @run testng/othervm java.net.http/jdk.internal.net.http.RawChannelTest + * @run junit/othervm java.net.http/jdk.internal.net.http.RawChannelTest */ // use -// @run testng/othervm -Dseed=6434511950803022575 +// @run junit/othervm -Dseed=6434511950803022575 // java.net.http/jdk.internal.net.http.RawChannelTest // to reproduce a failure with a particular seed (e.g. 6434511950803022575) // if this test is observed failing with that seed diff --git a/test/jdk/java/net/httpclient/whitebox/SSLEchoTubeTestDriver.java b/test/jdk/java/net/httpclient/whitebox/SSLEchoTubeTestDriver.java index d641513b298..b4b3e59326d 100644 --- a/test/jdk/java/net/httpclient/whitebox/SSLEchoTubeTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/SSLEchoTubeTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 +25,7 @@ * @test * @compile/module=java.net.http ../../../../../../lib/jdk/test/lib/net/SimpleSSLContext.java * @modules java.net.http/jdk.internal.net.http - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * java.net.http/jdk.internal.net.http.SSLEchoTubeTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/SSLFlowDelegateTestDriver.java b/test/jdk/java/net/httpclient/whitebox/SSLFlowDelegateTestDriver.java index a49f53a844a..cb8e9801ca8 100644 --- a/test/jdk/java/net/httpclient/whitebox/SSLFlowDelegateTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/SSLFlowDelegateTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ * downReader doesn't request any * @compile/module=java.net.http ../../../../../../lib/jdk/test/lib/net/SimpleSSLContext.java * @modules java.net.http/jdk.internal.net.http - * @run testng/othervm -Djdk.internal.httpclient.debug=true + * @run junit/othervm -Djdk.internal.httpclient.debug=true * -Djavax.net.debug=ssl:handshake * java.net.http/jdk.internal.net.http.SSLFlowDelegateTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/SSLTubeTestDriver.java b/test/jdk/java/net/httpclient/whitebox/SSLTubeTestDriver.java index b1994777b14..2c73de26648 100644 --- a/test/jdk/java/net/httpclient/whitebox/SSLTubeTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/SSLTubeTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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,7 +25,7 @@ * @test * @compile/module=java.net.http ../../../../../../lib/jdk/test/lib/net/SimpleSSLContext.java * @modules java.net.http/jdk.internal.net.http - * @run testng/othervm + * @run junit/othervm * -Djdk.internal.httpclient.debug=true * java.net.http/jdk.internal.net.http.SSLTubeTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/SelectorTestDriver.java b/test/jdk/java/net/httpclient/whitebox/SelectorTestDriver.java index 226e644e903..54d66d04cff 100644 --- a/test/jdk/java/net/httpclient/whitebox/SelectorTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/SelectorTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, 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,5 +25,5 @@ * @test * @bug 8151299 8164704 * @modules java.net.http/jdk.internal.net.http - * @run testng java.net.http/jdk.internal.net.http.SelectorTest + * @run junit java.net.http/jdk.internal.net.http.SelectorTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/WindowControllerTestDriver.java b/test/jdk/java/net/httpclient/whitebox/WindowControllerTestDriver.java index 7943bfceaa0..16ac4aaefb8 100644 --- a/test/jdk/java/net/httpclient/whitebox/WindowControllerTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/WindowControllerTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,5 +26,5 @@ * @bug 8207960 * @modules java.net.http/jdk.internal.net.http * @summary Non-negative WINDOW_UPDATE increments may leave the stream window size negative - * @run testng/othervm java.net.http/jdk.internal.net.http.WindowControllerTest + * @run junit/othervm java.net.http/jdk.internal.net.http.WindowControllerTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/WrapperTestDriver.java b/test/jdk/java/net/httpclient/whitebox/WrapperTestDriver.java index 7ea2b07e3a7..dfc808ff68b 100644 --- a/test/jdk/java/net/httpclient/whitebox/WrapperTestDriver.java +++ b/test/jdk/java/net/httpclient/whitebox/WrapperTestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,5 +24,5 @@ /* * @test * @modules java.net.http/jdk.internal.net.http - * @run testng java.net.http/jdk.internal.net.http.WrapperTest + * @run junit java.net.http/jdk.internal.net.http.WrapperTest */ diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AbstractSSLTubeTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AbstractSSLTubeTest.java index 944f8ae0872..699b537c980 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AbstractSSLTubeTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AbstractSSLTubeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,17 +26,13 @@ package jdk.internal.net.http; import jdk.internal.net.http.common.FlowTube; import jdk.internal.net.http.common.SSLTube; import jdk.internal.net.http.common.Utils; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLParameters; -import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStream; import java.nio.ByteBuffer; import java.util.List; -import java.util.StringTokenizer; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AuthenticationFilterTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AuthenticationFilterTest.java index 415caeb1196..2e9672e4725 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AuthenticationFilterTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/AuthenticationFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,9 +24,6 @@ package jdk.internal.net.http; import jdk.internal.net.http.common.HttpHeadersBuilder; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.testng.annotations.AfterClass; import java.lang.ref.Reference; import java.net.Authenticator; @@ -55,12 +52,15 @@ import static java.util.stream.Collectors.joining; import static java.net.http.HttpClient.Version.HTTP_1_1; import static java.net.http.HttpClient.Version.HTTP_2; import static java.net.http.HttpClient.Builder.NO_PROXY; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.*; public class AuthenticationFilterTest { - @DataProvider(name = "uris") - public Object[][] responses() { + public static Object[][] responses() { return new Object[][] { { "http://foo.com", HTTP_1_1, null }, { "http://foo.com", HTTP_2, null }, @@ -135,7 +135,8 @@ public class AuthenticationFilterTest { return s == null || s.isEmpty(); } - @Test(dataProvider = "uris") + @ParameterizedTest + @MethodSource("responses") public void testAuthentication(String uri, Version v, String proxy) throws Exception { String test = format("testAuthentication: {\"%s\", %s, \"%s\"}", uri, v, proxy); try { @@ -146,8 +147,8 @@ public class AuthenticationFilterTest { } } - @AfterClass - public void printDiagnostic() { + @AfterAll + public static void printDiagnostic() { if (FAILED.isEmpty()) { out.println("All tests passed"); return; @@ -183,7 +184,7 @@ public class AuthenticationFilterTest { HttpClientImpl client = facade.impl; AuthenticationFilter filter = new AuthenticationFilter(); - assertEquals(authenticator.COUNTER.get(), 0); + assertEquals(0, authenticator.COUNTER.get()); // Creates the first HttpRequestImpl, and call filter.request() with // it. The expectation is that the filter will not add any credentials, @@ -202,7 +203,7 @@ public class AuthenticationFilterTest { HttpHeaders hdrs = req.getSystemHeadersBuilder().build(); assertFalse(hdrs.firstValue(authorization(true)).isPresent()); assertFalse(hdrs.firstValue(authorization(false)).isPresent()); - assertEquals(authenticator.COUNTER.get(), 0); + assertEquals(0, authenticator.COUNTER.get()); // Creates the Response to the first request, and call filter.response // with it. That response has a 401 or 407 status code. @@ -221,9 +222,9 @@ public class AuthenticationFilterTest { out.println("Checking filter's response to " + unauthorized + " from " + uri); - assertTrue(next != null, "next should not be null"); + assertNotNull(next, "next should not be null"); String[] up = check(reqURI, next.getSystemHeadersBuilder().build(), proxy); - assertEquals(authenticator.COUNTER.get(), 1); + assertEquals(1, authenticator.COUNTER.get()); // Now simulate a new successful exchange to get the credentials in the cache // We first call filter.request with the request that was previously @@ -241,8 +242,8 @@ public class AuthenticationFilterTest { HttpHeaders h = HttpHeaders.of(Collections.emptyMap(), ACCEPT_ALL); response = new Response(next, exchange,h, null, 200, v); next = filter.response(response); - assertTrue(next == null, "next should be null"); - assertEquals(authenticator.COUNTER.get(), 1); + assertNull(next, "next should be null"); + assertEquals(1, authenticator.COUNTER.get()); // Now verify that the cache is used for the next request to the same server. // We're going to create a request to the same server by appending "/bar" to @@ -270,7 +271,7 @@ public class AuthenticationFilterTest { + " with proxy " + req2.proxy()); String[] up2 = check(reqURI, req2.getSystemHeadersBuilder().build(), proxy); assertTrue(Arrays.deepEquals(up, up2), format("%s:%s != %s:%s", up2[0], up2[1], up[0], up[1])); - assertEquals(authenticator.COUNTER.get(), 1); + assertEquals(1, authenticator.COUNTER.get()); // Now verify that the cache is not used if we send a request to a different server. // We're going to append ".bar" to the original request host name, and feed that @@ -316,7 +317,7 @@ public class AuthenticationFilterTest { java.util.stream.Stream.of(getAuthorization(h3, false)) .collect(joining(":"))); assertFalse(h3.firstValue(authorization(false)).isPresent()); - assertEquals(authenticator.COUNTER.get(), 1); + assertEquals(1, authenticator.COUNTER.get()); // Now we will verify that credentials for proxies are not used for servers and // conversely. @@ -365,7 +366,7 @@ public class AuthenticationFilterTest { String[] up4 = check(reqURI, h4, proxy); assertTrue(Arrays.deepEquals(up, up4), format("%s:%s != %s:%s", up4[0], up4[1], up[0], up[1])); } - assertEquals(authenticator.COUNTER.get(), 1); + assertEquals(1, authenticator.COUNTER.get()); if (proxy != null) { // Now if we were using a proxy, we're going to send the same request than @@ -380,7 +381,7 @@ public class AuthenticationFilterTest { MultiExchange multi5 = new MultiExchange(origReq5, req5, client, HttpResponse.BodyHandlers.replacing(null), null); out.println("Simulating new request to " + reqURI + " with a proxy " + req5.proxy()); - assertTrue(req5.proxy() == null, "req5.proxy() should be null"); + assertNull(req5.proxy(), "req5.proxy() should be null"); Exchange exchange5 = new Exchange<>(req5, multi5); filter.request(req5, multi5); out.println("Check that filter has not added server credentials from cache for " @@ -398,7 +399,7 @@ public class AuthenticationFilterTest { java.util.stream.Stream.of(getAuthorization(h5, true)) .collect(joining(":"))); assertFalse(h5.firstValue(authorization(true)).isPresent()); - assertEquals(authenticator.COUNTER.get(), 1); + assertEquals(1, authenticator.COUNTER.get()); // Now simulate a 401 response from the server HttpHeadersBuilder headers5Builder = new HttpHeadersBuilder(); @@ -410,11 +411,11 @@ public class AuthenticationFilterTest { out.println("Simulating " + unauthorized + " response from " + uri); HttpRequestImpl next5 = filter.response(response5); - assertEquals(authenticator.COUNTER.get(), 2); + assertEquals(2, authenticator.COUNTER.get()); out.println("Checking filter's response to " + unauthorized + " from " + uri); - assertTrue(next5 != null, "next5 should not be null"); + assertNotNull(next5, "next5 should not be null"); String[] up5 = check(reqURI, next5.getSystemHeadersBuilder().build(), null); // now simulate a 200 response from the server @@ -423,7 +424,7 @@ public class AuthenticationFilterTest { h = HttpHeaders.of(Map.of(), ACCEPT_ALL); response5 = new Response(next5, exchange5, h, null, 200, v); filter.response(response5); - assertEquals(authenticator.COUNTER.get(), 2); + assertEquals(2, authenticator.COUNTER.get()); // now send the request again, with proxy this time, and it should have both // server auth and proxy auth @@ -433,7 +434,7 @@ public class AuthenticationFilterTest { MultiExchange multi6 = new MultiExchange(origReq6, req6, client, HttpResponse.BodyHandlers.replacing(null), null); out.println("Simulating new request to " + reqURI + " with a proxy " + req6.proxy()); - assertTrue(req6.proxy() != null, "req6.proxy() should not be null"); + assertNotNull(req6.proxy(), "req6.proxy() should not be null"); Exchange exchange6 = new Exchange<>(req6, multi6); filter.request(req6, multi6); out.println("Check that filter has added server credentials from cache for " @@ -444,7 +445,7 @@ public class AuthenticationFilterTest { + reqURI + " (proxy: " + req6.proxy() + ")"); String[] up6 = check(reqURI, h6, proxy); assertTrue(Arrays.deepEquals(up, up6), format("%s:%s != %s:%s", up6[0], up6[1], up[0], up[1])); - assertEquals(authenticator.COUNTER.get(), 2); + assertEquals(2, authenticator.COUNTER.get()); } if (proxy == null && uri.contains("x/y/z")) { @@ -456,7 +457,7 @@ public class AuthenticationFilterTest { MultiExchange multi7 = new MultiExchange(origReq7, req7, client, HttpResponse.BodyHandlers.replacing(null), null); out.println("Simulating new request to " + reqURI7 + " with a proxy " + req7.proxy()); - assertTrue(req7.proxy() == null, "req7.proxy() should be null"); + assertNull(req7.proxy(), "req7.proxy() should be null"); Exchange exchange7 = new Exchange<>(req7, multi7); filter.request(req7, multi7); out.println("Check that filter has not added server credentials from cache for " @@ -475,7 +476,7 @@ public class AuthenticationFilterTest { java.util.stream.Stream.of(getAuthorization(h7, true)) .collect(joining(":"))); assertFalse(h7.firstValue(authorization(true)).isPresent()); - assertEquals(authenticator.COUNTER.get(), 1); + assertEquals(1, authenticator.COUNTER.get()); } @@ -516,7 +517,7 @@ public class AuthenticationFilterTest { out.println("user:password: " + u + ":" + p); String protocol = proxy != null ? "http" : reqURI.getScheme(); String expectedUser = "u." + protocol; - assertEquals(u, expectedUser); + assertEquals(expectedUser, u); String host = proxy == null ? reqURI.getHost() : proxy.substring(0, proxy.lastIndexOf(':')); int port = proxy == null ? reqURI.getPort() @@ -524,7 +525,7 @@ public class AuthenticationFilterTest { String expectedPw = concat(requestorType(proxy!=null), "basic", protocol, host, port, "earth", reqURI.toURL()); - assertEquals(p, expectedPw); + assertEquals(expectedPw, p); return new String[] {u, p}; } diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/DefaultProxy.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/DefaultProxy.java index 96d08ae2c34..819b02e7fc7 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/DefaultProxy.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/DefaultProxy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, 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,8 +29,9 @@ import java.net.ProxySelector; import java.net.URI; import java.net.http.HttpClient; import java.util.List; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class DefaultProxy { @@ -42,7 +43,7 @@ public class DefaultProxy { public void testDefault() { ProxySelector ps = getProxySelector(); System.out.println("HttpClientImpl proxySelector:" + ps); - assertEquals(ps, ProxySelector.getDefault()); + assertEquals(ProxySelector.getDefault(), ps); } // From the test driver @@ -56,21 +57,21 @@ public class DefaultProxy { URI uri = URI.create("http://foo.com/example.html"); List plist = ps.select(uri); System.out.println("proxy list for " + uri + " : " + plist); - assertEquals(plist.size(), 1); + assertEquals(1, plist.size()); Proxy proxy = plist.get(0); - assertEquals(proxy.type(), Proxy.Type.HTTP); + assertEquals(Proxy.Type.HTTP, proxy.type()); InetSocketAddress expectedAddr = InetSocketAddress.createUnresolved("foo.proxy.com", 9876); - assertEquals(proxy.address(), expectedAddr); + assertEquals(expectedAddr, proxy.address()); // nonProxyHosts uri = URI.create("http://foo.direct.com/example.html"); plist = ps.select(uri); System.out.println("proxy list for " + uri + " : " + plist); - assertEquals(plist.size(), 1); + assertEquals(1, plist.size()); proxy = plist.get(0); - assertEquals(proxy.type(), Proxy.Type.DIRECT); - assertEquals(proxy.address(), null); + assertEquals(Proxy.Type.DIRECT, proxy.type()); + assertEquals(null, proxy.address()); } // From the test driver @@ -83,21 +84,21 @@ public class DefaultProxy { URI uri = URI.create("https://foo.com/example.html"); List plist = ps.select(uri); System.out.println("proxy list for " + uri + " : " + plist); - assertEquals(plist.size(), 1); + assertEquals(1, plist.size()); Proxy proxy = plist.get(0); - assertEquals(proxy.type(), Proxy.Type.HTTP); + assertEquals(Proxy.Type.HTTP, proxy.type()); InetSocketAddress expectedAddr = InetSocketAddress.createUnresolved("secure.proxy.com", 5443); - assertEquals(proxy.address(), expectedAddr); + assertEquals(expectedAddr, proxy.address()); // nonProxyHosts uri = URI.create("https://foo.direct.com/example.html"); plist = ps.select(uri); System.out.println("proxy list for " + uri + " : " + plist); - assertEquals(plist.size(), 1); + assertEquals(1, plist.size()); proxy = plist.get(0); - assertEquals(proxy.type(), Proxy.Type.DIRECT); - assertEquals(proxy.address(), null); + assertEquals(Proxy.Type.DIRECT, proxy.type()); + assertEquals(null, proxy.address()); } } diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/FlowTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/FlowTest.java index 3e9e967c061..cd05196b653 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/FlowTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/FlowTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,8 +32,6 @@ import java.net.InetSocketAddress; import java.net.Socket; import java.nio.ByteBuffer; import java.util.List; -import java.util.Random; -import java.util.StringTokenizer; import java.util.concurrent.BlockingQueue; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; @@ -47,10 +45,10 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import javax.net.ssl.*; import jdk.internal.net.http.common.Utils; -import org.testng.annotations.Test; import jdk.internal.net.http.common.SSLFlowDelegate; -@Test +import org.junit.jupiter.api.Test; + public class FlowTest extends AbstractRandomTest { private final SubmissionPublisher> srcPublisher; @@ -241,7 +239,7 @@ public class FlowTest extends AbstractRandomTest { private void clientReader() { try { InputStream is = clientSock.getInputStream(); - final int bufsize = FlowTest.randomRange(512, 16 * 1024); + final int bufsize = AbstractRandomTest.randomRange(512, 16 * 1024); println("clientReader: bufsize = " + bufsize); while (true) { byte[] buf = new byte[bufsize]; @@ -315,8 +313,8 @@ public class FlowTest extends AbstractRandomTest { private final AtomicInteger loopCount = new AtomicInteger(); public String monitor() { - return "serverLoopback: loopcount = " + loopCount.toString() - + " clientRead: count = " + readCount.toString(); + return "serverLoopback: loopcount = " + loopCount.get() + + " clientRead: count = " + readCount.get(); } // thread2 @@ -324,7 +322,7 @@ public class FlowTest extends AbstractRandomTest { try { InputStream is = serverSock.getInputStream(); OutputStream os = serverSock.getOutputStream(); - final int bufsize = FlowTest.randomRange(512, 16 * 1024); + final int bufsize = AbstractRandomTest.randomRange(512, 16 * 1024); println("serverLoopback: bufsize = " + bufsize); byte[] bb = new byte[bufsize]; while (true) { diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/Http1HeaderParserTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/Http1HeaderParserTest.java index 9bde9109095..a4c7b76aba8 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/Http1HeaderParserTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/Http1HeaderParserTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,22 +36,22 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.IntStream; import sun.net.www.MessageHeader; -import org.testng.annotations.Test; -import org.testng.annotations.DataProvider; import static java.lang.System.out; import static java.lang.String.format; import static java.nio.charset.StandardCharsets.ISO_8859_1; import static java.nio.charset.StandardCharsets.US_ASCII; import static java.util.stream.Collectors.toList; -import static org.testng.Assert.*; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.*; // Mostly verifies the "new" Http1HeaderParser returns the same results as the // tried and tested sun.net.www.MessageHeader. public class Http1HeaderParserTest { - @DataProvider(name = "responses") - public Object[][] responses() { + public static Object[][] responses() { List responses = new ArrayList<>(); String[] basic = @@ -316,7 +316,8 @@ public class Http1HeaderParserTest { } - @Test(dataProvider = "responses") + @ParameterizedTest + @MethodSource("responses") public void verifyHeaders(String respString) throws Exception { System.out.println("\ntesting:\n\t" + respString .replace("\r\n", "") @@ -339,7 +340,7 @@ public class Http1HeaderParserTest { String statusLine1 = messageHeaderMap.get(null).get(0); String statusLine2 = decoder.statusLine(); if (statusLine1.startsWith("HTTP")) {// skip the case where MH's messes up the status-line - assertEquals(statusLine2, statusLine1, "Status-line not equal"); + assertEquals(statusLine1, statusLine2, "Status-line not equal"); } else { assertTrue(statusLine2.startsWith("HTTP/1."), "Status-line not HTTP/1."); } @@ -356,7 +357,7 @@ public class Http1HeaderParserTest { assertHeadersEqual(messageHeaderMap, decoderMap1, "messageHeaderMap not equal to decoderMap1"); - assertEquals(availableBytes, b.remaining(), + assertEquals(b.remaining(), availableBytes, String.format("stream available (%d) not equal to remaining (%d)", availableBytes, b.remaining())); // byte at a time @@ -366,14 +367,13 @@ public class Http1HeaderParserTest { .collect(toList()); while (decoder.parse(buffers.remove(0)) != true); Map> decoderMap2 = decoder.headers().map(); - assertEquals(availableBytes, buffers.size(), + assertEquals(buffers.size(), availableBytes, "stream available not equals to remaining buffers"); - assertEquals(decoderMap1, decoderMap2, "decoder maps not equal"); + assertEquals(decoderMap2, decoderMap1, "decoder maps not equal"); } - @DataProvider(name = "errors") - public Object[][] errors() { + public static Object[][] errors() { List responses = new ArrayList<>(); // These responses are parsed, somewhat, by MessageHeaders but give @@ -451,12 +451,15 @@ public class Http1HeaderParserTest { return responses.stream().map(p -> new Object[] { p }).toArray(Object[][]::new); } - @Test(dataProvider = "errors", expectedExceptions = ProtocolException.class) + @ParameterizedTest + @MethodSource("errors") public void errors(String respString) throws ProtocolException { - byte[] bytes = respString.getBytes(US_ASCII); - Http1HeaderParser decoder = new Http1HeaderParser(); - ByteBuffer b = ByteBuffer.wrap(bytes); - decoder.parse(b); + assertThrows(ProtocolException.class, () -> { + byte[] bytes = respString.getBytes(US_ASCII); + Http1HeaderParser decoder = new Http1HeaderParser(); + ByteBuffer b = ByteBuffer.wrap(bytes); + decoder.parse(b); + }); } void assertHeadersEqual(Map> expected, @@ -466,7 +469,7 @@ public class Http1HeaderParserTest { if (expected.equals(actual)) return; - assertEquals(expected.size(), actual.size(), + assertEquals(actual.size(), expected.size(), format("%s. Expected size %d, actual size %s. %nexpected= %s,%n actual=%s.", msg, expected.size(), actual.size(), mapToString(expected), mapToString(actual))); @@ -479,7 +482,7 @@ public class Http1HeaderParserTest { if (key.equalsIgnoreCase(other.getKey())) { found = true; List otherValues = other.getValue(); - assertEquals(values.size(), otherValues.size(), + assertEquals(otherValues.size(), values.size(), format("%s. Expected list size %d, actual size %s", msg, values.size(), otherValues.size())); if (!(values.containsAll(otherValues) && otherValues.containsAll(values))) @@ -508,11 +511,11 @@ public class Http1HeaderParserTest { public static void main(String... args) throws Exception { Http1HeaderParserTest test = new Http1HeaderParserTest(); int count = 0; - for (Object[] objs : test.responses()) { + for (Object[] objs : Http1HeaderParserTest.responses()) { out.println("Testing " + count++ + ", " + objs[0]); test.verifyHeaders((String) objs[0]); } - for (Object[] objs : test.errors()) { + for (Object[] objs : Http1HeaderParserTest.errors()) { out.println("Testing " + count++ + ", " + objs[0]); try { test.errors((String) objs[0]); diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/RawChannelTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/RawChannelTest.java index f6bcdcb4d33..62ca237d2f1 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/RawChannelTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/RawChannelTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, 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 @@ -47,10 +47,11 @@ import java.net.http.HttpResponse; import java.util.concurrent.atomic.AtomicReference; import jdk.internal.net.http.websocket.RawChannel; -import org.testng.annotations.Test; import static java.net.http.HttpResponse.BodyHandlers.discarding; import static java.util.concurrent.TimeUnit.SECONDS; -import static org.testng.Assert.assertEquals; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /* * This test exercises mechanics of _independent_ reads and writes on the @@ -222,8 +223,8 @@ public class RawChannelTest { closeChannel(chan); }); exit.await(); // All done, we need to compare results: - assertEquals(clientRead.get(), serverWritten.get()); - assertEquals(serverRead.get(), clientWritten.get()); + assertEquals(serverWritten.get(), clientRead.get()); + assertEquals(clientWritten.get(), serverRead.get()); Throwable serverError = testServer.failed.get(); if (serverError != null) { throw new AssertionError("TestServer failed: " diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLEchoTubeTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLEchoTubeTest.java index 2884b74eee5..4316a46a25c 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLEchoTubeTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLEchoTubeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,6 @@ import jdk.internal.net.http.common.FlowTube; import jdk.internal.net.http.common.SSLTube; import jdk.internal.net.http.common.SequentialScheduler; import jdk.internal.net.http.common.Utils; -import org.testng.annotations.Test; import java.io.IOException; import java.nio.ByteBuffer; @@ -44,7 +43,8 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; -@Test +import org.junit.jupiter.api.Test; + public class SSLEchoTubeTest extends AbstractSSLTubeTest { @Test diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLFlowDelegateTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLFlowDelegateTest.java index 6b031bdfa58..32511de173b 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLFlowDelegateTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLFlowDelegateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, 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 @@ -58,10 +58,11 @@ import jdk.internal.net.http.common.Logger; import jdk.internal.net.http.common.SSLFlowDelegate; import jdk.internal.net.http.common.SubscriberWrapper; import jdk.internal.net.http.common.Utils; -import org.testng.Assert; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; // jtreg test definition for this test resides in SSLFlowDelegateTestDriver.java public class SSLFlowDelegateTest { @@ -70,38 +71,38 @@ public class SSLFlowDelegateTest { private static final Random random = new Random(); private static final byte DATA_BYTE = (byte) random.nextInt(); - private ExecutorService executor; - private SSLParameters sslParams; - private SSLServerSocket sslServerSocket; - private SSLEngine clientEngine; - private CompletableFuture testCompletion; + private static ExecutorService executor; + private static SSLParameters sslParams; + private static SSLServerSocket sslServerSocket; + private static SSLEngine clientEngine; + private static CompletableFuture testCompletion; - @BeforeTest - public void beforeTest() throws Exception { - this.executor = Executors.newCachedThreadPool(); - this.testCompletion = new CompletableFuture<>(); + @BeforeAll + public static void beforeTest() throws Exception { + executor = Executors.newCachedThreadPool(); + testCompletion = new CompletableFuture<>(); final SSLParameters sp = new SSLParameters(); sp.setApplicationProtocols(new String[]{ALPN}); - this.sslParams = sp; + sslParams = sp; var sslContext = SimpleSSLContextWhiteboxAdapter.findSSLContext(); - this.sslServerSocket = startServer(sslContext); - println(debugTag, "Server started at " + this.sslServerSocket.getInetAddress() + ":" - + this.sslServerSocket.getLocalPort()); + sslServerSocket = startServer(sslContext); + println(debugTag, "Server started at " + sslServerSocket.getInetAddress() + ":" + + sslServerSocket.getLocalPort()); - this.clientEngine = createClientEngine(sslContext); + clientEngine = createClientEngine(sslContext); } - @AfterTest - public void afterTest() throws Exception { - if (this.sslServerSocket != null) { - println(debugTag, "Closing server socket " + this.sslServerSocket); - this.sslServerSocket.close(); + @AfterAll + public static void afterTest() throws Exception { + if (sslServerSocket != null) { + println(debugTag, "Closing server socket " + sslServerSocket); + sslServerSocket.close(); } - if (this.executor != null) { - println(debugTag, "Shutting down the executor " + this.executor); - this.executor.shutdownNow(); + if (executor != null) { + println(debugTag, "Shutting down the executor " + executor); + executor.shutdownNow(); } } @@ -117,30 +118,30 @@ public class SSLFlowDelegateTest { } } - private SSLServerSocket createSSLServerSocket( + private static SSLServerSocket createSSLServerSocket( final SSLContext ctx, final InetSocketAddress bindAddr) throws IOException { final SSLServerSocketFactory fac = ctx.getServerSocketFactory(); final SSLServerSocket sslServerSocket = (SSLServerSocket) fac.createServerSocket(); sslServerSocket.setReuseAddress(false); - sslServerSocket.setSSLParameters(this.sslParams); + sslServerSocket.setSSLParameters(sslParams); sslServerSocket.bind(bindAddr); return sslServerSocket; } - private SSLServerSocket startServer(final SSLContext ctx) throws Exception { + private static SSLServerSocket startServer(final SSLContext ctx) throws Exception { final SSLServerSocket sslServerSocket = createSSLServerSocket(ctx, new InetSocketAddress(InetAddress.getLoopbackAddress(), 0)); final Runnable serverResponsePusher = new ServerResponsePusher(sslServerSocket, - this.testCompletion); + testCompletion); final Thread serverThread = new Thread(serverResponsePusher, "serverResponsePusher"); // start the thread which will accept() a socket connection and send data over it serverThread.start(); return sslServerSocket; } - private SSLEngine createClientEngine(final SSLContext ctx) { + private static SSLEngine createClientEngine(final SSLContext ctx) { final SSLEngine clientEngine = ctx.createSSLEngine(); - clientEngine.setSSLParameters(this.sslParams); + clientEngine.setSSLParameters(sslParams); clientEngine.setUseClientMode(true); return clientEngine; } @@ -170,7 +171,7 @@ public class SSLFlowDelegateTest { // in various places in this test. If the "testCompletion" completes before // the "soleExpectedAppData" completes (typically due to some exception), // then we complete the "soleExpectedAppData" too. - this.testCompletion.whenComplete((r, t) -> { + testCompletion.whenComplete((r, t) -> { if (soleExpectedAppData.isDone()) { return; } @@ -221,7 +222,7 @@ public class SSLFlowDelegateTest { println(debugTag, "Waiting for handshake to complete"); final String negotiatedALPN = sslFlowDelegate.alpn().join(); println(debugTag, "handshake completed, with negotiated ALPN: " + negotiatedALPN); - Assert.assertEquals(negotiatedALPN, ALPN, "unexpected ALPN negotiated"); + assertEquals(ALPN, negotiatedALPN, "unexpected ALPN negotiated"); try { // now wait for the initial (and the only) chunk of application data to be // received by the AppResponseReceiver @@ -254,7 +255,7 @@ public class SSLFlowDelegateTest { private void failTest(final CompletionException ce) { final Throwable cause = ce.getCause(); - Assert.fail(cause.getMessage() == null ? "test failed" : cause.getMessage(), cause); + fail(cause.getMessage() == null ? "test failed" : cause.getMessage(), cause); } // uses reflection to get hold of the SSLFlowDelegate.reader.outputQ member field, @@ -288,7 +289,7 @@ public class SSLFlowDelegateTest { } println(debugTag, "num unsolicited bytes so far = " + numUnsolicitated); } - Assert.assertEquals(numUnsolicitated, 0, + assertEquals(0, numUnsolicitated, "SSLFlowDelegate has accumulated " + numUnsolicitated + " unsolicited bytes"); } diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLTubeTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLTubeTest.java index ac6a235b8e2..bb8d583e07b 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLTubeTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SSLTubeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ package jdk.internal.net.http; import jdk.internal.net.http.common.FlowTube; import jdk.internal.net.http.common.SSLFlowDelegate; import jdk.internal.net.http.common.Utils; -import org.testng.annotations.Test; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLParameters; @@ -51,7 +50,8 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.SubmissionPublisher; import java.util.concurrent.atomic.AtomicInteger; -@Test +import org.junit.jupiter.api.Test; + public class SSLTubeTest extends AbstractSSLTubeTest { @Test @@ -125,7 +125,7 @@ public class SSLTubeTest extends AbstractSSLTubeTest { private void clientReader() { try { InputStream is = clientSock.getInputStream(); - final int bufsize = randomRange(512, 16 * 1024); + final int bufsize = AbstractRandomTest.randomRange(512, 16 * 1024); System.out.println("clientReader: bufsize = " + bufsize); while (true) { byte[] buf = new byte[bufsize]; @@ -137,7 +137,7 @@ public class SSLTubeTest extends AbstractSSLTubeTest { allBytesReceived.await(); System.out.println("clientReader: closing publisher"); publisher.close(); - sleep(2000); + AbstractSSLTubeTest.sleep(2000); Utils.close(is, clientSock); return; } @@ -206,13 +206,13 @@ public class SSLTubeTest extends AbstractSSLTubeTest { try { InputStream is = serverSock.getInputStream(); OutputStream os = serverSock.getOutputStream(); - final int bufsize = randomRange(512, 16 * 1024); + final int bufsize = AbstractRandomTest.randomRange(512, 16 * 1024); System.out.println("serverLoopback: bufsize = " + bufsize); byte[] bb = new byte[bufsize]; while (true) { int n = is.read(bb); if (n == -1) { - sleep(2000); + AbstractSSLTubeTest.sleep(2000); is.close(); os.close(); serverSock.close(); diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SelectorTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SelectorTest.java index 5b8da3b9979..3027df0436e 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SelectorTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/SelectorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,20 +31,20 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; import java.net.http.HttpClient; import java.net.http.HttpResponse; -import org.testng.annotations.Test; import jdk.internal.net.http.websocket.RawChannel; import static java.lang.System.out; import static java.nio.charset.StandardCharsets.US_ASCII; import static java.util.concurrent.TimeUnit.SECONDS; import static java.net.http.HttpResponse.BodyHandlers.discarding; +import org.junit.jupiter.api.Test; + /** * Whitebox test of selector mechanics. Currently only a simple test * setting one read and one write event is done. It checks that the * write event occurs first, followed by the read event and then no * further events occur despite the conditions actually still existing. */ -@Test public class SelectorTest { AtomicInteger counter = new AtomicInteger(); diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/WindowControllerTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/WindowControllerTest.java index 0a94f471575..5df3b4227e6 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/WindowControllerTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/WindowControllerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,92 +23,93 @@ package jdk.internal.net.http; -import org.testng.annotations.Test; import static jdk.internal.net.http.frame.SettingsFrame.DEFAULT_INITIAL_WINDOW_SIZE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class WindowControllerTest { @Test public void testConnectionWindowOverflow() { WindowController wc = new WindowController(); - assertEquals(wc.connectionWindowSize(), DEFAULT_INITIAL_WINDOW_SIZE); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.connectionWindowSize(), DEFAULT_INITIAL_WINDOW_SIZE); + assertEquals(DEFAULT_INITIAL_WINDOW_SIZE, wc.connectionWindowSize()); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(DEFAULT_INITIAL_WINDOW_SIZE, wc.connectionWindowSize()); wc.registerStream(1, DEFAULT_INITIAL_WINDOW_SIZE); wc.tryAcquire(DEFAULT_INITIAL_WINDOW_SIZE - 1, 1, null); - assertEquals(wc.connectionWindowSize(), 1); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.connectionWindowSize(), 1); + assertEquals(1, wc.connectionWindowSize()); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(1, wc.connectionWindowSize()); wc.increaseConnectionWindow(Integer.MAX_VALUE - 1 -1); - assertEquals(wc.connectionWindowSize(), Integer.MAX_VALUE - 1); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.connectionWindowSize(), Integer.MAX_VALUE - 1); + assertEquals(Integer.MAX_VALUE - 1, wc.connectionWindowSize()); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(Integer.MAX_VALUE - 1, wc.connectionWindowSize()); wc.increaseConnectionWindow(1); - assertEquals(wc.connectionWindowSize(), Integer.MAX_VALUE); - assertEquals(wc.increaseConnectionWindow(1), false); - assertEquals(wc.increaseConnectionWindow(100), false); - assertEquals(wc.increaseConnectionWindow(Integer.MAX_VALUE), false); - assertEquals(wc.connectionWindowSize(), Integer.MAX_VALUE); + assertEquals(Integer.MAX_VALUE, wc.connectionWindowSize()); + assertEquals(false, wc.increaseConnectionWindow(1)); + assertEquals(false, wc.increaseConnectionWindow(100)); + assertEquals(false, wc.increaseConnectionWindow(Integer.MAX_VALUE)); + assertEquals(Integer.MAX_VALUE, wc.connectionWindowSize()); } @Test public void testStreamWindowOverflow() { WindowController wc = new WindowController(); wc.registerStream(1, DEFAULT_INITIAL_WINDOW_SIZE); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 1), false); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 1), false); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 1), false); + assertEquals(false, wc.increaseStreamWindow(Integer.MAX_VALUE, 1)); + assertEquals(false, wc.increaseStreamWindow(Integer.MAX_VALUE, 1)); + assertEquals(false, wc.increaseStreamWindow(Integer.MAX_VALUE, 1)); wc.registerStream(3, DEFAULT_INITIAL_WINDOW_SIZE); - assertEquals(wc.increaseStreamWindow(100, 3), true); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 3), false); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 3), false); + assertEquals(true, wc.increaseStreamWindow(100, 3)); + assertEquals(false, wc.increaseStreamWindow(Integer.MAX_VALUE, 3)); + assertEquals(false, wc.increaseStreamWindow(Integer.MAX_VALUE, 3)); wc.registerStream(5, 0); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 5), true); - assertEquals(wc.increaseStreamWindow(1, 5), false); - assertEquals(wc.increaseStreamWindow(1, 5), false); - assertEquals(wc.increaseStreamWindow(10, 5), false); + assertEquals(true, wc.increaseStreamWindow(Integer.MAX_VALUE, 5)); + assertEquals(false, wc.increaseStreamWindow(1, 5)); + assertEquals(false, wc.increaseStreamWindow(1, 5)); + assertEquals(false, wc.increaseStreamWindow(10, 5)); wc.registerStream(7, -1); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 7), true); - assertEquals(wc.increaseStreamWindow(1, 7), true); - assertEquals(wc.increaseStreamWindow(1, 7), false); - assertEquals(wc.increaseStreamWindow(10, 7), false); + assertEquals(true, wc.increaseStreamWindow(Integer.MAX_VALUE, 7)); + assertEquals(true, wc.increaseStreamWindow(1, 7)); + assertEquals(false, wc.increaseStreamWindow(1, 7)); + assertEquals(false, wc.increaseStreamWindow(10, 7)); wc.registerStream(9, -1); - assertEquals(wc.increaseStreamWindow(1, 9), true); - assertEquals(wc.increaseStreamWindow(1, 9), true); - assertEquals(wc.increaseStreamWindow(1, 9), true); - assertEquals(wc.increaseStreamWindow(10, 9), true); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 9), false); + assertEquals(true, wc.increaseStreamWindow(1, 9)); + assertEquals(true, wc.increaseStreamWindow(1, 9)); + assertEquals(true, wc.increaseStreamWindow(1, 9)); + assertEquals(true, wc.increaseStreamWindow(10, 9)); + assertEquals(false, wc.increaseStreamWindow(Integer.MAX_VALUE, 9)); wc.registerStream(11, -10); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.increaseStreamWindow(1, 11), true); - assertEquals(wc.streamWindowSize(11), 1); - assertEquals(wc.increaseStreamWindow(Integer.MAX_VALUE, 11), false); - assertEquals(wc.streamWindowSize(11), 1); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(true, wc.increaseStreamWindow(1, 11)); + assertEquals(1, wc.streamWindowSize(11)); + assertEquals(false, wc.increaseStreamWindow(Integer.MAX_VALUE, 11)); + assertEquals(1, wc.streamWindowSize(11)); } @Test @@ -125,9 +126,9 @@ public class WindowControllerTest { wc.tryAcquire(51, 5 , null); wc.adjustActiveStreams(-200); - assertEquals(wc.streamWindowSize(1), -149); - assertEquals(wc.streamWindowSize(3), -150); - assertEquals(wc.streamWindowSize(5), -151); + assertEquals(-149, wc.streamWindowSize(1)); + assertEquals(-150, wc.streamWindowSize(3)); + assertEquals(-151, wc.streamWindowSize(5)); } static final Class IE = InternalError.class; diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/WrapperTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/WrapperTest.java index 6dad2cc75b5..bc69c425678 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/WrapperTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/WrapperTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,11 +27,10 @@ import java.nio.ByteBuffer; import java.util.LinkedList; import java.util.List; import java.util.concurrent.*; -import java.util.concurrent.atomic.*; -import org.testng.annotations.Test; import jdk.internal.net.http.common.SubscriberWrapper; -@Test +import org.junit.jupiter.api.Test; + public class WrapperTest { static final int LO_PRI = 1; static final int HI_PRI = 2; diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/common/DemandTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/common/DemandTest.java index 4ea604fd488..1ea72f472e9 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/common/DemandTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/common/DemandTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,15 +23,16 @@ package jdk.internal.net.http.common; -import org.testng.annotations.Test; - import java.util.concurrent.CountDownLatch; import java.util.concurrent.CyclicBarrier; import java.util.concurrent.atomic.AtomicReference; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertThrows; public class DemandTest { @@ -59,53 +60,61 @@ public class DemandTest { public void test03() { Demand d = new Demand(); d.increase(3); - assertEquals(d.decreaseAndGet(3), 3); + assertEquals(3, d.decreaseAndGet(3)); } @Test public void test04() { Demand d = new Demand(); d.increase(3); - assertEquals(d.decreaseAndGet(5), 3); + assertEquals(3, d.decreaseAndGet(5)); } @Test public void test05() { Demand d = new Demand(); d.increase(7); - assertEquals(d.decreaseAndGet(4), 4); + assertEquals(4, d.decreaseAndGet(4)); } @Test public void test06() { Demand d = new Demand(); - assertEquals(d.decreaseAndGet(3), 0); + assertEquals(0, d.decreaseAndGet(3)); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void test07() { - Demand d = new Demand(); - d.increase(0); + assertThrows(IllegalArgumentException.class, () -> { + Demand d = new Demand(); + d.increase(0); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void test08() { - Demand d = new Demand(); - d.increase(-1); + assertThrows(IllegalArgumentException.class, () -> { + Demand d = new Demand(); + d.increase(-1); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void test09() { - Demand d = new Demand(); - d.increase(10); - d.decreaseAndGet(0); + assertThrows(IllegalArgumentException.class, () -> { + Demand d = new Demand(); + d.increase(10); + d.decreaseAndGet(0); + }); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void test10() { - Demand d = new Demand(); - d.increase(13); - d.decreaseAndGet(-3); + assertThrows(IllegalArgumentException.class, () -> { + Demand d = new Demand(); + d.increase(13); + d.decreaseAndGet(-3); + }); } @Test @@ -169,7 +178,7 @@ public class DemandTest { assertTrue(d.isFulfilled()); } - @Test(invocationCount = 32) + @Test public void test15() throws InterruptedException { int N = Math.max(2, Runtime.getRuntime().availableProcessors() + 1); int M = ((N + 1) * N) / 2; // 1 + 2 + 3 + ... N @@ -187,7 +196,7 @@ public class DemandTest { error.compareAndSet(null, e); } try { - assertEquals(d.decreaseAndGet(j), j); + assertEquals(j, d.decreaseAndGet(j)); } catch (Throwable t) { error.compareAndSet(null, t); } finally { @@ -197,6 +206,6 @@ public class DemandTest { } stop.await(); assertTrue(d.isFulfilled()); - assertEquals(error.get(), null); + assertNull(error.get()); } } diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/common/MinimalFutureTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/common/MinimalFutureTest.java index 01798a645a2..2c33f6f0018 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/common/MinimalFutureTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/common/MinimalFutureTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,19 +23,19 @@ package jdk.internal.net.http.common; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import static org.testng.Assert.assertThrows; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertThrows; public class MinimalFutureTest { - @Test(dataProvider = "futures") + @ParameterizedTest + @MethodSource("futures") public void test(CompletableFuture mf) { ExecutorService executor = Executors.newSingleThreadExecutor(); try { @@ -134,8 +134,7 @@ public class MinimalFutureTest { } - @DataProvider(name = "futures") - public Object[][] futures() { + public static Object[][] futures() { MinimalFuture mf = new MinimalFuture<>(); mf.completeExceptionally(new Throwable()); diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/frame/FramesDecoderTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/frame/FramesDecoderTest.java index 3db439d1c00..e8acc95c1d2 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/frame/FramesDecoderTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/frame/FramesDecoderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,15 +27,15 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; -import org.testng.Assert; -import org.testng.annotations.Test; import static java.lang.System.out; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.testng.Assert.*; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; public class FramesDecoderTest { - abstract class TestFrameProcessor implements FramesDecoder.FrameProcessor { + abstract static class TestFrameProcessor implements FramesDecoder.FrameProcessor { protected volatile int count; public int numberOfFramesDecoded() { return count; } } @@ -69,17 +69,17 @@ public class FramesDecoderTest { assertTrue(frame instanceof DataFrame); DataFrame dataFrame = (DataFrame) frame; List list = dataFrame.getData(); - assertEquals(list.size(), 1); + assertEquals(1, list.size()); ByteBuffer data = list.get(0); byte[] bytes = new byte[data.remaining()]; data.get(bytes); if (count == 0) { - assertEquals(new String(bytes, UTF_8), "XXXX"); + assertEquals("XXXX", new String(bytes, UTF_8)); out.println("First data received:" + data); - assertEquals(data.position(), data.limit()); // since bytes read - assertEquals(data.limit(), data.capacity()); + assertEquals(data.limit(), data.position()); // since bytes read + assertEquals(data.capacity(), data.limit()); } else { - assertEquals(new String(bytes, UTF_8), "YYYY"); + assertEquals("YYYY", new String(bytes, UTF_8)); out.println("Second data received:" + data); } count++; @@ -89,7 +89,7 @@ public class FramesDecoderTest { out.println("Sending " + combined + " to decoder: "); decoder.decode(combined); - Assert.assertEquals(testFrameProcessor.numberOfFramesDecoded(), 2); + assertEquals(2, testFrameProcessor.numberOfFramesDecoded()); } @@ -119,15 +119,15 @@ public class FramesDecoderTest { assertTrue(frame instanceof DataFrame); DataFrame dataFrame = (DataFrame) frame; List list = dataFrame.getData(); - assertEquals(list.size(), 1); + assertEquals(1, list.size()); ByteBuffer data = list.get(0); byte[] bytes = new byte[data.remaining()]; data.get(bytes); - assertEquals(new String(bytes, UTF_8), "XXXX"); + assertEquals("XXXX", new String(bytes, UTF_8)); out.println("First data received:" + data); - assertEquals(data.position(), data.limit()); // since bytes read + assertEquals(data.limit(), data.position()); // since bytes read //assertNotEquals(data.limit(), data.capacity()); - assertEquals(data.capacity(), 1024 - 9 /*frame header*/); + assertEquals(1024 - 9 /*frame header*/, data.capacity()); count++; } }; @@ -135,6 +135,6 @@ public class FramesDecoderTest { out.println("Sending " + combined + " to decoder: "); decoder.decode(combined); - Assert.assertEquals(testFrameProcessor.numberOfFramesDecoded(), 1); + assertEquals(1, testFrameProcessor.numberOfFramesDecoded()); } } diff --git a/test/jdk/java/nio/channels/AsynchronousSocketChannel/CompletionHandlerRelease.java b/test/jdk/java/nio/channels/AsynchronousSocketChannel/CompletionHandlerRelease.java index 7abbf064b40..962d7728a55 100644 --- a/test/jdk/java/nio/channels/AsynchronousSocketChannel/CompletionHandlerRelease.java +++ b/test/jdk/java/nio/channels/AsynchronousSocketChannel/CompletionHandlerRelease.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* @test * @bug 8202252 - * @run testng CompletionHandlerRelease + * @run junit CompletionHandlerRelease * @summary Verify that reference to CompletionHandler is cleared after use */ @@ -44,10 +44,12 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; public class CompletionHandlerRelease { @Test @@ -132,16 +134,16 @@ public class CompletionHandlerRelease { } } - private AsynchronousChannelGroup GROUP; + private static AsynchronousChannelGroup GROUP; - @BeforeTest - void setup() throws IOException { + @BeforeAll + static void setup() throws IOException { GROUP = AsynchronousChannelGroup.withFixedThreadPool(2, Executors.defaultThreadFactory()); } - @AfterTest - void cleanup() throws IOException { + @AfterAll + static void cleanup() throws IOException { GROUP.shutdownNow(); } @@ -199,13 +201,13 @@ public class CompletionHandlerRelease { } } - private void waitForRefToClear(Reference ref, ReferenceQueue queue) + private static void waitForRefToClear(Reference ref, ReferenceQueue queue) throws InterruptedException { Reference r; while ((r = queue.remove(20)) == null) { System.gc(); } - assertEquals(r, ref); + assertSame(ref, r); assertNull(r.get()); } } diff --git a/test/jdk/jdk/incubator/vector/ByteVector128Tests.java b/test/jdk/jdk/incubator/vector/ByteVector128Tests.java index 81224a27515..ca6fa537ac4 100644 --- a/test/jdk/jdk/incubator/vector/ByteVector128Tests.java +++ b/test/jdk/jdk/incubator/vector/ByteVector128Tests.java @@ -6979,7 +6979,7 @@ public class ByteVector128Tests extends AbstractVectorTest { static long ADDReduceLongMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/ByteVector256Tests.java b/test/jdk/jdk/incubator/vector/ByteVector256Tests.java index 1b76763b2a1..5c32d4a7f74 100644 --- a/test/jdk/jdk/incubator/vector/ByteVector256Tests.java +++ b/test/jdk/jdk/incubator/vector/ByteVector256Tests.java @@ -6979,7 +6979,7 @@ public class ByteVector256Tests extends AbstractVectorTest { static long ADDReduceLongMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/ByteVector512Tests.java b/test/jdk/jdk/incubator/vector/ByteVector512Tests.java index 83fd34a71aa..094f3bbebdc 100644 --- a/test/jdk/jdk/incubator/vector/ByteVector512Tests.java +++ b/test/jdk/jdk/incubator/vector/ByteVector512Tests.java @@ -6979,7 +6979,7 @@ public class ByteVector512Tests extends AbstractVectorTest { static long ADDReduceLongMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/ByteVector64Tests.java b/test/jdk/jdk/incubator/vector/ByteVector64Tests.java index 95caa7d2f00..e8ff81678cd 100644 --- a/test/jdk/jdk/incubator/vector/ByteVector64Tests.java +++ b/test/jdk/jdk/incubator/vector/ByteVector64Tests.java @@ -6979,7 +6979,7 @@ public class ByteVector64Tests extends AbstractVectorTest { static long ADDReduceLongMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/ByteVectorMaxTests.java b/test/jdk/jdk/incubator/vector/ByteVectorMaxTests.java index bcea4fa6afe..c53710c3fdd 100644 --- a/test/jdk/jdk/incubator/vector/ByteVectorMaxTests.java +++ b/test/jdk/jdk/incubator/vector/ByteVectorMaxTests.java @@ -6985,7 +6985,7 @@ public class ByteVectorMaxTests extends AbstractVectorTest { static long ADDReduceLongMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/DoubleVector128Tests.java b/test/jdk/jdk/incubator/vector/DoubleVector128Tests.java index 3a0ffe8d7c8..1457e5a51ca 100644 --- a/test/jdk/jdk/incubator/vector/DoubleVector128Tests.java +++ b/test/jdk/jdk/incubator/vector/DoubleVector128Tests.java @@ -5433,7 +5433,7 @@ relativeError)); static long ADDReduceLongMasked(double[] a, int idx, boolean[] mask) { double res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/DoubleVector256Tests.java b/test/jdk/jdk/incubator/vector/DoubleVector256Tests.java index b0ebfebfe59..e417abe52e6 100644 --- a/test/jdk/jdk/incubator/vector/DoubleVector256Tests.java +++ b/test/jdk/jdk/incubator/vector/DoubleVector256Tests.java @@ -5433,7 +5433,7 @@ relativeError)); static long ADDReduceLongMasked(double[] a, int idx, boolean[] mask) { double res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/DoubleVector512Tests.java b/test/jdk/jdk/incubator/vector/DoubleVector512Tests.java index e593da24ce8..d23b2bf1511 100644 --- a/test/jdk/jdk/incubator/vector/DoubleVector512Tests.java +++ b/test/jdk/jdk/incubator/vector/DoubleVector512Tests.java @@ -5433,7 +5433,7 @@ relativeError)); static long ADDReduceLongMasked(double[] a, int idx, boolean[] mask) { double res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/DoubleVector64Tests.java b/test/jdk/jdk/incubator/vector/DoubleVector64Tests.java index 6eb95ffdcc9..d2aff0b7ea5 100644 --- a/test/jdk/jdk/incubator/vector/DoubleVector64Tests.java +++ b/test/jdk/jdk/incubator/vector/DoubleVector64Tests.java @@ -5433,7 +5433,7 @@ relativeError)); static long ADDReduceLongMasked(double[] a, int idx, boolean[] mask) { double res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/DoubleVectorMaxTests.java b/test/jdk/jdk/incubator/vector/DoubleVectorMaxTests.java index b4c76d76f6e..2684ae2d0c6 100644 --- a/test/jdk/jdk/incubator/vector/DoubleVectorMaxTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleVectorMaxTests.java @@ -5439,7 +5439,7 @@ relativeError)); static long ADDReduceLongMasked(double[] a, int idx, boolean[] mask) { double res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/Float16Vector128Tests.java b/test/jdk/jdk/incubator/vector/Float16Vector128Tests.java index a7de1373193..452b02e9556 100644 --- a/test/jdk/jdk/incubator/vector/Float16Vector128Tests.java +++ b/test/jdk/jdk/incubator/vector/Float16Vector128Tests.java @@ -5436,7 +5436,7 @@ public class Float16Vector128Tests extends AbstractVectorTest { static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/Float16Vector256Tests.java b/test/jdk/jdk/incubator/vector/Float16Vector256Tests.java index b9f49fd4bb0..03e7f415545 100644 --- a/test/jdk/jdk/incubator/vector/Float16Vector256Tests.java +++ b/test/jdk/jdk/incubator/vector/Float16Vector256Tests.java @@ -5436,7 +5436,7 @@ public class Float16Vector256Tests extends AbstractVectorTest { static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/Float16Vector512Tests.java b/test/jdk/jdk/incubator/vector/Float16Vector512Tests.java index f943a017cb4..a4162f62eab 100644 --- a/test/jdk/jdk/incubator/vector/Float16Vector512Tests.java +++ b/test/jdk/jdk/incubator/vector/Float16Vector512Tests.java @@ -5436,7 +5436,7 @@ public class Float16Vector512Tests extends AbstractVectorTest { static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/Float16Vector64Tests.java b/test/jdk/jdk/incubator/vector/Float16Vector64Tests.java index b60eeda09b4..c67e9f2d0bf 100644 --- a/test/jdk/jdk/incubator/vector/Float16Vector64Tests.java +++ b/test/jdk/jdk/incubator/vector/Float16Vector64Tests.java @@ -5436,7 +5436,7 @@ public class Float16Vector64Tests extends AbstractVectorTest { static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/Float16VectorMaxTests.java b/test/jdk/jdk/incubator/vector/Float16VectorMaxTests.java index d641bed404a..684d43a6fe2 100644 --- a/test/jdk/jdk/incubator/vector/Float16VectorMaxTests.java +++ b/test/jdk/jdk/incubator/vector/Float16VectorMaxTests.java @@ -5442,7 +5442,7 @@ public class Float16VectorMaxTests extends AbstractVectorTest { static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/FloatVector128Tests.java b/test/jdk/jdk/incubator/vector/FloatVector128Tests.java index 957f9e17786..151ea17a886 100644 --- a/test/jdk/jdk/incubator/vector/FloatVector128Tests.java +++ b/test/jdk/jdk/incubator/vector/FloatVector128Tests.java @@ -5418,7 +5418,7 @@ relativeError)); static long ADDReduceLongMasked(float[] a, int idx, boolean[] mask) { float res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/FloatVector256Tests.java b/test/jdk/jdk/incubator/vector/FloatVector256Tests.java index 4d172afee5b..5315b69a5b6 100644 --- a/test/jdk/jdk/incubator/vector/FloatVector256Tests.java +++ b/test/jdk/jdk/incubator/vector/FloatVector256Tests.java @@ -5418,7 +5418,7 @@ relativeError)); static long ADDReduceLongMasked(float[] a, int idx, boolean[] mask) { float res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/FloatVector512Tests.java b/test/jdk/jdk/incubator/vector/FloatVector512Tests.java index b68f04cbab6..6a958511439 100644 --- a/test/jdk/jdk/incubator/vector/FloatVector512Tests.java +++ b/test/jdk/jdk/incubator/vector/FloatVector512Tests.java @@ -5418,7 +5418,7 @@ relativeError)); static long ADDReduceLongMasked(float[] a, int idx, boolean[] mask) { float res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/FloatVector64Tests.java b/test/jdk/jdk/incubator/vector/FloatVector64Tests.java index 660b0bbbb78..b06dff18194 100644 --- a/test/jdk/jdk/incubator/vector/FloatVector64Tests.java +++ b/test/jdk/jdk/incubator/vector/FloatVector64Tests.java @@ -5418,7 +5418,7 @@ relativeError)); static long ADDReduceLongMasked(float[] a, int idx, boolean[] mask) { float res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/FloatVectorMaxTests.java b/test/jdk/jdk/incubator/vector/FloatVectorMaxTests.java index 526b34038b3..9b84e852c1c 100644 --- a/test/jdk/jdk/incubator/vector/FloatVectorMaxTests.java +++ b/test/jdk/jdk/incubator/vector/FloatVectorMaxTests.java @@ -5424,7 +5424,7 @@ relativeError)); static long ADDReduceLongMasked(float[] a, int idx, boolean[] mask) { float res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/IntVector128Tests.java b/test/jdk/jdk/incubator/vector/IntVector128Tests.java index 40743ea9573..d62f5d8df00 100644 --- a/test/jdk/jdk/incubator/vector/IntVector128Tests.java +++ b/test/jdk/jdk/incubator/vector/IntVector128Tests.java @@ -7012,7 +7012,7 @@ public class IntVector128Tests extends AbstractVectorTest { static long ADDReduceLongMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/IntVector256Tests.java b/test/jdk/jdk/incubator/vector/IntVector256Tests.java index 881c7349cc0..bb2d1d717f4 100644 --- a/test/jdk/jdk/incubator/vector/IntVector256Tests.java +++ b/test/jdk/jdk/incubator/vector/IntVector256Tests.java @@ -7012,7 +7012,7 @@ public class IntVector256Tests extends AbstractVectorTest { static long ADDReduceLongMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/IntVector512Tests.java b/test/jdk/jdk/incubator/vector/IntVector512Tests.java index 38bc54fbc15..5ceba4e88ec 100644 --- a/test/jdk/jdk/incubator/vector/IntVector512Tests.java +++ b/test/jdk/jdk/incubator/vector/IntVector512Tests.java @@ -7012,7 +7012,7 @@ public class IntVector512Tests extends AbstractVectorTest { static long ADDReduceLongMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/IntVector64Tests.java b/test/jdk/jdk/incubator/vector/IntVector64Tests.java index db3af7c3e78..9d3849a2c04 100644 --- a/test/jdk/jdk/incubator/vector/IntVector64Tests.java +++ b/test/jdk/jdk/incubator/vector/IntVector64Tests.java @@ -7012,7 +7012,7 @@ public class IntVector64Tests extends AbstractVectorTest { static long ADDReduceLongMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/IntVectorMaxTests.java b/test/jdk/jdk/incubator/vector/IntVectorMaxTests.java index 949f919ea39..6c671a81bf1 100644 --- a/test/jdk/jdk/incubator/vector/IntVectorMaxTests.java +++ b/test/jdk/jdk/incubator/vector/IntVectorMaxTests.java @@ -7018,7 +7018,7 @@ public class IntVectorMaxTests extends AbstractVectorTest { static long ADDReduceLongMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/ShortVector128Tests.java b/test/jdk/jdk/incubator/vector/ShortVector128Tests.java index d3e76e097cc..da4f00b19bc 100644 --- a/test/jdk/jdk/incubator/vector/ShortVector128Tests.java +++ b/test/jdk/jdk/incubator/vector/ShortVector128Tests.java @@ -6964,7 +6964,7 @@ public class ShortVector128Tests extends AbstractVectorTest { static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/ShortVector256Tests.java b/test/jdk/jdk/incubator/vector/ShortVector256Tests.java index 64d9b9c9a94..1e792f2ca0b 100644 --- a/test/jdk/jdk/incubator/vector/ShortVector256Tests.java +++ b/test/jdk/jdk/incubator/vector/ShortVector256Tests.java @@ -6964,7 +6964,7 @@ public class ShortVector256Tests extends AbstractVectorTest { static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/ShortVector512Tests.java b/test/jdk/jdk/incubator/vector/ShortVector512Tests.java index 19053213187..fc3b6a33eb8 100644 --- a/test/jdk/jdk/incubator/vector/ShortVector512Tests.java +++ b/test/jdk/jdk/incubator/vector/ShortVector512Tests.java @@ -6964,7 +6964,7 @@ public class ShortVector512Tests extends AbstractVectorTest { static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/ShortVector64Tests.java b/test/jdk/jdk/incubator/vector/ShortVector64Tests.java index 20a7fc8a799..740dad10931 100644 --- a/test/jdk/jdk/incubator/vector/ShortVector64Tests.java +++ b/test/jdk/jdk/incubator/vector/ShortVector64Tests.java @@ -6964,7 +6964,7 @@ public class ShortVector64Tests extends AbstractVectorTest { static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/ShortVectorMaxTests.java b/test/jdk/jdk/incubator/vector/ShortVectorMaxTests.java index 93b21f95e83..caf36eeb935 100644 --- a/test/jdk/jdk/incubator/vector/ShortVectorMaxTests.java +++ b/test/jdk/jdk/incubator/vector/ShortVectorMaxTests.java @@ -6970,7 +6970,7 @@ public class ShortVectorMaxTests extends AbstractVectorTest { static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/jdk/incubator/vector/gen-template.sh b/test/jdk/jdk/incubator/vector/gen-template.sh index 673da7baaa9..4e961e2f2b0 100644 --- a/test/jdk/jdk/incubator/vector/gen-template.sh +++ b/test/jdk/jdk/incubator/vector/gen-template.sh @@ -495,8 +495,8 @@ gen_shift_cst_op "ROR" "ROR_scalar(a, CONST_SHIFT)" "BITWISE" gen_shift_cst_op "ROL" "ROL_scalar(a, CONST_SHIFT)" "BITWISE" # Binary operation with one memory operand -gen_binary_alu_mem_op "MIN+min+withMask", "scalar_max(a, b)" -gen_binary_alu_mem_op "MAX+max+withMask", "scalar_min(a, b)" +gen_binary_alu_mem_op "MIN+min+withMask", "scalar_min(a, b)" +gen_binary_alu_mem_op "MAX+max+withMask", "scalar_max(a, b)" # Masked reductions. gen_binary_op_no_masked "MIN+min" "scalar_min(a, b)" diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template b/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template index 7b2f0eb07fc..8606b9ba598 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template @@ -161,7 +161,7 @@ static long ADDReduceLongMasked($type$[] a, int idx, boolean[] mask) { $type$ res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - if(mask[i % SPECIES.length()]) { + if (mask[i % SPECIES.length()]) { res = scalar_add(res, a[i]); } } diff --git a/test/jdk/sun/nio/cs/TestStringCoding.java b/test/jdk/sun/nio/cs/TestStringCoding.java index d708ef180a2..b81ffb07d20 100644 --- a/test/jdk/sun/nio/cs/TestStringCoding.java +++ b/test/jdk/sun/nio/cs/TestStringCoding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ /* @test - * @bug 6636323 6636319 7040220 7096080 7183053 8080248 8054307 + * @bug 6636323 6636319 7040220 7096080 7183053 8080248 8054307 8372353 * @summary Test if StringCoding and NIO result have the same de/encoding result * @library /test/lib * @modules java.base/sun.nio.cs @@ -169,6 +169,12 @@ public class TestStringCoding { if (!Arrays.equals(baSC, baNIO)) { throw new RuntimeException("getBytes(cs) failed -> " + cs.name()); } + //encodedLength(cs); + int encodedLength = str.encodedLength(cs); + if (baSC.length != encodedLength) { + throw new RuntimeException(String.format("encodedLength failed (%d != %d) -> %s", + baSC.length, encodedLength, cs.name())); + } return baSC; } diff --git a/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java b/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java index 75f2af6db5a..412a811d219 100644 --- a/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java +++ b/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @summary Basic test for jhsdb launcher * @library /test/lib * @requires vm.hasSA + * @requires vm.gc != "Z" * @build jdk.test.lib.apps.* * @run main/timeout=480 BasicLauncherTest */ diff --git a/test/jdk/sun/tools/jhsdb/HeapDumpTest.java b/test/jdk/sun/tools/jhsdb/HeapDumpTest.java index c59e2b0e040..5ef1dadcb62 100644 --- a/test/jdk/sun/tools/jhsdb/HeapDumpTest.java +++ b/test/jdk/sun/tools/jhsdb/HeapDumpTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 8163346 * @summary Test hashing of extended characters in Serviceability Agent. * @requires vm.hasSA + * @requires vm.gc != "Z" * @library /test/lib * @compile -encoding utf8 HeapDumpTest.java * @run main/timeout=240 HeapDumpTest diff --git a/test/jdk/sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java b/test/jdk/sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java index bd5a400225f..fffbe439f94 100644 --- a/test/jdk/sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java +++ b/test/jdk/sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8230731 8001227 8231635 8231634 8196969 * @requires vm.hasSA + * @requires vm.gc != "Z" * @library /test/lib * @compile JShellHeapDumpTest.java * @run main/timeout=240 JShellHeapDumpTest nosleep diff --git a/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java b/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java index 6fbc96362a9..a9e5f7aeffe 100644 --- a/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java +++ b/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8225715 * @requires vm.hasSA + * @requires vm.gc != "Z" * @library /test/lib * @compile JShellHeapDumpTest.java * @run main/timeout=240 JShellHeapDumpTest diff --git a/test/jdk/sun/tools/jhsdb/JStackStressTest.java b/test/jdk/sun/tools/jhsdb/JStackStressTest.java index 97945b6092b..a28cdf3be5a 100644 --- a/test/jdk/sun/tools/jhsdb/JStackStressTest.java +++ b/test/jdk/sun/tools/jhsdb/JStackStressTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8262271 * @requires vm.hasSA + * @requires vm.gc != "Z" * @library /test/lib * @run main/timeout=240 JStackStressTest */ diff --git a/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java b/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java index 659eac2ee8f..b2c7ba0ef87 100644 --- a/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java +++ b/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, 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 jdk.test.lib.Utils; * @summary Unit test for jmap utility test heap configuration reader * * @requires vm.hasSA + * @requires vm.gc != "Z" * @library /test/lib * @modules java.management * jdk.hotspot.agent/sun.jvm.hotspot diff --git a/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/JPackageStringBundleTest.java b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/JPackageStringBundleTest.java new file mode 100644 index 00000000000..bf1eb2bdaec --- /dev/null +++ b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/JPackageStringBundleTest.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.jpackage.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrowsExactly; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.function.Function; +import java.util.regex.Pattern; +import java.util.stream.Stream; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +class JPackageStringBundleTest { + + @Test + void test_cannedFormattedString() { + assertFalse(JPackageStringBundle.MAIN.cannedFormattedString("error.version-string-empty").getValue().isBlank()); + } + + @Test + void test_cannedFormattedStringAsPattern() { + var pred = JPackageStringBundle.MAIN.cannedFormattedStringAsPattern("error.version-string-empty", UNREACHABLE_FORMAT_ARG_MAPPER).asMatchPredicate(); + + var str = JPackageStringBundle.MAIN.cannedFormattedString("error.version-string-empty").getValue(); + assertTrue(pred.test(str)); + assertFalse(pred.test(str + str)); + } + + @Test + void test_cannedFormattedStringAsPattern_with_arg() { + var pred = JPackageStringBundle.MAIN.cannedFormattedStringAsPattern("message.error-header", DEFAULT_FORMAT_ARG_MAPPER, "foo").asMatchPredicate(); + + for (var err : List.of("foo", "bar", "", "Unexpected value")) { + var str = JPackageStringBundle.MAIN.cannedFormattedString("message.error-header", err).getValue(); + assertTrue(pred.test(str)); + assertFalse(pred.test(err)); + } + } + + @ParameterizedTest + @MethodSource + void test_cannedFormattedString_wrong_argument_count(CannedFormattedString cannedStr) { + assertThrowsExactly(IllegalArgumentException.class, cannedStr::getValue); + } + + @Test + void test_cannedFormattedStringAsPattern_wrong_argument_count() { + assertThrowsExactly(IllegalArgumentException.class, () -> { + JPackageStringBundle.MAIN.cannedFormattedStringAsPattern("error.version-string-empty", UNREACHABLE_FORMAT_ARG_MAPPER, "foo"); + }); + + assertThrowsExactly(IllegalArgumentException.class, () -> { + JPackageStringBundle.MAIN.cannedFormattedStringAsPattern("message.error-header", UNREACHABLE_FORMAT_ARG_MAPPER); + }); + + assertThrowsExactly(IllegalArgumentException.class, () -> { + JPackageStringBundle.MAIN.cannedFormattedStringAsPattern("message.error-header", UNREACHABLE_FORMAT_ARG_MAPPER, "foo", "bar"); + }); + } + + @ParameterizedTest + @MethodSource + void test_toPattern(TestSpec test) { + var pattern = JPackageStringBundle.toPattern(new MessageFormat(test.formatter()), test.formatArgMapper(), test.args().toArray()); + assertEquals(test.expectedPattern().toString(), pattern.toString()); + } + + private static Collection test_cannedFormattedString_wrong_argument_count() { + return List.of( + JPackageStringBundle.MAIN.cannedFormattedString("error.version-string-empty", "foo"), + JPackageStringBundle.MAIN.cannedFormattedString("message.error-header"), + JPackageStringBundle.MAIN.cannedFormattedString("message.error-header", "foo", "bar") + ); + } + + private static Collection test_toPattern() { + + var testCases = new ArrayList(); + + testCases.addAll(List.of( + TestSpec.create("", Pattern.compile("")), + TestSpec.create("", Pattern.compile(""), "foo") + )); + + for (List args : List.of(List.of(), List.of("foo"))) { + Stream.of( + "Stop." + ).map(formatter -> { + return new TestSpec(formatter, args, Pattern.compile(Pattern.quote(formatter))); + }).forEach(testCases::add); + } + + testCases.add(TestSpec.create("Hello {1} {0}{1}!", Pattern.compile("\\QHello \\E.*\\Q \\E.*.*\\Q!\\E"), "foo", "bar")); + testCases.add(TestSpec.create("Hello {1} {0}{0} {0}{0}{0} {0}", Pattern.compile("\\QHello \\E.*\\Q \\E.*\\Q \\E.*\\Q \\E.*"), "foo", "bar")); + testCases.add(TestSpec.create("{0}{0}", Pattern.compile(".*"), "foo")); + + return testCases; + } + + record TestSpec(String formatter, List args, Pattern expectedPattern) { + TestSpec { + Objects.requireNonNull(formatter); + Objects.requireNonNull(args); + Objects.requireNonNull(expectedPattern); + } + + Function formatArgMapper() { + if (Pattern.compile(Pattern.quote(formatter)).toString().equals(expectedPattern.toString())) { + return UNREACHABLE_FORMAT_ARG_MAPPER; + } else { + return DEFAULT_FORMAT_ARG_MAPPER; + } + } + + static TestSpec create(String formatter, Pattern expectedPattern, Object... args) { + return new TestSpec(formatter, List.of(args), expectedPattern); + } + } + + private static final Pattern DEFAULT_FORMAT_ARG_PATTERN = Pattern.compile(".*"); + + private static final Function DEFAULT_FORMAT_ARG_MAPPER = _ -> { + return DEFAULT_FORMAT_ARG_PATTERN; + }; + + private static final Function UNREACHABLE_FORMAT_ARG_MAPPER = _ -> { + throw new AssertionError(); + }; +} diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java index 251d95a1089..2e58ea7a0ab 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java @@ -43,7 +43,6 @@ import java.security.SecureRandom; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Map; @@ -245,7 +244,12 @@ public class JPackageCommand extends CommandArguments { } public String version() { - return getArgumentValue("--app-version", () -> "1.0"); + return PropertyFinder.findAppProperty(this, + PropertyFinder.cmdlineOptionWithValue("--app-version"), + PropertyFinder.appImageFile(appImageFile -> { + return appImageFile.version(); + }) + ).orElse("1.0"); } public String name() { @@ -1050,6 +1054,10 @@ public class JPackageCommand extends CommandArguments { final var directoriesAssert = new ReadOnlyPathsAssert(copy); + standardAssertOutputValidators().forEach(validator -> { + validator.applyTo(copy); + }); + Executor.Result result; if (expectedExitCode.isEmpty()) { result = copy.createExecutor().executeWithoutExitCodeCheck(); @@ -1064,7 +1072,7 @@ public class JPackageCommand extends CommandArguments { ConfigFilesStasher.INSTANCE.accept(this); } - for (final var validator: validators) { + for (final var validator: copy.validators) { validator.accept(result); } @@ -1375,10 +1383,38 @@ public class JPackageCommand extends CommandArguments { TKit.assertFileExists(cmd.appLayout().libapplauncher()); } }), + LINUX_PACKAGE_ARCH(cmd -> { + if (TKit.isLinux() && !cmd.isImagePackageType()) { + var asserter = TKit.assertTextStream(LinuxUnexpectedBundleArchRegexp.VALUE).negate(); + return Stream.of(true, false).map(stderr -> { + var validator = new JPackageOutputValidator(); + if (stderr) { + return validator.stderr(); + } else { + return validator; + } + }).map(validator -> { + return validator.add(asserter); + }).toList(); + } else { + return List.of(); + } + }), ; - StandardAssert(Consumer action) { + StandardAssert( + Consumer action, + Function> outputValidatorsSupplier) { this.action = action; + this.outputValidatorsSupplier = outputValidatorsSupplier; + } + + StandardAssert(Consumer action) { + this(Objects.requireNonNull(action), null); + } + + StandardAssert(Function> outputValidatorsSupplier) { + this(null, Objects.requireNonNull(outputValidatorsSupplier)); } private static JPackageCommand convertFromRuntime(JPackageCommand cmd) { @@ -1390,7 +1426,38 @@ public class JPackageCommand extends CommandArguments { return copy; } + Stream outputValidators(JPackageCommand cmd) { + Objects.requireNonNull(cmd); + return Optional.ofNullable(outputValidatorsSupplier).map(v -> { + return v.apply(cmd); + }).stream().flatMap(Collection::stream); + } + + void apply(JPackageCommand cmd) { + Objects.requireNonNull(cmd); + if (action != null) { + action.accept(cmd); + } + } + private final Consumer action; + private final Function> outputValidatorsSupplier; + + private static final class LinuxUnexpectedBundleArchRegexp { + private static final Pattern ANY = Pattern.compile(".*"); + private static final Pattern ARCHITECTURE_PROPERTY = Pattern.compile("Arch|Architecture"); + + static final Pattern VALUE = JPackageStringBundle.MAIN.cannedFormattedStringAsPattern("error.unexpected-package-property", arg -> { + return switch ((String)arg) { + case "propertyName" -> { + yield ARCHITECTURE_PROPERTY; + } + default -> { + yield ANY; + } + }; + }, "propertyName", "expectedValue", "actualValue", "customResource"); + } } public JPackageCommand setStandardAsserts(StandardAssert ... asserts) { @@ -1407,11 +1474,17 @@ public class JPackageCommand extends CommandArguments { JPackageCommand runStandardAsserts() { for (var standardAssert : standardAsserts.stream().sorted().toList()) { - standardAssert.action.accept(this); + standardAssert.apply(this); } return this; } + private List standardAssertOutputValidators() { + return standardAsserts.stream().sorted().flatMap(standardAssert -> { + return standardAssert.outputValidators(this); + }).toList(); + } + private boolean expectAppImageFile() { if (isRuntime()) { return false; diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageStringBundle.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageStringBundle.java index 9425b84472c..cd8ffd853b7 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageStringBundle.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageStringBundle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,10 +23,16 @@ package jdk.jpackage.test; +import static jdk.jpackage.internal.util.function.ExceptionBox.toUnchecked; + import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.text.MessageFormat; -import static jdk.jpackage.internal.util.function.ExceptionBox.toUnchecked; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Function; +import java.util.regex.Pattern; public enum JPackageStringBundle { @@ -56,18 +62,95 @@ public enum JPackageStringBundle { } private String getFormattedString(String key, Object[] args) { - var str = getString(key); - if (args.length != 0) { - return MessageFormat.format(str, args); - } else { - return str; - } + return new FormattedMessage(key, args).value(); } public CannedFormattedString cannedFormattedString(String key, Object ... args) { return new CannedFormattedString(this::getFormattedString, key, args); } + public Pattern cannedFormattedStringAsPattern(String key, Function formatArgMapper, Object ... args) { + var fm = new FormattedMessage(key, args); + return fm.messageFormat().map(mf -> { + return toPattern(mf, formatArgMapper, args); + }).orElseGet(() -> { + return Pattern.compile(Pattern.quote(fm.value())); + }); + } + + static Pattern toPattern(MessageFormat mf, Function formatArgMapper, Object ... args) { + Objects.requireNonNull(mf); + Objects.requireNonNull(formatArgMapper); + + var patternSb = new StringBuilder(); + var runSb = new StringBuilder(); + + var it = mf.formatToCharacterIterator(args); + while (it.getIndex() < it.getEndIndex()) { + var runBegin = it.getRunStart(); + var runEnd = it.getRunLimit(); + if (runEnd < runBegin) { + throw new IllegalStateException(); + } + + var attrs = it.getAttributes(); + if (attrs.isEmpty()) { + // Regular text run. + runSb.setLength(0); + it.setIndex(runBegin); + for (int counter = runEnd - runBegin; counter != 0; --counter) { + runSb.append(it.current()); + it.next(); + } + patternSb.append(Pattern.quote(runSb.toString())); + } else { + // Format run. + int argi = (Integer)attrs.get(MessageFormat.Field.ARGUMENT); + var arg = args[argi]; + var pattern = Objects.requireNonNull(formatArgMapper.apply(arg)); + patternSb.append(pattern.toString()); + it.setIndex(runEnd); + } + } + + return Pattern.compile(patternSb.toString()); + } + + private final class FormattedMessage { + + FormattedMessage(String key, Object[] args) { + List.of(args).forEach(Objects::requireNonNull); + + var formatter = getString(key); + + var mf = new MessageFormat(formatter); + var formatCount = mf.getFormatsByArgumentIndex().length; + if (formatCount != args.length) { + throw new IllegalArgumentException(String.format( + "Expected %d arguments for [%s] string, but given %d", formatCount, key, args.length)); + } + + if (formatCount == 0) { + this.mf = null; + value = formatter; + } else { + this.mf = mf; + value = mf.format(args); + } + } + + String value() { + return value; + } + + Optional messageFormat() { + return Optional.ofNullable(mf); + } + + private final String value; + private final MessageFormat mf; + } + private final Class i18nClass; private final Method i18nClass_getString; } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LinuxHelper.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LinuxHelper.java index 78562b2ed26..66462bedfd7 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LinuxHelper.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LinuxHelper.java @@ -26,6 +26,7 @@ import static java.util.Collections.unmodifiableSortedSet; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toMap; import static java.util.stream.Collectors.toSet; +import static jdk.jpackage.internal.util.MemoizingSupplier.runOnce; import java.io.IOException; import java.io.UncheckedIOException; @@ -36,7 +37,6 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -46,35 +46,34 @@ import java.util.TreeMap; import java.util.TreeSet; import java.util.function.Function; import java.util.function.Predicate; +import java.util.function.Supplier; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Stream; +import jdk.internal.util.Architecture; import jdk.jpackage.internal.util.PathUtils; +import jdk.jpackage.internal.util.Result; import jdk.jpackage.internal.util.function.ThrowingConsumer; import jdk.jpackage.test.LauncherShortcut.InvokeShortcutSpec; import jdk.jpackage.test.PackageTest.PackageHandlers; public final class LinuxHelper { - private static String getReleaseSuffix(JPackageCommand cmd) { - final String value; - final PackageType packageType = cmd.packageType(); - switch (packageType) { - case LINUX_DEB: - value = Optional.ofNullable(cmd.getArgumentValue( - "--linux-app-release", () -> null)).map(v -> "-" + v).orElse( - ""); - break; - case LINUX_RPM: - value = "-" + cmd.getArgumentValue("--linux-app-release", - () -> "1"); - break; - - default: - value = null; + static String getReleaseSuffix(JPackageCommand cmd) { + cmd.verifyIsOfType(PackageType.LINUX); + var release = Optional.ofNullable(cmd.getArgumentValue("--linux-app-release")); + switch (cmd.packageType()) { + case LINUX_DEB -> { + return release.map(v -> "-" + v).orElse(""); + } + case LINUX_RPM -> { + return "-" + release.orElse("1"); + } + default -> { + throw new UnsupportedOperationException(); + } } - return value; } public static String getPackageName(JPackageCommand cmd) { @@ -333,10 +332,14 @@ public final class LinuxHelper { long packageSize = getInstalledPackageSizeKB(cmd); TKit.trace("InstalledPackageSize: " + packageSize); TKit.assertNotEquals(0, packageSize, String.format( - "Check installed size of [%s] package in not zero", packageName)); + "Check installed size of [%s] package is not zero", packageName)); final boolean checkPrerequisites; - if (cmd.isRuntime()) { + if (NativePackageType.VALUE != cmd.packageType()) { + // Alien packaging (DEB packaging on RPM Linux or RPM packaging on Debian). + // Don't validate required packages. + checkPrerequisites = false; + } else if (cmd.isRuntime()) { Path runtimeDir = cmd.appRuntimeDirectory(); Set expectedCriticalRuntimePaths = CRITICAL_RUNTIME_FILES.stream().map( runtimeDir::resolve).collect(toSet()); @@ -850,29 +853,7 @@ public final class LinuxHelper { } public static String getDefaultPackageArch(PackageType type) { - if (archs == null) { - archs = new HashMap<>(); - } - - String arch = archs.get(type); - if (arch == null) { - final Executor exec; - switch (type) { - case LINUX_DEB: - exec = Executor.of("dpkg", "--print-architecture"); - break; - - case LINUX_RPM: - exec = Executor.of("rpmbuild", "--eval=%{_target_cpu}"); - break; - - default: - throw new UnsupportedOperationException(); - } - arch = exec.executeAndGetFirstLineOfOutput(); - archs.put(type, arch); - } - return arch; + return LinuxPackageArchitecture.get(type); } private static String getServiceUnitFileName(String packageName, String launcherName) { @@ -960,7 +941,62 @@ public final class LinuxHelper { static final Set CRITICAL_RUNTIME_FILES = Set.of(Path.of( "lib/server/libjvm.so")); - private static Map archs; + private enum LinuxPackageArchitecture implements Supplier { + RPM("rpmbuild", "--eval=%{_target_cpu}"), + DEB("dpkg", "--print-architecture"), + ; + + LinuxPackageArchitecture(String... cmdline) { + this.cmdline = List.of(cmdline); + } + + static String get(PackageType type) { + Objects.requireNonNull(type); + if (type.isSupported()) { + return ARCHS.get(type).get(); + } else { + return Architecture.current().name().toLowerCase(); + } + } + + @Override + public String get() { + return Executor.of(cmdline).executeAndGetFirstLineOfOutput(); + } + + private final List cmdline; + + private static final Map> ARCHS = Map.of( + PackageType.LINUX_RPM, runOnce(RPM), + PackageType.LINUX_DEB, runOnce(DEB)); + } + + private static final class NativePackageType { + + static final PackageType VALUE; + + private static boolean isDebian() { + // we are just going to run "dpkg -s coreutils" and assume Debian + // or derivative if no error is returned. + return Result.of(Executor.of("dpkg", "-s", "coreutils")::execute).hasValue(); + } + + private static boolean isRpm() { + // we are just going to run "rpm -q rpm" and assume RPM + // or derivative if no error is returned. + return Result.of(Executor.of("rpm", "-q", "rpm")::execute).hasValue(); + } + + static { + if (isDebian()) { + VALUE = PackageType.LINUX_DEB; + } else if (isRpm()) { + VALUE = PackageType.LINUX_RPM; + } else { + VALUE = null; + } + } + } private static final Pattern XDG_CMD_ICON_SIZE_PATTERN = Pattern.compile("\\s--size\\s+(\\d+)\\b"); diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSign.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSign.java index 20f7ac41eef..81e5da34140 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSign.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSign.java @@ -67,6 +67,7 @@ import java.util.function.Supplier; import java.util.stream.Stream; import javax.naming.ldap.LdapName; import javax.naming.ldap.Rdn; +import jdk.internal.util.OSVersion; import jdk.jpackage.internal.util.MemoizingSupplier; import jdk.jpackage.internal.util.function.ExceptionBox; import jdk.jpackage.internal.util.function.ThrowingConsumer; @@ -233,7 +234,7 @@ import jdk.jpackage.internal.util.function.ThrowingSupplier; * An untrusted certificate can NOT be used with /usr/bin/codesign. Use * *
- * /usr/bin/security security add-trusted-cert -k foo.keychain cert.pem
+ * /usr/bin/security add-trusted-cert -k foo.keychain cert.pem
  * 
* * command to add trusted certificate from "cert.pem" file to "foo.keychain" @@ -440,7 +441,21 @@ public final class MacSign { } Keychain unlock() { - createExecutor("unlock-keychain").execute(); + var exec = createExecutor("unlock-keychain"); + + exec.execute(); + + if (UnlockKeychainWithOsascript.VALUE) { + exec = Executor.of("osascript") + .addArguments(SIGN_UTILS_SCRIPT.toString(), "run-shell-script") + .addArgument(Stream.concat( + Stream.of(exec.getExecutable().orElseThrow().toString()), + exec.getAllArguments().stream() + ).collect(joining(" "))); + + exec.execute(); + } + return this; } @@ -576,29 +591,43 @@ public final class MacSign { } private static CertificateStats create(KeychainWithCertsSpec spec) { - final var allCertificates = spec.keychain().findCertificates(); final List allResolvedCertificateRequests = new ArrayList<>(); final Map unmappedCertificates = new HashMap<>(); - withTempDirectory(workDir -> { - for (final var cert : allCertificates) { - ResolvedCertificateRequest resolvedCertificateRequest; - try { - resolvedCertificateRequest = new ResolvedCertificateRequest(cert); - } catch (RuntimeException ex) { - unmappedCertificates.put(cert, ExceptionBox.unbox(ex)); - continue; - } + final Runnable workload = () -> { + final var allCertificates = spec.keychain().findCertificates(); + withTempDirectory(workDir -> { + for (final var cert : allCertificates) { + ResolvedCertificateRequest resolvedCertificateRequest; + try { + resolvedCertificateRequest = new ResolvedCertificateRequest(cert); + } catch (RuntimeException ex) { + unmappedCertificates.put(cert, ExceptionBox.unbox(ex)); + continue; + } - if (spec.certificateRequests().stream().anyMatch(resolvedCertificateRequest.installed()::match)) { - final var certFile = workDir.resolve(CertificateHash.of(cert).toString() + ".pem"); - final var verifyStatus = verifyCertificate(resolvedCertificateRequest, spec.keychain(), certFile); - resolvedCertificateRequest = resolvedCertificateRequest.copyVerified(verifyStatus); - } + if (spec.certificateRequests().stream().anyMatch(resolvedCertificateRequest.installed()::match)) { + final var certFile = workDir.resolve(CertificateHash.of(cert).toString() + ".pem"); + final var verifyStatus = verifyCertificate(resolvedCertificateRequest, spec.keychain(), certFile); + resolvedCertificateRequest = resolvedCertificateRequest.copyVerified(verifyStatus); + } - allResolvedCertificateRequests.add(resolvedCertificateRequest); - } - }); + allResolvedCertificateRequests.add(resolvedCertificateRequest); + } + }); + }; + + // Starting from some macOS version, it is no longer necessary to have the keychain + // in the list of keychains when running the "/usr/bin/security verify-cert ..." command to verify its certificate(s). + // The exact version when they relaxed this constraint is unknown, but it is still required on Catalina 10.15.7. + // On Catalina, if the keychain is not in the list of keychains, "/usr/bin/security verify-cert ..." command + // executed on the certificates of this keychain returns "untrusted" result. + if (OSVersion.current().compareTo(new OSVersion(10, 16)) < 0) { + // macOS Catalina or older + withKeychains(spec).addToSearchList().run(workload); + } else { + workload.run(); + } return new CertificateStats(allResolvedCertificateRequests, List.copyOf(spec.certificateRequests()), unmappedCertificates); @@ -1272,7 +1301,11 @@ public final class MacSign { for (final var quite : List.of(true, false)) { result = security("verify-cert", "-L", "-n", quite ? "-q" : "-v", - "-c", certFile.normalize().toString(), + // Use "-r" option to verify the certificate against itself. + // "-c" option works on newer macOS versions, but on older ones (at least on Catalina 10.15.7), + // in case there are two self-signed certificates with the same name in the given keychain, + // it links them in the certificate list and fails verification. + "-r", certFile.normalize().toString(), "-k", keychain.name(), "-p", resolvedCertificateRequest.installed().type().verifyPolicy()).saveOutput(!quite).executeWithoutExitCodeCheck(); if (result.getExitCode() == 0) { @@ -1463,4 +1496,10 @@ public final class MacSign { // faketime is not a standard macOS command. // One way to get it is with Homebrew. private static final Path FAKETIME = Path.of(Optional.ofNullable(TKit.getConfigProperty("faketime")).orElse("/usr/local/bin/faketime")); + + // Run the "/usr/bin/system unlock-keychain" command in Terminal.app if + // the current process runs in an SSH session and the OS version is macOS Catalina or older. + private static final class UnlockKeychainWithOsascript { + static final boolean VALUE = System.getenv("SSH_CONNECTION") != null && OSVersion.current().compareTo(new OSVersion(10, 16)) < 0; + } } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSignVerify.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSignVerify.java index 01c510070be..404811ea0f8 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSignVerify.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacSignVerify.java @@ -93,8 +93,11 @@ public final class MacSignVerify { final var exec = Executor.of( "/usr/bin/codesign", "-d", - "--entitlements", "-", - "--xml", path.toString()).saveOutput().dumpOutput().binaryOutput(); + // `--entitlements :-` will print entitlements as XML plist in the stdout and "Executable=..." message to the stderr. + // Prefer this option combination to `--entitlements - --xml` as + // the latter doesn't work on older macOS releases (Proved unsupported on Catalina 10.15.7). + "--entitlements", ":-", + path.toString()).saveOutput().dumpOutput().binaryOutput(); final var result = exec.execute(); var xml = result.byteStdout(); if (xml.length == 0) { diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PropertyFinder.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PropertyFinder.java index 3d7ac490350..46425ceccbd 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PropertyFinder.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PropertyFinder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, 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 @@ -21,6 +21,7 @@ * questions. */ package jdk.jpackage.test; + import static jdk.jpackage.test.AdditionalLauncher.getAdditionalLauncherProperties; import java.nio.file.Path; @@ -66,8 +67,13 @@ final class PropertyFinder { } static Finder nop() { + return of(Optional.empty()); + } + + static Finder of(Optional v) { + Objects.requireNonNull(v); return target -> { - return Optional.empty(); + return v; }; } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java index db76309c292..04b828677ca 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java @@ -37,7 +37,6 @@ import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.LinkOption; import java.nio.file.Path; -import java.nio.file.StandardCopyOption; import java.nio.file.StandardWatchEventKinds; import java.nio.file.WatchEvent; import java.nio.file.WatchKey; @@ -606,25 +605,6 @@ public final class TKit { return JtregSkippedExceptionClass.INSTANCE.isInstance(t); } - public static Path createRelativePathCopy(final Path file) { - Path fileCopy = ThrowingSupplier.toSupplier(() -> { - Path localPath = createTempFile(file.getFileName()); - Files.copy(file, localPath, StandardCopyOption.REPLACE_EXISTING); - return localPath; - }).get().toAbsolutePath().normalize(); - - final Path basePath = Path.of(".").toAbsolutePath().normalize(); - try { - return basePath.relativize(fileCopy); - } catch (IllegalArgumentException ex) { - // May happen on Windows: java.lang.IllegalArgumentException: 'other' has different root - trace(String.format("Failed to relativize [%s] at [%s]", fileCopy, - basePath)); - printStackTrace(ex); - } - return file; - } - public static void waitForFileCreated(Path fileToWaitFor, Duration timeout, Duration afterCreatedTimeout) throws IOException { waitForFileCreated(fileToWaitFor, timeout); diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/MainTest.java b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/MainTest.java index 3f933093e97..1b89d23c301 100644 --- a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/MainTest.java +++ b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/MainTest.java @@ -154,6 +154,7 @@ public class MainTest extends JUnitAdapter { JPackageCommand.helloAppImage() .ignoreDefaultVerbose(true) + .ignoreDefaultRuntime(true) .useToolProvider(jpackageToolProviderMock) .execute(jpackageExitCode); } diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/OptionsValidationFailTest.excludes b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/OptionsValidationFailTest.excludes index f86fb9a3897..32968db0606 100644 --- a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/OptionsValidationFailTest.excludes +++ b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/cli/OptionsValidationFailTest.excludes @@ -28,16 +28,16 @@ ErrorTest.test(NATIVE; args-add=[--runtime-image, @@EMPTY_DIR@@]; errors=[messag ErrorTest.test(NATIVE; args-add=[--runtime-image, @@INVALID_MAC_RUNTIME_BUNDLE@@]; errors=[message.error-header+[error.invalid-runtime-image-missing-file, @@INVALID_MAC_RUNTIME_BUNDLE@@, Contents/Home/lib/**/libjli.dylib]]) ErrorTest.test(NATIVE; args-add=[--runtime-image, @@INVALID_MAC_RUNTIME_IMAGE@@]; errors=[message.error-header+[error.invalid-runtime-image-missing-file, @@INVALID_MAC_RUNTIME_IMAGE@@, lib/**/libjli.dylib]]) ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--app-version, 1.2.3.4.5]; errors=[message.error-header+[error.msi-product-version-components, 1.2.3.4.5], message.advice-header+[error.version-string-wrong-format.advice]]) -ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--app-version, 1.2.65536]; errors=[message.error-header+[error.msi-product-version-build-out-of-range, 1.2.65536], message.advice-header+[error.version-string-wrong-format.advice]]) -ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--app-version, 1.256]; errors=[message.error-header+[error.msi-product-version-minor-out-of-range, 1.256], message.advice-header+[error.version-string-wrong-format.advice]]) +ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--app-version, 1.2.65536]; errors=[message.error-header+[error.msi-product-version-build-out-of-range], message.advice-header+[error.version-string-wrong-format.advice]]) +ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--app-version, 1.256]; errors=[message.error-header+[error.msi-product-version-minor-out-of-range], message.advice-header+[error.version-string-wrong-format.advice]]) ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--app-version, 1234]; errors=[message.error-header+[error.msi-product-version-components, 1234], message.advice-header+[error.version-string-wrong-format.advice]]) -ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--app-version, 256.1]; errors=[message.error-header+[error.msi-product-version-major-out-of-range, 256.1], message.advice-header+[error.version-string-wrong-format.advice]]) +ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--app-version, 256.1]; errors=[message.error-header+[error.msi-product-version-major-out-of-range], message.advice-header+[error.version-string-wrong-format.advice]]) ErrorTest.test(WIN_EXE; app-desc=Hello; args-add=[--launcher-as-service]; errors=[message.error-header+[error.missing-service-installer], message.advice-header+[error.missing-service-installer.advice]]) ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--app-version, 1.2.3.4.5]; errors=[message.error-header+[error.msi-product-version-components, 1.2.3.4.5], message.advice-header+[error.version-string-wrong-format.advice]]) -ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--app-version, 1.2.65536]; errors=[message.error-header+[error.msi-product-version-build-out-of-range, 1.2.65536], message.advice-header+[error.version-string-wrong-format.advice]]) -ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--app-version, 1.256]; errors=[message.error-header+[error.msi-product-version-minor-out-of-range, 1.256], message.advice-header+[error.version-string-wrong-format.advice]]) +ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--app-version, 1.2.65536]; errors=[message.error-header+[error.msi-product-version-build-out-of-range], message.advice-header+[error.version-string-wrong-format.advice]]) +ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--app-version, 1.256]; errors=[message.error-header+[error.msi-product-version-minor-out-of-range], message.advice-header+[error.version-string-wrong-format.advice]]) ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--app-version, 1234]; errors=[message.error-header+[error.msi-product-version-components, 1234], message.advice-header+[error.version-string-wrong-format.advice]]) -ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--app-version, 256.1]; errors=[message.error-header+[error.msi-product-version-major-out-of-range, 256.1], message.advice-header+[error.version-string-wrong-format.advice]]) +ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--app-version, 256.1]; errors=[message.error-header+[error.msi-product-version-major-out-of-range], message.advice-header+[error.version-string-wrong-format.advice]]) ErrorTest.test(WIN_MSI; app-desc=Hello; args-add=[--launcher-as-service]; errors=[message.error-header+[error.missing-service-installer], message.advice-header+[error.missing-service-installer.advice]]) ErrorTest.test(args-add=[@foo]; errors=[message.error-header+[ERR_CannotParseOptions, foo]]) ErrorTest.testMacSignWithoutIdentity(IMAGE; app-desc=Hello; args-add=[--mac-sign, --mac-signing-keychain, @@EMPTY_KEYCHAIN@@]; errors=[message.error-header+[error.cert.not.found, CODE_SIGN, EMPTY_KEYCHAIN]]) diff --git a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/model/DottedVersionTest.java b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/model/DottedVersionTest.java index 885ea31f726..df020f1a34c 100644 --- a/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/model/DottedVersionTest.java +++ b/test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/model/DottedVersionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,8 +32,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrowsExactly; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertNotSame; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.MethodSource; @@ -108,12 +111,113 @@ public class DottedVersionTest { TestConfig.lazy("+1", "+1", 0, ""), TestConfig.lazy("-1", "-1", 0, ""), TestConfig.lazy("-0", "-0", 0, ""), - TestConfig.lazy("+0", "+0", 0, "") + TestConfig.lazy("+0", "+0", 0, ""), + TestConfig.lazy("+0", "+0", 0, ""), + TestConfig.lazy("1.2.3+ea", "+ea", 3, "1.2.3"), + TestConfig.lazy(".7", ".7", 0, ""), + TestConfig.lazy(".+7", ".+7", 0, "") )); return data; } + @ParameterizedTest + @MethodSource + public void testTrim(DottedVersion ver, String expectedStr, int limit) { + var expected = DottedVersion.lazy(expectedStr); + var actual = ver.trim(limit); + assertEquals(expected, actual); + if (limit >= ver.getComponents().length) { + assertSame(ver, actual); + } else { + assertNotSame(ver, actual); + } + assertEquals(expectedStr, actual.toString()); + } + + @ParameterizedTest + @MethodSource + public void testTrimNegative(DottedVersion ver, int limit) { + assertThrowsExactly(IllegalArgumentException.class, () -> { + ver.trim(limit); + }); + } + + private static Stream testTrim() { + + var testCases = new ArrayList(); + + for (var suffix : List.of("", ".foo", "-ea", "+345")) { + testCases.addAll(List.of( + Arguments.of("1.02.3" + suffix, "" + suffix, 0), + Arguments.of("1.02.3" + suffix, "1" + suffix, 1), + Arguments.of("1.02.3" + suffix, "1.02" + suffix, 2), + Arguments.of("1.02.3" + suffix, "1.02.3" + suffix, 3), + Arguments.of("1.02.3" + suffix, "1.02.3" + suffix, 4) + )); + } + + return testCases.stream().map(DottedVersionTest::mapFirstStringToDottedVersion); + } + + private static Stream testTrimNegative() { + return Stream.of( + Arguments.of("10.5.foo", -1) + ).map(DottedVersionTest::mapFirstStringToDottedVersion); + } + + @ParameterizedTest + @MethodSource + public void testPad(DottedVersion ver, String expectedStr, int limit) { + var expected = DottedVersion.lazy(expectedStr); + var actual = ver.pad(limit); + assertEquals(expected, actual); + if (limit <= ver.getComponents().length) { + assertSame(ver, actual); + } else { + assertNotSame(ver, actual); + } + assertEquals(expectedStr, actual.toString()); + } + + @ParameterizedTest + @MethodSource + public void testPadNegative(DottedVersion ver, int limit) { + assertThrowsExactly(IllegalArgumentException.class, () -> { + ver.pad(limit); + }); + } + + private static Stream testPad() { + + var testCases = new ArrayList(); + + for (var suffix : List.of("", ".foo", "-ea", "+345")) { + testCases.addAll(List.of( + Arguments.of("" + suffix, "" + suffix, 0), + Arguments.of("1.02.3" + suffix, "1.02.3" + suffix, 0), + Arguments.of("" + suffix, "0" + suffix, 1), + Arguments.of("1" + suffix, "1" + suffix, 1), + Arguments.of("1" + suffix, "1.0" + suffix, 2), + Arguments.of("1.02.3" + suffix, "1.02.3.0.0" + suffix, 5) + )); + } + + return testCases.stream().map(DottedVersionTest::mapFirstStringToDottedVersion); + } + + private static Stream testPadNegative() { + return Stream.of( + Arguments.of("10.5.foo", -1) + ).map(DottedVersionTest::mapFirstStringToDottedVersion); + } + + private static Arguments mapFirstStringToDottedVersion(Arguments v) { + var objs = v.get(); + objs[0] = DottedVersion.lazy((String)objs[0]); + return Arguments.of(objs); + } + record InvalidVersionTestSpec(String version, String invalidComponent) { public InvalidVersionTestSpec { Objects.requireNonNull(version); diff --git a/test/jdk/tools/jpackage/linux/LinuxResourceTest.java b/test/jdk/tools/jpackage/linux/LinuxResourceTest.java index b82706fc2c2..503c4db77fb 100644 --- a/test/jdk/tools/jpackage/linux/LinuxResourceTest.java +++ b/test/jdk/tools/jpackage/linux/LinuxResourceTest.java @@ -30,6 +30,7 @@ import java.util.Objects; import jdk.jpackage.test.Annotations.Test; import jdk.jpackage.test.CannedFormattedString; import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.JPackageCommand.StandardAssert; import jdk.jpackage.test.JPackageOutputValidator; import jdk.jpackage.test.LinuxHelper; import jdk.jpackage.test.PackageTest; @@ -66,7 +67,7 @@ public class LinuxResourceTest { final var packageProp = property("Package", "dont-install-me"); final var verProp = property("Version", "1.2.3-R2"); - final var arhProp = property("Architecture", "bar"); + final var archProp = property("Architecture", "bar"); TKit.createTextFile(controlFile, List.of( packageProp.format(), @@ -74,13 +75,15 @@ public class LinuxResourceTest { "Section: APPLICATION_SECTION", "Maintainer: APPLICATION_MAINTAINER", "Priority: optional", - arhProp.format(), + archProp.format(), "Provides: dont-install-me", "Description: APPLICATION_DESCRIPTION", "Installed-Size: APPLICATION_INSTALLED_SIZE", "Depends: PACKAGE_DEFAULT_DEPENDENCIES" )); + cmd.excludeStandardAsserts(StandardAssert.LINUX_PACKAGE_ARCH); + new JPackageOutputValidator() .expectMatchingStrings(MAIN.cannedFormattedString( "message.using-custom-resource", @@ -92,7 +95,7 @@ public class LinuxResourceTest { packageProp.expectedValue(LinuxHelper.getPackageName(cmd)).token("APPLICATION_PACKAGE").resourceDirFile(controlFile).validateOutput(cmd); verProp.expectedValue(cmd.version()).token("APPLICATION_VERSION_WITH_RELEASE").resourceDirFile(controlFile).validateOutput(cmd); - arhProp.expectedValue(LinuxHelper.getDefaultPackageArch(cmd.packageType())).token("APPLICATION_ARCH").resourceDirFile(controlFile).validateOutput(cmd); + archProp.expectedValue(LinuxHelper.getDefaultPackageArch(cmd.packageType())).token("APPLICATION_ARCH").resourceDirFile(controlFile).validateOutput(cmd); }) .forTypes(PackageType.LINUX_RPM) .addInitializer(cmd -> { diff --git a/test/jdk/tools/jpackage/macosx/SigningRuntimeImagePackageTest.java b/test/jdk/tools/jpackage/macosx/SigningRuntimeImagePackageTest.java index 54021aa2a0b..11b466ed715 100644 --- a/test/jdk/tools/jpackage/macosx/SigningRuntimeImagePackageTest.java +++ b/test/jdk/tools/jpackage/macosx/SigningRuntimeImagePackageTest.java @@ -200,7 +200,7 @@ public class SigningRuntimeImagePackageTest { // This way we can test if jpackage keeps or replaces the signature of // the predefined runtime bundle when backing it in the pkg or dmg installer. return new SignKeyOptionWithKeychain( - SignKeyOption.Type.SIGN_KEY_USER_SHORT_NAME, + SignKeyOption.Type.SIGN_KEY_IDENTITY_APP_IMAGE, SigningBase.StandardCertificateRequest.CODESIGN_ACME_TECH_LTD, SigningBase.StandardKeychain.MAIN.keychain()); } diff --git a/test/jdk/tools/jpackage/share/ErrorTest.java b/test/jdk/tools/jpackage/share/ErrorTest.java index 8bc7ba2521f..b325c02f039 100644 --- a/test/jdk/tools/jpackage/share/ErrorTest.java +++ b/test/jdk/tools/jpackage/share/ErrorTest.java @@ -945,13 +945,13 @@ public final class ErrorTest { .error("error.msi-product-version-components", "1.2.3.4.5") .advice("error.version-string-wrong-format.advice"), testSpec().type(type).addArgs("--app-version", "256.1") - .error("error.msi-product-version-major-out-of-range", "256.1") + .error("error.msi-product-version-major-out-of-range") .advice("error.version-string-wrong-format.advice"), testSpec().type(type).addArgs("--app-version", "1.256") - .error("error.msi-product-version-minor-out-of-range", "1.256") + .error("error.msi-product-version-minor-out-of-range") .advice("error.version-string-wrong-format.advice"), testSpec().type(type).addArgs("--app-version", "1.2.65536") - .error("error.msi-product-version-build-out-of-range", "1.2.65536") + .error("error.msi-product-version-build-out-of-range") .advice("error.version-string-wrong-format.advice") ); }).flatMap(x -> x).map(TestSpec.Builder::create).toList()); diff --git a/test/jdk/tools/jpackage/share/FileAssociationsTest.java b/test/jdk/tools/jpackage/share/FileAssociationsTest.java index c9bd690d73f..0af7e7a54ff 100644 --- a/test/jdk/tools/jpackage/share/FileAssociationsTest.java +++ b/test/jdk/tools/jpackage/share/FileAssociationsTest.java @@ -23,6 +23,8 @@ import static java.util.Map.entry; +import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.util.List; import jdk.jpackage.test.Annotations.Parameter; @@ -84,7 +86,7 @@ public class FileAssociationsTest { @Test @Parameter("true") @Parameter("false") - public static void test(boolean includeDescription) { + public static void test(boolean includeDescription) throws IOException { PackageTest packageTest = new PackageTest(); // Not supported @@ -96,10 +98,8 @@ public class FileAssociationsTest { } fa.applyTo(packageTest); - Path icon = TKit.TEST_SRC_ROOT.resolve(Path.of("resources", "icon" - + TKit.ICON_SUFFIX)); - - icon = TKit.createRelativePathCopy(icon); + var icon = TKit.createTempDirectory("icon-dir").resolve(ICON.getFileName()); + Files.copy(ICON, icon); new FileAssociations("jptest2") .setFilename("fa2") @@ -151,4 +151,6 @@ public class FileAssociationsTest { .addInitializer(JPackageCommand::setFakeRuntime) .setExpectedExitCode(1); } + + private static final Path ICON = TKit.TEST_SRC_ROOT.resolve(Path.of("resources", "icon" + TKit.ICON_SUFFIX)); } diff --git a/test/jdk/tools/jpackage/share/InstallDirTest.java b/test/jdk/tools/jpackage/share/InstallDirTest.java index 81d1fb3556e..4d5c1979190 100644 --- a/test/jdk/tools/jpackage/share/InstallDirTest.java +++ b/test/jdk/tools/jpackage/share/InstallDirTest.java @@ -102,10 +102,7 @@ public class InstallDirTest { .forTypes(PackageType.LINUX) .addInitializer(cmd -> { cmd.addArguments("--install-dir", installDir); - cmd.saveConsoleOutput(true); - }) - .addBundleVerifier((cmd, result) -> { - cmd.validateErr(JPackageCommand.makeError("error.invalid-install-dir")); + cmd.validateErr(JPackageCommand.makeError("error.invalid-install-dir", installDir)); }) .run(); } diff --git a/test/jdk/tools/jpackage/share/LicenseTest.java b/test/jdk/tools/jpackage/share/LicenseTest.java index 9c2d1077584..bf4c26fe76a 100644 --- a/test/jdk/tools/jpackage/share/LicenseTest.java +++ b/test/jdk/tools/jpackage/share/LicenseTest.java @@ -21,21 +21,23 @@ * questions. */ +import static jdk.internal.util.OperatingSystem.LINUX; + import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.List; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; -import static jdk.internal.util.OperatingSystem.LINUX; +import jdk.jpackage.internal.util.Slot; import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.PackageType; -import jdk.jpackage.test.PackageTest; -import jdk.jpackage.test.LinuxHelper; import jdk.jpackage.test.Executor; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.LinuxHelper; +import jdk.jpackage.test.PackageTest; +import jdk.jpackage.test.PackageType; import jdk.jpackage.test.TKit; /** @@ -93,11 +95,7 @@ public class LicenseTest { @Test public static void testCommon() { - PackageTest test = new PackageTest().configureHelloApp() - .addInitializer(cmd -> { - cmd.addArguments("--license-file", TKit.createRelativePathCopy( - LICENSE_FILE)); - }); + PackageTest test = new PackageTest().configureHelloApp().mutate(LicenseTest::setLicenseFile); initMacDmgLicenseVerifier(test.forTypes(PackageType.MAC_DMG)); initLinuxLicenseVerifier(test.forTypes(PackageType.LINUX)); @@ -127,19 +125,16 @@ public class LicenseTest { @Test(ifOS = LINUX) public static void testCustomDebianCopyright() { - new CustomDebianCopyrightTest().run(); + new CustomDebianCopyrightTest(false).run(); } @Test(ifOS = LINUX) public static void testCustomDebianCopyrightSubst() { - new CustomDebianCopyrightTest().withSubstitution(true).run(); + new CustomDebianCopyrightTest(true).run(); } private static PackageTest initMacDmgLicenseVerifier(PackageTest test) { - return test - .addBundleVerifier(cmd -> { - verifyLicenseFileInDMGPackage(cmd); - }); + return test.addBundleVerifier(LicenseTest::verifyLicenseFileInDMGPackage); } private static void verifyLicenseFileInDMGPackage(JPackageCommand cmd) @@ -179,10 +174,9 @@ public class LicenseTest { PackageTest test = new PackageTest() .forTypes(PackageType.LINUX) .configureHelloApp() + .addInitializer(JPackageCommand::setFakeRuntime) + .mutate(LicenseTest::setLicenseFile) .addInitializer(cmd -> { - cmd.setFakeRuntime(); - cmd.addArguments("--license-file", TKit.createRelativePathCopy( - LICENSE_FILE)); cmd.addArguments("--install-dir", installDir); }); @@ -191,6 +185,18 @@ public class LicenseTest { test.run(); } + private static void setLicenseFile(PackageTest test) { + var inputLicenseFile = Slot.createEmpty(); + + test.addRunOnceInitializer(() -> { + var dir = TKit.createTempDirectory("license-dir"); + inputLicenseFile.set(dir.resolve(LICENSE_FILE.getFileName())); + Files.copy(LICENSE_FILE, inputLicenseFile.get()); + }).addInitializer(cmd -> { + cmd.setArgumentValue("--license-file", inputLicenseFile.get()); + }); + } + private static Path rpmLicenseFile(JPackageCommand cmd) { final Path licenseRoot = Path.of( new Executor() @@ -296,12 +302,36 @@ public class LicenseTest { TKit.assertPathExists(licenseFile.getParent(), false); } - private static class CustomDebianCopyrightTest { - CustomDebianCopyrightTest() { - withSubstitution(false); + private record CustomDebianCopyrightTest(boolean withSubstitution) { + + private String copyright() { + // Different values just to make easy to figure out from the test log which test was executed. + if (withSubstitution) { + return "Duke (C)"; + } else { + return "Java (C)"; + } } - private List licenseFileText(String copyright, String licenseText) { + private String licenseText() { + // Different values just to make easy to figure out from the test log which test was executed. + if (withSubstitution) { + return "The quick brown fox\n jumps over the lazy dog"; + } else { + return "How vexingly quick daft zebras jump!"; + } + } + + private String name() { + // Different values just to make easy to figure out from the test log which test was executed. + if (withSubstitution) { + return "CustomDebianCopyrightWithSubst"; + } else { + return "CustomDebianCopyright"; + } + } + + static private List licenseFileText(String copyright, String licenseText) { List lines = new ArrayList<>(List.of( String.format("Copyright=%s", copyright), "Foo", @@ -313,28 +343,14 @@ public class LicenseTest { private List licenseFileText() { if (withSubstitution) { - return licenseFileText("APPLICATION_COPYRIGHT", - "APPLICATION_LICENSE_TEXT"); + return licenseFileText("APPLICATION_COPYRIGHT", "APPLICATION_LICENSE_TEXT"); } else { return expectedLicenseFileText(); } } private List expectedLicenseFileText() { - return licenseFileText(copyright, licenseText); - } - - CustomDebianCopyrightTest withSubstitution(boolean v) { - withSubstitution = v; - // Different values just to make easy to figure out from the test log which test was executed. - if (v) { - copyright = "Duke (C)"; - licenseText = "The quick brown fox\n jumps over the lazy dog"; - } else { - copyright = "Java (C)"; - licenseText = "How vexingly quick daft zebras jump!"; - } - return this; + return licenseFileText(copyright(), licenseText()); } void run() { @@ -343,20 +359,19 @@ public class LicenseTest { .addInitializer(cmd -> { // Create source license file. Files.write(srcLicenseFile, List.of( - licenseText.split("\\R", -1))); + licenseText().split("\\R", -1))); cmd.setFakeRuntime(); - cmd.setArgumentValue("--name", String.format("%s%s", - withSubstitution ? "CustomDebianCopyrightWithSubst" : "CustomDebianCopyright", - cmd.name())); + cmd.setArgumentValue("--name", String.format("%s%s", name(), cmd.name())); cmd.addArguments("--license-file", srcLicenseFile); - cmd.addArguments("--copyright", copyright); - cmd.addArguments("--resource-dir", RESOURCE_DIR); + cmd.addArguments("--copyright", copyright()); + + var resourceDir = TKit.createTempDirectory("resources"); + + cmd.addArguments("--resource-dir", resourceDir); // Create copyright template file in a resource dir. - Files.createDirectories(RESOURCE_DIR); - Files.write(RESOURCE_DIR.resolve("copyright"), - licenseFileText()); + Files.write(resourceDir.resolve("copyright"), licenseFileText()); }) .addInstallVerifier(cmd -> { Path installedLicenseFile = linuxLicenseFile(cmd); @@ -368,12 +383,6 @@ public class LicenseTest { }) .run(); } - - private boolean withSubstitution; - private String copyright; - private String licenseText; - - private final Path RESOURCE_DIR = TKit.workDir().resolve("resources"); } private static final Path LICENSE_FILE = TKit.TEST_SRC_ROOT.resolve( diff --git a/test/jdk/tools/jpackage/share/ModularAppTest.java b/test/jdk/tools/jpackage/share/ModularAppTest.java new file mode 100644 index 00000000000..b14d70cc8f3 --- /dev/null +++ b/test/jdk/tools/jpackage/share/ModularAppTest.java @@ -0,0 +1,336 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import static jdk.jpackage.internal.util.MemoizingSupplier.runOnce; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Stream; +import javax.xml.xpath.XPathExpressionException; +import jdk.internal.util.OperatingSystem; +import jdk.jpackage.internal.util.MacBundle; +import jdk.jpackage.internal.util.Slot; +import jdk.jpackage.internal.util.TokenReplace; +import jdk.jpackage.test.Annotations.Parameter; +import jdk.jpackage.test.Annotations.ParameterSupplier; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.CannedFormattedString; +import jdk.jpackage.test.Executor; +import jdk.jpackage.test.HelloApp; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.JavaAppDesc; +import jdk.jpackage.test.JavaTool; +import jdk.jpackage.test.PackageType; +import jdk.jpackage.test.TKit; + + +/* + * @test + * @summary jpackage bundling modular app + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @compile -Xlint:all -Werror ModularAppTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=ModularAppTest + */ + +public final class ModularAppTest { + + @Test + @ParameterSupplier + public void test(TestSpec spec) { + spec.run(); + } + + /** + * Test case for JDK-8233265. Adding modules in .jmod files for non-modular app + * results in unexpected jpackage failure. + */ + @Test + @Parameter("Hello!") + @Parameter("com.foo/com.foo.ModuleApp") + public void test8233265(String mainAppDesc) throws IOException { + JPackageCommand cmd = JPackageCommand.helloAppImage(mainAppDesc); + + // The test should make jpackage invoke jlink. + cmd.ignoreDefaultRuntime(true); + + var modulePath = Optional.ofNullable(cmd.getArgumentValue("--module-path")).map(Path::of).orElseGet(() -> { + var newModulePath = TKit.createTempDirectory("input-modules"); + cmd.addArguments("--module-path", newModulePath); + return newModulePath; + }); + + JavaAppDesc extraModule = JavaAppDesc.parse("x.jmod:com.x/com.x.Y"); + HelloApp.createBundle(extraModule, modulePath); + cmd.addArguments("--add-modules", extraModule.moduleName()); + + cmd.executeAndAssertHelloAppImageCreated(); + } + + /** + * Test case for JDK-8248254. App's module in the predefined runtime directory; + * no "--module-path" option on the command line. jpackage should find the app's + * module in the predefined runtime. + */ + @Test + @Parameter("IMAGE") + @Parameter(value = "MAC_BUNDLE", ifOS = OperatingSystem.MACOS) + public void test8248254(RuntimeType runtimeType) throws XPathExpressionException, IOException { + + final var appDesc = JavaAppDesc.parse("me.mymodule/me.mymodule.Main"); + + new JPackageCommand() + .setDefaultAppName() + .setPackageType(PackageType.IMAGE) + .setDefaultInputOutput() + .removeArgumentWithValue("--input") + .addArguments("--module", appDesc.moduleName() + "/" + appDesc.className()) + .setArgumentValue("--runtime-image", bakeModuleInRuntime(appDesc, runtimeType)) + .executeAndAssertHelloAppImageCreated(); + } + + /** + * Test case for JDK-8261518. App's module is baked into the predefined runtime + * image with jlink; no "--module-path" option on the command line. If there is + * a non-modular jar in the current directory, jpackage used to throw. + */ + @Test + @Parameter("IMAGE") + @Parameter(value = "MAC_BUNDLE", ifOS = OperatingSystem.MACOS) + public void test8261518(RuntimeType runtimeType) throws XPathExpressionException, IOException { + + final var appDesc = JavaAppDesc.parse("com.foo/com.foo.main.Aloha"); + + final var fooJarDir = TKit.createTempDirectory("foo"); + + // Create "foo.jar" in dedicated directory. + HelloApp.createBundle(JavaAppDesc.parse("foo.jar:"), fooJarDir); + + new JPackageCommand() + .setDefaultAppName() + .setPackageType(PackageType.IMAGE) + .setDefaultInputOutput() + .removeArgumentWithValue("--input") + .addArguments("--module", appDesc.moduleName() + "/" + appDesc.className()) + .setArgumentValue("--runtime-image", bakeModuleInRuntime(appDesc, runtimeType).toAbsolutePath()) + // Run jpackage in the directory with "foo.jar" + .setDirectory(fooJarDir).useToolProvider(false) + .executeAndAssertHelloAppImageCreated(); + } + + private static Path bakeModuleInRuntime(JavaAppDesc appDesc, RuntimeType runtimeType) throws IOException { + + final var moduleOutputDir = TKit.createTempDirectory("modules"); + HelloApp.createBundle(appDesc, moduleOutputDir); + + final var workDir = TKit.createTempDirectory("runtime").resolve("data"); + final Path jlinkOutputDir; + switch (runtimeType) { + case IMAGE -> { + jlinkOutputDir = workDir; + } + case MAC_BUNDLE -> { + var macBundle = new MacBundle(workDir); + + // Create macOS bundle structure sufficient to pass jpackage validation. + Files.createDirectories(macBundle.homeDir().getParent()); + Files.createDirectories(macBundle.macOsDir()); + Files.createFile(macBundle.infoPlistFile()); + jlinkOutputDir = macBundle.homeDir(); + } + default -> { + throw new AssertionError(); + } + } + + // List of modules required for the test app. + final var modules = new String[] { + "java.base", + "java.desktop", + appDesc.moduleName() + }; + + new Executor() + .setToolProvider(JavaTool.JLINK) + .dumpOutput() + .addArguments( + "--add-modules", String.join(",", modules), + "--output", jlinkOutputDir.toString(), + "--module-path", moduleOutputDir.resolve(appDesc.jarFileName()).toString(), + "--strip-debug", + "--no-header-files", + "--no-man-pages", + "--strip-native-commands") + .execute(); + + return workDir; + } + + enum RuntimeType { + IMAGE, + MAC_BUNDLE, + ; + } + + record TestSpec(List paths, String appDesc) { + TestSpec { + Objects.requireNonNull(paths); + Objects.requireNonNull(appDesc); + Objects.requireNonNull(JavaAppDesc.parse(appDesc).moduleName()); + } + + boolean isWithGoodPath() { + var isWithGoodPath = Slot.createEmpty(); + paths.forEach(path -> { + ALL_TOKENS.applyTo(path, token -> { + if (token.equals(Token.GOOD_DIR.token())) { + isWithGoodPath.set(true); + } + return token; + }); + }); + return isWithGoodPath.find().isPresent(); + } + + void run() { + var emptyDir = runOnce(() -> { + return TKit.createTempDirectory("empty-dir"); + }); + + var nonExistingDir = runOnce(() -> { + return TKit.withTempDirectory("non-existing-dir", x -> {}); + }); + + var goodDir = runOnce(() -> { + return TKit.createTempDirectory("modules"); + }); + + var theAppDesc = JavaAppDesc.parse(appDesc); + + HelloApp.createBundle(theAppDesc, goodDir.get()); + + var cmd = new JPackageCommand() + .setArgumentValue("--dest", TKit.workDir().resolve("output")) + .setDefaultAppName() + .setPackageType(PackageType.IMAGE) + // Ignore runtime that can be set for all tests. Usually if default + // runtime is set, it is fake one to save time on running jlink and + // copying megabytes of data from Java home to application image. + // We need proper runtime for this test. + .ignoreDefaultRuntime(true) + .addArguments("--module", String.join("/", theAppDesc.moduleName(), theAppDesc.className())); + + if (TKit.isWindows()) { + cmd.addArguments("--win-console"); + } + + paths.stream().map(path -> { + return ALL_TOKENS.applyTo(path, token -> { + return (switch (Token.valueOf(token.substring(2, token.length() - 2))) { + case EMPTY_DIR -> { + yield emptyDir; + } + case GOOD_DIR -> { + yield goodDir; + } + case NON_EXISTING_DIR -> { + yield nonExistingDir; + } + default -> { + throw new AssertionError(); + } + }).get(); + }); + }).mapMulti((path, acc) -> { + acc.accept("--module-path"); + acc.accept(path); + }).forEach(cmd::addArgument); + + if (isWithGoodPath()) { + cmd.executeAndAssertHelloAppImageCreated(); + } else { + final CannedFormattedString expectedErrorMessage; + if (paths.isEmpty()) { + expectedErrorMessage = JPackageCommand.makeError( + "ERR_MissingArgument2", "--runtime-image", "--module-path"); + } else { + expectedErrorMessage = JPackageCommand.makeError( + "error.no-module-in-path", theAppDesc.moduleName()); + } + + cmd.validateErr(expectedErrorMessage).execute(1); + } + } + + private static final TokenReplace ALL_TOKENS = + new TokenReplace(Stream.of(Token.values()).map(Token::token).toArray(String[]::new)); + } + + public static Collection test() { + + var testCases = new ArrayList(); + + for (String appDesc : List.of( + "benvenuto.jar:com.jar.foo/com.jar.foo.Hello", + "benvenuto.jmod:com.jmod.foo/com.jmod.foo.JModHello" + )) { + Stream.>of( + Stream.of(Token.GOOD_DIR, Token.EMPTY_DIR, Token.NON_EXISTING_DIR).map(Token::token), + Stream.of(Token.EMPTY_DIR, Token.NON_EXISTING_DIR, Token.GOOD_DIR).map(Token::token), + Stream.of(Token.GOOD_DIR.token() + "/a/b/c/d", Token.GOOD_DIR.token()), + Stream.of(), + Stream.of(Token.EMPTY_DIR).map(Token::token) + ).map(Stream::toList).map(paths -> { + return new TestSpec(paths, appDesc); + }).forEach(testCases::add); + } + + return testCases.stream().map(v -> { + return new Object[] {v}; + }).toList(); + } + + enum Token { + GOOD_DIR, + EMPTY_DIR, + NON_EXISTING_DIR, + ; + + String token() { + return makeToken(name()); + } + + private static String makeToken(String v) { + Objects.requireNonNull(v); + return String.format("@@%s@@", v); + } + } +} diff --git a/test/jdk/tools/jpackage/share/ModulePathTest.java b/test/jdk/tools/jpackage/share/ModulePathTest.java deleted file mode 100644 index 583dd1eb0c4..00000000000 --- a/test/jdk/tools/jpackage/share/ModulePathTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2019, 2026, 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.nio.file.Path; -import java.util.Collection; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import jdk.jpackage.test.CannedFormattedString; -import jdk.jpackage.test.TKit; -import jdk.jpackage.test.JavaAppDesc; -import jdk.jpackage.test.HelloApp; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.JPackageStringBundle; -import jdk.jpackage.test.PackageType; -import jdk.jpackage.test.Annotations.Parameter; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Annotations.Test; - - -/* - * @test - * @summary jpackage with --module-path testing - * @library /test/jdk/tools/jpackage/helpers - * @build jdk.jpackage.test.* - * @compile -Xlint:all -Werror ModulePathTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=ModulePathTest - */ - -public final class ModulePathTest { - - @Parameters - public static Collection data() { - return List.of(new String[][]{ - {GOOD_PATH, EMPTY_DIR, NON_EXISTING_DIR}, - {EMPTY_DIR, NON_EXISTING_DIR, GOOD_PATH}, - {GOOD_PATH + "/a/b/c/d", GOOD_PATH}, - {String.join(File.pathSeparator, EMPTY_DIR, NON_EXISTING_DIR, - GOOD_PATH)}, - {String.join(File.pathSeparator, EMPTY_DIR, NON_EXISTING_DIR), - String.join(File.pathSeparator, EMPTY_DIR, NON_EXISTING_DIR, - GOOD_PATH)}, - {}, - {EMPTY_DIR} - }); - } - - public ModulePathTest(String... modulePathArgs) { - this.modulePathArgs = List.of(modulePathArgs); - } - - @Test - @Parameter("benvenuto.jar:com.jar.foo/com.jar.foo.Hello") - @Parameter("benvenuto.jmod:com.jmod.foo/com.jmod.foo.JModHello") - public void test(String javaAppDesc) throws IOException { - JavaAppDesc appDesc = JavaAppDesc.parse(javaAppDesc); - - Path goodModulePath = TKit.createTempDirectory("modules"); - - HelloApp.createBundle(appDesc, goodModulePath); - - JPackageCommand cmd = new JPackageCommand() - .setArgumentValue("--dest", TKit.workDir().resolve("output")) - .setDefaultAppName() - .setPackageType(PackageType.IMAGE); - - if (TKit.isWindows()) { - cmd.addArguments("--win-console"); - } - - cmd.addArguments("--module", String.join("/", appDesc.moduleName(), - appDesc.className())); - - // Ignore runtime that can be set for all tests. Usually if default - // runtime is set, it is fake one to save time on running jlink and - // copying megabytes of data from Java home to application image. - // We need proper runtime for this test. - cmd.ignoreDefaultRuntime(true); - - Path emptyDir = TKit.createTempDirectory("empty-dir"); - Path nonExistingDir = TKit.withTempDirectory("non-existing-dir", x -> {}); - - Function substitute = str -> { - String v = str; - v = v.replace(GOOD_PATH, goodModulePath.toString()); - v = v.replace(EMPTY_DIR, emptyDir.toString()); - v = v.replace(NON_EXISTING_DIR, nonExistingDir.toString()); - return v; - }; - - boolean withGoodPath = modulePathArgs.stream().anyMatch( - s -> s.contains(GOOD_PATH)); - - cmd.addArguments(modulePathArgs.stream().map(arg -> Stream.of( - "--module-path", substitute.apply(arg))).flatMap(s -> s).collect( - Collectors.toList())); - - if (withGoodPath) { - cmd.executeAndAssertHelloAppImageCreated(); - } else { - final CannedFormattedString expectedErrorMessage; - if (modulePathArgs.isEmpty()) { - expectedErrorMessage = JPackageCommand.makeError( - "ERR_MissingArgument2", "--runtime-image", "--module-path"); - } else { - expectedErrorMessage = JPackageCommand.makeError( - "error.no-module-in-path", appDesc.moduleName()); - } - - cmd.validateErr(expectedErrorMessage).execute(1); - } - } - - private final List modulePathArgs; - - private static final String GOOD_PATH = "@GoodPath@"; - private static final String EMPTY_DIR = "@EmptyDir@"; - private static final String NON_EXISTING_DIR = "@NonExistingDir@"; -} diff --git a/test/jdk/tools/jpackage/share/ModulePathTest2.java b/test/jdk/tools/jpackage/share/ModulePathTest2.java deleted file mode 100644 index b2cc674e7e9..00000000000 --- a/test/jdk/tools/jpackage/share/ModulePathTest2.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2019, 2025, 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.IOException; -import java.nio.file.Path; -import jdk.jpackage.test.HelloApp; -import jdk.jpackage.test.JavaAppDesc; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Annotations.Parameter; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.TKit; - - -/* - * @test - * @summary jpackage with --module-path testing - * @library /test/jdk/tools/jpackage/helpers - * @build jdk.jpackage.test.* - * @compile -Xlint:all -Werror ModulePathTest2.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=ModulePathTest2 - */ - -public final class ModulePathTest2 { - - /** - * Test case for JDK-8233265. - * Adding modules in .jmod files for non-modular app results in unexpected - * jpackage failure. - * @param mainAppDesc - */ - @Test - @Parameter("Hello!") - @Parameter("com.foo/com.foo.ModuleApp") - public void test8233265(String mainAppDesc) throws IOException { - JPackageCommand cmd = JPackageCommand.helloAppImage(mainAppDesc); - - // The test should make jpackage invoke jlink. - cmd.ignoreDefaultRuntime(true); - - Path modulePath = cmd.getArgumentValue("--module-path", () -> null, Path::of); - if (modulePath == null) { - modulePath = TKit.createTempDirectory("input-modules"); - cmd.addArguments("--module-path", modulePath); - } - - JavaAppDesc extraModule = JavaAppDesc.parse("x.jmod:com.x/com.x.Y"); - HelloApp.createBundle(extraModule, modulePath); - cmd.addArguments("--add-modules", extraModule.moduleName()); - - cmd.executeAndAssertHelloAppImageCreated(); - } -} diff --git a/test/jdk/tools/jpackage/share/ModulePathTest3.java b/test/jdk/tools/jpackage/share/ModulePathTest3.java deleted file mode 100644 index c3960c0d4c8..00000000000 --- a/test/jdk/tools/jpackage/share/ModulePathTest3.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2020, 2025, 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.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import javax.xml.xpath.XPathExpressionException; -import jdk.jpackage.test.AppImageFile; -import jdk.jpackage.test.HelloApp; -import jdk.jpackage.test.JavaAppDesc; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Executor; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.JavaTool; -import jdk.jpackage.test.PackageType; -import jdk.jpackage.test.TKit; - - -/* - * @test - * @summary jpackage for app's module linked in external runtime - * @library /test/jdk/tools/jpackage/helpers - * @build jdk.jpackage.test.* - * @compile -Xlint:all -Werror ModulePathTest3.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=ModulePathTest3 - */ - -public final class ModulePathTest3 { - - public ModulePathTest3(String jlinkOutputSubdir, String runtimeSubdir) { - this.jlinkOutputSubdir = Path.of(jlinkOutputSubdir); - this.runtimeSubdir = Path.of(runtimeSubdir); - } - - /** - * Test case for JDK-8248254. - * App's module in runtime directory. - */ - @Test - public void test8248254() throws XPathExpressionException, IOException { - testIt("me.mymodule/me.mymodule.Main"); - } - - private void testIt(String mainAppDesc) throws XPathExpressionException, - IOException { - final JavaAppDesc appDesc = JavaAppDesc.parse(mainAppDesc); - final Path moduleOutputDir = TKit.createTempDirectory("modules"); - HelloApp.createBundle(appDesc, moduleOutputDir); - - final Path workDir = TKit.createTempDirectory("runtime").resolve("data"); - final Path jlinkOutputDir = workDir.resolve(jlinkOutputSubdir); - Files.createDirectories(jlinkOutputDir.getParent()); - - new Executor() - .setToolProvider(JavaTool.JLINK) - .dumpOutput() - .addArguments( - "--add-modules", appDesc.moduleName(), - "--output", jlinkOutputDir.toString(), - "--module-path", moduleOutputDir.resolve(appDesc.jarFileName()).toString(), - "--strip-debug", - "--no-header-files", - "--no-man-pages", - "--strip-native-commands") - .execute(); - - JPackageCommand cmd = new JPackageCommand() - .setDefaultAppName() - .setPackageType(PackageType.IMAGE) - .setDefaultInputOutput() - .removeArgumentWithValue("--input") - .addArguments("--module", appDesc.moduleName() + "/" + appDesc.className()) - .setArgumentValue("--runtime-image", workDir.resolve(runtimeSubdir)); - - cmd.executeAndAssertHelloAppImageCreated(); - - if (appDesc.moduleVersion() != null) { - String actualVersion = AppImageFile.load(cmd.outputBundle()).version(); - TKit.assertEquals(appDesc.moduleVersion(), actualVersion, - "Check application version"); - } - } - - @Parameters - public static Collection data() { - final List paths = new ArrayList<>(); - paths.add(new String[] { "", "" }); - if (TKit.isOSX()) { - // On OSX jpackage should accept both runtime root and runtime home - // directories. - paths.add(new String[] { "Contents/Home", "" }); - } - - List data = new ArrayList<>(); - for (var pathCfg : paths) { - data.add(new Object[] { pathCfg[0], pathCfg[1] }); - } - - return data; - } - - private final Path jlinkOutputSubdir; - private final Path runtimeSubdir; -} diff --git a/test/jdk/tools/jpackage/share/NoMPathRuntimeTest.java b/test/jdk/tools/jpackage/share/NoMPathRuntimeTest.java deleted file mode 100644 index 91679945925..00000000000 --- a/test/jdk/tools/jpackage/share/NoMPathRuntimeTest.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2020, 2025, 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.IOException; -import java.nio.file.Files; -import java.util.Collection; -import java.util.ArrayList; -import java.util.List; -import java.nio.file.Path; -import jdk.jpackage.test.Annotations.Parameters; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Executor; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.JavaAppDesc; -import jdk.jpackage.test.JavaTool; -import jdk.jpackage.test.TKit; -import jdk.jpackage.test.HelloApp; - - -/* - * @test - * @summary test '--runtime-image' option of jpackage - * @library /test/jdk/tools/jpackage/helpers - * @build jdk.jpackage.test.* - * @compile -Xlint:all -Werror NoMPathRuntimeTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=NoMPathRuntimeTest - */ - -public final class NoMPathRuntimeTest { - - public NoMPathRuntimeTest(String jlinkOutputSubdir, String runtimeSubdir) { - this.jlinkOutputSubdir = Path.of(jlinkOutputSubdir); - this.runtimeSubdir = Path.of(runtimeSubdir); - } - - @Test - public void test() throws IOException { - JavaAppDesc appDesc = JavaAppDesc.parse("com.foo/com.foo.main.Aloha"); - - JPackageCommand cmd = JPackageCommand.helloAppImage(appDesc); - - // Build module jar. - cmd.executePrerequisiteActions(); - - final Path workDir = TKit.createTempDirectory("runtime").resolve("data"); - final Path jlinkOutputDir = workDir.resolve(jlinkOutputSubdir); - Files.createDirectories(jlinkOutputDir.getParent()); - - // List of modules required for test app. - final var modules = new String[] { - "java.base", - "java.desktop" - }; - - Executor jlink = new Executor() - .setToolProvider(JavaTool.JLINK) - .dumpOutput() - .addArguments( - "--add-modules", String.join(",", modules), - "--output", jlinkOutputDir.toString(), - "--strip-debug", - "--no-header-files", - "--no-man-pages"); - - jlink.addArguments("--add-modules", appDesc.moduleName(), - "--module-path", Path.of(cmd.getArgumentValue("--module-path")) - .resolve("hello.jar").toString()); - - jlink.execute(); - - // non-modular jar in current dir caused error whe no module-path given - cmd.removeArgumentWithValue("--module-path"); - - cmd.setArgumentValue("--runtime-image", workDir.resolve(runtimeSubdir)); - Path junkJar = null; - try { - // create a non-modular jar in the current directory - junkJar = HelloApp.createBundle( - JavaAppDesc.parse("junk.jar:Hello"), Path.of(".")); - - cmd.executeAndAssertHelloAppImageCreated(); - } finally { - if (junkJar != null) { - TKit.deleteIfExists(junkJar); - } - } - - } - - @Parameters - public static Collection data() { - - final List paths = new ArrayList<>(); - paths.add(new String[] { "", "" }); - if (TKit.isOSX()) { - // On OSX jpackage should accept both runtime root and runtime home - // directories. - paths.add(new String[] { "Contents/Home", "" }); - } - - List data = new ArrayList<>(); - for (var pathCfg : paths) { - data.add(new Object[] { pathCfg[0], pathCfg[1] }); - } - - return data; - } - - private final Path jlinkOutputSubdir; - private final Path runtimeSubdir; -} diff --git a/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java b/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java index 7dcf025a506..d6cebde6444 100644 --- a/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java +++ b/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java @@ -21,13 +21,15 @@ * questions. */ +import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; -import jdk.jpackage.test.PackageTest; -import jdk.jpackage.test.JPackageCommand; -import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Annotations.Parameters; import java.util.List; +import jdk.jpackage.internal.util.Slot; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.PackageTest; import jdk.jpackage.test.PackageType; import jdk.jpackage.test.TKit; @@ -108,11 +110,7 @@ public class WinInstallerUiTest { } if (withLicense) { - test.addInitializer(cmd -> { - cmd.addArguments("--license-file", TKit.createRelativePathCopy( - TKit.TEST_SRC_ROOT.resolve(Path.of("resources", - "license.txt")))); - }); + setLicenseFile(test); } test.run(); @@ -133,7 +131,21 @@ public class WinInstallerUiTest { cmd.setArgumentValue("--name", sb.toString()); } + private static void setLicenseFile(PackageTest test) { + var inputLicenseFile = Slot.createEmpty(); + + test.addRunOnceInitializer(() -> { + var dir = TKit.createTempDirectory("license-dir"); + inputLicenseFile.set(dir.resolve(LICENSE_FILE.getFileName())); + Files.copy(LICENSE_FILE, inputLicenseFile.get()); + }).addInitializer(cmd -> { + cmd.setArgumentValue("--license-file", inputLicenseFile.get()); + }); + } + private final boolean withDirChooser; private final boolean withLicense; private final boolean withShortcutPrompt; + + private static final Path LICENSE_FILE = TKit.TEST_SRC_ROOT.resolve(Path.of("resources", "license.txt")); } diff --git a/test/langtools/jdk/javadoc/doclet/testSeeTag/TestSeeTag.java b/test/langtools/jdk/javadoc/doclet/testSeeTag/TestSeeTag.java index f3294f6647c..57854396cf4 100644 --- a/test/langtools/jdk/javadoc/doclet/testSeeTag/TestSeeTag.java +++ b/test/langtools/jdk/javadoc/doclet/testSeeTag/TestSeeTag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 8017191 8182765 8200432 8239804 8250766 8262992 8281944 8307377 + * 8284315 * @summary Javadoc is confused by at-link to imported classes outside of the set of generated packages * @library /tools/lib ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -103,7 +104,12 @@ public class TestSeeTag extends JavadocTester {
See Also:
    -
  • Object
  • +
  • +
    + invalid reference +
    Object[]
    +
    +
  • invalid reference diff --git a/test/langtools/tools/doclint/ReferenceTest.java b/test/langtools/tools/doclint/ReferenceTest.java index ca677d64927..63512d1efc4 100644 --- a/test/langtools/tools/doclint/ReferenceTest.java +++ b/test/langtools/tools/doclint/ReferenceTest.java @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 8004832 8020556 8002154 8200432 8177280 + * @bug 8004832 8020556 8002154 8200432 8177280 8284315 * @summary Add new doclint package * @modules jdk.javadoc/jdk.javadoc.internal.doclint * @build DocLintTester diff --git a/test/langtools/tools/doclint/ReferenceTest.out b/test/langtools/tools/doclint/ReferenceTest.out index 0b39ea20a41..4232f7b12ba 100644 --- a/test/langtools/tools/doclint/ReferenceTest.out +++ b/test/langtools/tools/doclint/ReferenceTest.out @@ -31,12 +31,24 @@ ReferenceTest.java:71: error: reference not found ReferenceTest.java:74: error: reference not found * @see not.Found ^ +ReferenceTest.java:79: error: reference not found + * {@link java.lang.String[]} + ^ +ReferenceTest.java:80: error: reference not found + * {@link java.lang.String[]#equals} + ^ ReferenceTest.java:81: error: reference not found * {@link not.Found[]} ^ +ReferenceTest.java:82: error: reference not found + * @see java.lang.String[] + ^ +ReferenceTest.java:83: error: reference not found + * @see java.lang.String[]#equals + ^ ReferenceTest.java:84: error: reference not found * @see not.Found[] ^ -12 errors +16 errors 1 warning diff --git a/test/langtools/tools/javac/doctree/ReferenceTest.java b/test/langtools/tools/javac/doctree/ReferenceTest.java index 540cb9a6621..83a10ee4d20 100644 --- a/test/langtools/tools/javac/doctree/ReferenceTest.java +++ b/test/langtools/tools/javac/doctree/ReferenceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 7021614 8278373 8164094 8371248 + * @bug 7021614 8278373 8164094 8371248 8284315 * @summary extend com.sun.source API to support parsing javadoc comments * @summary check references in at-see and {at-link} tags * @modules jdk.compiler @@ -56,6 +56,7 @@ import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.QualifiedNameable; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.tools.Diagnostic.Kind; @@ -84,11 +85,14 @@ import javax.tools.Diagnostic.Kind; * {@link #trees Field} * {@link #getSupportedSourceVersion Method} * {@link #init(ProcessingEnvironment Method} - * {@link double Class} + * {@link double type-only:double} + * {@link int type-only:int} + * {@link void type-only:void} * {@link double.NAN Bad} * {@link double#NAN Bad} * {@link double#double Bad} * {@link java.base/double Bad} + * {@link jdk.javadoc/double Bad} * * {@link List Interface} * {@link List.add Bad} @@ -100,15 +104,20 @@ import javax.tools.Diagnostic.Kind; * {@link Map.Entry#getKey Method} * {@link Map.Entry#setValue(Object) Method} * - * {@link java.base/java.util.List Bad} + * {@link java.lang.String[] type-only:array} + * {@link java.lang.String[].length Bad} + * {@link java.lang.String[]#length type-only:int} + * {@link java.lang.String[]#length() Bad} + * + * {@link java.base/java.util.List Interface} * {@link java.base/java.util.List.add Bad} - * {@link java.base/java.util.List#add Bad} - * {@link java.base/java.util.List#add(Object) Bad} - * {@link java.base/java.util.Map.Entry Bad} - * {@link java.base/java.util.Map.Entry Bad} + * {@link java.base/java.util.List#add Method} + * {@link java.base/java.util.List#add(Object) Method} + * {@link java.base/java.util.Map.Entry Interface} + * {@link java.base/java.util.Map.Entry Interface} * {@link java.base/java.util.Map.Entry.getKey Bad} - * {@link java.base/java.util.Map.Entry#getKey Bad} - * {@link java.base/java.util.Map.Entry#setValue(Object) Bad} + * {@link java.base/java.util.Map.Entry#getKey Method} + * {@link java.base/java.util.Map.Entry#setValue(Object) Method} * * @see java.lang Package * @see java.lang.ERROR Bad @@ -127,6 +136,14 @@ import javax.tools.Diagnostic.Kind; * @see java.lang.String#ERROR Bad * @see java.lang.String#equals(Object) Method * + * @see java.lang.String[] type-only:array + * @see java.lang.String[].length Bad + * @see java.lang.String[]#length type-only:int + * @see java.lang.String[]#length() Bad + * + * @see jdk.javadoc/jdk.javadoc.doclet.Doclet Interface + * @see jdk.compiler/jdk.javadoc.doclet.Doclet Bad + * * @see AbstractProcessor Class * * @see List#add(Object) Method @@ -200,15 +217,23 @@ public class ReferenceTest extends AbstractProcessor { String sig = tree.getSignature(); Element found = trees.getElement(new DocTreePath(getCurrentPath(), tree)); + TypeMirror type = trees.getType(new DocTreePath(getCurrentPath(), tree)); + if (found == null) { System.err.println(sig + " NOT FOUND"); } else { System.err.println(sig + " found " + found.getKind() + " " + found); + if (type == null) { + error(tree, "Did not find type for element " + found); + } else if (!erasure(type).equals(erasure(found.asType()))) { + error(tree, "Type " + erasure(type) + " does not match element " + erasure(found.asType())); + } } String expect = "UNKNOWN"; - if (label.size() > 0 && label.get(0) instanceof TextTree) - expect = ((TextTree) label.get(0)).getBody(); + if (!label.isEmpty() && label.getFirst() instanceof TextTree) { + expect = ((TextTree) label.getFirst()).getBody(); + } if (expect.startsWith("signature:")) { expect = expect.substring("signature:".length()); @@ -216,12 +241,25 @@ public class ReferenceTest extends AbstractProcessor { String signature = found.getKind().name() + ":" + elementSignature(found); if (!expect.equalsIgnoreCase(signature)) { - error(tree, "Unexpected value found: " + signature +", expected: " + expect); + error(tree, "Unexpected value found: " + signature + ", expected: " + expect); + } + } else if (expect.startsWith("type-only:")) { + expect = expect.substring("type-only:".length()); + if (found != null) { + error(tree, "Found element for type-only reference: " + found); + } + if (type == null) { + error(tree, "Found no type, expected: " + expect); + } else if (!expect.equalsIgnoreCase(type.getKind().name())) { + error(tree, "Found unexpected type: " + type + ", expected: " + expect); } } else { if (!expect.equalsIgnoreCase(found == null ? "bad" : found.getKind().name())) { error(tree, "Unexpected value found: " + found +", expected: " + expect); } + if (expect.equalsIgnoreCase("bad") && type != null) { + error(tree, "Found unexpected type: " + type + ", expected none"); + } } } @@ -252,6 +290,12 @@ public class ReferenceTest extends AbstractProcessor { default -> throw new AssertionError("Unhandled type kind: " + type.getKind()); }; } + + TypeMirror erasure(TypeMirror type) { + return type.getKind() == TypeKind.DECLARED + ? processingEnv.getTypeUtils().erasure(type) + : type; + } } /** @@ -317,11 +361,17 @@ class ReferenceTestExtras { * @see #X Field * @see #X() Method * @see #m Method + * @see X Type_Parameter + * @see Y Type_Parameter + * @see X#wait Method + * @see X#wait() Method + * @see Y#getSupportedSourceVersion Method + * @see Y#init(ProcessingEnvironment) Method * @see Inner#X Bad * @see Inner#X() Bad * @see Inner#m Bad */ - interface Inner {} + interface Inner {} } diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/StringLoopJmhBenchmark.java b/test/micro/org/openjdk/bench/java/lang/foreign/StringLoopJmhBenchmark.java new file mode 100644 index 00000000000..1733b73886e --- /dev/null +++ b/test/micro/org/openjdk/bench/java/lang/foreign/StringLoopJmhBenchmark.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2026, Google LLC. 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 org.openjdk.bench.java.lang.foreign; + +import java.nio.charset.StandardCharsets; +import java.util.concurrent.TimeUnit; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.annotations.State; + +@Warmup(time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(1) +@State(Scope.Benchmark) +public class StringLoopJmhBenchmark { + @Param({"10", "100", "1000", "100000"}) + int stringLength; + + @Param({"ASCII", "LATIN1", "UTF16"}) + String encoding; + + String stringData; + + @Setup + public void setUp() { + stringData = ""; + + // Character at the _end_ to affect if we hit + // - ASCII = compact strings and compatible with UTF-8 + // - LATIN1 = compact strings but not compatible with UTF-8 + // - UTF16 = 2-byte char storage and not compatible with UTF-8 + String c; + if (encoding.equals("ASCII")) { + c = "a"; + } else if (encoding.equals("LATIN1")) { + c = "\u00C4"; + } else if (encoding.equals("UTF16")) { + c = "\u2603"; + } else { + throw new IllegalArgumentException("Unknown encoding: " + encoding); + } + + var stringDataBuilder = new StringBuilder(stringLength + 1); + while (stringDataBuilder.length() < stringLength) { + stringDataBuilder.append((char) (Math.random() * 26) + 'a'); + } + stringData = stringDataBuilder.append(c).toString(); + } + + @Benchmark + public int utf8LenByLoop() { + final String s = stringData; + final int len = s.length(); + + // ASCII prefix strings. + int idx = 0; + for (char c; idx < len && (c = s.charAt(idx)) < 0x80; ++idx) {} + + // Entire string was ASCII. + if (idx == len) { + return len; + } + + int utf8Len = len; + for (char c; idx < len; ++idx) { + c = s.charAt(idx); + if (c < 0x80) { + utf8Len++; + } else if (c < 0x800) { + utf8Len += 2; + } else { + utf8Len += 3; + if (Character.isSurrogate(c)) { + int cp = Character.codePointAt(s, idx); + if (cp < Character.MIN_SUPPLEMENTARY_CODE_POINT) { + throw new RuntimeException("Unpaired surrogate"); + } + idx++; + } + } + } + return utf8Len; + } + + @Benchmark + public int getBytes() throws Exception { + return stringData.getBytes(StandardCharsets.UTF_8).length; + } + + @Benchmark + public int encodedLength() throws Exception { + return stringData.encodedLength(StandardCharsets.UTF_8); + } +} diff --git a/test/micro/org/openjdk/bench/java/util/Base64EncodeToString.java b/test/micro/org/openjdk/bench/java/util/Base64EncodeToString.java new file mode 100644 index 00000000000..5b259230341 --- /dev/null +++ b/test/micro/org/openjdk/bench/java/util/Base64EncodeToString.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2026, 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 org.openjdk.micro.bench.java.util; + +import org.openjdk.jmh.annotations.*; + +import java.util.Base64; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +@State(Scope.Benchmark) +@Warmup(iterations = 5, time = 2) +@Measurement(iterations = 5, time = 2) +@Fork(value = 2) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +public class Base64EncodeToString { + + private byte[] input; + + @Param({"10", "100", "1000", "10000"}) + private int inputSize; + + @Setup + public void setup() { + Random r = new Random(1123); + input = new byte[inputSize]; + r.nextBytes(input); + } + + @Benchmark + public String testEncodeToString() { + return Base64.getEncoder().encodeToString(input); + } +} +