Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions make/autoconf/jdk-options.m4
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_OPEN_OR_CUSTOM],

AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS],
[
# Should we build a JDK with/without sound ?
UTIL_ARG_ENABLE(NAME: jsound, DEFAULT: true,
RESULT: ENABLE_JSOUND,
DESC: [build with sound support],
CHECKING_MSG: [if we should build with sound support])
AC_SUBST(ENABLE_JSOUND)

# Should we build a JDK without a graphical UI?
UTIL_ARG_ENABLE(NAME: headless-only, DEFAULT: false,
RESULT: ENABLE_HEADLESS_ONLY,
Expand Down
2 changes: 2 additions & 0 deletions make/autoconf/spec.gmk.in
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ HOTSPOT_OVERRIDE_LIBPATH := @HOTSPOT_OVERRIDE_LIBPATH@
# Control use of precompiled header in hotspot libjvm build
USE_PRECOMPILED_HEADER := @USE_PRECOMPILED_HEADER@

ENABLE_JSOUND := @ENABLE_JSOUND@

# Only build headless support or not
ENABLE_HEADLESS_ONLY := @ENABLE_HEADLESS_ONLY@

Expand Down
77 changes: 39 additions & 38 deletions make/modules/java.desktop/Lib.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -40,44 +40,45 @@ include lib/Awt2dLibraries.gmk
################################################################################
# Create the libjsound library

ifeq ($(call isTargetOs, aix), false)

LIBJSOUND_CFLAGS := \
$(ALSA_CFLAGS) \
-DX_PLATFORM=X_$(OPENJDK_TARGET_OS_UPPERCASE) \
-DUSE_PORTS=TRUE \
-DUSE_DAUDIO=TRUE \
-DUSE_PLATFORM_MIDI_OUT=TRUE \
-DUSE_PLATFORM_MIDI_IN=TRUE \
#

ifeq ($(call isTargetOs, macosx), true)
LIBJSOUND_TOOLCHAIN := TOOLCHAIN_LINK_CXX
ifeq ($(ENABLE_JSOUND), true)
ifeq ($(call isTargetOs, aix), false)

LIBJSOUND_CFLAGS := \
$(ALSA_CFLAGS) \
-DX_PLATFORM=X_$(OPENJDK_TARGET_OS_UPPERCASE) \
-DUSE_PORTS=TRUE \
-DUSE_DAUDIO=TRUE \
-DUSE_PLATFORM_MIDI_OUT=TRUE \
-DUSE_PLATFORM_MIDI_IN=TRUE \
#

ifeq ($(call isTargetOs, macosx), true)
LIBJSOUND_TOOLCHAIN := TOOLCHAIN_LINK_CXX
endif

$(eval $(call SetupJdkLibrary, BUILD_LIBJSOUND, \
NAME := jsound, \
TOOLCHAIN := $(LIBJSOUND_TOOLCHAIN), \
OPTIMIZATION := LOW, \
CFLAGS := $(CFLAGS_JDKLIB) \
$(LIBJSOUND_CFLAGS), \
CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBJSOUND_CFLAGS), \
DISABLED_WARNINGS_gcc := undef, \
DISABLED_WARNINGS_clang := undef, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LIBS_unix := -ljava -ljvm, \
LIBS_linux := $(ALSA_LIBS), \
LIBS_macosx := -framework CoreAudio -framework CoreFoundation \
-framework CoreServices -framework AudioUnit \
-framework CoreMIDI -framework AudioToolbox $(LIBCXX), \
LIBS_windows := $(WIN_JAVA_LIB) advapi32.lib dsound.lib winmm.lib user32.lib ole32.lib, \
))

$(BUILD_LIBJSOUND): $(call FindLib, java.base, java)

TARGETS += $(BUILD_LIBJSOUND)
endif

$(eval $(call SetupJdkLibrary, BUILD_LIBJSOUND, \
NAME := jsound, \
TOOLCHAIN := $(LIBJSOUND_TOOLCHAIN), \
OPTIMIZATION := LOW, \
CFLAGS := $(CFLAGS_JDKLIB) \
$(LIBJSOUND_CFLAGS), \
CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBJSOUND_CFLAGS), \
DISABLED_WARNINGS_gcc := undef, \
DISABLED_WARNINGS_clang := undef, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LIBS_unix := -ljava -ljvm, \
LIBS_linux := $(ALSA_LIBS), \
LIBS_macosx := -framework CoreAudio -framework CoreFoundation \
-framework CoreServices -framework AudioUnit \
-framework CoreMIDI -framework AudioToolbox $(LIBCXX), \
LIBS_windows := $(WIN_JAVA_LIB) advapi32.lib dsound.lib winmm.lib user32.lib ole32.lib, \
))

