Compare commits

..

24 Commits

Author SHA1 Message Date
Vitaly Provodin
4d33a6087e Revert "8364583: ColorConvertOp fails for CMYK → RGB conversion"
This reverts commit 8585b46c12.
2025-11-14 03:27:40 +04:00
Vitaly Provodin
3fe0c9cb1d Revert "8370719: [Linux] Use /etc/os-release values for font configuration file names"
This reverts commit 984c87cf76.
2025-11-14 03:26:54 +04:00
Vitaly Provodin
a997241ac1 Revert "4954405: Data buffers created with an offset are unusable"
This reverts commit 146f8a83f9.
2025-11-14 03:26:54 +04:00
Vitaly Provodin
b2b340eed4 Revert "8371296: Refactor tests to use PEM API (Phase 1) - Fix WriteP12Test failure"
This reverts commit 463f5dc112.
2025-11-14 03:26:54 +04:00
Vitaly Provodin
5137f22ad9 Revert "8371184: Improve jpackage test coverage for "--app-image" option"
This reverts commit c8f5fd6ff3.
2025-11-14 03:26:54 +04:00
Vitaly Provodin
976afbfc70 Revert "8371141: Shenandoah: Many test timeouts with -XX:-UseTLAB"
This reverts commit 87c2091cd0.
2025-11-14 03:26:29 +04:00
Vitaly Provodin
d99ba93924 Revert "8369456: [TESTBUG] Fix the test failure of TestSelectFromTwoVectorOp.java on sve2 platforms"
This reverts commit 4e6cadf455.
2025-11-14 03:26:29 +04:00
Vitaly Provodin
14d9fa2e0b Revert "8371304: mismatch in file name and class name for ByteInterleavedRasterOffsetsTest.java"
This reverts commit d89c6a77f2.
2025-11-14 03:26:28 +04:00
Vitaly Provodin
f937431b50 Revert "8369489: Marker annotation on inner class access crashes javac compiler"
This reverts commit 8b536b5428.
2025-11-14 03:26:28 +04:00
Vitaly Provodin
94c9b0c104 Revert "8370175: State engine terminates when throwing self-caused exception"
This reverts commit a0e70c4e94.
2025-11-14 03:26:28 +04:00
Vitaly Provodin
246028d94b Revert "8334866: Improve Speed of ElfDecoder source search"
This reverts commit dddfcd03aa.
2025-11-14 03:26:28 +04:00
Vitaly Provodin
f1817ad1c6 Revert "8370874: [asan] ASAN build fails after JDK-8368365"
This reverts commit f5d8bd0dd5.
2025-11-14 03:26:27 +04:00
Vitaly Provodin
253cbec513 Revert "8370708: RISC-V: Add VerifyStackAtCalls"
This reverts commit 0737a56252.
2025-11-14 03:26:27 +04:00
Vitaly Provodin
935f13b07e Revert "8371197: G1: Use void for return type of G1RegionsOnNodes::add"
This reverts commit 6a51b51ba1.
2025-11-14 03:26:27 +04:00
Vitaly Provodin
7afc02734a Revert "8371133: Clarify the purpose of "src/jdk.compiler/share/classes/com/sun/tools/javac/resources/ct.properties""
This reverts commit f6f87bb675.
2025-11-14 03:26:26 +04:00
Vitaly Provodin
1282cf9366 Revert "8371205: AArch64: Remove unused cmpxchg* methods"
This reverts commit c9a98169cb.
2025-11-14 03:26:25 +04:00
Vitaly Provodin
c8a380d8ae Revert "8346719: Add relaunchers to the static JDK image for missing executables"
This reverts commit 2dd15cf5bf.
2025-11-14 03:26:25 +04:00
Vitaly Provodin
069292255b Revert "8371009: HttpClient javadoc synchronous example missing HttpRequest variable declaration"
This reverts commit 973dc3fc47.
2025-11-14 03:26:25 +04:00
Vitaly Provodin
6ecbca6e45 Revert "8370201: Test serviceability/sa/TestJhsdbJstackWithVirtualThread.java fails due to VM warnings"
This reverts commit b0536f9c2a.
2025-11-14 03:26:24 +04:00
Vitaly Provodin
e5891e11a5 Revert "8371354: Problem list serviceability/sa/TestJhsdbJstackMixedWithXComp.java due to JDK-8371194"
This reverts commit cf45e09c38.
2025-11-14 03:26:24 +04:00
Vitaly Provodin
bb506138f9 Revert "8370637: [Windows] Crash if use Graphics after PrintJob.end"
This reverts commit 7d93cb73c4.
2025-11-14 03:26:24 +04:00
Vitaly Provodin
b583ce21ea Revert "8360120: Bundled macOS applications not receiving OpenURL events when launched as subprocess"
This reverts commit 2872f815fd.
2025-11-14 03:26:24 +04:00
Vitaly Provodin
b92cc94e35 Revert "8368576: PrintJob.getGraphics() does not specify behavior after PrintJob.end()"
This reverts commit 5a37374dca.
2025-11-14 03:26:23 +04:00
Vitaly Provodin
dccc3331f0 Revert "8357034: GifImageDecoder can produce wrong transparent pixels"
This reverts commit acc8a76db2.
2025-11-14 03:26:23 +04:00
90 changed files with 1230 additions and 2207 deletions

View File

