Skip to content

Commit 42710e8

Browse files
committed
Merge latest openjdk
2 parents 27b6455 + 0138c9a commit 42710e8

File tree

28 files changed

+488
-280
lines changed

28 files changed

+488
-280
lines changed

make/RunTests.gmk

+14-11
Original file line numberDiff line numberDiff line change
@@ -732,14 +732,16 @@ endef
732732
#
733733
SetupAOT = $(NamedParamsMacroTemplate)
734734
define SetupAOTBody
735-
$1_AOT_JDK_CONF := $$($1_TEST_SUPPORT_DIR)/aot/jdk.aotconf
736-
$1_AOT_JDK_CACHE := $$($1_TEST_SUPPORT_DIR)/aot/jdk.aotcache
737-
$1_AOT_JDK_LOG := $$($1_TEST_SUPPORT_DIR)/aot/TestSetupAOT.log
735+
$1_AOT_JDK_OUTPUT_DIR := $$($1_TEST_SUPPORT_DIR)/aot
736+
$1_AOT_JDK_CONF := $$($1_AOT_JDK_OUTPUT_DIR)/jdk.aotconf
737+
$1_AOT_JDK_CACHE := $$($1_AOT_JDK_OUTPUT_DIR)/jdk.aotcache
738+
$1_AOT_JDK_LOG := $$($1_AOT_JDK_OUTPUT_DIR)/TestSetupAOT.log
738739

739-
# We execute the training run with $(TEST_IMAGE_DIR)/setup_aot/TestSetupAOT.class
740+
# We execute the training run with the TestSetupAOT class from $(TEST_IMAGE_DIR)/setup_aot/TestSetupAOT.jar
740741
# to touch a fair number of classes inside the JDK. Note that we can't specify a classpath,
741742
# or else the AOT cache cannot be used with jtreg test cases that use a different value
742-
# for their classpaths. Instead, we run in the $(TEST_IMAGE_DIR)/setup_aot/ directory.
743+
# for their classpaths. Instead, we cd in the $$($1_AOT_JDK_OUTPUT_DIR) directory,
744+
# extract the TestSetupAOT.jar there, and run in that directory without specifying a classpath.
743745
# The "java" launcher will have an implicit classpath of ".", so it can pick up the TestSetupAOT
744746
# class from the JVM's current directory.
745747
#
@@ -748,19 +750,20 @@ define SetupAOTBody
748750
# only classes from the JDK.
749751

750752
$$($1_AOT_JDK_CACHE): $$(JDK_IMAGE_DIR)/release
751-
$$(call MakeDir, $$($1_TEST_SUPPORT_DIR)/aot)
753+
$$(call MakeDir, $$($1_AOT_JDK_OUTPUT_DIR))
752754