$(BUILD_LIBJSOUND): $(call FindLib, java.base, java)

TARGETS += $(BUILD_LIBJSOUND)

endif

################################################################################
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/cpu/arm/frame_arm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
// between a callee frame and its stack arguments, where it is part
// of the caller/callee overlap
metadata_words_at_top = 0,
// in bytes
frame_alignment = 16,
// size, in words, of maximum shift in frame position due to alignment
align_wiggle = 1
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/cpu/ppc/frame_ppc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,7 @@
// between a callee frame and its stack arguments, where it is part
// of the caller/callee overlap
metadata_words_at_top = sizeof(java_abi) >> LogBytesPerWord,
// size, in words, of frame metadata at the frame top that needs
// to be reserved for callee functions in the runtime
// in bytes
frame_alignment = 16,
frame_alignment_in_words = frame_alignment >> LogBytesPerWord,
// size, in words, of maximum shift in frame position due to alignment
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/cpu/x86/frame_x86.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@
// between a callee frame and its stack arguments, where it is part
// of the caller/callee overlap
metadata_words_at_top = 0,
// size, in words, of frame metadata at the frame top that needs
// to be reserved for callee functions in the runtime
// in bytes
frame_alignment = 16,
// size, in words, of maximum shift in frame position due to alignment
align_wiggle = 1
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/cpu/zero/frame_zero.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
// between a callee frame and its stack arguments, where it is part
// of the caller/callee overlap
metadata_words_at_top = 0,
// in bytes
frame_alignment = 16,
// size, in words, of maximum shift in frame position due to alignment
align_wiggle = 1
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/lang/StringLatin1.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/lang/invoke/VarHandles.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
Expand Down Expand Up @@ -196,7 +196,7 @@ static VarHandle makeArrayElementHandle(Class<?> arrayClass) {

Class<?> componentType = arrayClass.getComponentType();

int aoffset = UNSAFE.arrayBaseOffset(arrayClass);
int aoffset = (int) UNSAFE.arrayBaseOffset(arrayClass);
int ascale = UNSAFE.arrayIndexScale(arrayClass);
int ashift = 31 - Integer.numberOfLeadingZeros(ascale);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6366,7 +6366,7 @@ public final void compute() {
= U.objectFieldOffset(ConcurrentHashMap.class, "cellsBusy");
private static final long CELLVALUE
= U.objectFieldOffset(CounterCell.class, "value");
private static final int ABASE = U.arrayBaseOffset(Node[].class);
private static final long ABASE = U.arrayBaseOffset(Node[].class);
private static final int ASHIFT;

static {
Expand Down
12 changes: 6 additions & 6 deletions src/java.base/share/classes/java/util/zip/CRC32C.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
Expand Down Expand Up @@ -222,9 +222,9 @@ private static int updateBytes(int crc, byte[] b, int off, int end) {
if (end - off >= 8 && Unsafe.ARRAY_BYTE_INDEX_SCALE == 1) {

// align on 8 bytes
int alignLength
long alignLength
= (8 - ((Unsafe.ARRAY_BYTE_BASE_OFFSET + off) & 0x7)) & 0x7;
for (int alignEnd = off + alignLength; off < alignEnd; off++) {
for (long alignEnd = off + alignLength; off < alignEnd; off++) {
crc = (crc >>> 8) ^ byteTable[(crc ^ b[off]) & 0xFF];
}

Expand All @@ -238,11 +238,11 @@ private static int updateBytes(int crc, byte[] b, int off, int end) {
int secondHalf;
if (Unsafe.ADDRESS_SIZE == 4) {
// On 32 bit platforms read two ints instead of a single 64bit long
firstHalf = UNSAFE.getInt(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
secondHalf = UNSAFE.getInt(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off
firstHalf = UNSAFE.getInt(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
secondHalf = UNSAFE.getInt(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off
+ Integer.BYTES);
} else {
long value = UNSAFE.getLong(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
long value = UNSAFE.getLong(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off);
if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
firstHalf = (int) value;
secondHalf = (int) (value >>> 32);
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/util/zip/ZipUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,19 +716,19 @@ public static long mismatch(MemorySegment srcSegment, long srcFromOffset, long s

private static long getBaseAndScale(Class<?> arrayType) {
if (arrayType.equals(byte[].class)) {
return (long) Unsafe.ARRAY_BYTE_BASE_OFFSET | ((long)Unsafe.ARRAY_BYTE_INDEX_SCALE << 32);
return Unsafe.ARRAY_BYTE_BASE_OFFSET | ((long)Unsafe.ARRAY_BYTE_INDEX_SCALE << 32);
} else if (arrayType.equals(char[].class)) {
return (long) Unsafe.ARRAY_CHAR_BASE_OFFSET | ((long)Unsafe.ARRAY_CHAR_INDEX_SCALE << 32);
return Unsafe.ARRAY_CHAR_BASE_OFFSET | ((long)Unsafe.ARRAY_CHAR_INDEX_SCALE << 32);
} else if (arrayType.equals(short[].class)) {
return (long)Unsafe.ARRAY_SHORT_BASE_OFFSET | ((long)Unsafe.ARRAY_SHORT_INDEX_SCALE << 32);
return Unsafe.ARRAY_SHORT_BASE_OFFSET | ((long)Unsafe.ARRAY_SHORT_INDEX_SCALE << 32);
} else if (arrayType.equals(int[].class)) {
return (long)Unsafe.ARRAY_INT_BASE_OFFSET | ((long) Unsafe.ARRAY_INT_INDEX_SCALE << 32);
return Unsafe.ARRAY_INT_BASE_OFFSET | ((long)Unsafe.ARRAY_INT_INDEX_SCALE << 32);
} else if (arrayType.equals(float[].class)) {
return (long)Unsafe.ARRAY_FLOAT_BASE_OFFSET | ((long)Unsafe.ARRAY_FLOAT_INDEX_SCALE << 32);
return Unsafe.ARRAY_FLOAT_BASE_OFFSET | ((long)Unsafe.ARRAY_FLOAT_INDEX_SCALE << 32);
} else if (arrayType.equals(long[].class)) {
return (long)Unsafe.ARRAY_LONG_BASE_OFFSET | ((long)Unsafe.ARRAY_LONG_INDEX_SCALE << 32);
return Unsafe.ARRAY_LONG_BASE_OFFSET | ((long)Unsafe.ARRAY_LONG_INDEX_SCALE << 32);
} else if (arrayType.equals(double[].class)) {
return (long)Unsafe.ARRAY_DOUBLE_BASE_OFFSET | ((long)Unsafe.ARRAY_DOUBLE_INDEX_SCALE << 32);
return Unsafe.ARRAY_DOUBLE_BASE_OFFSET | ((long)Unsafe.ARRAY_DOUBLE_INDEX_SCALE << 32);
} else {
throw new IllegalArgumentException("Not a supported array class: " + arrayType.getSimpleName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
public abstract sealed class HeapMemorySegmentImpl extends AbstractMemorySegmentImpl {

private static final Unsafe UNSAFE = Unsafe.getUnsafe();
private static final int BYTE_ARR_BASE = UNSAFE.arrayBaseOffset(byte[].class);
private static final long BYTE_ARR_BASE = UNSAFE.arrayBaseOffset(byte[].class);

private static final long MAX_ALIGN_1 = ValueLayout.JAVA_BYTE.byteAlignment();
private static final long MAX_ALIGN_2 = ValueLayout.JAVA_SHORT.byteAlignment();
Expand Down Expand Up @@ -89,7 +89,7 @@ ByteBuffer makeByteBuffer() {
throw new UnsupportedOperationException("Not an address to an heap-allocated byte array");
}
JavaNioAccess nioAccess = SharedSecrets.getJavaNioAccess();
return nioAccess.newHeapByteBuffer(baseByte, (int)offset - BYTE_ARR_BASE, (int) byteSize(), null);
return nioAccess.newHeapByteBuffer(baseByte, (int)(offset - BYTE_ARR_BASE), (int) byteSize(), null);
}

// factories
Expand Down
36 changes: 23 additions & 13 deletions src/java.base/share/classes/jdk/internal/misc/Unsafe.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 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
Expand Down Expand Up @@ -1037,8 +1037,11 @@ private void checkWritebackEnabled() {
* This constant differs from all results that will ever be returned from
* {@link #staticFieldOffset}, {@link #objectFieldOffset},
* or {@link #arrayBaseOffset}.
* <p>
* The static type is @code long} to emphasize that long arithmetic should
* always be used for offset calculations to avoid overflows.
*/
public static final int INVALID_FIELD_OFFSET = -1;
public static final long INVALID_FIELD_OFFSET = -1;

/**
* Reports the location of a given field in the storage allocation of its
Expand Down Expand Up @@ -1166,11 +1169,15 @@ public void ensureClassInitialized(Class<?> c) {
* for the same class, you may use that scale factor, together with this
* base offset, to form new offsets to access elements of arrays of the
* given class.
* <p>
* The return value is in the range of a {@code int}. The return type is
* {@code long} to emphasize that long arithmetic should always be used
* for offset calculations to avoid overflows.
*
* @see #getInt(Object, long)
* @see #putInt(Object, long, int)
*/
public int arrayBaseOffset(Class<?> arrayClass) {
public long arrayBaseOffset(Class<?> arrayClass) {
if (arrayClass == null) {
throw new NullPointerException();
}
Expand All @@ -1180,39 +1187,39 @@ public int arrayBaseOffset(Class<?> arrayClass) {


/** The value of {@code arrayBaseOffset(boolean[].class)} */
public static final int ARRAY_BOOLEAN_BASE_OFFSET
public static final long ARRAY_BOOLEAN_BASE_OFFSET
= theUnsafe.arrayBaseOffset(boolean[].class);

/** The value of {@code arrayBaseOffset(byte[].class)} */
public static final int ARRAY_BYTE_BASE_OFFSET
public static final long ARRAY_BYTE_BASE_OFFSET
= theUnsafe.arrayBaseOffset(byte[].class);

/** The value of {@code arrayBaseOffset(short[].class)} */
public static final int ARRAY_SHORT_BASE_OFFSET
public static final long ARRAY_SHORT_BASE_OFFSET
= theUnsafe.arrayBaseOffset(short[].class);

/** The value of {@code arrayBaseOffset(char[].class)} */
public static final int ARRAY_CHAR_BASE_OFFSET
public static final long ARRAY_CHAR_BASE_OFFSET
= theUnsafe.arrayBaseOffset(char[].class);

/** The value of {@code arrayBaseOffset(int[].class)} */
public static final int ARRAY_INT_BASE_OFFSET
public static final long ARRAY_INT_BASE_OFFSET
= theUnsafe.arrayBaseOffset(int[].class);

/** The value of {@code arrayBaseOffset(long[].class)} */
public static final int ARRAY_LONG_BASE_OFFSET
public static final long ARRAY_LONG_BASE_OFFSET
= theUnsafe.arrayBaseOffset(long[].class);

/** The value of {@code arrayBaseOffset(float[].class)} */
public static final int ARRAY_FLOAT_BASE_OFFSET
public static final long ARRAY_FLOAT_BASE_OFFSET
= theUnsafe.arrayBaseOffset(float[].class);

/** The value of {@code arrayBaseOffset(double[].class)} */
public static final int ARRAY_DOUBLE_BASE_OFFSET
public static final long ARRAY_DOUBLE_BASE_OFFSET
= theUnsafe.arrayBaseOffset(double[].class);

/** The value of {@code arrayBaseOffset(Object[].class)} */
public static final int ARRAY_OBJECT_BASE_OFFSET
public static final long ARRAY_OBJECT_BASE_OFFSET
= theUnsafe.arrayBaseOffset(Object[].class);

/**
Expand All @@ -1221,6 +1228,9 @@ public int arrayBaseOffset(Class<?> arrayClass) {
* will generally not work properly with accessors like {@link
* #getByte(Object, long)}, so the scale factor for such classes is reported
* as zero.
* <p>
* The computation of the actual memory offset should always use {@code
* long} arithmetic to avoid overflows.
*
* @see #arrayBaseOffset
* @see #getInt(Object, long)
Expand Down Expand Up @@ -3833,7 +3843,7 @@ private void putShortParts(Object o, long offset, byte i0, byte i1) {
private native Object staticFieldBase0(Field f);
private native boolean shouldBeInitialized0(Class<?> c);
private native void ensureClassInitialized0(Class<?> c);
private native int arrayBaseOffset0(Class<?> arrayClass);
private native int arrayBaseOffset0(Class<?> arrayClass); // public version returns long to promote correct arithmetic
private native int arrayIndexScale0(Class<?> arrayClass);
private native int getLoadAverage0(double[] loadavg, int nelems);

Expand Down
Loading
Loading