@@ -461,9 +461,9 @@ $(eval $(call SetupTarget, symbols-image, \
TARGET := symbols, \
))
$(eval $(call SetupTarget, static-launchers, \
$(eval $(call SetupTarget, static-launcher, \
MAKEFILE := StaticLibs, \
TARGET := static-launchers, \
TARGET := static-launcher, \
DEPS := hotspot-static-libs static-libs, \
))
@@ -1290,7 +1290,7 @@ ifeq ($(call isTargetOs, macosx), true)
legacy-images: mac-legacy-jre-bundle
endif
static-exploded-image: static-launchers exploded-image
static-exploded-image: static-launcher exploded-image
# These targets build the various documentation images
docs-jdk-image: docs-jdk

View File

@@ -48,8 +48,8 @@ ifneq ($(word 2, $(wildcard $(HOTSPOT_STATIC_LIB_PATH))), )
endif
# Find all modules with static libraries
STATIC_LIB_MODULES := $(sort $(patsubst $(SUPPORT_OUTPUTDIR)/modules_static-libs/%, \
%, $(wildcard $(SUPPORT_OUTPUTDIR)/modules_static-libs/*)))
STATIC_LIB_MODULES := $(patsubst $(SUPPORT_OUTPUTDIR)/modules_static-libs/%, \
%, $(wildcard $(SUPPORT_OUTPUTDIR)/modules_static-libs/*))
# Filter out known broken libraries. This is a temporary measure until
# proper support for these libraries can be provided.
@@ -123,18 +123,13 @@ else
$(error Unsupported platform)
endif
################################################################################
# Build the java static launcher
################################################################################
$(eval $(call SetupBuildLauncher, java, \
ENABLE_ARG_FILES := true, \
EXPAND_CLASSPATH_WILDCARDS := true, \
EXTRA_RCFLAGS := $(JAVA_RCFLAGS), \
VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \
OPTIMIZATION := HIGH, \
MACOSX_PRIVILEGED := true, \
STATIC_LAUNCHER := true, \
CFLAGS := -DSTATIC_BUILD, \
LDFLAGS := $(LDFLAGS_STATIC_JDK), \
LIBS := $(STATIC_LIBS) $(EXTERNAL_LIBS), \
LINK_TYPE := C++, \
@@ -151,53 +146,7 @@ TARGETS += $(java)
JAVA_LAUNCHER := $(BUILD_LAUNCHER_java_TARGET)
static-launchers: $(java)
################################################################################
# Build relaunchers (thin wrappers calling the java binary) for all other
# JDK launchers.
################################################################################
RELAUNCHER_SRC := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/launcher
# $1: The module name
# $2: The launcher name
define SetupRelauncher
$1_$2_LAUNCHER_ARGS_LINE := $$(call ReadFile, $$(SUPPORT_OUTPUTDIR)/static-native/relaunchers/$1/$2-relauncher-arguments.txt)
# Restore |||| with space
$1_$2_LAUNCHER_ARGS := '{ $$(subst ||||,$(SPACE),$$(strip $$(foreach a, $$($1_$2_LAUNCHER_ARGS_LINE), "-J$$a"$$(COMMA) )) ) }'
$$(eval $$(call SetupJdkExecutable, BUILD_relauncher_$2, \
NAME := $2, \
EXTRA_FILES := $$(RELAUNCHER_SRC)/relauncher.c, \
CFLAGS := -DLAUNCHER_ARGS=$$($1_$2_LAUNCHER_ARGS), \
LIBS_windows := shlwapi.lib, \
OUTPUT_DIR := $$(STATIC_LAUNCHER_OUTPUT_DIR), \
OBJECT_DIR := $$(STATIC_LAUNCHER_OUTPUT_DIR)/relaunchers/$2, \
))
TARGETS += $$(BUILD_relauncher_$2)
RELAUNCHERS += $$(BUILD_relauncher_$2_TARGET)
static-launchers: $$(BUILD_relauncher_$2)
endef
# Find all modules with launchers
LAUNCHER_MODULES := $(sort $(patsubst $(SUPPORT_OUTPUTDIR)/modules_static-launchers/%, \
%, $(wildcard $(SUPPORT_OUTPUTDIR)/modules_static-launchers/*)))
# Find launchers for each module
$(foreach module, $(LAUNCHER_MODULES), \
$(eval LAUNCHERS_$(module) := $(if $(wildcard \
$(SUPPORT_OUTPUTDIR)/modules_static-launchers/$(module)/module-included-launchers.txt), \
$(shell cat \
$(SUPPORT_OUTPUTDIR)/modules_static-launchers/$(module)/module-included-launchers.txt))) \
)
# For all launchers (except java and javaw), setup a relauncher build
$(foreach module, $(LAUNCHER_MODULES), \
$(foreach launcher, $(filter-out java javaw, $(LAUNCHERS_$(module))), \
$(eval $(call SetupRelauncher,$(module),$(launcher)))))
static-launcher: $(java)
################################################################################
#
@@ -239,72 +188,26 @@ TARGETS += $(copy-from-jdk-image)
$(copy-from-jdk-image): | static-jdk-info
$(eval $(call SetupCopyFiles, copy-static-launchers, \
FILES := $(JAVA_LAUNCHER) $(RELAUNCHERS), \
$(eval $(call SetupCopyFiles, copy-static-launcher, \
FILES := $(JAVA_LAUNCHER), \
DEST := $(STATIC_JDK_IMAGE_DIR)/bin, \
))
TARGETS += $(copy-static-launchers)
TARGETS += $(copy-static-launcher)
$(eval $(call SetupCopyFiles, copy-static-launchers-debuginfo, \
$(eval $(call SetupCopyFiles, copy-static-launcher-debuginfo, \
SRC := $(STATIC_LAUNCHER_OUTPUT_DIR), \
DEST := $(STATIC_JDK_IMAGE_DIR)/bin, \
FILES := $(call FindDebuginfoFiles, $(STATIC_LAUNCHER_OUTPUT_DIR)), \
))
TARGETS += $(copy-static-launchers-debuginfo)
TARGETS += $(copy-static-launcher-debuginfo)
# Copy the microsoft runtime libraries on windows
ifeq ($(call isTargetOs, windows), true)
# Chmod to avoid permission issues if bundles are unpacked on unix platforms.
# Use separate macro calls in case the source files are not in the same
# directory.
$(eval $(call SetupCopyFiles, copy-windows-msvcr, \
DEST := $(STATIC_JDK_IMAGE_DIR)/bin, \
FILES := $(MSVCR_DLL), \
MACRO := copy-and-chmod-executable, \
))
TARGETS += $(copy-windows-msvcr)
$(eval $(call SetupCopyFiles, copy-windows-vcruntime, \
DEST := $(STATIC_JDK_IMAGE_DIR)/bin, \
FILES := $(VCRUNTIME_1_DLL), \
MACRO := copy-and-chmod-executable, \
))
TARGETS += $(copy-windows-vcruntime)
$(eval $(call SetupCopyFiles, copy-windows-msvcp, \
DEST := $(STATIC_JDK_IMAGE_DIR)/bin, \
FILES := $(MSVCP_DLL), \
MACRO := copy-and-chmod-executable, \
))
TARGETS += $(copy-windows-msvcp)
copy-windows-libs := $(copy-windows-msvcr) $(copy-windows-vcruntime) $(copy-windows-msvcp)
ifneq ($(UCRT_DLL_DIR), )
$(eval $(call SetupCopyFiles, copy-windows-ucrt, \
DEST := $(STATIC_JDK_IMAGE_DIR)/bin, \
SRC := $(UCRT_DLL_DIR), \
FILES := $(wildcard $(UCRT_DLL_DIR)/*.dll), \
MACRO := copy-and-chmod-executable, \
))
TARGETS += $(copy-windows-ucrt)
copy-windows-libs += $(copy-windows-ucrt)
endif
endif
static-jdk-image: $(copy-from-jdk-image) $(copy-static-launchers) \
$(copy-static-launchers-debuginfo) $(copy-windows-libs)
static-jdk-image: $(copy-from-jdk-image) $(copy-static-launcher) $(copy-static-launcher-debuginfo)
TARGETS += static-jdk-image
.PHONY: static-launchers static-jdk-image
.PHONY: static-launcher static-jdk-image
################################################################################

View File

@@ -43,9 +43,6 @@ LAUNCHER_CFLAGS += -I$(TOPDIR)/src/java.base/share/native/launcher \
MACOSX_PLIST_DIR := $(TOPDIR)/src/java.base/macosx/native/launcher
JAVA_MANIFEST := $(TOPDIR)/src/java.base/windows/native/launcher/java.manifest
INCLUDED_LAUNCHERS_FILE := $(SUPPORT_OUTPUTDIR)/modules_static-launchers/$(MODULE)/module-included-launchers.txt
INCLUDED_LAUNCHERS :=
################################################################################
# Build standard launcher.
@@ -77,29 +74,18 @@ define SetupBuildLauncherBody
$1_MAIN_MODULE := $(MODULE)
$1_RELAUNCHER_ARGUMENTS :=
ifneq ($$($1_MAIN_CLASS), )
$1_JAVA_ARGS += -Xms8m
$1_LAUNCHER_CLASS := -m $$($1_MAIN_MODULE)/$$($1_MAIN_CLASS)
endif
ifeq ($$($1_ENABLE_ARG_FILES), true)
$1_CFLAGS += -DDISABLE_ARGFILE=JNI_FALSE
else
$1_CFLAGS += -DDISABLE_ARGFILE=JNI_TRUE
# This must be the first argument given, if it should be present
$1_RELAUNCHER_ARGUMENTS += -DjavaLauncherArgFiles=false
endif
ifeq ($$($1_EXPAND_CLASSPATH_WILDCARDS), true)
$1_CFLAGS += -DCLASSPATH_WILDCARDS=JNI_TRUE
else
$1_CFLAGS += -DCLASSPATH_WILDCARDS=JNI_FALSE
$1_RELAUNCHER_ARGUMENTS += -DjavaLauncherWildcards=false
$1_CFLAGS += -DEXPAND_CLASSPATH_WILDCARDS
endif
$1_RELAUNCHER_ARGUMENTS += -DjavaLauncherProgname=$1
ifeq ($$($1_ENABLE_ARG_FILES), true)
$1_CFLAGS += -DENABLE_ARG_FILES
endif
ifeq ($(call isTargetOs, windows), true)
ifeq ($$($1_WINDOWS_JAVAW), true)
@@ -108,14 +94,9 @@ define SetupBuildLauncherBody
endif
ifneq ($$($1_JAVA_ARGS), )
$1_PREFIXED_JAVA_ARGS := $$(addprefix -J, $$($1_JAVA_ARGS)) \
$$($1_LAUNCHER_CLASS)
$1_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, $$($1_PREFIXED_JAVA_ARGS), \
"$$a"$(COMMA) )) }'
$1_JAVA_ARGS_STR := '{ $$(strip $$(foreach a, \
$$(addprefix -J, $$($1_JAVA_ARGS)) $$($1_LAUNCHER_CLASS), "$$a"$(COMMA) )) }'
$1_CFLAGS += -DJAVA_ARGS=$$($1_JAVA_ARGS_STR)
# To preserve spaces, substitute them with a hopefully unique pattern
$1_RELAUNCHER_ARGUMENTS += \
-DjavaLauncherArgs=$$(subst $$(SPACE),||||,$$($1_PREFIXED_JAVA_ARGS))
endif
ifeq ($(call isTargetOs, macosx), true)
@@ -191,28 +172,8 @@ define SetupBuildLauncherBody
))
$1 += $$(BUILD_LAUNCHER_$1)
$1_RELAUNCHER_ARGUMENTS_FILE := \
$$(SUPPORT_OUTPUTDIR)/static-native/relaunchers/$$(MODULE)/$1-relauncher-arguments.txt
$1_VARDEPS := $$($1_RELAUNCHER_ARGUMENTS)
$1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
$$($1_RELAUNCHER_ARGUMENTS_FILE).vardeps)
$$($1_RELAUNCHER_ARGUMENTS_FILE):
$$(call MakeDir, $$(@D))
$$(ECHO) '$$($1_RELAUNCHER_ARGUMENTS)' > $$@
$1 += $$($1_RELAUNCHER_ARGUMENTS_FILE)
TARGETS += $$($1)
# Record the fact that this launcher is part of the current module.
INCLUDED_LAUNCHERS += $1
# Add a dependency from this launcher to the launcher list
$$(INCLUDED_LAUNCHERS_FILE): $$($1)
$$(BUILD_LAUNCHER_$1): $$(BUILD_PLIST_$1)
ifeq ($(call isTargetOs, macosx), true)
@@ -281,14 +242,5 @@ endif
################################################################################
# We need to keep track of which launchers are created by this module. This
# information is required for static builds, to know which relaunchers to
# create. The file module-included-launchers.txt is then read in StaticLibs.gmk.
$(INCLUDED_LAUNCHERS_FILE):
$(call MakeDir, $(@D))
$(ECHO) $(INCLUDED_LAUNCHERS) > $@
TARGETS += $(INCLUDED_LAUNCHERS_FILE)
endif # include guard
include MakeIncludeEnd.gmk

View File

@@ -73,7 +73,7 @@ ifeq ($(call isTargetOs, linux), true)
$(eval $(call SetupJdkExecutable, BUILD_JEXEC, \
NAME := jexec, \
EXTRA_FILES := $(TOPDIR)/src/$(MODULE)/unix/native/launcher/jexec.c, \
SRC := $(TOPDIR)/src/$(MODULE)/unix/native/launcher, \
OPTIMIZATION := LOW, \
EXTRA_HEADER_DIRS := libjli, \
CFLAGS_linux := -fPIC, \

View File

@@ -25,6 +25,7 @@
################################################################################
include LauncherCommon.gmk
include LibCommon.gmk
JPACKAGE_OUTPUT_DIR := \

View File

@@ -2722,8 +2722,9 @@ void C2_MacroAssembler::select_from_two_vectors(FloatRegister dst, FloatRegister
assert_different_registers(dst, src1, src2, index, tmp);
// The cases that can reach this method are -
// - UseSVE = 0/1, vector_length_in_bytes = 8 or 16, excluding double and long types
// - UseSVE = 2, vector_length_in_bytes >= 8, for all types
// - UseSVE = 0, vector_length_in_bytes = 8 or 16
// - UseSVE = 1, vector_length_in_bytes = 8 or 16
// - UseSVE = 2, vector_length_in_bytes >= 8
//
// SVE/SVE2 tbl instructions are generated when UseSVE = 1 with vector_length_in_bytes = 8
// and UseSVE = 2 with vector_length_in_bytes >= 8

View File

@@ -3315,6 +3315,97 @@ void MacroAssembler::reinit_heapbase()
}
}
// this simulates the behaviour of the x86 cmpxchg instruction using a
// load linked/store conditional pair. we use the acquire/release
// versions of these instructions so that we flush pending writes as
// per Java semantics.
// n.b the x86 version assumes the old value to be compared against is
// in rax and updates rax with the value located in memory if the
// cmpxchg fails. we supply a register for the old value explicitly
// the aarch64 load linked/store conditional instructions do not
// accept an offset. so, unlike x86, we must provide a plain register
// to identify the memory word to be compared/exchanged rather than a
// register+offset Address.
void MacroAssembler::cmpxchgptr(Register oldv, Register newv, Register addr, Register tmp,
Label &succeed, Label *fail) {
// oldv holds comparison value
// newv holds value to write in exchange
// addr identifies memory word to compare against/update
if (UseLSE) {
mov(tmp, oldv);
casal(Assembler::xword, oldv, newv, addr);
cmp(tmp, oldv);
br(Assembler::EQ, succeed);
membar(AnyAny);
} else {
Label retry_load, nope;
prfm(Address(addr), PSTL1STRM);
bind(retry_load);
// flush and load exclusive from the memory location
// and fail if it is not what we expect
ldaxr(tmp, addr);
cmp(tmp, oldv);
br(Assembler::NE, nope);
// if we store+flush with no intervening write tmp will be zero
stlxr(tmp, newv, addr);
cbzw(tmp, succeed);
// retry so we only ever return after a load fails to compare
// ensures we don't return a stale value after a failed write.
b(retry_load);
// if the memory word differs we return it in oldv and signal a fail
bind(nope);
membar(AnyAny);
mov(oldv, tmp);
}
if (fail)
b(*fail);
}
void MacroAssembler::cmpxchg_obj_header(Register oldv, Register newv, Register obj, Register tmp,
Label &succeed, Label *fail) {
assert(oopDesc::mark_offset_in_bytes() == 0, "assumption");
cmpxchgptr(oldv, newv, obj, tmp, succeed, fail);
}
void MacroAssembler::cmpxchgw(Register oldv, Register newv, Register addr, Register tmp,
Label &succeed, Label *fail) {
// oldv holds comparison value
// newv holds value to write in exchange
// addr identifies memory word to compare against/update
// tmp returns 0/1 for success/failure
if (UseLSE) {
mov(tmp, oldv);
casal(Assembler::word, oldv, newv, addr);
cmp(tmp, oldv);
br(Assembler::EQ, succeed);
membar(AnyAny);
} else {
Label retry_load, nope;
prfm(Address(addr), PSTL1STRM);
bind(retry_load);
// flush and load exclusive from the memory location
// and fail if it is not what we expect
ldaxrw(tmp, addr);
cmp(tmp, oldv);
br(Assembler::NE, nope);
// if we store+flush with no intervening write tmp will be zero
stlxrw(tmp, newv, addr);
cbzw(tmp, succeed);
// retry so we only ever return after a load fails to compare
// ensures we don't return a stale value after a failed write.
b(retry_load);
// if the memory word differs we return it in oldv and signal a fail
bind(nope);
membar(AnyAny);
mov(oldv, tmp);
}
if (fail)
b(*fail);
}
// A generic CAS; success or failure is in the EQ flag. A weak CAS
// doesn't retry and may fail spuriously. If the oldval is wanted,
// Pass a register for the result, otherwise pass noreg.

View File

@@ -1200,6 +1200,16 @@ public:
void cmpoop(Register obj1, Register obj2);
// Various forms of CAS
void cmpxchg_obj_header(Register oldv, Register newv, Register obj, Register tmp,
Label &succeed, Label *fail);
void cmpxchgptr(Register oldv, Register newv, Register addr, Register tmp,
Label &succeed, Label *fail);
void cmpxchgw(Register oldv, Register newv, Register addr, Register tmp,
Label &succeed, Label *fail);
void atomic_add(Register prev, RegisterOrConstant incr, Register addr);
void atomic_addw(Register prev, RegisterOrConstant incr, Register addr);
void atomic_addal(Register prev, RegisterOrConstant incr, Register addr);

View File

@@ -1184,8 +1184,6 @@ bool is_CAS(int opcode, bool maybe_volatile)
}
}
constexpr uint64_t MAJIK_DWORD = 0xabbaabbaabbaabbaull;
// predicate controlling translation of CAS
//
// returns true if CAS needs to use an acquiring load otherwise false
@@ -1365,15 +1363,10 @@ void MachPrologNode::format(PhaseRegAlloc *ra_, outputStream *st) const {
st->print("# stack bang size=%d\n\t", framesize);
}
st->print("sd fp, [sp, #%d]\n\t", - 2 * wordSize);
st->print("sd ra, [sp, #%d]\n\t", - wordSize);
if (PreserveFramePointer) { st->print("sub fp, sp, #%d\n\t", 2 * wordSize); }
st->print("sub sp, sp, #%d\n\t", framesize);
st->print("sd fp, [sp, #%d]\n\t", framesize - 2 * wordSize);
st->print("sd ra, [sp, #%d]\n\t", framesize - wordSize);
if (PreserveFramePointer) { st->print("add fp, sp, #%d\n\t", framesize); }
if (VerifyStackAtCalls) {
st->print("mv t2, %ld\n\t", MAJIK_DWORD);
st->print("sd t2, [sp, #%d]\n\t", framesize - 3 * wordSize);
}
if (C->stub_function() == nullptr) {
st->print("ld t0, [guard]\n\t");
@@ -1415,11 +1408,6 @@ void MachPrologNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const {
__ build_frame(framesize);
if (VerifyStackAtCalls) {
__ mv(t2, MAJIK_DWORD);
__ sd(t2, Address(sp, framesize - 3 * wordSize));
}
if (C->stub_function() == nullptr) {
BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
// Dummy labels for just measuring the code size
@@ -1441,6 +1429,10 @@ void MachPrologNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const {
bs->nmethod_entry_barrier(masm, slow_path, continuation, guard);
}
if (VerifyStackAtCalls) {
Unimplemented();
}
C->output()->set_frame_complete(__ offset());
if (C->has_mach_constant_base_node()) {
@@ -2439,13 +2431,7 @@ encode %{
enc_class riscv_enc_call_epilog() %{
if (VerifyStackAtCalls) {
// Check that stack depth is unchanged: find majik cookie on stack
int framesize = ra_->reg2offset_unchecked(OptoReg::add(ra_->_matcher._old_SP, -3 * VMRegImpl::slots_per_word));
Label stack_ok;
__ ld(t1, Address(sp, framesize));
__ mv(t2, MAJIK_DWORD);
__ beq(t2, t1, stack_ok);
__ stop("MAJIK_DWORD not found");
__ bind(stack_ok);
__ call_Unimplemented();
}
%}

View File

@@ -2368,7 +2368,7 @@ void SharedRuntime::generate_deopt_blob() {
// EPILOG must remove this many slots.
// RISCV needs two words for RA (return address) and FP (frame pointer).
uint SharedRuntime::in_preserve_stack_slots() {
return 2 * VMRegImpl::slots_per_word + (VerifyStackAtCalls ? 0 : 2) ;
return 2 * VMRegImpl::slots_per_word;
}
uint SharedRuntime::out_preserve_stack_slots() {

View File

@@ -3467,7 +3467,7 @@ bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType bt) {
if (size_in_bits < 128) {
return false;
}
if (size_in_bits < 512 && !VM_Version::supports_avx512vl()) {
if ((size_in_bits < 512 && !VM_Version::supports_avx512vl())) {
return false;
}
if (bt == T_SHORT && !VM_Version::supports_avx512bw()) {

View File

@@ -41,10 +41,10 @@ private:
public:
G1EdenRegions() : _length(0), _used_bytes(0), _regions_on_node() { }
void add(G1HeapRegion* hr) {
uint add(G1HeapRegion* hr) {
assert(hr->is_eden(), "must be");
_length++;
_regions_on_node.add(hr);
return _regions_on_node.add(hr);
}
void clear() {

View File

@@ -35,13 +35,16 @@ G1RegionsOnNodes::~G1RegionsOnNodes() {
FREE_C_HEAP_ARRAY(uint, _count_per_node);
}
void G1RegionsOnNodes::add(G1HeapRegion* hr) {
uint G1RegionsOnNodes::add(G1HeapRegion* hr) {
uint node_index = hr->node_index();
// Update only if the node index is valid.
if (node_index < _numa->num_active_nodes()) {
*(_count_per_node + node_index) += 1;
return node_index;
}
return G1NUMA::UnknownNodeIndex;
}
void G1RegionsOnNodes::clear() {

View File

@@ -40,8 +40,8 @@ public:
~G1RegionsOnNodes();
// Increase _count_per_node for the node of given heap region.
void add(G1HeapRegion* hr);
// Increase _count_per_node for the node of given heap region and returns node index.
uint add(G1HeapRegion* hr);
void clear();

View File

@@ -32,10 +32,10 @@ G1SurvivorRegions::G1SurvivorRegions() :
_used_bytes(0),
_regions_on_node() {}
void G1SurvivorRegions::add(G1HeapRegion* hr) {
uint G1SurvivorRegions::add(G1HeapRegion* hr) {
assert(hr->is_survivor(), "should be flagged as survivor region");
_regions.append(hr);
_regions_on_node.add(hr);
return _regions_on_node.add(hr);
}
uint G1SurvivorRegions::length() const {

View File

@@ -42,7 +42,7 @@ class G1SurvivorRegions {
public:
G1SurvivorRegions();
void add(G1HeapRegion* hr);
uint add(G1HeapRegion* hr);
void convert_to_eden();

View File

@@ -2408,7 +2408,7 @@ void PhaseChaitin::dump_frame() const {
tty->print_cr("saved fp register");
else if (return_addr == OptoReg::add(reg, 2*VMRegImpl::slots_per_word) &&
VerifyStackAtCalls)
tty->print_cr("<Majik cookie> +VerifyStackAtCalls");
tty->print_cr("0xBADB100D +VerifyStackAtCalls");
else
tty->print_cr("in_preserve");
} else if ((int)OptoReg::reg2stack(reg) < fixed_slots) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@@ -25,7 +25,6 @@
#ifdef ADDRESS_SANITIZER
#include "logging/log.hpp"
#include "runtime/globals_extension.hpp"
#include "sanitizers/address.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/vmError.hpp"

View File

@@ -684,8 +684,9 @@ bool ElfFile::create_new_dwarf_file(const char* filepath) {
// Starting point of reading line number and filename information from the DWARF file.
bool DwarfFile::get_filename_and_line_number(const uint32_t offset_in_library, char* filename, const size_t filename_len,
int* line, const bool is_pc_after_call) {
DebugAranges debug_aranges(this);
uint32_t compilation_unit_offset = 0; // 4-bytes for 32-bit DWARF
if (!_debug_aranges.find_compilation_unit_offset(offset_in_library, &compilation_unit_offset)) {
if (!debug_aranges.find_compilation_unit_offset(offset_in_library, &compilation_unit_offset)) {
DWARF_LOG_ERROR("Failed to find .debug_info offset for the compilation unit.");
return false;
}
@@ -707,87 +708,11 @@ bool DwarfFile::get_filename_and_line_number(const uint32_t offset_in_library, c
return true;
}
// Build sorted cache of all address ranges for binary search.
DwarfFile::DebugAranges::CacheHint DwarfFile::DebugAranges::ensure_cached() {
if (_cache._failed) {
return CacheHint::FAILED;
}
if (_cache._initialized) {
return CacheHint::VALID;
}
assert(_cache._capacity == 0, "need fresh cache");
assert(_cache._count == 0, "need fresh cache");
const long pos = _reader.get_position();
if (!read_section_header()) {
_cache.destroy(true);
return CacheHint::FAILED;
}
// Start with reasonable initial capacity to minimize number of grow/realloc calls.
// Assume ~3% of the .debug_aranges is DebugArangesSetHeader and the rest is made up of AddressDescriptors.
const uintptr_t estimated_set_header_size = _size_bytes / 32;
const size_t initial_capacity = (_size_bytes - estimated_set_header_size) / sizeof(AddressDescriptor);
_cache._entries = NEW_C_HEAP_ARRAY_RETURN_NULL(ArangesEntry, initial_capacity, mtInternal);
if (_cache._entries == nullptr) {
_cache.destroy(true);
_reader.set_position(pos);
return CacheHint::TRY_LINEAR_SCAN;
}
_cache._capacity = initial_capacity;
_cache._count = 0;
// Read all sets and their descriptors
while (_reader.has_bytes_left()) {
DebugArangesSetHeader set_header;
if (!read_set_header(set_header)) {
break;
}
// Read all address descriptors for this set into the cache.
AddressDescriptor descriptor;
do {
if (!read_address_descriptor(descriptor)) {
_cache.destroy(true);
return CacheHint::FAILED;
}
if (!is_terminating_entry(set_header, descriptor) && descriptor.range_length > 0 &&
!_cache.add_entry(descriptor, set_header._debug_info_offset)) {
_cache.destroy(true);
_reader.set_position(pos);
return CacheHint::TRY_LINEAR_SCAN;
}
} while (!is_terminating_entry(set_header, descriptor) && _reader.has_bytes_left());
}
if (_cache._count == 0) {
_cache.destroy(false);
// No entries found, unusual but still valid.
return CacheHint::VALID;
}
_cache.sort();
_cache._initialized = true;
DWARF_LOG_INFO("Built .debug_aranges cache for '%s' with %zu entries", this->_dwarf_file->filepath(), _cache._count);
return CacheHint::VALID;
}
// (2) The .debug_aranges section contains a number of entries/sets. Each set contains one or multiple address range descriptors of the
// form [beginning_address, beginning_address+length). Start reading these sets and their descriptors until we find one that contains
// 'offset_in_library'. Read the debug_info_offset field from the header of this set which defines the offset for the compilation unit.
// This process is described in section 6.1.2 of the DWARF 4 spec.
bool DwarfFile::DebugAranges::find_compilation_unit_offset(const uint32_t offset_in_library, uint32_t* compilation_unit_offset) {
switch (ensure_cached()) {
case CacheHint::VALID:
return _cache.find_compilation_unit_offset(offset_in_library, compilation_unit_offset);
case CacheHint::TRY_LINEAR_SCAN:
break;
case CacheHint::FAILED:
return false;
}
// Fall back to linear scan if building of the cache failed, which can happen
// if there are C heap allocation errors.
DWARF_LOG_INFO("Falling back to linear scan of .debug_aranges for '%s'", _dwarf_file->filepath());
if (!read_section_header()) {
DWARF_LOG_ERROR("Failed to read a .debug_aranges header.");
return false;
@@ -825,7 +750,6 @@ bool DwarfFile::DebugAranges::read_section_header() {
}
_section_start_address = shdr.sh_offset;
_size_bytes = shdr.sh_size;
_reader.set_max_pos(shdr.sh_offset + shdr.sh_size);
return _reader.set_position(shdr.sh_offset);
}
@@ -905,74 +829,6 @@ bool DwarfFile::DebugAranges::is_terminating_entry(const DwarfFile::DebugAranges
return is_terminating;
}
// Sort entries by beginning_address, when same then sort longest range first.
int DwarfFile::ArangesCache::compare_aranges_entries(const ArangesEntry& a, const ArangesEntry& b) {
if (a.beginning_address < b.beginning_address) {
return -1;
} else if (a.beginning_address > b.beginning_address) {
return 1;
}
uintptr_t len_a = a.end_address - a.beginning_address;
uintptr_t len_b = b.end_address - b.beginning_address;
if (len_a < len_b) {
return 1;
} else if (len_a > len_b) {
return -1;
}
return 0;
}
void DwarfFile::ArangesCache::sort() {
QuickSort::sort(_entries, _count, compare_aranges_entries);
}
bool DwarfFile::ArangesCache::add_entry(const AddressDescriptor& descriptor, uint32_t debug_info_offset) {
if (_count >= _capacity && !grow()) {
return false;
}
_entries[_count] = ArangesEntry(
descriptor.beginning_address,
descriptor.beginning_address + descriptor.range_length,
debug_info_offset
);
_count++;
return true;
}
bool DwarfFile::ArangesCache::grow() {
size_t new_capacity = _capacity == 0 ? 128 : _capacity * 1.5;
ArangesEntry* new_entries = REALLOC_C_HEAP_ARRAY_RETURN_NULL(ArangesEntry, _entries, new_capacity, mtInternal);
if (new_entries == nullptr) {
return false;
}
_entries = new_entries;
_capacity = new_capacity;
return true;
}
bool DwarfFile::ArangesCache::find_compilation_unit_offset(uint32_t offset_in_library, uint32_t* compilation_unit_offset) const {
if (!_initialized || _entries == nullptr || _count == 0) {
return false;
}
size_t left = 0;
size_t right = _count;
while (left < right) {
size_t mid = left + (right - left) / 2;
const ArangesEntry& entry = _entries[mid];
if (offset_in_library < entry.beginning_address) {
right = mid;
} else if (offset_in_library >= entry.end_address) {
left = mid + 1;
} else {
*compilation_unit_offset = entry.debug_info_offset;
return true;
}
}
return false;
}
// Find the .debug_line offset for the line number program by reading from the .debug_abbrev and .debug_info section.
bool DwarfFile::CompilationUnit::find_debug_line_offset(uint32_t* debug_line_offset) {
// (3a,b)

View File

@@ -72,7 +72,6 @@ typedef Elf32_Sym Elf_Sym;
#include "memory/allocation.hpp"
#include "utilities/checkedCast.hpp"
#include "utilities/decoder.hpp"
#include "utilities/quickSort.hpp"
#ifdef ASSERT
// Helper macros to print different log levels during DWARF parsing
@@ -95,10 +94,10 @@ typedef Elf32_Sym Elf_Sym;
#define DWARF_LOG_TRACE(format, ...)
#endif
class DwarfFile;
class ElfFuncDescTable;
class ElfStringTable;
class ElfSymbolTable;
class ElfFuncDescTable;
class DwarfFile;
// ELF section, may or may not have cached data
class ElfSection {
@@ -202,7 +201,6 @@ class ElfFile: public CHeapObj<mtInternal> {
bool get_source_info(uint32_t offset_in_library, char* filename, size_t filename_len, int* line, bool is_pc_after_call);
DEBUG_ONLY(const char* filepath() const { return _filepath; })
private:
// sanity check, if the file is a real elf file
static bool is_elf_file(Elf_Ehdr&);
@@ -399,6 +397,7 @@ class ElfFile: public CHeapObj<mtInternal> {
* - Complete information about intermediate states/results when parsing the DWARF file.
*/
class DwarfFile : public ElfFile {
static constexpr uint8_t ADDRESS_SIZE = NOT_LP64(4) LP64_ONLY(8);
// We only support 32-bit DWARF (emitted by GCC) which uses 32-bit values for DWARF section lengths and offsets
// relative to the beginning of a section.
@@ -436,63 +435,6 @@ class DwarfFile : public ElfFile {
bool read_non_null_char(char* result);
};
// Address descriptor defining a range that is covered by a compilation unit. It is defined in section 6.1.2 after
// the set header in the DWARF 4 spec.
struct AddressDescriptor {
uintptr_t beginning_address = 0;
uintptr_t range_length = 0;
};
// Entry in ArangesCache, corresponding to an entry in .debug_aranges section.
struct ArangesEntry {
uintptr_t beginning_address;
uintptr_t end_address;
uint32_t debug_info_offset;
ArangesEntry() : beginning_address(0), end_address(0), debug_info_offset(0) {}
ArangesEntry(uintptr_t begin, uintptr_t end, uint32_t offset)
: beginning_address(begin), end_address(end), debug_info_offset(offset) {}
};
// Cache for .debug_aranges to enable binary search for address lookup.
// DebugAranges uses this cache to resolve the compilation_unit_offset, rather than doing a linear scan on the files
// in each invocation of DebugAranges::find_compilation_unit_offset.
struct ArangesCache {
ArangesEntry* _entries;
size_t _count;
size_t _capacity;
bool _initialized;
bool _failed;
ArangesCache() : _entries(nullptr), _count(0), _capacity(0), _initialized(false), _failed(false) {}
ArangesCache(const ArangesCache&) = delete;
ArangesCache& operator=(const ArangesCache&) = delete;
~ArangesCache() {
this->free();
}
void destroy(bool failed) {
this->free();
_count = 0;
_capacity = 0;
_failed = failed;
}
bool find_compilation_unit_offset(uint32_t offset_in_library, uint32_t* compilation_unit_offset) const;
bool valid() const { return _initialized && !_failed; }
bool add_entry(const AddressDescriptor& descriptor, uint32_t debug_info_offset);
void sort();
private:
static int compare_aranges_entries(const ArangesEntry& a, const ArangesEntry& b);
bool grow();
void free() {
if (_entries != nullptr) {
FREE_C_HEAP_ARRAY(ArangesEntry, _entries);
_entries = nullptr;
}
}
};
// (2) Processing the .debug_aranges section to find the compilation unit which covers offset_in_library.
// This is specified in section 6.1.2 of the DWARF 4 spec.
//
@@ -533,22 +475,16 @@ class DwarfFile : public ElfFile {
uint8_t _segment_size;
};
enum class CacheHint {
// Do not retry as linear scan won't be able to read this either.
FAILED,
// Cache is usable, no need to fall back to linear scan.
VALID,
// Cache is unusable, possible reasons are C heap allocation failures. Fall back to linear scan.
TRY_LINEAR_SCAN,
// Address descriptor defining a range that is covered by a compilation unit. It is defined in section 6.1.2 after
// the set header in the DWARF 4 spec.
struct AddressDescriptor {
uintptr_t beginning_address = 0;
uintptr_t range_length = 0;
};
DwarfFile* _dwarf_file;
ArangesCache _cache;
MarkedDwarfFileReader _reader;
uintptr_t _section_start_address;
uintptr_t _size_bytes;
// a calculated end position
long _entry_end;
@@ -563,9 +499,9 @@ class DwarfFile : public ElfFile {
const AddressDescriptor& descriptor);
public:
DebugAranges(DwarfFile* dwarf_file) : _dwarf_file(dwarf_file), _reader(dwarf_file->fd()),
_section_start_address(0), _size_bytes(0), _entry_end(0) {}
_section_start_address(0), _entry_end(0) {}
bool find_compilation_unit_offset(uint32_t offset_in_library, uint32_t* compilation_unit_offset);
CacheHint ensure_cached();
};
// (3a-c,e) The compilation unit is read from the .debug_info section. The structure of .debug_info is shown in the
@@ -948,8 +884,7 @@ class DwarfFile : public ElfFile {
};
public:
DwarfFile(const char* filepath) : ElfFile(filepath), _debug_aranges(this) {
}
DwarfFile(const char* filepath) : ElfFile(filepath) {}
/*
* Starting point of reading line number and filename information from the DWARF file.
@@ -962,9 +897,6 @@ class DwarfFile : public ElfFile {
* More details about the different phases can be found at the associated methods.
*/
bool get_filename_and_line_number(uint32_t offset_in_library, char* filename, size_t filename_len, int* line, bool is_pc_after_call);
private:
DebugAranges _debug_aranges;
};
#endif // !_WINDOWS && !__APPLE__

View File

@@ -0,0 +1,75 @@
/*
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#ifndef _DEFINES_H
#define _DEFINES_H
#include "java.h"
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
/*
* This file contains commonly defined constants used only by main.c
* and should not be included by another file.
*/
#ifndef VERSION_STRING
/* make sure the compilation fails */
#error "VERSION_STRING must be defined"
#endif
/* Unused, but retained for JLI_Launch compatibility*/
#define DOT_VERSION "0.0"
#ifdef JAVA_ARGS
#ifdef PROGNAME
static const char* const_progname = PROGNAME;
#else
static char* const_progname = NULL;
#endif
static const char* const_jargs[] = JAVA_ARGS;
#else /* !JAVA_ARGS */
static const char* const_progname = "java";
static const char** const_jargs = NULL;
#endif /* JAVA_ARGS */
#ifdef LAUNCHER_NAME
static const char* const_launcher = LAUNCHER_NAME;
#else /* LAUNCHER_NAME */
static char* const_launcher = NULL;
#endif /* LAUNCHER_NAME */
#ifdef EXPAND_CLASSPATH_WILDCARDS
static const jboolean const_cpwildcard = JNI_TRUE;
#else
static const jboolean const_cpwildcard = JNI_FALSE;
#endif /* EXPAND_CLASSPATH_WILDCARDS */
#ifdef ENABLE_ARG_FILES
static const jboolean const_disable_argfile = JNI_FALSE;
#else
static const jboolean const_disable_argfile = JNI_TRUE;
#endif
#endif /*_DEFINES_H */

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
* 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,60 +30,10 @@
* tools. The rest of the files will be linked in.
*/
#include "java.h"
#include "defines.h"
#include "jli_util.h"
#include "jni.h"
// Unused, but retained for JLI_Launch compatibility
#define DOT_VERSION "0.0"
// This is reported when requesting a full version
static char* launcher = LAUNCHER_NAME;
// This is used as the name of the executable in the help message
static char* progname = PROGNAME;
#ifdef JAVA_ARGS
static const char* jargs[] = JAVA_ARGS;
#else
static const char** jargs = NULL;
#endif
static int jargc;
static jboolean cpwildcard = CLASSPATH_WILDCARDS;
static jboolean disable_argfile = DISABLE_ARGFILE;
#ifdef STATIC_BUILD
static void check_relauncher_argument(char* arg) {
if (strcmp(arg, "-J-DjavaLauncherWildcards=false") == 0) {
cpwildcard = JNI_FALSE;
}
const char *progname_prefix = "-J-DjavaLauncherProgname=";
size_t progname_prefix_len = strlen(progname_prefix);
if (strncmp(arg, progname_prefix, progname_prefix_len) == 0) {
progname = arg + progname_prefix_len;
}
const char *args_prefix = "-J-DjavaLauncherArgs=";
size_t args_prefix_len = strlen(args_prefix);
if (strncmp(arg, args_prefix, args_prefix_len) == 0) {
char* java_args_ptr = arg + args_prefix_len;
size_t java_args_len = strlen(arg) - args_prefix_len;
JLI_List java_args = JLI_List_new(java_args_len);
char* next_space;
while ((next_space = strchr(java_args_ptr, ' ')) != NULL) {
size_t next_arg_len = next_space - java_args_ptr;
JLI_List_addSubstring(java_args, java_args_ptr, next_arg_len);
java_args_ptr = next_space + 1;
}
JLI_List_add(java_args, java_args_ptr);
jargc = (int) java_args->size;
jargs = (const char**) java_args->elements;
}
}
#endif
/*
* Entry point.
*/
@@ -94,7 +44,7 @@ char **__initenv;
int WINAPI
WinMain(HINSTANCE inst, HINSTANCE previnst, LPSTR cmdline, int cmdshow)
{
const jboolean javaw = JNI_TRUE;
const jboolean const_javaw = JNI_TRUE;
__initenv = _environ;
@@ -102,25 +52,19 @@ WinMain(HINSTANCE inst, HINSTANCE previnst, LPSTR cmdline, int cmdshow)
JNIEXPORT int
main(int argc, char **argv)
{
const jboolean javaw = JNI_FALSE;
const jboolean const_javaw = JNI_FALSE;
#endif /* JAVAW */
int margc;
char** margv;
int jargc;
const char** jargv = const_jargs;
jargc = (sizeof(jargs) / sizeof(char *)) > 1
? sizeof(jargs) / sizeof(char *)
jargc = (sizeof(const_jargs) / sizeof(char *)) > 1
? sizeof(const_jargs) / sizeof(char *)
: 0; // ignore the null terminator index
#ifdef STATIC_BUILD
// Relaunchers always give -J-DjavaLauncherArgFiles as the first argument, if present
// We must check disable_argfile before calling JLI_InitArgProcessing.
if (argc > 1 && strcmp(argv[1], "-J-DjavaLauncherArgFiles=false") == 0) {
disable_argfile = JNI_TRUE;
}
#endif
JLI_InitArgProcessing(jargc > 0, disable_argfile);
JLI_InitArgProcessing(jargc > 0, const_disable_argfile);
#ifdef _WIN32
{
@@ -159,9 +103,6 @@ main(int argc, char **argv)
StdArg *stdargs = JLI_GetStdArgs();
for (i = 0 ; i < margc ; i++) {
margv[i] = stdargs[i].arg;
#ifdef STATIC_BUILD
check_relauncher_argument(margv[i]);
#endif
}
margv[i] = NULL;
}
@@ -186,9 +127,6 @@ main(int argc, char **argv)
}
// Iterate the rest of command line
for (i = 1; i < argc; i++) {
#ifdef STATIC_BUILD
check_relauncher_argument(argv[i]);
#endif
JLI_List argsInFile = JLI_PreprocessArg(argv[i], JNI_TRUE);
if (NULL == argsInFile) {
JLI_List_add(args, JLI_StringDup(argv[i]));
@@ -210,12 +148,12 @@ main(int argc, char **argv)
}
#endif /* WIN32 */
return JLI_Launch(margc, margv,
jargc, jargs,
jargc, jargv,
0, NULL,
VERSION_STRING,
DOT_VERSION,
progname,
launcher,
(const_progname != NULL) ? const_progname : *margv,
(const_launcher != NULL) ? const_launcher : *margv,
jargc > 0,
cpwildcard, javaw, 0);
const_cpwildcard, const_javaw, 0);
}

View File

@@ -1,113 +0,0 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define JAVA_EXECUTABLE_NAME "java"
#ifndef LAUNCHER_ARGS
#error LAUNCHER_ARGS must be defined
#endif
static char *launcher_args[] = LAUNCHER_ARGS;
int main(int argc, char *argv[]) {
////////////////////////////////////////////////////////////////////////////
// Create a fully qualified path to the java executable in the same
// directory as this file resides in.
char *our_full_path = realpath(argv[0], NULL);
if (our_full_path == NULL) {
perror("failed to get the full path of the executable");
return 1;
}
char *last_slash_pos = strrchr(our_full_path, '/');
if (last_slash_pos == NULL) {
fprintf(stderr, "no '/' found in the full path of the executable\n");
return 1;
}
size_t base_length = last_slash_pos - our_full_path + 1;
size_t java_path_length = base_length + strlen(JAVA_EXECUTABLE_NAME) + 1;
char *java_path = malloc(java_path_length);
if (java_path == NULL) {
perror("malloc failed");
return 1;
}
memcpy(java_path, our_full_path, base_length);
strcpy(java_path + base_length, JAVA_EXECUTABLE_NAME);
////////////////////////////////////////////////////////////////////////////
// Build the argument list: our executable name + launcher args + users args
int launcher_argsc = sizeof(launcher_args) / sizeof(char *);
char **java_args = malloc((launcher_argsc + argc + 1) * sizeof(char *));
if (java_args == NULL) {
perror("malloc failed");
return 1;
}
// Our executable name
java_args[0] = argv[0];
// Launcher arguments
for (int i = 0; i < launcher_argsc; i++) {
java_args[i + 1] = launcher_args[i];
}
// User arguments
for (int i = 1; i < argc; i++) {
java_args[launcher_argsc + i] = argv[i];
}
java_args[launcher_argsc + argc] = NULL;
////////////////////////////////////////////////////////////////////////////
// Finally execute the real java process with the constructed arguments
if (getenv("_JAVA_LAUNCHER_DEBUG")) {
char *program_name = basename(argv[0]);
fprintf(stderr, "%s: executing: '%s'", program_name, java_path);
for (int i = 0; java_args[i] != NULL; i++) {
fprintf(stderr, " '%s' ", java_args[i]);
}
fprintf(stderr, "\n");
}
execv(java_path, java_args);
// Should not reach here, unless something went wrong
perror("execv failed");
return 1;
}

View File

@@ -322,9 +322,6 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
char jdkroot[], jint so_jdkroot,
char jvmpath[], jint so_jvmpath,
char jvmcfg[], jint so_jvmcfg) {
/* Compute/set the name of the executable */
SetExecname(*pargv);
if (JLI_IsStaticallyLinked()) {
// With static builds, all JDK and VM natives are statically linked
// with the launcher executable. No need to manipulate LD_LIBRARY_PATH
@@ -346,6 +343,9 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
size_t new_runpath_size;
#endif /* SETENV_REQUIRED */
/* Compute/set the name of the executable */
SetExecname(*pargv);
/* Check to see if the jvmpath exists */
/* Find out where the JDK is that we will be using. */
if (!GetJDKInstallRoot(jdkroot, so_jdkroot, JNI_FALSE)) {

View File

@@ -1,246 +0,0 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include <shlwapi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#define JAVA_EXECUTABLE_NAME "java.exe"
#ifndef LAUNCHER_ARGS
#error LAUNCHER_ARGS must be defined
#endif
static char* launcher_args[] = LAUNCHER_ARGS;
char* quote_argument(char* arg) {
// See https://learn.microsoft.com/en-us/archive/blogs/twistylittlepassagesallalike/everyone-quotes-command-line-arguments-the-wrong-way
// for an explanation of how to properly quote command lines for CreateProcess
size_t arg_length = strlen(arg);
if (strcspn(arg, " \t\n\v\"") == arg_length) {
// No quoting is needed
return arg;
}
// Worst-case buffer size: all characters need a backslash, and starting + end quotes
size_t buffer_size = arg_length * 2 + 3;
char* buffer = malloc(buffer_size);
if (buffer == NULL) {
return NULL;
}
int backslashes = 0;
char* write_pos = buffer;
char* read_pos = arg;
// Start with a quote character
*write_pos++ = '"';
while (*read_pos) {
while (*read_pos == '\\') {
read_pos++;
backslashes++;
}
if (*read_pos == '"') {
// Any potential backslashes before a quote needs to be doubled,
// and the quote needs to be escaped with an additional backslash
for (int i = 0; i < backslashes * 2 + 1; i++) {
*write_pos++ = '\\';
}
*write_pos++ = *read_pos++;
backslashes = 0;
} else {
// Backslashes not preceeding a quote are copied without escaping
for (int i = 0; i < backslashes; i++) {
*write_pos++ = '\\';
}
if (*read_pos) {
*write_pos++ = *read_pos++;
backslashes = 0;
}
}
}
// If the string ended with backslashes, they need to be doubled before
// the final quote character
for (int i = 0; i < backslashes; i++) {
*write_pos++ = '\\';
}
*write_pos++ = '"';
*write_pos = '\0';
return buffer;
}
int main(int argc, char* argv[]) {
////////////////////////////////////////////////////////////////////////////
// Create a fully qualified path to the java executable in the same
// directory as this file resides in.
// Calculate path length first
DWORD our_full_path_len = GetFullPathName(argv[0], 0, NULL, NULL);
if (our_full_path_len == 0) {
fprintf(stderr, "failed to get the full path of the executable: %lu\n", GetLastError());
return 1;
}
char* our_full_path = malloc(our_full_path_len + 1);
if (our_full_path == NULL) {
perror("malloc failed");
return 1;
}
if (GetFullPathName(argv[0], our_full_path_len + 1, our_full_path, NULL) == 0) {
fprintf(stderr, "failed to get the full path of the executable: %lu\n", GetLastError());
return 1;
}
char *last_slash_pos = strrchr(our_full_path, '\\');
if (last_slash_pos == NULL) {
fprintf(stderr, "no '\\' found in the full path of the executable\n");
return 1;
}
size_t base_length = last_slash_pos - our_full_path + 1;
size_t java_path_length = base_length + strlen(JAVA_EXECUTABLE_NAME) + 1;
char *java_path = malloc(java_path_length);
if (java_path == NULL) {
perror("malloc failed");
return 1;
}
memcpy(java_path, our_full_path, base_length);
strcpy(java_path + base_length, JAVA_EXECUTABLE_NAME);
////////////////////////////////////////////////////////////////////////////
// Build the argument list: our executable name + launcher args + users args
int launcher_argsc = sizeof(launcher_args) / sizeof(char *);
char **java_args = malloc((launcher_argsc + argc + 1) * sizeof(char *));
if (java_args == NULL) {
perror("malloc failed");
return 1;
}
// Our executable name
java_args[0] = quote_argument(argv[0]);
if (java_args[0] == NULL) {
perror("malloc failed");
return 1;
}
// Launcher arguments
for (int i = 0; i < launcher_argsc; i++) {
char* quoted = quote_argument(launcher_args[i]);
if (quoted == NULL) {
perror("malloc failed");
return 1;
}
java_args[i + 1] = quoted;
}
// User arguments
for (int i = 1; i < argc; i++) {
char* quoted = quote_argument(argv[i]);
if (quoted == NULL) {
perror("malloc failed");
return 1;
}
java_args[launcher_argsc + i] = quoted;
}
java_args[launcher_argsc + argc] = NULL;
// Windows needs the command line as a single string, not as an array of char*
size_t total_length = 0;
for (int i = 0; java_args[i] != NULL; i++) {
char* arg = java_args[i];
total_length += strlen(java_args[i]) + 1;
}
char* command_line = malloc(total_length);
if (command_line == NULL) {
perror("malloc failed");
return 1;
}
// Concatenate the quoted arguments with a space between them
char* write_pos = command_line;
for (int i = 0; java_args[i] != NULL; i++) {
size_t arg_len = strlen(java_args[i]);
memcpy(write_pos, java_args[i], arg_len);
write_pos += arg_len;
// Append a space
*write_pos++ = ' ';
}
// Replace the last space with a null terminator
write_pos--;
*write_pos = '\0';
////////////////////////////////////////////////////////////////////////////
// Finally execute the real java process with the constructed arguments
if (GetEnvironmentVariable("_JAVA_LAUNCHER_DEBUG", NULL, 0)) {
char *program_name = PathFindFileName(argv[0]);
fprintf(stderr, "%s: executing: '%s' '%s'\n", program_name, java_path, command_line);
}
STARTUPINFO si;
PROCESS_INFORMATION pi;
memset(&si, 0, sizeof(si));
memset(&pi, 0, sizeof(pi));
// Windows has no equivalent of exec, so start the process and wait for it
// to finish, to be able to return the same exit code
if (!CreateProcess(java_path, command_line, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
fprintf(stderr, "CreateProcess failed: %lu\n", GetLastError());
return 1;
}
if (WaitForSingleObject(pi.hProcess, INFINITE) == WAIT_FAILED) {
fprintf(stderr, "WaitForSingleObject failed: %lu\n", GetLastError());
return 1;
}
DWORD exit_code;
if (!GetExitCodeProcess(pi.hProcess, &exit_code)) {
fprintf(stderr, "GetExitCodeProcess failed: %lu\n", GetLastError());
return 1;
}
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return exit_code;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -78,7 +78,6 @@ public final class Application {
private static final PlatformLogger focusRequestLog = PlatformLogger.getLogger("jb.focus.requests");
private static native void nativeInitializeApplicationDelegate();
private static native void nativeInstallOpenURLEventHandler();
static Application sApplication = null;
@@ -215,7 +214,6 @@ public final class Application {
* @since Java for Mac OS X 10.5 Update 8
*/
public void setOpenURIHandler(final OpenURIHandler openURIHandler) {
nativeInstallOpenURLEventHandler();
eventHandler.openURIDispatcher.setHandler(openURIHandler);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,6 @@
BOOL fHandlesDocumentTypes;
BOOL fHandlesURLTypes;
BOOL fOpenURLHandlerInstalled;
}
@property (nonatomic, retain) NSMenuItem *fPreferencesMenu;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -244,9 +244,11 @@ AWT_ASSERT_APPKIT_THREAD;
NSBundle *bundle = [NSBundle mainBundle];
fHandlesDocumentTypes = [bundle objectForInfoDictionaryKey:@"CFBundleDocumentTypes"] != nil || [bundle _hasEAWTOverride:@"DocumentHandler"];
fHandlesURLTypes = [bundle objectForInfoDictionaryKey:@"CFBundleURLTypes"] != nil || [bundle _hasEAWTOverride:@"URLHandler"];
fOpenURLHandlerInstalled = NO;
if (fHandlesURLTypes) {
[self _installOpenURLHandler];
[[NSAppleEventManager sharedAppleEventManager] setEventHandler:self
andSelector:@selector(_handleOpenURLEvent:withReplyEvent:)
forEventClass:kInternetEventClass
andEventID:kAEGetURL];
}
// By HIG, Preferences are not available unless there is a handler. By default in Mac OS X,
@@ -306,19 +308,9 @@ static jclass sjc_AppEventHandler = NULL;
#define GET_APPEVENTHANDLER_CLASS_RETURN(ret) \
GET_CLASS_RETURN(sjc_AppEventHandler, "com/apple/eawt/_AppEventHandler", ret);
- (void)_installOpenURLHandler {
AWT_ASSERT_APPKIT_THREAD;
if (fOpenURLHandlerInstalled) return;
[[NSAppleEventManager sharedAppleEventManager] setEventHandler:self
andSelector:@selector(_handleOpenURLEvent:withReplyEvent:)
forEventClass:kInternetEventClass
andEventID:kAEGetURL];
fOpenURLHandlerInstalled = YES;
}
- (void)_handleOpenURLEvent:(NSAppleEventDescriptor *)openURLEvent withReplyEvent:(NSAppleEventDescriptor *)replyEvent {
if (!fHandlesURLTypes) return;
NSString *url = [[openURLEvent paramDescriptorForKeyword:keyDirectObject] stringValue];
[ApplicationDelegate _openURL:url];
@@ -648,24 +640,6 @@ JNI_COCOA_ENTER(env);
JNI_COCOA_EXIT(env);
}
/*
* Class: com_apple_eawt_Application
* Method: nativeInstallOpenURLEventHandler
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_com_apple_eawt_Application_nativeInstallOpenURLEventHandler
(JNIEnv *env, jclass clz)
{
JNI_COCOA_ENTER(env);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
ApplicationDelegate *delegate = [ApplicationDelegate sharedDelegate];
if (delegate != nil) {
[delegate _installOpenURLHandler];
}
}];
JNI_COCOA_EXIT(env);
}
/*
* Class: com_apple_eawt__AppEventHandler
* Method: nativeOpenCocoaAboutWindow

View File

@@ -46,8 +46,6 @@ public abstract class PrintJob {
* The page is sent to the printer when the graphics
* object is disposed. This graphics object will also implement
* the PrintGraphics interface.
* If {@code PrintJob.end()} has been called, this method will
* return {@code null}.
* @see PrintGraphics
* @return the graphics context for printing the next page
*/

View File

@@ -808,7 +808,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp {
idx = 0;
for (int x = 0; x < w; x++) {
pixel = srcRas.getDataElements(x, y, pixel);
color = srcCM.getNormalizedComponents(pixel, null, 0);
color = srcCM.getNormalizedComponents(pixel, color, 0);
if (needSrcAlpha) {
alpha[x] = color[srcNumComp];
}

View File

@@ -206,7 +206,7 @@ public class ByteInterleavedRaster extends ByteComponentRaster {
this.pixelStride = csm.getPixelStride();
this.dataOffsets = csm.getBandOffsets();
for (int i = 0; i < getNumDataElements(); i++) {
dataOffsets[i] += dataBuffer.getOffset() + xOffset*pixelStride+yOffset*scanlineStride;
dataOffsets[i] += xOffset*pixelStride+yOffset*scanlineStride;
}
} else if (sampleModel instanceof SinglePixelPackedSampleModel) {
SinglePixelPackedSampleModel sppsm =
@@ -227,7 +227,7 @@ public class ByteInterleavedRaster extends ByteComponentRaster {
}
this.bandOffset = this.dataOffsets[0];
this.dbOffsetPacked = -
this.dbOffsetPacked = dataBuffer.getOffset() -
sampleModelTranslateY*scanlineStride -
sampleModelTranslateX*pixelStride;
this.dbOffset = dbOffsetPacked -

View File

@@ -343,7 +343,6 @@ public class GifImageDecoder extends ImageDecoder {
private short[] prefix = new short[4096];
private byte[] suffix = new byte[4096];
private byte[] outCode = new byte[4097];
private boolean isSavedModelReliable = true;
private static native void initIDs();
@@ -397,7 +396,7 @@ public class GifImageDecoder extends ImageDecoder {
int off = y * global_width + x2;
boolean save = (curframe.disposal_method == GifFrame.DISPOSAL_SAVE);
if (trans_pixel >= 0 && !curframe.initialframe) {
if (saved_image != null && model.equals(saved_model) && isSavedModelReliable) {
if (saved_image != null && model.equals(saved_model)) {
for (int i = rasbeg; i < rasend; i++, off++) {
byte pixel = rasline[i];
if ((pixel & 0xff) == trans_pixel) {
@@ -407,8 +406,6 @@ public class GifImageDecoder extends ImageDecoder {
}
}
} else {
isSavedModelReliable = false;
// We have to do this the hard way - only transmit
// the non-transparent sections of the line...
// Fix for 6301050: the interlacing is ignored in this case
@@ -600,7 +597,6 @@ public class GifImageDecoder extends ImageDecoder {
}
return false;
}
boolean ret = parseImage(x, y, width, height,
interlace, initCodeSize,
block, rasline, model);

View File

@@ -317,14 +317,42 @@ public final class FcFontConfiguration extends FontConfiguration {
return;
}
try {
File f = new File("/etc/os-release");
if (f.canRead()) {
File f;
if ((f = new File("/etc/lsb-release")).canRead()) {
/* Ubuntu and (perhaps others) use only lsb-release.
* Syntax and encoding is compatible with java properties.
* For Ubuntu the ID is "Ubuntu".
*/
Properties props = new Properties();
try (FileInputStream fis = new FileInputStream(f)) {
props.load(fis);
}
osName = extractInfo(props.getProperty("DISTRIB_ID"));
osVersion = extractInfo(props.getProperty("DISTRIB_RELEASE"));
} else if ((f = new File("/etc/redhat-release")).canRead()) {
osName = "RedHat";
osVersion = getVersionString(f);
} else if ((f = new File("/etc/SuSE-release")).canRead()) {
osName = "SuSE";
osVersion = getVersionString(f);
} else if ((f = new File("/etc/turbolinux-release")).canRead()) {
osName = "Turbo";
osVersion = getVersionString(f);
} else if ((f = new File("/etc/fedora-release")).canRead()) {
osName = "Fedora";
osVersion = getVersionString(f);
} else if ((f = new File("/etc/os-release")).canRead()) {
Properties props = new Properties();
try (FileInputStream fis = new FileInputStream(f)) {
props.load(fis);
}
osName = extractInfo(props.getProperty("ID"));
osName = extractInfo(props.getProperty("NAME"));
osVersion = extractInfo(props.getProperty("VERSION_ID"));
if (osName.equals("SLES")) {
osName = "SuSE";
} else {
osName = extractInfo(props.getProperty("ID"));
}
}
} catch (Exception e) {
if (FontUtilities.debugFonts()) {

View File

@@ -91,14 +91,42 @@ public final class MFontConfiguration extends FontConfiguration {
if (osName.equals("Linux")) {
try {
File f = new File("/etc/os-release");
if (f.canRead()) {
File f;
if ((f = new File("/etc/fedora-release")).canRead()) {
osName = "Fedora";
osVersion = getVersionString(f);
} else if ((f = new File("/etc/redhat-release")).canRead()) {
osName = "RedHat";
osVersion = getVersionString(f);
} else if ((f = new File("/etc/turbolinux-release")).canRead()) {
osName = "Turbo";
osVersion = getVersionString(f);
} else if ((f = new File("/etc/SuSE-release")).canRead()) {
osName = "SuSE";
osVersion = getVersionString(f);
} else if ((f = new File("/etc/lsb-release")).canRead()) {
/* Ubuntu and (perhaps others) use only lsb-release.
* Syntax and encoding is compatible with java properties.
* For Ubuntu the ID is "Ubuntu".
*/
Properties props = new Properties();
try (FileInputStream fis = new FileInputStream(f)) {
props.load(fis);
}
osName = extractInfo(props.getProperty("ID"));
osName = extractInfo(props.getProperty("DISTRIB_ID"));
osVersion = extractInfo(props.getProperty("DISTRIB_RELEASE"));
} else if ((f = new File("/etc/os-release")).canRead()) {
Properties props = new Properties();
try (FileInputStream fis = new FileInputStream(f)) {
props.load(fis);
}
osName = extractInfo(props.getProperty("NAME"));
osVersion = extractInfo(props.getProperty("VERSION_ID"));
if (osName.equals("SLES")) {
osName = "SuSE";
} else {
osName = extractInfo(props.getProperty("ID"));
}
}
} catch (Exception e) {
}

View File

@@ -929,35 +929,35 @@ public final class WPrinterJob extends RasterPrinterJob
* Return the Window's device context that we are printing
* into.
*/
private synchronized long getPrintDC() {
private long getPrintDC() {
return handleRecord.mPrintDC;
}
private synchronized void setPrintDC(long mPrintDC) {
private void setPrintDC(long mPrintDC) {
handleRecord.mPrintDC = mPrintDC;
}
private synchronized long getDevMode() {
private long getDevMode() {
return handleRecord.mPrintHDevMode;
}
private synchronized void setDevMode(long mPrintHDevMode) {
private void setDevMode(long mPrintHDevMode) {
handleRecord.mPrintHDevMode = mPrintHDevMode;
}
private synchronized long getDevNames() {
private long getDevNames() {
return handleRecord.mPrintHDevNames;
}
private synchronized void setDevNames(long mPrintHDevNames) {
private void setDevNames(long mPrintHDevNames) {
handleRecord.mPrintHDevNames = mPrintHDevNames;
}
protected synchronized void beginPath() {
protected void beginPath() {
beginPath(getPrintDC());
}
protected synchronized void endPath() {
protected void endPath() {
endPath(getPrintDC());
}
@@ -972,23 +972,23 @@ public final class WPrinterJob extends RasterPrinterJob
setGraphicsMode(graphicsMode);
}
protected synchronized void closeFigure() {
protected void closeFigure() {
closeFigure(getPrintDC());
}
protected synchronized void fillPath() {
protected void fillPath() {
fillPath(getPrintDC());
}
protected synchronized void moveTo(float x, float y) {
protected void moveTo(float x, float y) {
moveTo(getPrintDC(), x, y);
}
protected synchronized void lineTo(float x, float y) {
protected void lineTo(float x, float y) {
lineTo(getPrintDC(), x, y);
}
protected synchronized void polyBezierTo(float control1x, float control1y,
protected void polyBezierTo(float control1x, float control1y,
float control2x, float control2y,
float endX, float endY) {
@@ -1003,14 +1003,14 @@ public final class WPrinterJob extends RasterPrinterJob
* be one of the following Windows constants:
* {@code ALTERNATE} or {@code WINDING}.
*/
protected synchronized void setPolyFillMode(int fillRule) {
protected void setPolyFillMode(int fillRule) {
setPolyFillMode(getPrintDC(), fillRule);
}
/**
* Set the GDI graphics mode to {@code GM_ADVANCED}.
*/
private synchronized int setAdvancedGraphicsMode() {
private int setAdvancedGraphicsMode() {
return setAdvancedGraphicsMode(getPrintDC());
}
@@ -1020,28 +1020,28 @@ public final class WPrinterJob extends RasterPrinterJob
* be one of the following Windows constants:
* {@code GM_COMPATIBLE} or {@code GM_ADVANCED}.
*/
private synchronized void setGraphicsMode(int mode) {
private void setGraphicsMode(int mode) {
setGraphicsMode(getPrintDC(), mode);
}
/**
* Scale the GDI World Transform.
*/
private synchronized void scale(double scaleX, double scaleY) {
private void scale(double scaleX, double scaleY) {
scale(getPrintDC(), scaleX, scaleY);
}
/**
* Get the GDI World Transform.
*/
private synchronized void getWorldTransform(double[] transform) {
private void getWorldTransform(double[] transform) {
getWorldTransform(getPrintDC(), transform);
}
/**
* Set the GDI World Transform.
*/
private synchronized void setWorldTransform(double[] transform) {
private void setWorldTransform(double[] transform) {
setWorldTransform(getPrintDC(), transform);
}
@@ -1051,7 +1051,7 @@ public final class WPrinterJob extends RasterPrinterJob
* is created, select it in the current printing device
* context and free the old brush.
*/
protected synchronized void selectSolidBrush(Color color) {
protected void selectSolidBrush(Color color) {
/* We only need to select a brush if the color has changed.
*/
@@ -1070,7 +1070,7 @@ public final class WPrinterJob extends RasterPrinterJob
* Return the x coordinate of the current pen
* position in the print device context.
*/
protected synchronized int getPenX() {
protected int getPenX() {
return getPenX(getPrintDC());
}
@@ -1080,7 +1080,7 @@ public final class WPrinterJob extends RasterPrinterJob
* Return the y coordinate of the current pen
* position in the print device context.
*/
protected synchronized int getPenY() {
protected int getPenY() {
return getPenY(getPrintDC());
}
@@ -1089,16 +1089,16 @@ public final class WPrinterJob extends RasterPrinterJob
* Set the current path in the printer device's
* context to be clipping path.
*/
protected synchronized void selectClipPath() {
protected void selectClipPath() {
selectClipPath(getPrintDC());
}
protected synchronized void frameRect(float x, float y, float width, float height) {
protected void frameRect(float x, float y, float width, float height) {
frameRect(getPrintDC(), x, y, width, height);
}
protected synchronized void fillRect(float x, float y, float width, float height,
protected void fillRect(float x, float y, float width, float height,
Color color) {
float[] rgb = color.getRGBColorComponents(null);
@@ -1109,7 +1109,7 @@ public final class WPrinterJob extends RasterPrinterJob
}
protected synchronized void selectPen(float width, Color color) {
protected void selectPen(float width, Color color) {
float[] rgb = color.getRGBColorComponents(null);
@@ -1120,7 +1120,7 @@ public final class WPrinterJob extends RasterPrinterJob
}
protected synchronized boolean selectStylePen(int cap, int join, float width,
protected boolean selectStylePen(int cap, int join, float width,
Color color) {
long endCap;
@@ -1152,7 +1152,7 @@ public final class WPrinterJob extends RasterPrinterJob
* Set a GDI font capable of drawing the java Font
* passed in.
*/
protected synchronized boolean setFont(String family, float size, int style,
protected boolean setFont(String family, float size, int style,
int rotation, float awScale) {
if (family.isEmpty()) {
@@ -1187,7 +1187,7 @@ public final class WPrinterJob extends RasterPrinterJob
/**
* Set the GDI color for text drawing.
*/
protected synchronized void setTextColor(Color color) {
protected void setTextColor(Color color) {
/* We only need to select a brush if the color has changed.
*/
@@ -1206,7 +1206,7 @@ public final class WPrinterJob extends RasterPrinterJob
* Draw the string {@code text} to the printer's
* device context at the specified position.
*/
protected synchronized void textOut(String str, float x, float y,
protected void textOut(String str, float x, float y,
float[] positions) {
/* Don't leave handling of control chars to GDI.
* If control chars are removed, 'positions' isn't valid.
@@ -1226,7 +1226,7 @@ public final class WPrinterJob extends RasterPrinterJob
* Draw the glyphs {@code glyphs} to the printer's
* device context at the specified position.
*/
protected synchronized void glyphsOut(int []glyphs, float x, float y,
protected void glyphsOut(int []glyphs, float x, float y,
float[] positions) {
/* TrueType glyph codes are 16 bit values, so can be packed
@@ -1254,7 +1254,7 @@ public final class WPrinterJob extends RasterPrinterJob
* rendering so also remove them for measurement so that
* this measurement can be properly compared with JDK measurement.
*/
protected synchronized int getGDIAdvance(String text) {
protected int getGDIAdvance(String text) {
/* Don't leave handling of control chars to GDI. */
text = removeControlChars(text);
if (text.length() == 0) {
@@ -1275,7 +1275,7 @@ public final class WPrinterJob extends RasterPrinterJob
* by {@code srcX}, {@code srcY},
* {@code srcWidth}, and srcHeight.
*/
protected synchronized void drawImage3ByteBGR(byte[] image,
protected void drawImage3ByteBGR(byte[] image,
float destX, float destY,
float destWidth, float destHeight,
float srcX, float srcY,
@@ -1306,7 +1306,7 @@ public final class WPrinterJob extends RasterPrinterJob
* There's no alignment problem as GDI expects this to be packed
* and each struct will start on a 4 byte boundary anyway.
*/
protected synchronized void drawDIBImage(byte[] image,
protected void drawDIBImage(byte[] image,
float destX, float destY,
float destWidth, float destHeight,
float srcX, float srcY,
@@ -1338,7 +1338,7 @@ public final class WPrinterJob extends RasterPrinterJob
* Begin a new page.
*/
@Override
protected synchronized void startPage(PageFormat format, Printable painter,
protected void startPage(PageFormat format, Printable painter,
int index, boolean paperChanged) {
/* Invalidate any device state caches we are
@@ -1355,7 +1355,7 @@ public final class WPrinterJob extends RasterPrinterJob
* End a page.
*/
@Override
protected synchronized void endPage(PageFormat format, Printable painter,
protected void endPage(PageFormat format, Printable painter,
int index) {
deviceEndPage(format, painter, index);
@@ -1402,7 +1402,7 @@ public final class WPrinterJob extends RasterPrinterJob
* is reflected back up to Java code
*/
@Override
protected synchronized native void initPrinter();
protected native void initPrinter();
/**
* Call Window's StartDoc routine to begin a
@@ -1415,10 +1415,10 @@ public final class WPrinterJob extends RasterPrinterJob
* user may cancel out of it. Note that the implementation of
* cancel() throws PrinterAbortException to indicate the user cancelled.
*/
private synchronized native boolean _startDoc(String dest, String jobName)
private native boolean _startDoc(String dest, String jobName)
throws PrinterException;
@Override
protected synchronized void startDoc() throws PrinterException {
protected void startDoc() throws PrinterException {
if (!_startDoc(mDestination, getJobName())) {
cancel();
}
@@ -1429,31 +1429,31 @@ public final class WPrinterJob extends RasterPrinterJob
* print job.
*/
@Override
protected synchronized native void endDoc();
protected native void endDoc();
/**
* Call Window's AbortDoc routine to abort a
* print job.
*/
@Override
protected synchronized native void abortDoc();
protected native void abortDoc();
/**
* Call Windows native resource freeing APIs
*/
private static synchronized native void deleteDC(long dc, long devmode, long devnames);
private static native void deleteDC(long dc, long devmode, long devnames);
/**
* Begin a new page. This call's Window's
* StartPage routine.
*/
protected synchronized native void deviceStartPage(PageFormat format, Printable painter,
protected native void deviceStartPage(PageFormat format, Printable painter,
int index, boolean paperChanged);
/**
* End a page. This call's Window's EndPage
* routine.
*/
protected synchronized native void deviceEndPage(PageFormat format, Printable painter,
protected native void deviceEndPage(PageFormat format, Printable painter,
int index);
/**
@@ -1464,46 +1464,46 @@ public final class WPrinterJob extends RasterPrinterJob
* specified by the caller.
*/
@Override
protected synchronized native void printBand(byte[] data, int x, int y,
protected native void printBand(byte[] data, int x, int y,
int width, int height);
/**
* Begin a Window's rendering path in the device
* context {@code printDC}.
*/
protected synchronized native void beginPath(long printDC);
protected native void beginPath(long printDC);
/**
* End a Window's rendering path in the device
* context {@code printDC}.
*/
protected synchronized native void endPath(long printDC);
protected native void endPath(long printDC);
/**
* Close a subpath in a Window's rendering path in the device
* context {@code printDC}.
*/
protected synchronized native void closeFigure(long printDC);
protected native void closeFigure(long printDC);
/**
* Fill a defined Window's rendering path in the device
* context {@code printDC}.
*/
protected synchronized native void fillPath(long printDC);
protected native void fillPath(long printDC);
/**
* Move the Window's pen position to {@code (x,y)}
* in the device context {@code printDC}.
*/
protected synchronized native void moveTo(long printDC, float x, float y);
protected native void moveTo(long printDC, float x, float y);
/**
* Draw a line from the current pen position to
* {@code (x,y)} in the device context {@code printDC}.
*/
protected synchronized native void lineTo(long printDC, float x, float y);
protected native void lineTo(long printDC, float x, float y);
protected synchronized native void polyBezierTo(long printDC,
protected native void polyBezierTo(long printDC,
float control1x, float control1y,
float control2x, float control2y,
float endX, float endY);
@@ -1514,13 +1514,13 @@ public final class WPrinterJob extends RasterPrinterJob
* be one of the following Windows constants:
* {@code ALTERNATE} or {@code WINDING}.
*/
protected synchronized native void setPolyFillMode(long printDC, int fillRule);
protected native void setPolyFillMode(long printDC, int fillRule);
/**
* Set the GDI graphics mode to {@code GM_ADVANCED}
* into the device context {@code printDC}.
*/
protected synchronized native int setAdvancedGraphicsMode(long printDC);
protected native int setAdvancedGraphicsMode(long printDC);
/**
* Set the GDI graphics {@code mode}
@@ -1529,25 +1529,25 @@ public final class WPrinterJob extends RasterPrinterJob
* be one of the following Windows constants:
* {@code GM_COMPATIBLE} or {@code GM_ADVANCED}.
*/
protected synchronized native void setGraphicsMode(long printDC, int mode);
protected native void setGraphicsMode(long printDC, int mode);
/**
* Scale the GDI World Transform
* of the device context {@code printDC}.
*/
protected synchronized native void scale(long printDC, double scaleX, double scaleY);
protected native void scale(long printDC, double scaleX, double scaleY);
/**
* Get the GDI World Transform
* from the device context {@code printDC}.
*/
protected synchronized native void getWorldTransform(long printDC, double[] transform);
protected native void getWorldTransform(long printDC, double[] transform);
/**
* Set the GDI World Transform
* into the device context {@code printDC}.
*/
protected synchronized native void setWorldTransform(long printDC, double[] transform);
protected native void setWorldTransform(long printDC, double[] transform);
/**
* Create a Window's solid brush for the color specified
@@ -1555,7 +1555,7 @@ public final class WPrinterJob extends RasterPrinterJob
* is created, select it in the device
* context {@code printDC} and free the old brush.
*/
protected synchronized native void selectSolidBrush(long printDC,
protected native void selectSolidBrush(long printDC,
int red, int green, int blue);
/**
@@ -1563,32 +1563,32 @@ public final class WPrinterJob extends RasterPrinterJob
* position in the device context
* {@code printDC}.
*/
protected synchronized native int getPenX(long printDC);
protected native int getPenX(long printDC);
/**
* Return the y coordinate of the current pen
* position in the device context
* {@code printDC}.
*/
protected synchronized native int getPenY(long printDC);
protected native int getPenY(long printDC);
/**
* Select the device context's current path
* to be the clipping path.
*/
protected synchronized native void selectClipPath(long printDC);
protected native void selectClipPath(long printDC);
/**
* Draw a rectangle using specified brush.
*/
protected synchronized native void frameRect(long printDC, float x, float y,
protected native void frameRect(long printDC, float x, float y,
float width, float height);
/**
* Fill a rectangle specified by the coordinates using
* specified brush.
*/
protected synchronized native void fillRect(long printDC, float x, float y,
protected native void fillRect(long printDC, float x, float y,
float width, float height,
int red, int green, int blue);
@@ -1596,14 +1596,14 @@ public final class WPrinterJob extends RasterPrinterJob
* Create a solid brush using the RG & B colors and width.
* Select this brush and delete the old one.
*/
protected synchronized native void selectPen(long printDC, float width,
protected native void selectPen(long printDC, float width,
int red, int green, int blue);
/**
* Create a solid brush using the RG & B colors and specified
* pen styles. Select this created brush and delete the old one.
*/
protected synchronized native boolean selectStylePen(long printDC, long cap,
protected native boolean selectStylePen(long printDC, long cap,
long join, float width,
int red, int green, int blue);
@@ -1611,7 +1611,7 @@ public final class WPrinterJob extends RasterPrinterJob
* Set a GDI font capable of drawing the java Font
* passed in.
*/
protected synchronized native boolean setFont(long printDC, String familyName,
protected native boolean setFont(long printDC, String familyName,
float fontSize,
boolean bold,
boolean italic,
@@ -1622,7 +1622,7 @@ public final class WPrinterJob extends RasterPrinterJob
/**
* Set the GDI color for text drawing.
*/
protected synchronized native void setTextColor(long printDC,
protected native void setTextColor(long printDC,
int red, int green, int blue);
@@ -1631,12 +1631,12 @@ public final class WPrinterJob extends RasterPrinterJob
* context {@code printDC} at the specified
* position.
*/
protected synchronized native void textOut(long printDC, String text,
protected native void textOut(long printDC, String text,
int strlen, boolean glyphs,
float x, float y, float[] positions);
private synchronized native int getGDIAdvance(long printDC, String text);
private native int getGDIAdvance(long printDC, String text);
/**
* Draw the DIB compatible image buffer represented by
@@ -1653,7 +1653,7 @@ public final class WPrinterJob extends RasterPrinterJob
* At the very least it needs to be padded so each scanline is
* DWORD aligned. Also we "flip" the image to make it a bottom-up DIB.
*/
private synchronized native void drawDIBImage(long printDC, byte[] image,
private native void drawDIBImage(long printDC, byte[] image,
float destX, float destY,
float destWidth, float destHeight,
float srcX, float srcY,

View File

@@ -1523,7 +1523,6 @@ Java_sun_awt_windows_WPrinterJob_endDoc(JNIEnv *env, jobject self) {
if (printDC != NULL){
SAVE_CONTROLWORD
::EndDoc(printDC);
AwtPrintControl::setPrintDC(env, self, (HDC)NULL);
RESTORE_CONTROLWORD
}
@@ -1584,9 +1583,7 @@ Java_sun_awt_windows_WPrinterJob_deleteDC
TRY_NO_VERIFY;
if ((HDC)dc != NULL) {
DeletePrintDC((HDC)dc);
}
DeletePrintDC((HDC)dc);
if ((HGLOBAL)devmode != NULL){
::GlobalFree((HGLOBAL)devmode);
@@ -1853,9 +1850,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_printBand
jint width, jint height) {
HDC printDC = AwtPrintControl::getPrintDC(env, self);
if ((HDC)printDC == NULL) {
return;
}
doPrintBand(env, printDC, imageArray, x, y, width, height);
}
@@ -1868,10 +1862,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_beginPath
(JNIEnv *env , jobject self, jlong printDC) {
TRY;
if ((HDC)printDC == NULL) {
return;
}
(void) ::BeginPath((HDC)printDC);
CATCH_BAD_ALLOC;
@@ -1886,10 +1876,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_endPath
(JNIEnv *env, jobject self, jlong printDC) {
TRY;
if ((HDC)printDC == NULL) {
return;
}
(void) ::EndPath((HDC)printDC);
CATCH_BAD_ALLOC;
@@ -1904,10 +1890,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_fillPath
(JNIEnv *env, jobject self, jlong printDC) {
TRY;
if ((HDC)printDC == NULL) {
return;
}
(void) ::FillPath((HDC)printDC);
CATCH_BAD_ALLOC;
@@ -1922,10 +1904,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_closeFigure
(JNIEnv *env, jobject self, jlong printDC) {
TRY;
if ((HDC)printDC == NULL) {
return;
}
(void) ::CloseFigure((HDC)printDC);
CATCH_BAD_ALLOC;
@@ -1940,10 +1918,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_lineTo
(JNIEnv *env, jobject self, jlong printDC, jfloat x, jfloat y) {
TRY;
if ((HDC)printDC == NULL) {
return;
}
(void) ::LineTo((HDC)printDC, ROUND_TO_LONG(x), ROUND_TO_LONG(y));
CATCH_BAD_ALLOC;
@@ -1959,10 +1933,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_moveTo
(JNIEnv *env, jobject self, jlong printDC, jfloat x, jfloat y) {
TRY;
if ((HDC)printDC == NULL) {
return;
}
(void) ::MoveToEx((HDC)printDC, ROUND_TO_LONG(x), ROUND_TO_LONG(y), NULL);
CATCH_BAD_ALLOC;
@@ -1981,10 +1951,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_polyBezierTo
TRY;
if ((HDC)printDC == NULL) {
return;
}
POINT points[3];
points[0].x = ROUND_TO_LONG(control1x);
@@ -2008,10 +1974,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_setPolyFillMode
(JNIEnv *env, jobject self, jlong printDC, jint fillRule) {
TRY;
if ((HDC)printDC == NULL) {
return;
}
(void) ::SetPolyFillMode((HDC)printDC, fillRule);
CATCH_BAD_ALLOC;
@@ -2026,10 +1988,6 @@ JNIEXPORT jint JNICALL Java_sun_awt_windows_WPrinterJob_setAdvancedGraphicsMode
(JNIEnv *env, jobject self, jlong printDC) {
TRY;
if ((HDC)printDC == NULL) {
return 0;
}
int oldGraphicsMode = ::SetGraphicsMode((HDC)printDC, GM_ADVANCED);
DASSERT(oldGraphicsMode != 0);
return (jint) oldGraphicsMode;
@@ -2046,10 +2004,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_setGraphicsMode
(JNIEnv *env, jobject self, jlong printDC, jint mode) {
TRY;
if ((HDC)printDC == NULL) {
return;
}
int oldGraphicsMode = ::SetGraphicsMode((HDC)printDC, mode);
DASSERT(oldGraphicsMode != 0);
@@ -2065,10 +2019,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_scale
(JNIEnv *env, jobject self, jlong printDC, jdouble scaleX, jdouble scaleY) {
TRY;
if ((HDC)printDC == NULL) {
return;
}
XFORM xForm;
xForm.eM11 = (FLOAT) scaleX;
@@ -2093,10 +2043,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_getWorldTransform
(JNIEnv* env, jobject self, jlong printDC, jdoubleArray transform) {
TRY;
if ((HDC)printDC == NULL) {
return;
}
double elems[6];
XFORM xForm;
@@ -2124,10 +2070,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_setWorldTransform
(JNIEnv* env, jobject self, jlong printDC, jdoubleArray transform) {
TRY;
if ((HDC)printDC == NULL) {
return;
}
double *elems;
XFORM xForm;
@@ -2158,10 +2100,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_selectSolidBrush
TRY;
if ((HDC)printDC == NULL) {
return;
}
HBRUSH colorBrush = ::CreateSolidBrush(RGB(red, green, blue));
HBRUSH oldBrush = (HBRUSH)::SelectObject((HDC)printDC, colorBrush);
DeleteObject(oldBrush);
@@ -2179,10 +2117,6 @@ JNIEXPORT jint JNICALL Java_sun_awt_windows_WPrinterJob_getPenX
TRY;
if ((HDC)printDC == NULL) {
return 0;
}
POINT where;
::GetCurrentPositionEx((HDC)printDC, &where);
@@ -2201,10 +2135,6 @@ JNIEXPORT jint JNICALL Java_sun_awt_windows_WPrinterJob_getPenY
TRY;
if ((HDC)printDC == NULL) {
return 0;
}
POINT where;
::GetCurrentPositionEx((HDC)printDC, &where);
@@ -2223,10 +2153,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_selectClipPath
TRY;
if ((HDC)printDC == NULL) {
return;
}
::SelectClipPath((HDC)printDC, RGN_COPY);
CATCH_BAD_ALLOC;
@@ -2244,10 +2170,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_frameRect
TRY;
if ((HDC)printDC == NULL) {
return;
}
POINT points[5];
points[0].x = ROUND_TO_LONG(x);
@@ -2278,10 +2200,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_fillRect
TRY;
if ((HDC)printDC == NULL) {
return;
}
RECT rect;
rect.left = ROUND_TO_LONG(x);
rect.top = ROUND_TO_LONG(y);
@@ -2310,10 +2228,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_selectPen
TRY;
if ((HDC)printDC == NULL) {
return;
}
HPEN hpen = ::CreatePen(PS_SOLID, ROUND_TO_LONG(width),
RGB(red, green, blue));
@@ -2340,10 +2254,6 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_windows_WPrinterJob_selectStylePen
TRY;
if ((HDC)printDC == NULL) {
return JNI_FALSE;
}
LOGBRUSH logBrush;
logBrush.lbStyle = PS_SOLID ;
@@ -2377,10 +2287,6 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_windows_WPrinterJob_setFont
jfloat fontSize, jboolean isBold, jboolean isItalic, jint rotation,
jfloat awScale)
{
if ((HDC)printDC == NULL) {
return JNI_FALSE;
}
jboolean didSetFont = JNI_FALSE;
didSetFont = jFontToWFontW(env, (HDC)printDC,
@@ -2411,10 +2317,6 @@ static jboolean jFontToWFontW(JNIEnv *env, HDC printDC, jstring fontName,
LOGFONTW matchedLogFont;
BOOL foundFont = false; // Assume we didn't find a matching GDI font.
if ((HDC)printDC == NULL) {
return JNI_FALSE;
}
memset(&matchedLogFont, 0, sizeof(matchedLogFont));
LPCWSTR fontNameW = JNU_GetStringPlatformChars(env, fontName, NULL);
@@ -2576,10 +2478,6 @@ static int embolden(int currentWeight)
JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_setTextColor
(JNIEnv *env, jobject self, jlong printDC, jint red, jint green, jint blue) {
if ((HDC)printDC == NULL) {
return;
}
(void) ::SetTextColor( (HDC)printDC, RGB(red, green, blue));
}
@@ -2587,11 +2485,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_setTextColor
JNIEXPORT jint JNICALL Java_sun_awt_windows_WPrinterJob_getGDIAdvance
(JNIEnv *env, jobject self, jlong printDC, jstring text)
{
if ((HDC)printDC == NULL) {
return 0;
}
SIZE size;
LPCWSTR wText = JNU_GetStringPlatformChars(env, text, NULL);
CHECK_NULL_RETURN(wText, 0);
@@ -2645,9 +2538,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_textOut
(JNIEnv *env, jobject self, jlong printDC, jstring text, jint strLen,
jboolean glyphCodes, jfloat x, jfloat y, jfloatArray positions)
{
if ((HDC)printDC == NULL) {
return;
}
long posX = ROUND_TO_LONG(x);
long posY = ROUND_TO_LONG(y);
@@ -2942,10 +2832,6 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_WPrinterJob_drawDIBImage
jfloat srcWidth, jfloat srcHeight,
jint bitCount, jbyteArray bmiColorsArray) {
if ((HDC)printDC == NULL) {
return;
}
int result = 0;
assert(printDC != NULL);
@@ -3036,10 +2922,6 @@ static void doPrintBand(JNIEnv *env, HDC printDC, jbyteArray imageArray,
TRY;
if ((HDC)printDC == NULL) {
return;
}
jbyte *image = NULL;
try {
long scanLineStride = J2DRasterBPP * width;
@@ -3084,10 +2966,6 @@ static int bitsToDevice(HDC printDC, jbyte *image, long destX, long destY,
long width, long height) {
int result = 0;
if ((HDC)printDC == NULL) {
return result;
}
assert(printDC != NULL);
assert(image != NULL);
assert(destX >= 0);
@@ -3829,10 +3707,6 @@ static double convertToPoints(long value, int units) {
*/
void setCapabilities(JNIEnv *env, jobject self, HDC printDC) {
if ((HDC)printDC == NULL) {
return;
}
jboolean err;
// width of page in pixels
jint pageWid = GetDeviceCaps(printDC, PHYSICALWIDTH);

View File

@@ -102,17 +102,13 @@ import jdk.internal.net.http.HttpClientBuilderImpl;
* .proxy(ProxySelector.of(new InetSocketAddress("proxy.example.com", 80)))
* .authenticator(Authenticator.getDefault())
* .build();
*
* HttpRequest request = HttpRequest.newBuilder()
* .uri(URI.create("https://foo.com/"))
* .build();
* HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
* System.out.println(response.statusCode());
* System.out.println(response.body()); }
*
* <p><b>Asynchronous Example</b>
* {@snippet :
* HttpRequest request = HttpRequest.newBuilder()
* HttpRequest request = HttpRequest.newBuilder()
* .uri(URI.create("https://foo.com/"))
* .timeout(Duration.ofMinutes(2))
* .header("Content-Type", "application/json")

View File

@@ -1542,17 +1542,7 @@ public class JavacParser implements Parser {
switch (expr.getTag()) {
case REFERENCE: {
JCMemberReference mref = (JCMemberReference) expr;
if (TreeInfo.isType(mref.expr, names)) {
mref.expr = insertAnnotationsToMostInner(mref.expr, typeAnnos, false);
} else {
//the selector is not a type, error recovery:
JCAnnotatedType annotatedType =
toP(F.at(pos).AnnotatedType(typeAnnos, mref.expr));
int termStart = getStartPos(mref.expr);
mref.expr = syntaxError(termStart, List.of(annotatedType),
Errors.IllegalStartOfType);
}
mref.pos = getStartPos(mref.expr);
mref.expr = toP(F.at(pos).AnnotatedType(typeAnnos, mref.expr));
t = mref;
break;
}

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
# 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,6 @@
# questions.
#
# This file was originally used to produce the `proprietary` warning when
# accessing non-APIs, and to hide some non-APIs in JDK <= 8. This has been
# superseded by the module system and `--release`. But, when compiling with
# `--source 8`, it is still used for this purpose by
# `com.sun.tools.javac.file.JRTIndex`.
#
# The build generates `jdk.compiler/com/sun/tools/javac/resources/ct.java` from
# this file, which is then used at runtime.
apple.laf.*: hidden
apple.security.*: hidden
com.apple.eawt.*: hidden

View File

@@ -437,19 +437,6 @@ public class TreeInfo {
* Return true if the AST corresponds to a static select of the kind A.B
*/
public static boolean isStaticSelector(JCTree base, Names names) {
return isTypeSelector(base, names, TreeInfo::isStaticSym);
}
//where
private static boolean isStaticSym(JCTree tree) {
Symbol sym = symbol(tree);
return (sym.kind == TYP || sym.kind == PCK);
}
public static boolean isType(JCTree base, Names names) {
return isTypeSelector(base, names, _ -> true);
}
private static boolean isTypeSelector(JCTree base, Names names, Predicate<JCTree> checkStaticSym) {
if (base == null)
return false;
switch (base.getTag()) {
@@ -457,9 +444,9 @@ public class TreeInfo {
JCIdent id = (JCIdent)base;
return id.name != names._this &&
id.name != names._super &&
checkStaticSym.test(base);
isStaticSym(base);
case SELECT:
return checkStaticSym.test(base) &&
return isStaticSym(base) &&
isStaticSelector(((JCFieldAccess)base).selected, names);
case TYPEAPPLY:
case TYPEARRAY:
@@ -470,6 +457,11 @@ public class TreeInfo {
return false;
}
}
//where
private static boolean isStaticSym(JCTree tree) {
Symbol sym = symbol(tree);
return (sym.kind == TYP || sym.kind == PCK);
}
/** Return true if a tree represents the null literal. */
public static boolean isNull(JCTree tree) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* 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,9 +29,6 @@ import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Set;
import java.util.stream.IntStream;
import jdk.jshell.spi.ExecutionControl;
import jdk.jshell.spi.SPIResolutionException;
@@ -338,15 +335,10 @@ public class DirectExecutionControl implements ExecutionControl {
* @throws ExecutionControl.InternalException for internal problems
*/
protected String throwConvertedInvocationException(Throwable cause) throws RunException, InternalException {
// Guard against recursive cause chains by
// using a Set with identity equality semantics.
Set<Throwable> dejaVu = Collections.newSetFromMap(new IdentityHashMap<>());
dejaVu.add(cause);
throw asRunException(cause, dejaVu);
throw asRunException(cause);
}
private RunException asRunException(Throwable ex, Set<Throwable> dejaVu) {
private RunException asRunException(Throwable ex) {
if (ex instanceof SPIResolutionException) {
SPIResolutionException spire = (SPIResolutionException) ex;
return new ResolutionException(spire.id(), spire.getStackTrace());
@@ -355,14 +347,7 @@ public class DirectExecutionControl implements ExecutionControl {
ex.getClass().getName(),
ex.getStackTrace());
Throwable cause = ex.getCause();
if (cause != null) {
Throwable throwable = dejaVu.add(cause)
? asRunException(cause, dejaVu)
: new UserException("CIRCULAR REFERENCE!",
cause.getClass().getName(),
cause.getStackTrace());
ue.initCause(throwable);
}
ue.initCause(cause == null ? null : asRunException(cause));
return ue;
}
}

View File

@@ -1,3 +1,38 @@
# Require javac
runtime/HiddenClasses/DefineHiddenClass.java 8346719 generic-all
# Require jstack
runtime/Thread/TestThreadDumpClassInitMonitor.java 8346719 generic-all
runtime/Thread/TestThreadDumpSMRInfo.java 8346719 generic-all
serviceability/tmtools/jstack/DaemonThreadTest.java 8346719 generic-all
serviceability/tmtools/jstack/JstackThreadTest.java 8346719 generic-all
serviceability/tmtools/jstack/SpreadLockTest.java 8346719 generic-all
serviceability/tmtools/jstack/ThreadNamesTest.java 8346719 generic-all
serviceability/tmtools/jstack/TraveledLockTest.java 8346719 generic-all
serviceability/tmtools/jstack/WaitNotifyThreadTest.java 8346719 generic-all
serviceability/tmtools/jstat/GcCapacityTest.java 8346719 generic-all
serviceability/tmtools/jstat/GcCauseTest01.java 8346719 generic-all
serviceability/tmtools/jstat/GcCauseTest02.java 8346719 generic-all
serviceability/tmtools/jstat/GcCauseTest03.java 8346719 generic-all
serviceability/tmtools/jstat/GcNewTest.java 8346719 generic-all
serviceability/tmtools/jstat/GcTest01.java 8346719 generic-all
serviceability/tmtools/jstat/GcTest02.java 8346719 generic-all
# Require jcmd
serviceability/HeapDump/DuplicateArrayClassesTest.java 8346719 generic-all
serviceability/HeapDump/FieldsInInstanceTest.java 8346719 generic-all
serviceability/attach/ConcAttachTest.java 8346719 generic-all
serviceability/attach/RemovingUnixDomainSocketTest.java 8346719 generic-all
serviceability/jvmti/vthread/HeapDump/VThreadInHeapDump.java#default 8346719 generic-all
serviceability/jvmti/vthread/HeapDump/VThreadInHeapDump.java#no-vmcontinuations 8346719 generic-all
# Require jhsdb
serviceability/sa/ClhsdbCDSCore.java 8346719 generic-all
serviceability/sa/ClhsdbFindPC.java#no-xcomp-core 8346719 generic-all
serviceability/sa/ClhsdbFindPC.java#xcomp-core 8346719 generic-all
serviceability/sa/ClhsdbPmap.java#core 8346719 generic-all
serviceability/sa/ClhsdbPstack.java#core 8346719 generic-all
# Dynamically link with JDK/VM native libraries
gtest/GTestWrapper.java 8356201 generic-all
gtest/LargePageGtests.java#use-large-pages 8356201 generic-all

View File

@@ -94,9 +94,6 @@ gc/TestAllocHumongousFragment.java#g1 8298781 generic-all
gc/TestAllocHumongousFragment.java#static 8298781 generic-all
gc/shenandoah/oom/TestAllocOutOfMemory.java#large 8344312 linux-ppc64le
gc/shenandoah/TestEvilSyncBug.java#generational 8345501 generic-all
gc/shenandoah/TestRetainObjects.java#no-tlab 8361099 generic-all
gc/shenandoah/TestSieveObjects.java#no-tlab 8361099 generic-all
gc/shenandoah/TestSieveObjects.java#no-tlab-genshen 8361099 generic-all
#############################################################################
@@ -144,7 +141,6 @@ serviceability/sa/TestJmapCore.java 8318754 macosx-aarch64
serviceability/sa/TestJmapCoreMetaspace.java 8318754 macosx-aarch64
serviceability/sa/ClhsdbThreadContext.java 8356704 windows-x64
serviceability/sa/TestJhsdbJstackMixedWithXComp.java 8371194 linux-x64
serviceability/jvmti/stress/StackTrace/NotSuspended/GetStackTraceNotSuspendedStressTest.java 8315980 linux-all,windows-x64

View File

@@ -1,6 +1,5 @@
/*
* Copyright (c) 2025, Arm Limited. All rights reserved.
* Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -186,14 +185,8 @@ public class TestSelectFromTwoVectorOp {
@Test
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_16, ">0"},
applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"},
applyIfCPUFeature = {"asimd", "true"},
applyIf = {"MaxVectorSize", ">=16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_16, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_16, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_16, ">0"},
applyIfCPUFeatureAnd = {"avx512_vbmi", "true", "avx512vl", "true"},
applyIf = {"MaxVectorSize", ">=16"})
@@ -207,10 +200,7 @@ public class TestSelectFromTwoVectorOp {
applyIf = {"MaxVectorSize", ">=32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_32, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_32, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">32"})
applyIf = {"MaxVectorSize", ">=32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_32, ">0"},
applyIfCPUFeatureAnd = {"avx512_vbmi", "true", "avx512vl", "true"},
applyIf = {"MaxVectorSize", ">=32"})
@@ -224,10 +214,7 @@ public class TestSelectFromTwoVectorOp {
applyIf = {"MaxVectorSize", ">=64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_64, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_64, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">64"})
applyIf = {"MaxVectorSize", ">=64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VB, IRNode.VECTOR_SIZE_64, ">0"},
applyIfCPUFeatureAnd = {"avx512_vbmi", "true", "avx512f", "true"},
applyIf = {"MaxVectorSize", ">=64"})
@@ -261,10 +248,7 @@ public class TestSelectFromTwoVectorOp {
applyIf = {"MaxVectorSize", ">=16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_8, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_8, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">16"})
applyIf = {"MaxVectorSize", ">=16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_8, ">0"},
applyIfCPUFeatureAnd = {"avx512bw", "true", "avx512vl", "true"},
applyIf = {"MaxVectorSize", ">=16"})
@@ -278,10 +262,7 @@ public class TestSelectFromTwoVectorOp {
applyIf = {"MaxVectorSize", ">=32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_16, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_16, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">32"})
applyIf = {"MaxVectorSize", ">=32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_16, ">0"},
applyIfCPUFeatureAnd = {"avx512bw", "true", "avx512vl", "true"},
applyIf = {"MaxVectorSize", ">=32"})
@@ -295,10 +276,7 @@ public class TestSelectFromTwoVectorOp {
applyIf = {"MaxVectorSize", ">=64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_32, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_32, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">64"})
applyIf = {"MaxVectorSize", ">=64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VS, IRNode.VECTOR_SIZE_32, ">0"},
applyIfCPUFeatureAnd = {"avx512bw", "true", "avx512f", "true"},
applyIf = {"MaxVectorSize", ">=64"})
@@ -331,13 +309,7 @@ public class TestSelectFromTwoVectorOp {
applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"},
applyIf = {"MaxVectorSize", ">=16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_4, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_4, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_4, ">0"},
applyIfCPUFeature = {"avx512vl", "true"},
applyIfCPUFeatureOr = {"sve2", "true", "avx512vl", "true"},
applyIf = {"MaxVectorSize", ">=16"})
public static void selectFromTwoVector_Int128() {
IntSelectFromTwoVectorKernel(IntVector.SPECIES_128, ia, ib, iindex[1]);
@@ -348,13 +320,7 @@ public class TestSelectFromTwoVectorOp {
applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"},
applyIf = {"MaxVectorSize", ">=32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_8, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_8, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_8, ">0"},
applyIfCPUFeature = {"avx512vl", "true"},
applyIfCPUFeatureOr = {"sve2", "true", "avx512vl", "true"},
applyIf = {"MaxVectorSize", ">=32"})
public static void selectFromTwoVector_Int256() {
IntSelectFromTwoVectorKernel(IntVector.SPECIES_256, ia, ib, iindex[2]);
@@ -365,13 +331,7 @@ public class TestSelectFromTwoVectorOp {
applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"},
applyIf = {"MaxVectorSize", ">=64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_16, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_16, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VI, IRNode.VECTOR_SIZE_16, ">0"},
applyIfCPUFeature = {"avx512f", "true"},
applyIfCPUFeatureOr = {"sve2", "true", "avx512f", "true"},
applyIf = {"MaxVectorSize", ">=64"})
public static void selectFromTwoVector_Int512() {
IntSelectFromTwoVectorKernel(IntVector.SPECIES_512, ia, ib, iindex[3]);
@@ -402,13 +362,7 @@ public class TestSelectFromTwoVectorOp {
applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"},
applyIf = {"MaxVectorSize", ">=16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_4, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_4, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_4, ">0"},
applyIfCPUFeature = {"avx512vl", "true"},
applyIfCPUFeatureOr = {"sve2", "true", "avx512vl", "true"},
applyIf = {"MaxVectorSize", ">=16"})
public static void selectFromTwoVector_Float128() {
FloatSelectFromTwoVectorKernel(FloatVector.SPECIES_128, fa, fb, findex[1]);
@@ -419,13 +373,7 @@ public class TestSelectFromTwoVectorOp {
applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"},
applyIf = {"MaxVectorSize", ">=32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_8, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_8, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_8, ">0"},
applyIfCPUFeature = {"avx512vl", "true"},
applyIfCPUFeatureOr = {"sve2", "true", "avx512vl", "true"},
applyIf = {"MaxVectorSize", ">=32"})
public static void selectFromTwoVector_Float256() {
FloatSelectFromTwoVectorKernel(FloatVector.SPECIES_256, fa, fb, findex[2]);
@@ -436,13 +384,7 @@ public class TestSelectFromTwoVectorOp {
applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"},
applyIf = {"MaxVectorSize", ">=64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_16, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_16, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VF, IRNode.VECTOR_SIZE_16, ">0"},
applyIfCPUFeature = {"avx512f", "true"},
applyIfCPUFeatureOr = {"sve2", "true", "avx512f", "true"},
applyIf = {"MaxVectorSize", ">=64"})
public static void selectFromTwoVector_Float512() {
FloatSelectFromTwoVectorKernel(FloatVector.SPECIES_512, fa, fb, findex[3]);
@@ -465,13 +407,7 @@ public class TestSelectFromTwoVectorOp {
applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"},
applyIf = {"MaxVectorSize", ">=16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_2, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_2, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_2, ">0"},
applyIfCPUFeature = {"avx512vl", "true"},
applyIfCPUFeatureOr = {"sve2", "true", "avx512vl", "true"},
applyIf = {"MaxVectorSize", ">=16"})
public static void selectFromTwoVector_Double128() {
DoubleSelectFromTwoVectorKernel(DoubleVector.SPECIES_128, da, db, dindex[0]);
@@ -482,13 +418,7 @@ public class TestSelectFromTwoVectorOp {
applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"},
applyIf = {"MaxVectorSize", ">=32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_4, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_4, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_4, ">0"},
applyIfCPUFeature = {"avx512vl", "true"},
applyIfCPUFeatureOr = {"sve2", "true", "avx512vl", "true"},
applyIf = {"MaxVectorSize", ">=32"})
public static void selectFromTwoVector_Double256() {
DoubleSelectFromTwoVectorKernel(DoubleVector.SPECIES_256, da, db, dindex[1]);
@@ -499,13 +429,7 @@ public class TestSelectFromTwoVectorOp {
applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"},
applyIf = {"MaxVectorSize", ">=64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_8, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_8, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VD, IRNode.VECTOR_SIZE_8, ">0"},
applyIfCPUFeature = {"avx512f", "true"},
applyIfCPUFeatureOr = {"sve2", "true", "avx512f", "true"},
applyIf = {"MaxVectorSize", ">=64"})
public static void selectFromTwoVector_Double512() {
DoubleSelectFromTwoVectorKernel(DoubleVector.SPECIES_512, da, db, dindex[2]);
@@ -528,13 +452,7 @@ public class TestSelectFromTwoVectorOp {
applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"},
applyIf = {"MaxVectorSize", ">=16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_2, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_2, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">16"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_2, ">0"},
applyIfCPUFeature = {"avx512vl", "true"},
applyIfCPUFeatureOr = {"sve2", "true", "avx512vl", "true"},
applyIf = {"MaxVectorSize", ">=16"})
public static void selectFromTwoVector_Long128() {
LongSelectFromTwoVectorKernel(LongVector.SPECIES_128, la, lb, lindex[0]);
@@ -545,13 +463,7 @@ public class TestSelectFromTwoVectorOp {
applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"},
applyIf = {"MaxVectorSize", ">=32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_4, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_4, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">32"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_4, ">0"},
applyIfCPUFeature = {"avx512vl", "true"},
applyIfCPUFeatureOr = {"sve2", "true", "avx512vl", "true"},
applyIf = {"MaxVectorSize", ">=32"})
public static void selectFromTwoVector_Long256() {
LongSelectFromTwoVectorKernel(LongVector.SPECIES_256, la, lb, lindex[1]);
@@ -562,13 +474,7 @@ public class TestSelectFromTwoVectorOp {
applyIfCPUFeatureAnd = {"asimd", "true", "sve2", "false"},
applyIf = {"MaxVectorSize", ">=64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_8, ">0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", "64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_8, "0"},
applyIfCPUFeature = {"sve2", "true"},
applyIf = {"MaxVectorSize", ">64"})
@IR(counts = {IRNode.SELECT_FROM_TWO_VECTOR_VL, IRNode.VECTOR_SIZE_8, ">0"},
applyIfCPUFeature = {"avx512f", "true"},
applyIfCPUFeatureOr = {"sve2", "true", "avx512f", "true"},
applyIf = {"MaxVectorSize", ">=64"})
public static void selectFromTwoVector_Long512() {
LongSelectFromTwoVectorKernel(LongVector.SPECIES_512, la, lb, lindex[2]);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -67,7 +67,7 @@ public class RemovingUnixDomainSocketTest {
"jcmd exitValue = " + out.getExitValue());
out.shouldHaveExitValue(0);
out.stderrShouldBeEmptyIgnoreVMWarnings();
out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();
}
public static void main(String... args) throws Exception {

View File

@@ -75,7 +75,7 @@ public class ClhsdbJstackXcompStress {
System.err.println(out.getStderr());
}
out.stderrShouldBeEmptyIgnoreVMWarnings();
out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();
out.stdoutShouldNotContain("Error occurred during stack walking:");
out.stdoutShouldContain(LingeredAppWithRecComputation.THREAD_NAME);
List<String> stdoutList = Arrays.asList(out.getStdout().split("\\R"));

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -70,7 +70,7 @@ public class JhsdbThreadInfoTest {
out.shouldNotContain(" prio=0 ");
out.shouldNotContain(" java.lang.Thread.State: UNKNOWN");
out.stderrShouldBeEmptyIgnoreVMWarnings();
out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();
System.out.println("Test Completed");
} catch (Exception ex) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -68,7 +68,7 @@ public class TestJhsdbJstackLock {
out.shouldMatch("^\\s+- locked <0x[0-9a-f]+> \\(a java\\.lang\\.Class for int\\)$");
out.shouldMatch("^\\s+- waiting on (<0x[0-9a-f]+> \\(a java\\.lang\\.Object\\)|<no object reference available>)$");
out.stderrShouldBeEmptyIgnoreVMWarnings();
out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();
System.out.println("Test Completed");
} finally {

View File

@@ -58,7 +58,7 @@ public class TestJhsdbJstackWithVirtualThread {
System.out.println(out.getStdout());
System.err.println(out.getStderr());
out.stderrShouldBeEmptyIgnoreVMWarnings();
out.stderrShouldBeEmptyIgnoreDeprecatedWarnings();
out.shouldNotContain("must have non-zero frame size");
}

View File

@@ -1,26 +1,14 @@
###########################################################################
#
# Copyright (c) 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.
#
###########################################################################
# Require jarsigner
java/lang/System/LoggerFinder/SignedLoggerFinderTest/SignedLoggerFinderTest.java 8346719 generic-all
java/util/jar/JarFile/jarVerification/MultiProviderTest.java 8346719 generic-all
# Currently empty
# Require jar
java/lang/System/MacEncoding/TestFileEncoding.java 8346719 generic-all
java/util/ResourceBundle/modules/basic/BasicTest.java 8346719 generic-all
# Require javac
java/util/ResourceBundle/modules/layer/LayerTest.java 8346719 generic-all
java/util/ResourceBundle/modules/unnamed/UnNamedTest.java 8346719 generic-all
# Require jps
java/util/concurrent/locks/Lock/TimedAcquireLeak.java 8346719 generic-all

View File

@@ -23,12 +23,12 @@
/*
* @test
* @bug 8370141 8370637
* @summary Test no crash printing to Graphics after job is ended.
* @key headful printer
* @run main PrintJobAfterEndTest
*/
@test
@bug 8370141
@summary Test no crash printing to Graphics after job is ended.
@key headful printer
@run main PrintJobAfterEndTest
*/
import java.awt.Frame;
import java.awt.Graphics;

View File

@@ -1,73 +0,0 @@
/*
* Copyright (c) 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.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.ComponentColorModel;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferByte;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
/*
* @test
* @bug 4954405
* @summary Verify DataBuffer offsets are handled by ByteInterleavedRaster
*/
public class ByteInterleavedRasterOffsetsTest {
public static void main(String[] args) {
byte[] data = { 0, -1, 0, 0 }; // only set the R sample.
int[] bandOffsets = { 0, 1, 2 };
DataBuffer databuf = new DataBufferByte(data, 3, 1);
WritableRaster raster =
Raster.createInterleavedRaster(databuf, 1, 1, 3, 3, bandOffsets, null);
int[] pixels = raster.getPixels(0, 0, 1, 1, (int[])null);
byte[] elements = (byte[])raster.getDataElements(0, 0, null);
ColorModel colorModel = new ComponentColorModel(
ColorSpace.getInstance(ColorSpace.CS_sRGB), false, false,
ColorModel.OPAQUE, DataBuffer.TYPE_BYTE);
BufferedImage img = new BufferedImage(colorModel, raster, false, null);
int pixel = img.getRGB(0, 0);
System.out.println("PIXEL0=" + Integer.toHexString(pixels[0]));
System.out.println("PIXEL1=" + Integer.toHexString(pixels[1]));
System.out.println("PIXEL2=" + Integer.toHexString(pixels[2]));
System.out.println("ELEMENT0=" + Integer.toHexString(elements[0] & 0xff));
System.out.println("ELEMENT1=" + Integer.toHexString(elements[1] & 0xff));
System.out.println("ELEMENT2=" + Integer.toHexString(elements[2] & 0xff));
System.out.println("PIXEL=" + Integer.toHexString(pixel));
if ((pixels[0] != 0xff) || (pixels[1] != 0) || (pixels[2] != 0)) {
throw new RuntimeException("Unexpected pixels");
}
if (((elements[0] & 0xff) != 0xff) || (elements[1] != 0) || (elements[2] != 0)) {
throw new RuntimeException("Unexpected elements");
}
if (pixel != 0xffff0000) {
throw new RuntimeException("Unexpected pixel");
}
}
}

View File

@@ -1,51 +0,0 @@
/*
* Copyright (c) 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.File;
import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
import java.awt.image.ColorConvertOp;
import java.awt.image.ColorModel;
import javax.imageio.ImageIO;
/*
* @test
* @bug 8364583
* @summary Verify CMYK images work with ColorConvertOp
*/
public class ColorConvertOpCMYK {
public static void main(String[] args) throws Exception {
String sep = System.getProperty("file.separator");
String dir = System.getProperty("test.src", ".");
String prefix = dir + sep;
File file = new File(prefix + "black_cmyk.jpg");
BufferedImage source = ImageIO.read(file);
ColorModel sourceModel = source.getColorModel();
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
ColorConvertOp convertOp = new ColorConvertOp(cs, null);
BufferedImage rgb = convertOp.filter(source, null);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 B

View File

@@ -21,10 +21,10 @@
* questions.
*/
/*
/**
* @test
* @key printer
* @bug 8370141 8370637
* @bug 8370141
* @summary No crash when printing after job completed.
* @run main PrintAfterEndTest
*/

View File

@@ -0,0 +1,124 @@
/*
* Copyright (c) 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.
*/
/*
* @test
* @bug 8370344
* @requires os.family != "windows"
* @requires vm.flavor != "zero"
* @requires vm.hasJFR
* @summary Test closing a shared scope during faulting access
*
* @library /test/lib
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main jdk.test.lib.FileInstaller sharedCloseJfr.jfc sharedCloseJfr.jfc
* @run main/othervm
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:CompileCommand=exclude,*TestSharedCloseJFR.main
* -XX:StartFlightRecording:filename=recording.jfr,dumponexit=true,settings=sharedCloseJfr.jfc
* TestSharedCloseJFR
*/
import jdk.test.whitebox.WhiteBox;
import java.io.RandomAccessFile;
import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.ValueLayout;
import java.nio.channels.FileChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
// We are interested in the following scenario:
// When accessing a memory-mapped file that is truncated
// a segmentation fault will occur (see also test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java)
//
// This segmentation fault will be caught in the VM's signal handler
// and get turned into an InternalError by a VM handshake operation.
// This handshake operation calls back into Java to the constructor
// of InternalError. This constructor calls super constructors until
// it ends up in the constructor of Throwable, where JFR starts logging
// the Throwable being created. This logging code adds a bunch
// of extra Java frames to the stack.
//
// All of this occurs during the original memory access, i.e.
// while we are inside a @Scoped method call (jdk.internal.misc.ScopedMemoryAccess).
// If at this point a shared arena is closed in another thread,
// the shared scope closure handshake (src/hotspot/share/prims/scopedMemoryAccess.cpp)
// will see all the extra frames added by JFR and the InternalError constructor,
// while walking the stack of the thread doing the faulting access.
//
// This test is here to make sure that the shared scope closure handshake can
// deal with that situation.
public class TestSharedCloseJFR {
private static final int PAGE_SIZE = WhiteBox.getWhiteBox().getVMPageSize();
public static void main(String[] args) throws Throwable {
String fileName = "tmp.txt";
Path path = Path.of(fileName);
AtomicBoolean stop = new AtomicBoolean();
Files.write(path, "1".repeat(PAGE_SIZE + 1000).getBytes());
try (RandomAccessFile file = new RandomAccessFile(fileName, "rw")) {
FileChannel fileChannel = file.getChannel();
MemorySegment segment =
fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, fileChannel.size(), Arena.ofAuto());
// truncate file
// this will make the access fault
Files.write(path, "2".getBytes());
// start worker thread
CountDownLatch latch = new CountDownLatch(1);
Thread.ofPlatform().start(() -> {
latch.countDown();
while (!stop.get()) {
Arena.ofShared().close(); // hammer VM with handshakes
}
});
// wait util the worker thread has started
latch.await();
// access (should fault)
// try it a few times until we get a handshake during JFR reporting
for (int i = 0; i < 50_000; i++) {
try {
segment.get(ValueLayout.JAVA_INT, PAGE_SIZE);
throw new RuntimeException("InternalError was expected");
} catch (InternalError e) {
// InternalError as expected
if (!e.getMessage().contains("a fault occurred in an unsafe memory access")) {
throw new RuntimeException("Unexpected exception", e);
}
}
}
} finally {
// stop worker
stop.set(true);
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration label="Custom" version="2.0">
<event name="jdk.JavaErrorThrow">
<setting name="enabled" control="enable-errors">true</setting>
<setting name="stackTrace">true</setting>
</event>
</configuration>

View File

@@ -0,0 +1,131 @@
/*
* Copyright (c) 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.
*/
/*
* @test
* @bug 8370344
* @library /test/lib
* @run junit/native TestSharedCloseJvmti
*/
import jdk.test.lib.Utils;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
import org.junit.jupiter.api.Test;
import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.ValueLayout;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class TestSharedCloseJvmti {
private static final String JVMTI_AGENT_LIB = Path.of(Utils.TEST_NATIVE_PATH, System.mapLibraryName("SharedCloseAgent"))
.toAbsolutePath().toString();
@Test
void eventDuringScopedAccess() throws Throwable {
List<String> command = new ArrayList<>(List.of(
"-agentpath:" + JVMTI_AGENT_LIB,
"-Xcheck:jni",
EventDuringScopedAccessRunner.class.getName()
));
try {
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(command);
Process process = ProcessTools.startProcess("fork", pb, null, null, 1L, TimeUnit.MINUTES);
OutputAnalyzer output = new OutputAnalyzer(process);
output.shouldHaveExitValue(0);
output.stderrShouldContain("Exception in thread \"Trigger\" jdk.internal.misc.ScopedMemoryAccess$ScopedAccessError: Invalid memory access");
} catch (TimeoutException e) {
throw new RuntimeException("Timeout while waiting for forked process");
}
}
public static class EventDuringScopedAccessRunner {
static final int ADDED_FRAMES = 10;
static final CountDownLatch MAIN_LATCH = new CountDownLatch(1);
static final CountDownLatch TARGET_LATCH = new CountDownLatch(1);
static volatile int SINK;
public static void main(String[] args) throws Throwable {
try (Arena arena = Arena.ofShared()) {
MemorySegment segment = arena.allocate(4);
// run in separate thread so that waiting on
// latch doesn't block main thread
Thread.ofPlatform().name("Trigger").start(() -> {
SINK = segment.get(ValueLayout.JAVA_INT, 0);
});
// wait until trigger thread is in JVMTI event callback
MAIN_LATCH.await();
}
// Notify trigger thread that arena was closed
TARGET_LATCH.countDown();
}
static boolean reentrant = false;
// called by jvmti agent
// we get here after checking arena liveness
private static void target() {
String callerName = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).walk(frames ->
frames.skip(2).findFirst().orElseThrow().getClassName());
if (!callerName.equals("jdk.internal.misc.ScopedMemoryAccess")) {
return;
}
if (reentrant) {
// put some frames on the stack, so stack walk does not see @Scoped method
addFrames(0);
} else {
reentrant = true;
try (Arena arena = Arena.ofConfined()) {
SINK = arena.allocate(4).get(ValueLayout.JAVA_INT, 0);
}
reentrant = false;
}
}
private static void addFrames(int depth) {
if (depth >= ADDED_FRAMES) {
// notify main thread to close the arena
MAIN_LATCH.countDown();
try {
// wait here until main thread has closed arena
TARGET_LATCH.await();
} catch (InterruptedException ex) {
throw new RuntimeException("Unexpected interruption");
}
return;
}
addFrames(depth + 1);
}
}
}

View File

@@ -0,0 +1,133 @@
/*
* Copyright (c) 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.
*/
#include <jvmti.h>
#include <string.h>
static jclass MAIN_CLS;
static jmethodID TARGET_ID;
static const char* TARGET_CLASS_NAME = "TestSharedCloseJvmti$EventDuringScopedAccessRunner";
static const char* TARGET_METHOD_NAME = "target";
static const char* TARGET_METHOD_SIG = "()V";
static const char* INTERCEPT_CLASS_NAME = "Ljdk/internal/foreign/MemorySessionImpl;";
static const char* INTERCEPT_METHOD_NAME = "checkValidStateRaw";
void start(jvmtiEnv*, JNIEnv* jni_env, jthread) {
jclass cls = jni_env->FindClass(TARGET_CLASS_NAME);
if (cls == nullptr) {
jni_env->ExceptionDescribe();
return;
}
MAIN_CLS = (jclass) jni_env->NewGlobalRef(cls);
TARGET_ID = jni_env->GetStaticMethodID(cls, TARGET_METHOD_NAME, TARGET_METHOD_SIG);
if (TARGET_ID == nullptr) {
jni_env->ExceptionDescribe();
return;
}
}
void method_exit(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jmethodID method,
jboolean was_popped_by_exception, jvalue return_value) {
char* method_name = nullptr;
jvmtiError err = jvmti_env->GetMethodName(method, &method_name, nullptr, nullptr);
if (err != JVMTI_ERROR_NONE) {
return;
}
if (strcmp(method_name, INTERCEPT_METHOD_NAME) != 0) {
jvmti_env->Deallocate((unsigned char*) method_name);
return;
}
jclass cls;
err = jvmti_env->GetMethodDeclaringClass(method, &cls);
if (err != JVMTI_ERROR_NONE) {
jvmti_env->Deallocate((unsigned char*) method_name);
return;
}
char* class_sig = nullptr;
err = jvmti_env->GetClassSignature(cls, &class_sig, nullptr);
if (err != JVMTI_ERROR_NONE) {
jvmti_env->Deallocate((unsigned char*) method_name);
return;
}
if (strcmp(class_sig, INTERCEPT_CLASS_NAME) != 0) {
jvmti_env->Deallocate((unsigned char*) method_name);
jvmti_env->Deallocate((unsigned char*) class_sig);
return;
}
jni_env->CallStaticVoidMethod(MAIN_CLS, TARGET_ID);
if (jni_env->ExceptionOccurred()) {
jni_env->ExceptionDescribe();
}
jvmti_env->Deallocate((unsigned char*) method_name);
jvmti_env->Deallocate((unsigned char*) class_sig);
}
JNIEXPORT jint JNICALL
Agent_OnLoad(JavaVM *vm, char *options, void *reserved) {
jvmtiEnv* env;
jint jni_err = vm->GetEnv((void**) &env, JVMTI_VERSION);
if (jni_err != JNI_OK) {
return jni_err;
}
jvmtiCapabilities capabilities{};
capabilities.can_generate_method_exit_events = 1;
jvmtiError err = env->AddCapabilities(&capabilities);
if (err != JVMTI_ERROR_NONE) {
return err;
}
jvmtiEventCallbacks callbacks;
callbacks.VMInit = start;
callbacks.MethodExit = method_exit;
err = env->SetEventCallbacks(&callbacks, (jint) sizeof(callbacks));
if (err != JVMTI_ERROR_NONE) {
return err;
}
err = env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_METHOD_EXIT, nullptr);
if (err != JVMTI_ERROR_NONE) {
return err;
}
err = env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr);
if (err != JVMTI_ERROR_NONE) {
return err;
}
return 0;
}

View File

@@ -133,7 +133,7 @@ public class WriteP12Test {
public static void main(String[] args) throws UnrecoverableKeyException,
KeyStoreException, NoSuchProviderException,
NoSuchAlgorithmException, IOException, CertificateException {
NoSuchAlgorithmException, IOException {
WriteP12Test jstest = new WriteP12Test();
out.println("test WriteP12CertChain");
/*

View File

@@ -65,16 +65,12 @@ public class GifBuilder {
/**
* This creates a sample gif image based on a series of FrameDescriptions,
* and the calls {@link GifComparison#run(URL)}
*
* @param frameDir an optional directory to write all frames as PNGs to.
* See {@link GifComparison#run(URL, File)}
*/
public static void test(FrameDescription[] frameDescriptions,
File frameDir)
public static void test(FrameDescription... frameDescriptions)
throws Throwable {
File file = createTestFile(frameDescriptions);
try {
GifComparison.run(file.toURI().toURL(), frameDir);
GifComparison.run(file.toURI().toURL());
} finally {
file.delete();
}

View File

@@ -38,7 +38,6 @@ import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.ImageConsumer;
import java.awt.image.IndexColorModel;
import java.io.File;
import java.net.URL;
import java.util.Hashtable;
import java.util.LinkedList;
@@ -60,21 +59,13 @@ public class GifComparison {
* if ImageIO and ToolkitImage produce different BufferedImage renderings.
*
* @param srcURL the URL of the image to inspect
* @param frameDir an optional directory to write frames to as PNG images.
* The frames should render identically whether we use
* the ImageIO model or the ToolkitImage model. If they're
* identical, then we only output one image, such as
* "frame_0.png". If they're different then we'll
* output two images: "frame_0_iio.png" and
* "frame_0_awt.png".
*
* @return the last frame encoded as a TYPE_INT_ARGB image.
* <p>
* Unit tests may further inspect this image to make sure certain
* conditions are met.
*/
public static BufferedImage run(URL srcURL, File frameDir)
throws Throwable {
public static BufferedImage run(URL srcURL) throws Throwable {
System.out.println("Comparing ImageIO vs ToolkitImage rendering of " +
srcURL);
ImageIOModel ioModel = new ImageIOModel(srcURL);
@@ -82,67 +73,41 @@ public class GifComparison {
BufferedImage lastImage = null;
// if frameDir exists: test & export all frames.
// Otherwise: only test the last frame
int startIndex = frameDir == null ? ioModel.frames.size() - 1 : 0;
int a = ioModel.frames.size() - 1;
BufferedImage ioImg = ioModel.getFrame(a);
BufferedImage awtImage = awtModel.getFrame(a);
for (int a = startIndex; a < ioModel.frames.size(); a++) {
BufferedImage ioImg = ioModel.getFrame(a);
BufferedImage awtImage = awtModel.getFrame(a);
lastImage = awtImage;
lastImage = awtImage;
if (!(ioImg.getWidth() == awtImage.getWidth() &&
ioImg.getHeight() == awtImage.getHeight()))
throw new Error("These images are not the same size: " +
ioImg.getWidth() + "x" + ioImg.getHeight() + " vs " +
awtImage.getWidth() + "x" + awtImage.getHeight());
try {
if (!(ioImg.getWidth() == awtImage.getWidth() &&
ioImg.getHeight() == awtImage.getHeight()))
throw new Error("These images are not the same size: " +
ioImg.getWidth() + "x" + ioImg.getHeight() +
" vs " +
awtImage.getWidth() + "x" + awtImage.getHeight());
for (int y = 0; y < ioImg.getHeight(); y++) {
for (int x = 0; x < ioImg.getWidth(); x++) {
int argb1 = ioImg.getRGB(x, y);
int argb2 = awtImage.getRGB(x, y);
for (int y = 0; y < ioImg.getHeight(); y++) {
for (int x = 0; x < ioImg.getWidth(); x++) {
int argb1 = ioImg.getRGB(x, y);
int argb2 = awtImage.getRGB(x, y);
int alpha1 = (argb1 & 0xff000000) >> 24;
int alpha2 = (argb2 & 0xff000000) >> 24;
if (alpha1 == 0 && alpha2 == 0) {
continue;
} else if (alpha1 == 0 || alpha2 == 0) {
throw new Error("pixels at (" + x + ", " + y +
") have different opacities: " +
Integer.toUnsignedString(argb1, 16) +
" vs " +
Integer.toUnsignedString(argb2, 16));
}
int rgb1 = argb1 & 0xffffff;
int rgb2 = argb2 & 0xffffff;
if (rgb1 != rgb2) {
throw new Error("pixels at (" + x + ", " + y +
") have different opaque RGB values: " +
Integer.toUnsignedString(rgb1, 16) +
" vs " +
Integer.toUnsignedString(rgb2, 16));
}
}
int alpha1 = (argb1 & 0xff000000) >> 24;
int alpha2 = (argb2 & 0xff000000) >> 24;
if (alpha1 == 0 && alpha2 == 0) {
continue;
} else if (alpha1 == 0 || alpha2 == 0) {
throw new Error("pixels at (" + x + ", " + y +
") have different opacities: " +
Integer.toUnsignedString(argb1, 16) + " vs " +
Integer.toUnsignedString(argb2, 16));
}
if (frameDir != null) {
// the two models are identical, so simply write one image:
File pngFile = new File(frameDir, "frame_" + a + ".png");
ImageIO.write(ioImg, "png", pngFile);
System.out.println("\tWrote " + pngFile);
int rgb1 = argb1 & 0xffffff;
int rgb2 = argb2 & 0xffffff;
if (rgb1 != rgb2) {
throw new Error("pixels at (" + x + ", " + y +
") have different opaque RGB values: " +
Integer.toUnsignedString(rgb1, 16) + " vs " +
Integer.toUnsignedString(rgb2, 16));
}
} catch (Throwable t) {
if (frameDir != null) {
File f1 = new File(frameDir, "frame_" + + a + "_iio.png");
File f2 = new File(frameDir, "frame_" + + a + "_awt.png");
ImageIO.write(ioImg, "png", f1);
ImageIO.write(awtImage, "png", f2);
System.out.println("\tWrote " + f1 + " vs " + f2);
}
throw t;
}
}
System.out.println("Passed");

View File

@@ -28,26 +28,14 @@
* the disposal method changes from 2 to 1
*/
import java.io.File;
public class GifEmptyBackgroundTest {
public static void main(String[] args) throws Throwable {
GifBuilder.FrameDescription[] frames =
new GifBuilder.FrameDescription[] {
GifBuilder.test(
new GifBuilder.FrameDescription(
GifBuilder.Disposal.restoreToBackgroundColor, false),
new GifBuilder.FrameDescription(
GifBuilder.Disposal.doNotDispose, false),
new GifBuilder.FrameDescription(
GifBuilder.Disposal.doNotDispose, false)
};
File dir = null;
// un-comment to visually inspect the frames:
// dir = new File("8356137-frames");
// dir.mkdir();
GifBuilder.test(frames, dir);
GifBuilder.Disposal.doNotDispose, false) );
}
}

View File

@@ -1,53 +0,0 @@
/*
* Copyright (c) 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.
*/
/*
* @test
* @bug 8357034
* @summary This test verifies that when the transparent pixel index changes
* and we're rendering on top of another frame we respect the new transparency.
*/
import java.io.File;
public class GifSavedImageTransparentTest {
public static void main(String[] args) throws Throwable {
GifBuilder.FrameDescription[] frames =
new GifBuilder.FrameDescription[] {
new GifBuilder.FrameDescription(
GifBuilder.Disposal.doNotDispose, false),
new GifBuilder.FrameDescription(
GifBuilder.Disposal.doNotDispose, true),
new GifBuilder.FrameDescription(
GifBuilder.Disposal.doNotDispose, true)
};
File dir = null;
// un-comment to visually inspect the frames:
// dir = new File("8357034-frames");
// dir.mkdir();
GifBuilder.test(frames, dir);
}
}

View File

@@ -351,8 +351,7 @@ public class PackageTestTest extends JUnitAdapter {
}
@Override
public JPackageCommand verifyIsOfType(Set<PackageType> types) {
return this;
public void verifyIsOfType(PackageType ... types) {
}
@Override

View File

@@ -165,7 +165,7 @@ public final class AdditionalLauncher {
public void applyTo(JPackageCommand cmd) {
cmd.addPrerequisiteAction(this::initialize);
cmd.addVerifyAction(createVerifierAsConsumer(), JPackageCommand.ActionRole.LAUNCHER_VERIFIER);
cmd.addVerifyAction(createVerifierAsConsumer());
}
public void applyTo(PackageTest test) {

View File

@@ -192,7 +192,9 @@ final class ConfigFilesStasher {
}
private static ApplicationLayout appImageAppLayout(JPackageCommand cmd) {
cmd.verifyNotRuntime();
if (cmd.isRuntime()) {
throw new UnsupportedOperationException();
}
if (cmd.isImagePackageType()) {
return platformAppImage();

View File

@@ -28,16 +28,13 @@ import static java.util.stream.Collectors.mapping;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
import static java.util.stream.Collectors.toSet;
import static java.util.stream.Collectors.toCollection;
import static jdk.jpackage.test.AdditionalLauncher.forEachAdditionalLauncher;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.security.SecureRandom;
import java.util.ArrayList;
@@ -51,7 +48,6 @@ import java.util.Objects;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.Set;
import java.util.TreeSet;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
@@ -60,7 +56,6 @@ import java.util.regex.Pattern;
import java.util.spi.ToolProvider;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import jdk.jpackage.internal.util.function.ThrowingConsumer;
import jdk.jpackage.internal.util.function.ThrowingFunction;
import jdk.jpackage.internal.util.function.ThrowingRunnable;
@@ -90,6 +85,7 @@ public class JPackageCommand extends CommandArguments<JPackageCommand> {
ignoreDefaultRuntime = cmd.ignoreDefaultRuntime;
ignoreDefaultVerbose = cmd.ignoreDefaultVerbose;
this.immutable = immutable;
dmgInstallDir = cmd.dmgInstallDir;
prerequisiteActions = new Actions(cmd.prerequisiteActions);
verifyActions = new Actions(cmd.verifyActions);
standardAsserts = cmd.standardAsserts;
@@ -169,6 +165,11 @@ public class JPackageCommand extends CommandArguments<JPackageCommand> {
return null;
}
public String getArgumentValue(String argName,
Function<JPackageCommand, String> defaultValueSupplier) {
return getArgumentValue(argName, defaultValueSupplier, v -> v);
}
public <T> T getArgumentValue(String argName,
Supplier<T> defaultValueSupplier,
Function<String, T> stringConverter) {
@@ -331,35 +332,16 @@ public class JPackageCommand extends CommandArguments<JPackageCommand> {
return this;
}
public JPackageCommand usePredefinedAppImage(Path predefinedAppImagePath) {
return setArgumentValue("--app-image", Objects.requireNonNull(predefinedAppImagePath))
.removeArgumentWithValue("--input");
}
JPackageCommand addPrerequisiteAction(ThrowingConsumer<JPackageCommand> action) {
prerequisiteActions.add(action);
return this;
}
JPackageCommand addVerifyAction(ThrowingConsumer<JPackageCommand> action) {
return addVerifyAction(action, ActionRole.DEFAULT);
}
enum ActionRole {
DEFAULT,
LAUNCHER_VERIFIER,
;
}
JPackageCommand addVerifyAction(ThrowingConsumer<JPackageCommand> action, ActionRole actionRole) {
verifyActions.add(action, actionRole);
verifyActions.add(action);
return this;
}
Stream<ThrowingConsumer<JPackageCommand>> getVerifyActionsWithRole(ActionRole actionRole) {
return verifyActions.actionsWithRole(actionRole);
}
/**
* Shorthand for {@code helloAppImage(null)}.
*/
@@ -568,7 +550,11 @@ public class JPackageCommand extends CommandArguments<JPackageCommand> {
}
if (TKit.isOSX()) {
return MacHelper.getInstallationDirectory(this);
if (packageType() == PackageType.MAC_DMG && dmgInstallDir != null) {
return dmgInstallDir;
} else {
return MacHelper.getInstallationDirectory(this);
}
}
throw TKit.throwUnknownPlatformError();
@@ -690,11 +676,10 @@ public class JPackageCommand extends CommandArguments<JPackageCommand> {
return Collections.unmodifiableList(names);
}
JPackageCommand verifyNotRuntime() {
private void verifyNotRuntime() {
if (isRuntime()) {
throw new UnsupportedOperationException("Java runtime packaging");
throw new IllegalArgumentException("Java runtime packaging");
}
return this;
}
/**
@@ -1227,52 +1212,6 @@ public class JPackageCommand extends CommandArguments<JPackageCommand> {
MacHelper.verifyUnsignedBundleSignature(cmd);
}
}),
PREDEFINED_APP_IMAGE_COPY(cmd -> {
Optional.ofNullable(cmd.getArgumentValue("--app-image")).filter(_ -> {
return !TKit.isOSX() || !MacHelper.signPredefinedAppImage(cmd);
}).map(Path::of).ifPresent(predefinedAppImage -> {
TKit.trace(String.format(
"Check contents of the predefined app image [%s] copied verbatim",
predefinedAppImage));
var outputAppImageDir = cmd.pathToUnpackedPackageFile(cmd.appInstallationDirectory());
try (var walk = Files.walk(predefinedAppImage)) {
var filteredWalk = walk;
if (!cmd.expectAppImageFile()) {
var appImageFile = AppImageFile.getPathInAppImage(predefinedAppImage);
// Exclude ".jpackage.xml" as it should no be in the output bundle.
var pred = Predicate.<Path>isEqual(appImageFile).negate();
if (TKit.isOSX()) {
// On MacOS exclude files that can be signed as their digests change.
pred = pred.and(path -> {
return MacHelper.isVerbatimCopyFromPredefinedAppImage(cmd, path);
});
}
filteredWalk = walk.filter(pred);
}
var verbatimPaths = filteredWalk.collect(toCollection(TreeSet::new));
// Remove nonempty directories from the collection of paths copied verbatim.
verbatimPaths.removeAll(verbatimPaths.stream().map(Path::getParent).toList());
verbatimPaths.forEach(ThrowingConsumer.toConsumer(p -> {
if (Files.isDirectory(p, LinkOption.NOFOLLOW_LINKS)) {
TKit.assertDirectoryExists(p);
} else {
TKit.assertSameFileContent(p, outputAppImageDir.resolve(predefinedAppImage.relativize(p)));
}
}));
} catch (IOException ex) {
throw new UncheckedIOException(ex);
}
TKit.trace("Done");
});
})
;
StandardAssert(Consumer<JPackageCommand> action) {
@@ -1281,7 +1220,9 @@ public class JPackageCommand extends CommandArguments<JPackageCommand> {
private static JPackageCommand convertFromRuntime(JPackageCommand cmd) {
var copy = cmd.createMutableCopy();
copy.immutable = false;
copy.removeArgumentWithValue("--runtime-image");
copy.dmgInstallDir = cmd.appInstallationDirectory();
if (!copy.hasArgument("--name")) {
copy.addArguments("--name", cmd.nameFromRuntimeImage().orElseThrow());
}
@@ -1499,35 +1440,29 @@ public class JPackageCommand extends CommandArguments<JPackageCommand> {
return getPrintableCommandLine();
}
public final JPackageCommand verifyIsOfType(PackageType ... types) {
return verifyIsOfType(Set.of(types));
public void verifyIsOfType(Collection<PackageType> types) {
verifyIsOfType(types.toArray(PackageType[]::new));
}
public final JPackageCommand verifyIsOfType(Iterable<PackageType> types) {
return verifyIsOfType(StreamSupport.stream(types.spliterator(), false).collect(toSet()));
}
public JPackageCommand verifyIsOfType(Set<PackageType> types) {
Objects.requireNonNull(types);
public void verifyIsOfType(PackageType ... types) {
final var typesSet = Stream.of(types).collect(Collectors.toSet());
if (!hasArgument("--type")) {
if (!isImagePackageType()) {
if ((TKit.isLinux() && types.equals(PackageType.LINUX)) || (TKit.isWindows() && types.equals(PackageType.WINDOWS))) {
return this;
if ((TKit.isLinux() && typesSet.equals(PackageType.LINUX)) || (TKit.isWindows() && typesSet.equals(PackageType.WINDOWS))) {
return;
}
if (TKit.isOSX() && types.equals(PackageType.MAC)) {
return this;
if (TKit.isOSX() && typesSet.equals(PackageType.MAC)) {
return;
}
} else if (types.equals(Set.of(PackageType.IMAGE))) {
return this;
} else if (typesSet.equals(Set.of(PackageType.IMAGE))) {
return;
}
}
if (!types.contains(packageType())) {
throw new UnsupportedOperationException(String.format("Unsupported operation for type [%s]", packageType().getType()));
if (!typesSet.contains(packageType())) {
throw new IllegalArgumentException("Unexpected type");
}
return this;
}
public CfgFile readLauncherCfgFile() {
@@ -1623,47 +1558,18 @@ public class JPackageCommand extends CommandArguments<JPackageCommand> {
}
void add(ThrowingConsumer<JPackageCommand> action) {
add(action, ActionRole.DEFAULT);
}
void add(ThrowingConsumer<JPackageCommand> action, ActionRole role) {
Objects.requireNonNull(action);
verifyMutable();
actions.add(new Action(action, role));
}
Stream<ThrowingConsumer<JPackageCommand>> actionsWithRole(ActionRole role) {
Objects.requireNonNull(role);
return actions.stream().filter(action -> {
return Objects.equals(action.role(), role);
}).map(Action::impl);
}
private static final class Action implements Consumer<JPackageCommand> {
Action(ThrowingConsumer<JPackageCommand> impl, ActionRole role) {
this.impl = Objects.requireNonNull(impl);
this.role = Objects.requireNonNull(role);
}
ActionRole role() {
return role;
}
ThrowingConsumer<JPackageCommand> impl() {
return impl;
}
@Override
public void accept(JPackageCommand cmd) {
if (!executed) {
executed = true;
ThrowingConsumer.toConsumer(impl).accept(cmd);
actions.add(new Consumer<JPackageCommand>() {
@Override
public void accept(JPackageCommand t) {
if (!executed) {
executed = true;
ThrowingConsumer.toConsumer(action).accept(t);
}
}
}
private final ActionRole role;
private final ThrowingConsumer<JPackageCommand> impl;
private boolean executed;
private boolean executed;
});
}
@Override
@@ -1672,7 +1578,7 @@ public class JPackageCommand extends CommandArguments<JPackageCommand> {
actions.forEach(action -> action.accept(JPackageCommand.this));
}
private final List<Action> actions;
private final List<Consumer<JPackageCommand>> actions;
}
private Boolean withToolProvider;
@@ -1683,6 +1589,7 @@ public class JPackageCommand extends CommandArguments<JPackageCommand> {
private boolean ignoreDefaultRuntime;
private boolean ignoreDefaultVerbose;
private boolean immutable;
private Path dmgInstallDir;
private final Actions prerequisiteActions;
private final Actions verifyActions;
private Path executeInDirectory;

View File

@@ -24,7 +24,6 @@ package jdk.jpackage.test;
import static java.util.stream.Collectors.toMap;
import static jdk.jpackage.test.AdditionalLauncher.NO_ICON;
import static jdk.jpackage.test.AdditionalLauncher.getAdditionalLauncherProperties;
import static jdk.jpackage.test.LauncherShortcut.LINUX_SHORTCUT;
import java.io.IOException;
@@ -35,7 +34,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
@@ -74,12 +72,6 @@ public final class LauncherVerifier {
new LauncherVerifier(cmd).verify(cmd, Action.EXECUTE_LAUNCHER);
}
static String launcherDescription(JPackageCommand cmd, String launcherName) {
return launcherDescription(cmd, launcherName, (theCmd, theLauncherName) -> {
return getAdditionalLauncherProperties(theCmd, theLauncherName);
});
}
public enum Action {
VERIFY_ICON(LauncherVerifier::verifyIcon),
@@ -145,8 +137,8 @@ public final class LauncherVerifier {
}
private String getDescription(JPackageCommand cmd) {
return launcherDescription(cmd, name, (theCmd, theLauncherName) -> {
return properties.orElseThrow();
return findProperty("description").orElseGet(() -> {
return cmd.getArgumentValue("--description", cmd::name);
});
}
@@ -280,11 +272,7 @@ public final class LauncherVerifier {
}
private void verifyDescription(JPackageCommand cmd) throws IOException {
if (TKit.isWindows() && !cmd.hasArgument("--app-image")) {
// On Windows, check the description if the predefined app image is not configured.
// The description and the icon are encoded in the launcher executable, which should be
// copied verbatim from the predefined app image into the output bundle.
// This check is done in the JPackageCommand class, so there is no need to duplicate it here.
if (TKit.isWindows()) {
String expectedDescription = getDescription(cmd);
Path launcherPath = cmd.appLauncherPath(name);
String actualDescription =
@@ -436,24 +424,6 @@ public final class LauncherVerifier {
});
}
private static String launcherDescription(
JPackageCommand cmd,
String launcherName,
BiFunction<JPackageCommand, String, PropertyFile> addLauncherPropertyFileGetter) {
return PropertyFinder.findLauncherProperty(cmd, launcherName,
PropertyFinder.cmdlineOptionWithValue("--description"),
PropertyFinder.launcherPropertyFile("description"),
PropertyFinder.nop()
).orElseGet(() -> {
if (cmd.isMainLauncher(launcherName)) {
return cmd.mainLauncherName();
} else {
return launcherDescription(cmd, null, addLauncherPropertyFileGetter);
}
});
}
private static final class DefaultEntitlements {
private static Map<String, Object> loadFromResources(String resourceName) {

View File

@@ -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.test.AdditionalLauncher.getAdditionalLauncherProperties;
import java.io.IOException;
import java.io.UncheckedIOException;
@@ -559,7 +560,14 @@ public final class LinuxHelper {
TKit.assertTrue(mandatoryKeys.isEmpty(), String.format(
"Check for missing %s keys in the file", mandatoryKeys));
final var launcherDescription = LauncherVerifier.launcherDescription(cmd, launcherName);
final String launcherDescription;
if (cmd.name().equals(launcherName) || predefinedAppImage.isPresent()) {
launcherDescription = Optional.ofNullable(cmd.getArgumentValue("--description")).orElseGet(cmd::name);
} else {
launcherDescription = getAdditionalLauncherProperties(cmd, launcherName).findProperty("description").or(() -> {
return Optional.ofNullable(cmd.getArgumentValue("--description"));
}).orElseGet(cmd::name);
}
for (var e : List.of(
Map.entry("Type", "Application"),

View File

@@ -545,43 +545,6 @@ public final class MacHelper {
}
}
static boolean isVerbatimCopyFromPredefinedAppImage(JPackageCommand cmd, Path path) {
cmd.verifyIsOfType(PackageType.MAC);
final var predefinedAppImage = Path.of(cmd.getArgumentValue("--app-image"));
final var appLayout = ApplicationLayout.macAppImage().resolveAt(predefinedAppImage);
if (!path.startsWith(predefinedAppImage)) {
throw new IllegalArgumentException(
String.format("Path [%s] is not in directory [%s]", path, predefinedAppImage));
}
if (path.startsWith(appLayout.contentDirectory().resolve("_CodeSignature"))) {
// A file in the "Contents/_CodeSignature" directory.
return false;
}
final var outputAppImageDir = cmd.pathToUnpackedPackageFile(cmd.appInstallationDirectory());
final var outputAppImagePath = outputAppImageDir.resolve(predefinedAppImage.relativize(path));
if (path.startsWith(appLayout.launchersDirectory()) &&
cmd.launcherNames(true).stream().map(cmd::appLauncherPath).collect(toSet()).contains(outputAppImagePath)) {
// The `path` references a launcher.
// It can be signed and its digest may change.
return false;
}
if (path.startsWith(appLayout.runtimeHomeDirectory().resolve("bin"))) {
// The `path` references an executable native command in JDK's "bin" subdirectory.
// It can be signed and its digest may change.
return false;
}
return true;
}
static void verifyUnsignedBundleSignature(JPackageCommand cmd) {
if (!cmd.isImagePackageType()) {
MacSignVerify.assertUnsigned(cmd.outputBundle());
@@ -753,8 +716,12 @@ public final class MacHelper {
final var defaultInstallLocation = Path.of(
cmd.isRuntime() ? "/Library/Java/JavaVirtualMachines" : "/Applications");
final Path installLocation = Optional.ofNullable(cmd.getArgumentValue("--install-dir"))
.map(Path::of).orElse(defaultInstallLocation);
final Path installLocation;
if (cmd.packageType() == PackageType.MAC_DMG) {
installLocation = defaultInstallLocation;
} else {
installLocation = cmd.getArgumentValue("--install-dir", () -> defaultInstallLocation, Path::of);
}
return installLocation.resolve(cmd.name() + (cmd.isRuntime() ? ".jdk" : ".app"));
}

View File

@@ -60,7 +60,6 @@ import java.util.stream.StreamSupport;
import jdk.jpackage.internal.util.function.ThrowingBiConsumer;
import jdk.jpackage.internal.util.function.ThrowingConsumer;
import jdk.jpackage.internal.util.function.ThrowingRunnable;
import jdk.jpackage.test.JPackageCommand.ActionRole;
/**
@@ -234,15 +233,6 @@ public final class PackageTest extends RunnablePackageTest {
return this;
}
public PackageTest usePredefinedAppImage(JPackageCommand appImageCmd) {
appImageCmd.verifyIsOfType(PackageType.IMAGE);
addInitializer(cmd -> {
cmd.usePredefinedAppImage(appImageCmd.outputBundle());
});
appImageCmd.getVerifyActionsWithRole(ActionRole.LAUNCHER_VERIFIER).forEach(this::addInstallVerifier);
return this;
}
public PackageTest disablePackageInstaller() {
currentTypes.forEach(disabledInstallers::add);
return this;

View File

@@ -26,9 +26,7 @@ import static jdk.jpackage.test.AdditionalLauncher.getAdditionalLauncherProperti
import java.nio.file.Path;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.function.UnaryOperator;
import jdk.jpackage.test.AdditionalLauncher.PropertyFile;
@@ -44,12 +42,6 @@ final class PropertyFinder {
};
}
default Finder<T> defaultValue(Supplier<String> v) {
return target -> {
return Optional.of(find(target).orElseGet(v));
};
}
default Finder<T> map(UnaryOperator<String> v) {
Objects.requireNonNull(v);
return target -> {
@@ -142,27 +134,7 @@ final class PropertyFinder {
Finder<PropertyFile> addLauncherPropertyFileFinder,
Finder<AppImageFile> appImageFileFinder) {
return findLauncherProperty(
cmd,
launcherName,
(theCmd, theLauncherName) -> {
return getAdditionalLauncherProperties(theCmd, theLauncherName);
},
cmdlineFinder,
addLauncherPropertyFileFinder,
appImageFileFinder);
}
static Optional<String> findLauncherProperty(
JPackageCommand cmd,
String launcherName,
BiFunction<JPackageCommand, String, PropertyFile> addLauncherPropertyFileGetter,
Finder<JPackageCommand> cmdlineFinder,
Finder<PropertyFile> addLauncherPropertyFileFinder,
Finder<AppImageFile> appImageFileFinder) {
Objects.requireNonNull(cmd);
Objects.requireNonNull(addLauncherPropertyFileGetter);
Objects.requireNonNull(cmdlineFinder);
Objects.requireNonNull(addLauncherPropertyFileFinder);
Objects.requireNonNull(appImageFileFinder);
@@ -176,7 +148,7 @@ final class PropertyFinder {
if (mainLauncher) {
reply = cmdlineFinder.find(cmd);
} else if (appImageFilePath.isEmpty()) {
var props = addLauncherPropertyFileGetter.apply(cmd, launcherName);
var props = getAdditionalLauncherProperties(cmd, launcherName);
reply = addLauncherPropertyFileFinder.find(props);
} else {
reply = Optional.empty();

View File

@@ -199,8 +199,10 @@ public class SigningPackageTwoStepTest {
test.forTypes(signPackage.keySet()).addRunOnceInitializer(() -> {
appImageCmd.setArgumentValue("--dest", TKit.createTempDirectory("appimage")).execute(0);
}).usePredefinedAppImage(appImageCmd).addInitializer(cmd -> {
}).addInitializer(cmd -> {
MacHelper.useKeychain(cmd, keychain);
cmd.addArguments("--app-image", appImageCmd.outputBundle());
cmd.removeArgumentWithValue("--input");
Optional.ofNullable(signPackage.get(cmd.packageType())).ifPresent(signOption -> {
signOption.setTo(cmd);
});

View File

@@ -196,22 +196,27 @@ public class AddLShortcutTest {
// and applies shortcut configuration to the main launcher in the native packaging jpackage command.
//
var appImageCmd = JPackageCommand.helloAppImage()
.setArgumentValue("--name", "foo")
.setFakeRuntime();
Path[] predefinedAppImage = new Path[1];
for (var i = 1; i != cfgs.length; ++i) {
var al = new AdditionalLauncher("launcher-" + i);
cfgs[i].applyToAdditionalLauncher(al);
al.withoutVerifyActions(Action.EXECUTE_LAUNCHER).applyTo(appImageCmd);
}
new PackageTest().addRunOnceInitializer(() -> {
var cmd = JPackageCommand.helloAppImage()
.setArgumentValue("--name", "foo")
.setFakeRuntime();
new PackageTest()
.addRunOnceInitializer(appImageCmd::execute)
.usePredefinedAppImage(appImageCmd)
.addInitializer(cmd -> {
for (var i = 1; i != cfgs.length; ++i) {
var al = new AdditionalLauncher("launcher-" + i);
cfgs[i].applyToAdditionalLauncher(al);
al.withoutVerifyActions(Action.EXECUTE_LAUNCHER).applyTo(cmd);
}
cmd.execute();
predefinedAppImage[0] = cmd.outputBundle();
}).addInitializer(cmd -> {
cfgs[0].applyToMainLauncher(cmd);
cmd.removeArgumentWithValue("--input");
cmd.setArgumentValue("--name", "AddLShortcutDir2Test");
cmd.addArguments("--app-image", predefinedAppImage[0]);
}).run(RunnablePackageTest.Action.CREATE_AND_UNPACK);
}
@@ -232,15 +237,20 @@ public class AddLShortcutTest {
shortcutArgs.add(startupDirectory.asStringValue());
}
var appImageCmd = JPackageCommand.helloAppImage()
.setArgumentValue("--name", "foo")
.setFakeRuntime();
Path[] predefinedAppImage = new Path[1];
new PackageTest()
.addRunOnceInitializer(appImageCmd::execute)
.usePredefinedAppImage(appImageCmd)
.addInitializer(cmd -> {
new PackageTest().addRunOnceInitializer(() -> {
var cmd = JPackageCommand.helloAppImage()
.setArgumentValue("--name", "foo")
.setFakeRuntime();
cmd.execute();
predefinedAppImage[0] = cmd.outputBundle();
}).addInitializer(cmd -> {
cmd.removeArgumentWithValue("--input");
cmd.setArgumentValue("--name", "AddLShortcutDir3Test");
cmd.addArguments("--app-image", predefinedAppImage[0]);
cmd.ignoreDefaultVerbose(true);
}).addInitializer(cmd -> {
cmd.addArguments(shortcutArgs);

View File

@@ -275,9 +275,10 @@ public class AddLauncherTest {
if (withPredefinedAppImage) {
new PackageTest().addInitializer(cmd -> {
cmd.setArgumentValue("--name", "Bar");
// Should not have impact on launcher descriptions, but it does.
// Should not have impact of launcher descriptions, but it does.
cmd.setArgumentValue("--description", "Installer");
}).usePredefinedAppImage(target.cmd().orElseThrow()).mutate(addLinuxShortcuts()).run(Action.CREATE_AND_UNPACK);
cmd.removeArgumentWithValue("--input").setArgumentValue("--app-image", target.cmd().orElseThrow().outputBundle());
}).mutate(addLinuxShortcuts()).run(Action.CREATE_AND_UNPACK);
}
}

View File

@@ -499,11 +499,11 @@ public class AppContentTest {
return new FileContentFactory(() -> {
var basedir = TKit.createTempDirectory("content").resolve(path);
for (var textFile : List.of(
for (var textFile : Map.ofEntries(
entry("woods/moose", "The moose"),
entry("woods/bear", "The bear"),
entry("woods/trees/jay", "The gray jay")
)) {
).entrySet()) {
var src = basedir.resolve(textFile.getKey());
Files.createDirectories(src.getParent());
TKit.createTextFile(src, Stream.of(textFile.getValue()));

View File

@@ -62,12 +62,15 @@ public class AppImagePackageTest {
@Test
public static void test() {
final var appImageCmd = createAppImageCommand();
var appImageCmd = JPackageCommand.helloAppImage()
.setArgumentValue("--dest", TKit.createTempDirectory("appimage"));
new PackageTest()
.addRunOnceInitializer(appImageCmd::execute)
.usePredefinedAppImage(appImageCmd)
.addBundleDesktopIntegrationVerifier(false).run();
.addInitializer(cmd -> {
cmd.addArguments("--app-image", appImageCmd.outputBundle());
cmd.removeArgumentWithValue("--input");
}).addBundleDesktopIntegrationVerifier(false).run();
}
/**
@@ -82,7 +85,10 @@ public class AppImagePackageTest {
@Parameter("false")
public static void testEmpty(boolean withIcon) throws IOException {
final var appImageCmd = createAppImageCommand();
var appImageCmd = JPackageCommand.helloAppImage()
.setFakeRuntime()
.setArgumentValue("--name", "EmptyAppImagePackageTest")
.setArgumentValue("--dest", TKit.createTempDirectory("appimage"));
new PackageTest()
.addRunOnceInitializer(appImageCmd::execute)
@@ -110,11 +116,12 @@ public class AppImagePackageTest {
TKit.trace("Done");
}
})
.usePredefinedAppImage(appImageCmd)
.addInitializer(cmd -> {
cmd.addArguments("--app-image", appImageCmd.outputBundle());
if (withIcon) {
cmd.setArgumentValue("--icon", iconPath("icon"));
cmd.addArguments("--icon", iconPath("icon"));
}
cmd.removeArgumentWithValue("--input");
cmd.excludeStandardAsserts(
StandardAssert.MAIN_JAR_FILE,
@@ -153,8 +160,10 @@ public class AppImagePackageTest {
*/
@Test
public static void testBadAppImage3() {
Path appImageDir = TKit.createTempDirectory("appimage");
final var appImageCmd = createAppImageCommand();
JPackageCommand appImageCmd = JPackageCommand.helloAppImage().
setFakeRuntime().setArgumentValue("--dest", appImageDir);
configureBadAppImage(appImageCmd.outputBundle()).addRunOnceInitializer(() -> {
appImageCmd.execute();
@@ -167,8 +176,10 @@ public class AppImagePackageTest {
*/
@Test
public static void testBadAppImageFile() {
final var appImageRoot = TKit.createTempDirectory("appimage");
final var appImageCmd = createAppImageCommand();
final var appImageCmd = JPackageCommand.helloAppImage().
setFakeRuntime().setArgumentValue("--dest", appImageRoot);
final var appImageDir = appImageCmd.outputBundle();
@@ -191,17 +202,13 @@ public class AppImagePackageTest {
private static PackageTest configureBadAppImage(Path appImageDir, CannedFormattedString expectedError) {
return new PackageTest().addInitializer(cmd -> {
cmd.usePredefinedAppImage(appImageDir);
cmd.addArguments("--app-image", appImageDir);
cmd.removeArgumentWithValue("--input");
cmd.ignoreDefaultVerbose(true); // no "--verbose" option
cmd.validateOutput(expectedError);
}).setExpectedExitCode(1);
}
private static JPackageCommand createAppImageCommand() {
final var appImageRoot = TKit.createTempDirectory("appimage");
return JPackageCommand.helloAppImage().setFakeRuntime().setArgumentValue("--dest", appImageRoot);
}
private static Path iconPath(String name) {
return TKit.TEST_SRC_ROOT.resolve(Path.of("resources", name
+ TKit.ICON_SUFFIX));

View File

@@ -34,6 +34,8 @@ import jdk.jpackage.test.JPackageStringBundle;
import jdk.jpackage.test.PackageTest;
import jdk.jpackage.test.PackageType;
import jdk.jpackage.test.RunnablePackageTest.Action;
import jdk.jpackage.test.TKit;
import jdk.jpackage.test.TKit.TextStreamVerifier;
/**
* Test --install-dir parameter. Output of the test should be
@@ -111,9 +113,9 @@ public class InstallDirTest {
.run();
}
record TestSpec(Path installDir, boolean runtimeInstaller) {
record DmgTestSpec(Path installDir, boolean runtimeInstaller) {
TestSpec {
DmgTestSpec {
Objects.requireNonNull(installDir);
}
@@ -133,8 +135,8 @@ public class InstallDirTest {
return this;
}
TestSpec create() {
return new TestSpec(installDir, runtimeInstaller);
DmgTestSpec create() {
return new DmgTestSpec(installDir, runtimeInstaller);
}
private Path installDir;
@@ -152,7 +154,7 @@ public class InstallDirTest {
}
void run() {
final var test = new PackageTest().ignoreBundleOutputDir();
final var test = new PackageTest().forTypes(PackageType.MAC_DMG).ignoreBundleOutputDir();
if (runtimeInstaller) {
test.addInitializer(cmd -> {
cmd.removeArgumentWithValue("--input");
@@ -162,33 +164,33 @@ public class InstallDirTest {
}
test.addInitializer(JPackageCommand::setFakeRuntime).addInitializer(cmd -> {
cmd.setArgumentValue("--install-dir", installDir);
cmd.addArguments("--install-dir", installDir);
}).run(Action.CREATE_AND_UNPACK);
}
}
@Test(ifOS = OperatingSystem.MACOS)
@ParameterSupplier
public static void testMac(TestSpec testSpec) {
public static void testDmg(DmgTestSpec testSpec) {
testSpec.run();
}
public static List<Object[]> testMac() {
public static List<Object[]> testDmg() {
return Stream.of(
TestSpec.build().acceptedInstallDir("/foo"),
TestSpec.build().acceptedInstallDir("/foo/bar"),
TestSpec.build().acceptedInstallDir("/foo").runtimeInstaller(),
TestSpec.build().acceptedInstallDir("/foo/bar").runtimeInstaller(),
DmgTestSpec.build().acceptedInstallDir("/foo"),
DmgTestSpec.build().acceptedInstallDir("/foo/bar"),
DmgTestSpec.build().acceptedInstallDir("/foo").runtimeInstaller(),
DmgTestSpec.build().acceptedInstallDir("/foo/bar").runtimeInstaller(),
TestSpec.build().acceptedInstallDir("/Library/Java/JavaVirtualMachines"),
TestSpec.build().acceptedInstallDir("/Applications").runtimeInstaller(),
DmgTestSpec.build().acceptedInstallDir("/Library/Java/JavaVirtualMachines"),
DmgTestSpec.build().acceptedInstallDir("/Applications").runtimeInstaller(),
TestSpec.build().acceptedInstallDir("/Applications"),
TestSpec.build().acceptedInstallDir("/Applications/foo/bar/buz"),
DmgTestSpec.build().acceptedInstallDir("/Applications"),
DmgTestSpec.build().acceptedInstallDir("/Applications/foo/bar/buz"),
TestSpec.build().runtimeInstaller().acceptedInstallDir("/Library/Java/JavaVirtualMachines"),
TestSpec.build().runtimeInstaller().acceptedInstallDir("/Library/Java/JavaVirtualMachines/foo/bar/buz")
).map(TestSpec.Builder::create).map(testSpec -> {
DmgTestSpec.build().runtimeInstaller().acceptedInstallDir("/Library/Java/JavaVirtualMachines"),
DmgTestSpec.build().runtimeInstaller().acceptedInstallDir("/Library/Java/JavaVirtualMachines/foo/bar/buz")
).map(DmgTestSpec.Builder::create).map(testSpec -> {
return new Object[] { testSpec };
}).toList();
}

View File

@@ -22,12 +22,13 @@
*/
import java.nio.file.Path;
import java.io.IOException;
import jdk.jpackage.test.AdditionalLauncher;
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;
import jdk.jpackage.test.Annotations.Test;
import jdk.jpackage.test.JPackageCommand;
/**
* Test multiple launchers in two phases. First test creates app image and then
@@ -54,7 +55,7 @@ import jdk.jpackage.test.TKit;
public class MultiLauncherTwoPhaseTest {
@Test
public static void test() {
public static void test() throws IOException {
Path appimageOutput = TKit.createTempDirectory("appimage");
JPackageCommand appImageCmd = JPackageCommand.helloAppImage()
@@ -67,9 +68,12 @@ public class MultiLauncherTwoPhaseTest {
launcher2.applyTo(appImageCmd);
PackageTest packageTest = new PackageTest()
.addRunOnceInitializer(appImageCmd::execute)
.addRunOnceInitializer(() -> appImageCmd.execute())
.addBundleDesktopIntegrationVerifier(true)
.usePredefinedAppImage(appImageCmd)
.addInitializer(cmd -> {
cmd.addArguments("--app-image", appImageCmd.outputBundle());
cmd.removeArgumentWithValue("--input");
})
.forTypes(PackageType.WINDOWS)
.addInitializer(cmd -> {
cmd.addArguments("--win-shortcut", "--win-menu",

View File

@@ -22,12 +22,13 @@
*/
import java.nio.file.Path;
import jdk.jpackage.test.Annotations.Parameter;
import jdk.jpackage.test.Annotations.Test;
import jdk.jpackage.test.JPackageCommand;
import java.io.IOException;
import jdk.jpackage.test.PackageTest;
import jdk.jpackage.test.PackageType;
import jdk.jpackage.test.TKit;
import jdk.jpackage.test.Annotations.Test;
import jdk.jpackage.test.Annotations.Parameter;
import jdk.jpackage.test.JPackageCommand;
/**
* Test creation of packages in tho phases with different names.
@@ -57,7 +58,9 @@ public class MultiNameTwoPhaseTest {
@Parameter({"MultiNameTest", ""})
@Parameter({"", "MultiNameTestInstaller"})
@Parameter({"", ""})
public static void test(String appName, String installName) {
public static void test(String... testArgs) throws IOException {
String appName = testArgs[0];
String installName = testArgs[1];
Path appimageOutput = TKit.createTempDirectory("appimage");
@@ -71,8 +74,9 @@ public class MultiNameTwoPhaseTest {
PackageTest packageTest = new PackageTest()
.addRunOnceInitializer(() -> appImageCmd.execute())
.addBundleDesktopIntegrationVerifier(true)
.usePredefinedAppImage(appImageCmd)
.addInitializer(cmd -> {
cmd.addArguments("--app-image", appImageCmd.outputBundle());
cmd.removeArgumentWithValue("--input");
cmd.removeArgumentWithValue("--name");
if (!installName.isEmpty()) {
cmd.addArguments("--name", installName);

View File

@@ -107,7 +107,10 @@ public class PostImageScriptTest {
});
}
case EXTERNAL_APP_IMAGE -> {
test.usePredefinedAppImage(appImageCmd);
test.addInitializer(cmd -> {
cmd.removeArgumentWithValue("--input");
cmd.addArguments("--app-image", appImageCmd.outputBundle());
});
}
}

View File

@@ -243,7 +243,10 @@ public class ServiceTest {
new PackageTest().excludeTypes(MAC_DMG)
.addRunOnceInitializer(appImageCmd.cmd().orElseThrow()::execute)
.usePredefinedAppImage(appImageCmd.cmd().orElseThrow())
.addInitializer(cmd -> {
cmd.removeArgumentWithValue("--input");
cmd.addArguments("--app-image", appImageCmd.cmd().orElseThrow().outputBundle());
})
.addInitializer(cmd -> {
if (mainLauncherAsService) {
cmd.addArgument("--launcher-as-service");

View File

@@ -24,11 +24,9 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Stream;
import jdk.jpackage.test.Annotations.Test;
import jdk.jpackage.test.JPackageCommand;
import jdk.jpackage.test.PackageTest;
import jdk.jpackage.test.JPackageCommand;
import jdk.jpackage.test.Annotations.Test;
import jdk.jpackage.test.RunnablePackageTest.Action;
import jdk.jpackage.test.TKit;
@@ -50,13 +48,13 @@ import jdk.jpackage.test.TKit;
public class Win8282351Test {
@Test
public void test() {
public void test() throws IOException {
Path appimageOutput = TKit.createTempDirectory("appimage");
JPackageCommand appImageCmd = JPackageCommand.helloAppImage()
.setFakeRuntime().setArgumentValue("--dest", appimageOutput);
var filesWithDollarCharsInNames = Stream.of(
String[] filesWithDollarCharsInNames = new String[]{
"Pane$$anon$$greater$1.class",
"$",
"$$",
@@ -65,11 +63,11 @@ public class Win8282351Test {
"$$$$$",
"foo$.class",
"1$b$$a$$$r$$$$.class"
).map(Path::of).toList();
};
var dirsWithDollarCharsInNames = List.of(
filesWithDollarCharsInNames.stream().reduce(Path.of("foo"), Path::resolve)
);
String[] dirsWithDollarCharsInNames = new String[]{
Path.of("foo", String.join("/", filesWithDollarCharsInNames)).toString()
};
String name = appImageCmd.name() + "$-$$-$$$";
@@ -77,7 +75,7 @@ public class Win8282351Test {
.addRunOnceInitializer(() -> {
appImageCmd.execute();
for (var path : filesWithDollarCharsInNames) {
createImageFile(appImageCmd, path);
createImageFile(appImageCmd, Path.of(path));
}
for (var path : dirsWithDollarCharsInNames) {
@@ -85,15 +83,16 @@ public class Win8282351Test {
appImageCmd.outputBundle().resolve(path));
}
})
.usePredefinedAppImage(appImageCmd)
.addInitializer(cmd -> {
cmd.setArgumentValue("--name", name);
cmd.addArguments("--app-image", appImageCmd.outputBundle());
cmd.removeArgumentWithValue("--input");
cmd.addArgument("--win-menu");
cmd.addArgument("--win-shortcut");
})
.addInstallVerifier(cmd -> {
for (var path : filesWithDollarCharsInNames) {
verifyImageFile(appImageCmd, path);
verifyImageFile(appImageCmd, Path.of(path));
}
for (var path : dirsWithDollarCharsInNames) {

View File

@@ -1,26 +1,29 @@
###########################################################################
#
# Copyright (c) 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.
#
###########################################################################
# Requires javadoc
jdk/javadoc/tool/6964914/TestStdDoclet.java 8346719 generic-all
jdk/javadoc/tool/6964914/TestUserDoclet.java 8346719 generic-all
jdk/javadoc/tool/AddOpensTest.java 8346719 generic-all
jdk/javadoc/tool/EncodingTest.java 8346719 generic-all
jdk/javadoc/tool/EnsureNewOldDoclet.java 8346719 generic-all
jdk/javadoc/tool/QuietOption.java 8346719 generic-all
jdk/javadoc/tool/testLocaleOption/TestLocaleOption.java 8346719 generic-all
# Currently empty
# Requires javac
tools/javac/ClassPathTest/ClassPathTest.java 8346719 generic-all
tools/javac/Paths/ClassPath.java 8346719 generic-all
tools/javac/Paths/WildcardMineField.java 8346719 generic-all
tools/javac/T8132562/ClassPathWithDoubleQuotesTest.java 8346719 generic-all
tools/javac/file/MultiReleaseJar/MultiReleaseJarTest.java 8346719 generic-all
tools/javac/modules/AllDefaultTest.java 8346719 generic-all
tools/javac/modules/EnvVarTest.java 8346719 generic-all
tools/javac/modules/InheritRuntimeEnvironmentTest.java 8346719 generic-all
tools/javac/modules/NPEEmptyFileTest.java 8346719 generic-all
tools/javac/newlines/NewLineTest.java 8346719 generic-all
tools/javac/options/smokeTests/OptionSmokeTest.java 8346719 generic-all
tools/javac/platform/PlatformProviderTest.java 8346719 generic-all
tools/javac/processing/options/testPrintProcessorInfo/TestWithXstdout.java 8346719 generic-all
# Requires jar
tools/jdeps/MultiReleaseJar.java 8346719 generic-all
# Requires jimage
tools/javac/Paths/MineField.java 8346719 generic-all

View File

@@ -24,7 +24,7 @@
/*
* @test
* @summary Tests for exceptions
* @bug 8198801 8212167 8210527 8370175
* @bug 8198801 8212167 8210527
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* jdk.jdeps/com.sun.tools.javap
@@ -320,16 +320,6 @@ public class ExceptionsTest extends KullaTesting {
assertExecuteException("f();", StackOverflowError.class);
}
@Test
public void recursiveCauses() {
assertEval("var one = new Throwable();");
assertEval("var two = new Error();");
assertEval("one.initCause(two);");
assertEval("two.initCause(one);");
assertExecuteException("throw one;", Throwable.class);
assertExecuteException("throw two;", Error.class);
}
private StackTraceElement newStackTraceElement(String className, String methodName, Snippet key, int lineNumber) {
return new StackTraceElement(className, methodName, "#" + key.id(), lineNumber);
}

View File

@@ -1,190 +0,0 @@
/*
* Copyright (c) 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.
*/
/*
* @test
* @bug 8369489
* @summary Verify annotations on member references work reasonably.
* @library /tools/lib /tools/javac/lib
* @modules
* jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* @build toolbox.ToolBox toolbox.JavacTask
* @run junit TypeAnnosOnMemberReferenceTest
*/
import com.sun.source.tree.IdentifierTree;
import com.sun.source.tree.Tree;
import com.sun.source.tree.VariableTree;
import com.sun.source.util.TreePath;
import com.sun.source.util.TreeScanner;
import com.sun.source.util.Trees;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.ElementFilter;
import org.junit.jupiter.api.Test;
import toolbox.JavacTask;
import toolbox.Task;
import toolbox.ToolBox;
public class TypeAnnosOnMemberReferenceTest {
private ToolBox tb = new ToolBox();
@Test
public void testAnnoOnMemberRef() throws Exception {
Path base = Paths.get(".");
Path src = base.resolve("src");
Path classes = base.resolve("classes");
Files.createDirectories(classes);
tb.writeJavaFiles(src,
"""
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
public class Test {
interface I {
void foo(int i);
}
@Target(ElementType.TYPE_USE)
@interface Ann1 {}
@Target(ElementType.TYPE_USE)
@interface Ann2 {}
I i = @Ann1 Test @Ann2 []::new;
}
""");
Path classDir = getClassDir();
new JavacTask(tb)
.classpath(classDir)
.outdir(classes)
.options("-processor", VerifyAnnotations.class.getName())
.files(tb.findJavaFiles(src))
.outdir(classes)
.run(Task.Expect.SUCCESS);
}
public Path getClassDir() {
String classes = ToolBox.testClasses;
if (classes == null) {
return Paths.get("build");
} else {
return Paths.get(classes);
}
}
@SupportedAnnotationTypes("*")
public static final class VerifyAnnotations extends AbstractProcessor {
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latestSupported();
}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
TypeElement testElement = processingEnv.getElementUtils().getTypeElement("Test");
VariableElement iElement = ElementFilter.fieldsIn(testElement.getEnclosedElements()).getFirst();
Trees trees = Trees.instance(processingEnv);
TreePath iPath = trees.getPath(iElement);
StringBuilder text = new StringBuilder();
new TreeScanner<>() {
int ident = 0;
@Override
public Object scan(Tree tree, Object p) {
if (tree != null) {
String indent =
Stream.generate(() -> " ")
.limit(ident)
.collect(Collectors.joining());
text.append("\n")
.append(indent)
.append("(")
.append(tree.getKind());
ident += 4;
super.scan(tree, p);
ident -= 4;
text.append("\n")
.append(indent)
.append(")");
}
return null;
}
@Override
public Object visitIdentifier(IdentifierTree node, Object p) {
text.append(" ").append(node.getName());
return super.visitIdentifier(node, p);
}
}.scan(((VariableTree) iPath.getLeaf()).getInitializer(), null);
String expected =
"""
(MEMBER_REFERENCE
(ANNOTATED_TYPE
(TYPE_ANNOTATION
(IDENTIFIER Ann2
)
)
(ARRAY_TYPE
(ANNOTATED_TYPE
(TYPE_ANNOTATION
(IDENTIFIER Ann1
)
)
(IDENTIFIER Test
)
)
)
)
)""";
String actual = text.toString();
if (!expected.equals(actual)) {
throw new AssertionError("Expected: " + expected + "," +
"got: " + actual);
}
return false;
}
}
}

View File

@@ -23,7 +23,7 @@
/*
* @test
* @bug 7073631 7159445 7156633 8028235 8065753 8205418 8205913 8228451 8237041 8253584 8246774 8256411 8256149 8259050 8266436 8267221 8271928 8275097 8293897 8295401 8304671 8310326 8312093 8312204 8315452 8337976 8324859 8344706 8351260 8370865 8369489
* @bug 7073631 7159445 7156633 8028235 8065753 8205418 8205913 8228451 8237041 8253584 8246774 8256411 8256149 8259050 8266436 8267221 8271928 8275097 8293897 8295401 8304671 8310326 8312093 8312204 8315452 8337976 8324859 8344706 8351260 8370865
* @summary tests error and diagnostics positions
* @author Jan Lahoda
* @modules jdk.compiler/com.sun.tools.javac.api
@@ -3124,33 +3124,6 @@ public class JavacParserTest extends TestCase {
codes);
}
@Test //JDK-8369489
void testTypeAnnotationBrokenMethodRef() throws IOException {
String code = """
public class Test {
Object o1 = @Ann any()::test;
Object o2 = @Ann any().field::test;
}
""";
DiagnosticCollector<JavaFileObject> coll =
new DiagnosticCollector<>();
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, fm, coll,
null,
null, Arrays.asList(new MyFileObject(code)));
//no exceptions:
ct.parse().iterator().next();
List<String> codes = new LinkedList<>();
for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
codes.add(d.getLineNumber() + ":" + d.getColumnNumber() + ":" + d.getCode());
}
assertEquals("testTypeAnnotationBrokenMethodRef: " + codes,
List.of("2:22:compiler.err.illegal.start.of.type",
"3:22:compiler.err.illegal.start.of.type"),
codes);
}
void run(String[] args) throws Exception {
int passed = 0, failed = 0;
final Pattern p = (args != null && args.length > 0)

View File

@@ -1,26 +1,2 @@
###########################################################################
#
# Copyright (c) 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.
#
###########################################################################
# Currently empty
# Requires jcmd
jdk/test/lib/hprof/HprofTest.java 8346719 generic-all

View File

@@ -0,0 +1,92 @@
/*
* Copyright (c) 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.
*/
package org.openjdk.bench.java.lang.foreign;
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.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import java.lang.foreign.Arena;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime)
@Warmup(iterations = 5, time = 10, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 10, time = 10, timeUnit = TimeUnit.SECONDS)
@State(Scope.Benchmark)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Fork(value = 1, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" })
public class SharedCloseStackWalk {
@Param({"1", "10", "100"})
int numOtherThread;
@Param({"10", "100", "1000"})
int extraFrames;
@Param({"false", "true"})
boolean virtualThreads;
private CountDownLatch stop;
@Setup
public void setup() {
stop = new CountDownLatch(1);
for (int i = 0; i < numOtherThread; i++) {
(virtualThreads
? Thread.ofVirtual()
: Thread.ofPlatform()).start(() -> recurse(0));
}
}
@TearDown
public void teardown() {
stop.countDown();
}
@Benchmark
public void sharedOpenClose() {
Arena.ofShared().close();
}
private void recurse(int depth) {
if (depth == extraFrames) {
try {
stop.await();
} catch (InterruptedException e) {
throw new RuntimeException("Don't interrupt me!", e);
}
} else {
recurse(depth + 1);
}
}
}