753755
$$(call LogWarn, AOT: Create cache configuration) \
754-
$$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/aot, ( \
755-
$(CD) $(TEST_IMAGE_DIR)/setup_aot; \
756+
$$(call ExecuteWithLog, $$($1_AOT_JDK_OUTPUT_DIR), ( \
757+
cd $$($1_AOT_JDK_OUTPUT_DIR); \
758+
$(JAR) --extract --file $(TEST_IMAGE_DIR)/setup_aot/TestSetupAOT.jar; \
756759
$$(FIXPATH) $(JDK_UNDER_TEST)/bin/java $$($1_VM_OPTIONS) \
757-
-Xlog:cds,cds+class=debug:file=$$($1_AOT_JDK_CONF).log -Xlog:cds*=error \
760+
-Xlog:class+load,cds,cds+class=debug:file=$$($1_AOT_JDK_CONF).log -Xlog:cds*=error \
758761
-XX:AOTMode=record -XX:AOTConfiguration=$$($1_AOT_JDK_CONF) \
759-
TestSetupAOT > $$($1_AOT_JDK_LOG) \
762+
TestSetupAOT $$($1_AOT_JDK_OUTPUT_DIR) > $$($1_AOT_JDK_LOG) \
760763
))
761764

762765
$$(call LogWarn, AOT: Generate AOT cache $$($1_AOT_JDK_CACHE) with flags: $$($1_VM_OPTIONS))
763-
$$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/aot, ( \
766+
$$(call ExecuteWithLog, $$($1_AOT_JDK_OUTPUT_DIR), ( \
764767
$$(FIXPATH) $(JDK_UNDER_TEST)/bin/java \
765768
$$($1_VM_OPTIONS) -Xlog:cds,cds+class=debug:file=$$($1_AOT_JDK_CACHE).log -Xlog:cds*=error \
766769
-XX:ExtraSharedClassListFile=$(JDK_UNDER_TEST)/lib/classlist \

make/modules/java.base/lib/CoreLibraries.gmk

+1-6
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,9 @@ ifeq ($(INCLUDE), true)
3232
## Build libverify
3333
################################################################################
3434

35-
LIBVERIFY_OPTIMIZATION := HIGH
36-
ifeq ($(call isTargetOs, linux)+$(COMPILE_WITH_DEBUG_SYMBOLS), true+true)
37-
LIBVERIFY_OPTIMIZATION := LOW
38-
endif
39-
4035
$(eval $(call SetupJdkLibrary, BUILD_LIBVERIFY, \
4136
NAME := verify, \
42-
OPTIMIZATION := $(LIBVERIFY_OPTIMIZATION), \
37+
OPTIMIZATION := HIGH, \
4338
DISABLED_WARNINGS_gcc_check_code.c := unused-variable, \
4439
DISABLED_WARNINGS_clang_check_code.c := unused-variable, \
4540
EXTRA_HEADER_DIRS := libjava, \

make/test/BuildTestSetupAOT.gmk

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ include JavaCompilation.gmk
3737

3838
SETUP_AOT_BASEDIR := $(TOPDIR)/test/setup_aot
3939
SETUP_AOT_SUPPORT := $(SUPPORT_OUTPUTDIR)/test/setup_aot
40-
SETUP_AOT_CLASS := $(SETUP_AOT_SUPPORT)/classes/TestSetupAOT.class
40+
SETUP_AOT_JAR := $(SETUP_AOT_SUPPORT)/TestSetupAOT.jar
4141

4242
$(eval $(call SetupJavaCompilation, BUILD_SETUP_AOT, \
4343
TARGET_RELEASE := $(TARGET_RELEASE_NEWJDK_UPGRADED), \
4444
SRC := $(SETUP_AOT_BASEDIR), \
4545
BIN := $(SETUP_AOT_SUPPORT)/classes, \
46+
JAR := $(SETUP_AOT_JAR), \
4647
))
4748

4849
TARGETS += $(BUILD_SETUP_AOT)
@@ -53,9 +54,8 @@ TARGETS += $(BUILD_SETUP_AOT)
5354

5455
# Copy to hotspot jtreg test image
5556
$(eval $(call SetupCopyFiles, COPY_SETUP_AOT, \
56-
SRC := $(SETUP_AOT_SUPPORT)/classes, \
5757
DEST := $(TEST_IMAGE_DIR)/setup_aot, \
58-
FILES := TestSetupAOT.class, \
58+
FILES := $(SETUP_AOT_JAR), \
5959
))
6060

6161
IMAGES_TARGETS += $(COPY_SETUP_AOT)

src/java.base/share/classes/jdk/internal/foreign/ArenaImpl.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,11 @@ public void close() {
4848
}
4949

5050
public NativeMemorySegmentImpl allocateNoInit(long byteSize, long byteAlignment) {
51-
Utils.checkAllocationSizeAndAlign(byteSize, byteAlignment);
52-
return SegmentFactories.allocateSegment(byteSize, byteAlignment, session, shouldReserveMemory);
51+
return SegmentFactories.allocateNativeSegment(byteSize, byteAlignment, session, shouldReserveMemory, false);
5352
}
5453

5554
@Override
5655
public NativeMemorySegmentImpl allocate(long byteSize, long byteAlignment) {
57-
NativeMemorySegmentImpl segment = allocateNoInit(byteSize, byteAlignment);
58-
segment.fill((byte)0);
59-
return segment;
56+
return SegmentFactories.allocateNativeSegment(byteSize, byteAlignment, session, shouldReserveMemory, true);
6057
}
6158
}

src/java.base/share/classes/jdk/internal/foreign/SegmentFactories.java

+43-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,7 @@
3535
import jdk.internal.foreign.HeapMemorySegmentImpl.OfShort;
3636
import jdk.internal.misc.Unsafe;
3737
import jdk.internal.misc.VM;
38+
import jdk.internal.vm.annotation.DontInline;
3839
import jdk.internal.vm.annotation.ForceInline;
3940

4041
import java.lang.foreign.MemorySegment;
@@ -175,39 +176,63 @@ public static OfDouble arrayOfDoubleSegment(Object base, long offset, long lengt
175176
return new OfDouble(offset, base, length, readOnly, bufferScope);
176177
}
177178

178-
public static NativeMemorySegmentImpl allocateSegment(long byteSize, long byteAlignment, MemorySessionImpl sessionImpl,
179-
boolean shouldReserve) {
179+
public static NativeMemorySegmentImpl allocateNativeSegment(long byteSize, long byteAlignment, MemorySessionImpl sessionImpl,
180+
boolean shouldReserve, boolean init) {
181+
long address = SegmentFactories.allocateNativeInternal(byteSize, byteAlignment, sessionImpl, shouldReserve, init);
182+
return new NativeMemorySegmentImpl(address, byteSize, false, sessionImpl);
183+
}
184+
185+
private static long allocateNativeInternal(long byteSize, long byteAlignment, MemorySessionImpl sessionImpl,
186+
boolean shouldReserve, boolean init) {
180187
ensureInitialized();
188+
Utils.checkAllocationSizeAndAlign(byteSize, byteAlignment);
181189
sessionImpl.checkValidState();
182190
if (VM.isDirectMemoryPageAligned()) {
183191
byteAlignment = Math.max(byteAlignment, AbstractMemorySegmentImpl.NIO_ACCESS.pageSize());
184192
}
185-
long alignedSize = Math.max(1L, byteAlignment > MAX_MALLOC_ALIGN ?
186-
byteSize + (byteAlignment - 1) :
187-
byteSize);
193+
// Align the allocation size up to a multiple of 8 so we can init the memory with longs
194+
long alignedSize = init ? Utils.alignUp(byteSize, Long.BYTES) : byteSize;
195+
196+
long allocationSize;
197+
long allocationBase;
198+
long result;
199+
if (byteAlignment > MAX_MALLOC_ALIGN) {
200+
allocationSize = alignedSize + byteAlignment - MAX_MALLOC_ALIGN;
201+
if (shouldReserve) {
202+
AbstractMemorySegmentImpl.NIO_ACCESS.reserveMemory(allocationSize, byteSize);
203+
}
204+
205+
allocationBase = allocateMemoryWrapper(allocationSize);
206+
result = Utils.alignUp(allocationBase, byteAlignment);
207+
} else {
208+
allocationSize = alignedSize;
209+
if (shouldReserve) {
210+
AbstractMemorySegmentImpl.NIO_ACCESS.reserveMemory(allocationSize, byteSize);
211+
}
188212

189-
if (shouldReserve) {
190-
AbstractMemorySegmentImpl.NIO_ACCESS.reserveMemory(alignedSize, byteSize);
213+
allocationBase = allocateMemoryWrapper(allocationSize);
214+
result = allocationBase;
191215
}
192216

193-
long buf = allocateMemoryWrapper(alignedSize);
194-
long alignedBuf = Utils.alignUp(buf, byteAlignment);
195-
NativeMemorySegmentImpl segment = new NativeMemorySegmentImpl(buf, alignedSize,
196-
false, sessionImpl);
217+
if (init) {
218+
initNativeMemory(result, alignedSize);
219+
}
197220
sessionImpl.addOrCleanupIfFail(new MemorySessionImpl.ResourceList.ResourceCleanup() {
198221
@Override
199222
public void cleanup() {
200-
UNSAFE.freeMemory(buf);
223+
UNSAFE.freeMemory(allocationBase);
201224
if (shouldReserve) {
202-
AbstractMemorySegmentImpl.NIO_ACCESS.unreserveMemory(alignedSize, byteSize);
225+
AbstractMemorySegmentImpl.NIO_ACCESS.unreserveMemory(allocationSize, byteSize);
203226
}
204227
}
205228
});
206-
if (alignedSize != byteSize) {
207-
long delta = alignedBuf - buf;
208-
segment = (NativeMemorySegmentImpl) segment.asSlice(delta, byteSize);
229+
return result;
230+
}
231+
232+
private static void initNativeMemory(long address, long byteSize) {
233+
for (long i = 0; i < byteSize; i += Long.BYTES) {
234+
UNSAFE.putLongUnaligned(null, address + i, 0);
209235
}
210-
return segment;
211236
}
212237

213238
private static long allocateMemoryWrapper(long size) {

src/java.base/share/classes/jdk/internal/misc/VM.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -151,12 +151,12 @@ public static long maxDirectMemory() {
151151
// aligned. The "-XX:+PageAlignDirectMemory" option can be used to force
152152
// buffers, allocated by ByteBuffer.allocateDirect, to be page aligned.
153153
@Stable
154-
private static boolean pageAlignDirectMemory;
154+
private static Boolean pageAlignDirectMemory;
155155

156156
// Returns {@code true} if the direct buffers should be page aligned. This
157157
// variable is initialized by saveAndRemoveProperties.
158158
public static boolean isDirectMemoryPageAligned() {
159-
return pageAlignDirectMemory;
159+
return pageAlignDirectMemory != null && pageAlignDirectMemory;
160160
}
161161

162162
/**
@@ -261,9 +261,7 @@ public static void saveProperties(Map<String, String> props) {
261261
}
262262

263263
// Check if direct buffers should be page aligned
264-
s = props.get("sun.nio.PageAlignDirectMemory");
265-
if ("true".equals(s))
266-
pageAlignDirectMemory = true;
264+
pageAlignDirectMemory = "true".equals(props.get("sun.nio.PageAlignDirectMemory"));
267265
}
268266

269267
// Initialize any miscellaneous operating system settings that need to be

src/java.base/share/classes/jdk/internal/ref/CleanerImpl.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -135,8 +135,14 @@ public void run() {
135135
mlThread.eraseThreadLocals();
136136
}
137137
try {
138-
// Wait for a Ref, with a timeout to avoid getting hung
139-
// due to a race with clear/clean
138+
// Wait for a Ref, with a timeout to avoid a potential hang.
139+
// The Cleaner may become unreachable and its cleanable run,
140+
// while there are registered cleanables for other objects.
141+
// If the application explicitly calls clean() on all remaining
142+
// Cleanables, there won't be any references enqueued to unblock
143+
// this. Using a timeout is simpler than unblocking this by
144+
// having cleaning of the last registered cleanable enqueue a
145+
// dummy reference.
140146
Cleanable ref = (Cleanable) queue.remove(60 * 1000L);
141147
if (ref != null) {
142148
ref.clean();

src/jdk.jfr/share/conf/jfr/default.jfc

+6
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@
9595
<setting name="threshold" control="locking-threshold">20 ms</setting>
9696
</event>
9797

98+
<event name="jdk.JavaMonitorNotify">
99+
<setting name="enabled">false</setting>
100+
<setting name="stackTrace">true</setting>
101+
<setting name="threshold">0 ms</setting>
102+
</event>
103+
98104
<event name="jdk.JavaMonitorInflate">
99105
<setting name="enabled">false</setting>
100106
<setting name="stackTrace">true</setting>

src/jdk.jfr/share/conf/jfr/profile.jfc

+6
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@
9595
<setting name="threshold" control="locking-threshold">10 ms</setting>
9696
</event>
9797

98+
<event name="jdk.JavaMonitorNotify">
99+
<setting name="enabled">false</setting>
100+
<setting name="stackTrace">true</setting>
101+
<setting name="threshold">0 ms</setting>
102+
</event>
103+
98104
<event name="jdk.JavaMonitorInflate">
99105
<setting name="enabled">false</setting>
100106
<setting name="stackTrace">true</setting>

src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacBaseInstallerBundler.java

-16
Original file line numberDiff line numberDiff line change
@@ -141,22 +141,6 @@ protected void validateAppImageAndBundeler(
141141
Map<String, ? super Object> params) throws ConfigException {
142142
if (PREDEFINED_APP_IMAGE.fetchFrom(params) != null) {
143143
Path applicationImage = PREDEFINED_APP_IMAGE.fetchFrom(params);
144-
if (!IOUtils.exists(applicationImage)) {
145-
throw new ConfigException(
146-
MessageFormat.format(I18N.getString(
147-
"message.app-image-dir-does-not-exist"),
148-
PREDEFINED_APP_IMAGE.getID(),
149-
applicationImage.toString()),
150-
MessageFormat.format(I18N.getString(
151-
"message.app-image-dir-does-not-exist.advice"),
152-
PREDEFINED_APP_IMAGE.getID()));
153-
}
154-
if (APP_NAME.fetchFrom(params) == null) {
155-
throw new ConfigException(
156-
I18N.getString("message.app-image-requires-app-name"),
157-
I18N.getString(
158-
"message.app-image-requires-app-name.advice"));
159-
}
160144
if (AppImageFile.load(applicationImage).isSigned()) {
161145
if (!Files.exists(
162146
PackageFile.getPathInAppImage(applicationImage))) {

src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgBundler.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ public String getID() {
685685
}
686686

687687
private static boolean isValidBundleIdentifier(String id) {
688+
Objects.requireNonNull(id);
688689
for (int i = 0; i < id.length(); i++) {
689690
char a = id.charAt(i);
690691
// We check for ASCII codes first which we accept. If check fails,
@@ -709,12 +710,6 @@ public boolean validate(Map<String, ? super Object> params)
709710
validateAppImageAndBundeler(params);
710711

711712
String identifier = MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params);
712-
if (identifier == null) {
713-
throw new ConfigException(
714-
I18N.getString("message.app-image-requires-identifier"),
715-
I18N.getString(
716-
"message.app-image-requires-identifier.advice"));
717-
}
718713
if (!isValidBundleIdentifier(identifier)) {
719714
throw new ConfigException(
720715
MessageFormat.format(I18N.getString(

src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources.properties

-6
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ message.ignoring.symlink=Warning: codesign is skipping the symlink {0}.
7272
message.already.signed=File already signed: {0}.
7373
message.keychain.error=Error: unable to get keychain list.
7474
message.building-bundle=Building Mac App Store Package for {0}.
75-
message.app-image-dir-does-not-exist=Specified application image directory {0}: {1} does not exists.
76-
message.app-image-dir-does-not-exist.advice=Confirm that the value for {0} exists.
77-
message.app-image-requires-app-name=When using an external app image you must specify the app name.
78-
message.app-image-requires-app-name.advice=Set the app name via the -name CLI flag, the fx:application/@name ANT attribute, or via the 'appName' bundler argument.
79-
message.app-image-requires-identifier=Unable to extract identifier from app image.
80-
message.app-image-requires-identifier.advice=Use "--verbose" for extended error message or specify it via "--mac-package-identifier".
8175
message.invalid-identifier=invalid mac bundle identifier [{0}].
8276
message.invalid-identifier.advice=specify identifier with "--mac-package-identifier".
8377
message.building-dmg=Building DMG package for {0}.

src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -547,9 +547,6 @@ public boolean processArguments() {
547547
}
548548
usedNames.add(slName);
549549
}
550-
if (runtimeInstaller && bp.getName() == null) {
551-
throw new PackagerException("ERR_NoJreInstallerName");
552-
}
553550

554551
generateBundle(bp.getBundleParamsAsMap());
555552
return true;

src/jdk.jpackage/share/classes/jdk/jpackage/internal/LauncherData.java

-5
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,6 @@ private static LauncherData createNonModular(
178178
launcherData.qualifiedClassName = getMainClass(params);
179179

180180
launcherData.mainJarName = getMainJarName(params);
181-
if (launcherData.mainJarName == null && launcherData.qualifiedClassName
182-
== null) {
183-
throw new ConfigException(I18N.getString("error.no-main-jar-parameter"),
184-
null);
185-
}
186181

187182
Path mainJarDir = StandardBundlerParam.SOURCE_DIR.fetchFrom(params);
188183

0 commit comments

Comments
 (0)