diff --git a/doc/hotspot-style.html b/doc/hotspot-style.html index 0305bfeca03bd..9f26fc6636205 100644 --- a/doc/hotspot-style.html +++ b/doc/hotspot-style.html @@ -217,10 +217,10 @@
All .cpp files include precompiled.hpp as the first include -line.
precompiled.hpp is just a build time optimization, so don't rely -on it to resolve include problems.
Some build configurations use precompiled headers to speed up the +build times. The precompiled headers are included in the precompiled.hpp +file. Note that precompiled.hpp is just a build time optimization, so +don't rely on it to resolve include problems.
Keep the include lines alphabetically sorted.
Put conditional inclusions (#if ...
) at the end of
the include list.
'\u007a'
- * + * 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 @@ -1172,11 +1175,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. + *
+ * 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(); } @@ -1186,39 +1193,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); /** @@ -1227,6 +1234,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. + *
+ * The computation of the actual memory offset should always use {@code + * long} arithmetic to avoid overflows. * * @see #arrayBaseOffset * @see #getInt(Object, long) @@ -3840,7 +3850,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); diff --git a/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java b/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java index a24f8389709d0..1a56c3c64fd47 100644 --- a/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java +++ b/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, 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 @@ -457,8 +457,8 @@ public static int mismatch(boolean[] a, int aFromIndex, if (length > 7) { if (a[aFromIndex] != b[bFromIndex]) return 0; - int aOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + aFromIndex; - int bOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + bFromIndex; + long aOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + aFromIndex; + long bOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + bFromIndex; i = vectorizedMismatch( a, aOffset, b, bOffset, @@ -550,8 +550,8 @@ public static int mismatch(byte[] a, int aFromIndex, if (length > 7) { if (a[aFromIndex] != b[bFromIndex]) return 0; - int aOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + aFromIndex; - int bOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + bFromIndex; + long aOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + aFromIndex; + long bOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + bFromIndex; i = vectorizedMismatch( a, aOffset, b, bOffset, @@ -599,8 +599,8 @@ public static int mismatch(char[] a, int aFromIndex, if (length > 3) { if (a[aFromIndex] != b[bFromIndex]) return 0; - int aOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE); - int bOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE); + long aOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE); + long bOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE); i = vectorizedMismatch( a, aOffset, b, bOffset, @@ -648,8 +648,8 @@ public static int mismatch(short[] a, int aFromIndex, if (length > 3) { if (a[aFromIndex] != b[bFromIndex]) return 0; - int aOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE); - int bOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE); + long aOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE); + long bOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE); i = vectorizedMismatch( a, aOffset, b, bOffset, @@ -697,8 +697,8 @@ public static int mismatch(int[] a, int aFromIndex, if (length > 1) { if (a[aFromIndex] != b[bFromIndex]) return 0; - int aOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_INT_INDEX_SCALE); - int bOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_INT_INDEX_SCALE); + long aOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_INT_INDEX_SCALE); + long bOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_INT_INDEX_SCALE); i = vectorizedMismatch( a, aOffset, b, bOffset, @@ -729,8 +729,8 @@ public static int mismatch(float[] a, int aFromIndex, int i = 0; if (length > 1) { if (Float.floatToRawIntBits(a[aFromIndex]) == Float.floatToRawIntBits(b[bFromIndex])) { - int aOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE); - int bOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE); + long aOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE); + long bOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE); i = vectorizedMismatch( a, aOffset, b, bOffset, @@ -787,8 +787,8 @@ public static int mismatch(long[] a, int aFromIndex, } if (a[aFromIndex] != b[bFromIndex]) return 0; - int aOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE); - int bOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE); + long aOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE); + long bOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE); int i = vectorizedMismatch( a, aOffset, b, bOffset, @@ -813,8 +813,8 @@ public static int mismatch(double[] a, int aFromIndex, } int i = 0; if (Double.doubleToRawLongBits(a[aFromIndex]) == Double.doubleToRawLongBits(b[bFromIndex])) { - int aOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE); - int bOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE); + long aOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE); + long bOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE); i = vectorizedMismatch( a, aOffset, b, bOffset, diff --git a/src/java.base/share/classes/jdk/internal/util/DecimalDigits.java b/src/java.base/share/classes/jdk/internal/util/DecimalDigits.java index 2c140bfbc134a..d3df46dcd3c4d 100644 --- a/src/java.base/share/classes/jdk/internal/util/DecimalDigits.java +++ b/src/java.base/share/classes/jdk/internal/util/DecimalDigits.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -62,7 +62,7 @@ public final class DecimalDigits { private static final short[] DIGITS; static { - short[] digits = new short[10 * 10]; + short[] digits = new short[128]; for (int i = 0; i < 10; i++) { short hi = (short) (i + '0'); @@ -394,7 +394,7 @@ public static int getChars(long i, int index, char[] buf) { * @param v to convert */ public static void putPair(char[] buf, int charPos, int v) { - int packed = DIGITS[v]; + int packed = DIGITS[v & 0x7f]; buf[charPos ] = (char) (packed & 0xFF); buf[charPos + 1] = (char) (packed >> 8); } @@ -407,7 +407,7 @@ public static void putPair(char[] buf, int charPos, int v) { * @param v to convert */ public static void putPairLatin1(byte[] buf, int charPos, int v) { - int packed = DIGITS[v]; + int packed = DIGITS[v & 0x7f]; putCharLatin1(buf, charPos, packed & 0xFF); putCharLatin1(buf, charPos + 1, packed >> 8); } @@ -420,13 +420,13 @@ public static void putPairLatin1(byte[] buf, int charPos, int v) { * @param v to convert */ public static void putPairUTF16(byte[] buf, int charPos, int v) { - int packed = DIGITS[v]; + int packed = DIGITS[v & 0x7f]; putCharUTF16(buf, charPos, packed & 0xFF); putCharUTF16(buf, charPos + 1, packed >> 8); } private static void putCharLatin1(byte[] buf, int charPos, int c) { - UNSAFE.putByte(buf, ARRAY_BYTE_BASE_OFFSET + (long) charPos, (byte) c); + UNSAFE.putByte(buf, ARRAY_BYTE_BASE_OFFSET + charPos, (byte) c); } private static void putCharUTF16(byte[] buf, int charPos, int c) { diff --git a/src/java.base/share/classes/jdk/internal/util/OctalDigits.java b/src/java.base/share/classes/jdk/internal/util/OctalDigits.java deleted file mode 100644 index c41d0f755743b..0000000000000 --- a/src/java.base/share/classes/jdk/internal/util/OctalDigits.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2023, 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. - */ - -package jdk.internal.util; - -import jdk.internal.access.JavaLangAccess; -import jdk.internal.access.SharedSecrets; -import jdk.internal.vm.annotation.Stable; - -/** - * Digits class for octal digits. - * - * @since 21 - */ -public final class OctalDigits { - private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess(); - - @Stable - private static final short[] DIGITS; - - static { - short[] digits = new short[8 * 8]; - - for (int i = 0; i < 8; i++) { - short lo = (short) (i + '0'); - - for (int j = 0; j < 8; j++) { - short hi = (short) ((j + '0') << 8); - digits[(i << 3) + j] = (short) (hi | lo); - } - } - - DIGITS = digits; - } - - /** - * Constructor. - */ - private OctalDigits() { - } - - /** - * Insert digits for long value in buffer from high index to low index. - * - * @param value value to convert - * @param index insert point + 1 - * @param buffer byte buffer to copy into - * - * @return the last index used - */ - public static int getCharsLatin1(long value, int index, byte[] buffer){ - while ((value & ~0x3F) != 0) { - int digits = DIGITS[((int) value) & 0x3F]; - value >>>= 6; - buffer[--index] = (byte) (digits >> 8); - buffer[--index] = (byte) (digits & 0xFF); - } - - int digits = DIGITS[(int) (value & 0x3F)]; - buffer[--index] = (byte) (digits >> 8); - - if (7 < value) { - buffer[--index] = (byte) (digits & 0xFF); - } - - return index; - } - - - /** - * This is a variant of {@link OctalDigits#getCharsLatin1(long, int, byte[])}, but for - * UTF-16 coder. - * - * @param value value to convert - * @param index insert point + 1 - * @param buffer byte buffer to copy into - * - * @return the last index used - */ - public static int getCharsUTF16(long value, int index, byte[] buffer){ - while ((value & ~0x3F) != 0) { - int pair = (int) DIGITS[((int) value) & 0x3F]; - JLA.putCharUTF16(buffer, --index, pair >> 8); - JLA.putCharUTF16(buffer, --index, pair & 0xFF); - value >>>= 6; - } - - int digits = DIGITS[(int) (value & 0x3F)]; - JLA.putCharUTF16(buffer, --index, digits >> 8); - - if (7 < value) { - JLA.putCharUTF16(buffer, --index, digits & 0xFF); - } - - return index; - } - - /** - * Calculate the number of digits required to represent the long. - * - * @param value value to convert - * - * @return number of digits - */ - public static int stringSize(long value) { - return value == 0 ? 1 : ((66 - Long.numberOfLeadingZeros(value)) / 3); - } -} diff --git a/src/java.base/unix/classes/sun/nio/fs/UnixUserDefinedFileAttributeView.java b/src/java.base/unix/classes/sun/nio/fs/UnixUserDefinedFileAttributeView.java index 5b8d50dabf2e8..d2295ce3cc586 100644 --- a/src/java.base/unix/classes/sun/nio/fs/UnixUserDefinedFileAttributeView.java +++ b/src/java.base/unix/classes/sun/nio/fs/UnixUserDefinedFileAttributeView.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -182,7 +182,7 @@ public int read(String name, ByteBuffer dst) throws IOException { int n = read(name, address, rem); // copy from buffer into backing array - long off = dst.arrayOffset() + pos + (long) Unsafe.ARRAY_BYTE_BASE_OFFSET; + long off = dst.arrayOffset() + pos + Unsafe.ARRAY_BYTE_BASE_OFFSET; unsafe.copyMemory(null, address, dst.array(), off, n); dst.position(pos + n); @@ -241,7 +241,7 @@ public int write(String name, ByteBuffer src) throws IOException { if (src.hasArray()) { // copy from backing array into buffer - long off = src.arrayOffset() + pos + (long) Unsafe.ARRAY_BYTE_BASE_OFFSET; + long off = src.arrayOffset() + pos + Unsafe.ARRAY_BYTE_BASE_OFFSET; unsafe.copyMemory(src.array(), off, null, address, rem); } else { // backing array not accessible so transfer via temporary array diff --git a/src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java b/src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java index 5881ba55ef399..4c6b451b7e4de 100644 --- a/src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java +++ b/src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -51,7 +51,6 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; -import java.util.Arrays; import sun.awt.X11.XBaseWindow; import com.sun.java.swing.plaf.gtk.GTKConstants.TextDirection; @@ -521,6 +520,20 @@ public boolean isRunningOnWayland() { // application icons). private static final WindowFocusListener waylandWindowFocusListener; + private static boolean containsWaylandWindowFocusListener(Window window) { + if (window == null) { + return false; + } + + for (WindowFocusListener focusListener : window.getWindowFocusListeners()) { + if (focusListener == waylandWindowFocusListener) { + return true; + } + } + + return false; + } + static { if (isOnWayland()) { waylandWindowFocusListener = new WindowAdapter() { @@ -530,13 +543,22 @@ public void windowLostFocus(WindowEvent e) { Window oppositeWindow = e.getOppositeWindow(); // The focus can move between the window calling the popup, - // and the popup window itself. + // and the popup window itself or its children. // We only dismiss the popup in other cases. if (oppositeWindow != null) { - if (window == oppositeWindow.getParent() ) { + if (containsWaylandWindowFocusListener(oppositeWindow.getOwner())) { addWaylandWindowFocusListenerToWindow(oppositeWindow); return; } + + Window owner = window.getOwner(); + while (owner != null) { + if (owner == oppositeWindow) { + return; + } + owner = owner.getOwner(); + } + if (window.getParent() == oppositeWindow) { return; } @@ -557,11 +579,11 @@ public void windowLostFocus(WindowEvent e) { } private static void addWaylandWindowFocusListenerToWindow(Window window) { - if (!Arrays - .asList(window.getWindowFocusListeners()) - .contains(waylandWindowFocusListener) - ) { + if (!containsWaylandWindowFocusListener(window)) { window.addWindowFocusListener(waylandWindowFocusListener); + for (Window ownedWindow : window.getOwnedWindows()) { + addWaylandWindowFocusListenerToWindow(ownedWindow); + } } } diff --git a/src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c b/src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c index d6ff51f801866..356b52dfb3487 100644 --- a/src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c +++ b/src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c @@ -43,6 +43,12 @@ #define VERBOSE_AWT_DEBUG #endif +#define CHECK_EXCEPTION_FATAL(env, message) \ + if ((*env)->ExceptionCheck(env)) { \ + (*env)->ExceptionDescribe(env); \ + (*env)->FatalError(env, message); \ + } + static void *awtHandle = NULL; typedef jint JNICALL JNI_OnLoad_type(JavaVM *vm, void *reserved); @@ -61,16 +67,13 @@ JNIEXPORT jboolean JNICALL AWTIsHeadless() { env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); graphicsEnvClass = (*env)->FindClass(env, "java/awt/GraphicsEnvironment"); - if (graphicsEnvClass == NULL) { - return JNI_TRUE; - } + CHECK_EXCEPTION_FATAL(env, "FindClass java/awt/GraphicsEnvironment failed"); headlessFn = (*env)->GetStaticMethodID(env, graphicsEnvClass, "isHeadless", "()Z"); - if (headlessFn == NULL) { - return JNI_TRUE; - } + CHECK_EXCEPTION_FATAL(env, "GetStaticMethodID isHeadless failed"); isHeadless = (*env)->CallStaticBooleanMethod(env, graphicsEnvClass, headlessFn); + // If an exception occurred, we assume headless mode and carry on. if ((*env)->ExceptionCheck(env)) { (*env)->ExceptionClear(env); return JNI_TRUE; @@ -79,12 +82,6 @@ JNIEXPORT jboolean JNICALL AWTIsHeadless() { return isHeadless; } -#define CHECK_EXCEPTION_FATAL(env, message) \ - if ((*env)->ExceptionCheck(env)) { \ - (*env)->ExceptionClear(env); \ - (*env)->FatalError(env, message); \ - } - /* * Pathnames to the various awt toolkits */ diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java index e53cc798e61d0..790dc85166b62 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -33,6 +33,7 @@ import java.awt.Graphics2D; import java.awt.Insets; import java.awt.Rectangle; +import java.awt.geom.AffineTransform; import javax.swing.JComponent; import javax.swing.JProgressBar; @@ -128,38 +129,43 @@ protected void paintDeterminate(Graphics g, JComponent c) { if (xp != null) { boolean vertical = (progressBar.getOrientation() == JProgressBar.VERTICAL); boolean isLeftToRight = WindowsGraphicsUtils.isLeftToRight(c); - int barRectWidth = progressBar.getWidth(); - int barRectHeight = progressBar.getHeight()-1; + Graphics2D g2 = (Graphics2D) g; + AffineTransform at = g2.getTransform(); + double scaleX = at.getScaleX(); + double scaleY = at.getScaleY(); + + int barRectWidth = (int)Math.ceil(progressBar.getWidth() * scaleX); + int barRectHeight = (int)Math.ceil(progressBar.getHeight() * scaleY); + // amount of progress to draw - int amountFull = getAmountFull(null, barRectWidth, barRectHeight); + int amountFull = (int)(getAmountFull(null, barRectWidth, barRectHeight) / scaleX); paintXPBackground(g, vertical, barRectWidth, barRectHeight); + // Paint progress if (progressBar.isStringPainted()) { // Do not paint the standard stripes from the skin, because they obscure // the text g.setColor(progressBar.getForeground()); - barRectHeight -= 2; - barRectWidth -= 2; if (barRectWidth <= 0 || barRectHeight <= 0) { return; } - Graphics2D g2 = (Graphics2D)g; g2.setStroke(new BasicStroke((float)(vertical ? barRectWidth : barRectHeight), BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); if (!vertical) { if (isLeftToRight) { - g2.drawLine(2, barRectHeight / 2 + 1, - amountFull - 2, barRectHeight / 2 + 1); + g2.drawLine(0, barRectHeight / 2, + amountFull, barRectHeight / 2); } else { g2.drawLine(2 + barRectWidth, barRectHeight / 2 + 1, 2 + barRectWidth - (amountFull - 2), barRectHeight / 2 + 1); } - paintString(g, 0, 0, barRectWidth, barRectHeight, amountFull, null); + paintString(g, 0, 0, (int)(barRectWidth / scaleX), + (int)(barRectHeight / scaleY), amountFull, null); } else { g2.drawLine(barRectWidth/2 + 1, barRectHeight + 1, barRectWidth/2 + 1, barRectHeight + 1 - amountFull + 2); diff --git a/src/java.management/share/classes/java/lang/management/ManagementPermission.java b/src/java.management/share/classes/java/lang/management/ManagementPermission.java index 2dbee65e5cb72..7c9958d72cb05 100644 --- a/src/java.management/share/classes/java/lang/management/ManagementPermission.java +++ b/src/java.management/share/classes/java/lang/management/ManagementPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -31,6 +31,7 @@ * @apiNote * This permission cannot be used for controlling access to resources * as the Security Manager is no longer supported. + * Consequently this class is deprecated for removal in a future release. * * @author Mandy Chung * @since 1.5 @@ -41,8 +42,11 @@ * @see java.security.PermissionCollection * @see java.lang.SecurityManager * + * @deprecated This class was only useful in conjunction with the Security Manager, + * which is no longer supported. There is no replacement for this class. + * */ - +@Deprecated(since="25", forRemoval=true) public final class ManagementPermission extends java.security.BasicPermission { private static final long serialVersionUID = 1897496590799378737L; diff --git a/src/java.management/share/classes/javax/management/MBeanPermission.java b/src/java.management/share/classes/javax/management/MBeanPermission.java index 46717846cb3c9..abc3cdda7a89c 100644 --- a/src/java.management/share/classes/javax/management/MBeanPermission.java +++ b/src/java.management/share/classes/javax/management/MBeanPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -161,9 +161,14 @@ * @apiNote * This permission cannot be used for controlling access to resources * as the Security Manager is no longer supported. + * Consequently this class is deprecated for removal in a future release. + * + * @deprecated This class was only useful in conjunction with the Security Manager, + * which is no longer supported. There is no replacement for this class. * * @since 1.5 */ +@Deprecated(since="25", forRemoval=true) public class MBeanPermission extends Permission { private static final long serialVersionUID = -2416928705275160661L; diff --git a/src/java.management/share/classes/javax/management/MBeanServerPermission.java b/src/java.management/share/classes/javax/management/MBeanServerPermission.java index dc77d605912b2..c59c3e5ec3567 100644 --- a/src/java.management/share/classes/javax/management/MBeanServerPermission.java +++ b/src/java.management/share/classes/javax/management/MBeanServerPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -67,9 +67,14 @@ * @apiNote * This permission cannot be used for controlling access to resources * as the Security Manager is no longer supported. + * Consequently this class is deprecated for removal in a future release. + * + * @deprecated This class was only useful in conjunction with the Security Manager, + * which is no longer supported. There is no replacement for this class. * * @since 1.5 */ +@Deprecated(since="25", forRemoval=true) public class MBeanServerPermission extends BasicPermission { private static final long serialVersionUID = -5661980843569388590L; @@ -334,6 +339,7 @@ public PermissionCollection newPermissionCollection() { * implementation from defining a PermissionCollection there with an * optimized "implies" method. */ +@SuppressWarnings("removal") class MBeanServerPermissionCollection extends PermissionCollection { /** @serial Null if no permissions in collection, otherwise a single permission that is the union of all permissions that diff --git a/src/java.management/share/classes/javax/management/MBeanTrustPermission.java b/src/java.management/share/classes/javax/management/MBeanTrustPermission.java index d961fe471930a..2929b5c6097be 100644 --- a/src/java.management/share/classes/javax/management/MBeanTrustPermission.java +++ b/src/java.management/share/classes/javax/management/MBeanTrustPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -44,9 +44,14 @@ * @apiNote * This permission cannot be used for controlling access to resources * as the Security Manager is no longer supported. + * Consequently this class is deprecated for removal in a future release. + * + * @deprecated This class was only useful in conjunction with the Security Manager, + * which is no longer supported. There is no replacement for this class. * * @since 1.5 */ +@Deprecated(since="25", forRemoval=true) public class MBeanTrustPermission extends BasicPermission { private static final long serialVersionUID = -2952178077029018140L; diff --git a/src/java.management/share/classes/javax/management/remote/SubjectDelegationPermission.java b/src/java.management/share/classes/javax/management/remote/SubjectDelegationPermission.java index e2346e92bd5e5..9c5f4f05927ab 100644 --- a/src/java.management/share/classes/javax/management/remote/SubjectDelegationPermission.java +++ b/src/java.management/share/classes/javax/management/remote/SubjectDelegationPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -56,9 +56,14 @@ * @apiNote * This permission cannot be used for controlling access to resources * as the Security Manager is no longer supported. + * Consequently this class is deprecated for removal in a future release. + * + * @deprecated This class was only useful in conjunction with the Security Manager, + * which is no longer supported. There is no replacement for this class. * * @since 1.5 */ +@Deprecated(since="25", forRemoval=true) public final class SubjectDelegationPermission extends BasicPermission { private static final long serialVersionUID = 1481618113008682343L; diff --git a/src/java.naming/share/classes/com/sun/jndi/ldap/DefaultResponseControlFactory.java b/src/java.naming/share/classes/com/sun/jndi/ldap/DefaultResponseControlFactory.java index 89b01484cd4f1..534aa95a91690 100644 --- a/src/java.naming/share/classes/com/sun/jndi/ldap/DefaultResponseControlFactory.java +++ b/src/java.naming/share/classes/com/sun/jndi/ldap/DefaultResponseControlFactory.java @@ -36,7 +36,7 @@ *
* This class implements the LDAPv3 Control for paged-results as defined in - * RFC 2696. + * RFC 2696. * * The control's value has the following ASN.1 definition: *
{@code diff --git a/src/java.naming/share/classes/javax/naming/ldap/PagedResultsResponseControl.java b/src/java.naming/share/classes/javax/naming/ldap/PagedResultsResponseControl.java index d9d20f2bdedb2..798eea5a35541 100644 --- a/src/java.naming/share/classes/javax/naming/ldap/PagedResultsResponseControl.java +++ b/src/java.naming/share/classes/javax/naming/ldap/PagedResultsResponseControl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -40,7 +40,7 @@ ** This class implements the LDAPv3 Response Control for * paged-results as defined in - * RFC 2696. + * RFC 2696. * * The control's value has the following ASN.1 definition: *
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java index f449fc317e1aa..b772959b811e0 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java @@ -155,7 +155,11 @@ private static synchronized void initialize(TypeDataBase db) { virtualConstructor.addMapping("NotificationThread", NotificationThread.class); virtualConstructor.addMapping("StringDedupThread", StringDedupThread.class); virtualConstructor.addMapping("AttachListenerThread", AttachListenerThread.class); - virtualConstructor.addMapping("DeoptimizeObjectsALotThread", DeoptimizeObjectsALotThread.class); + + /* Only add DeoptimizeObjectsALotThread if it is actually present in the type database. */ + if (db.lookupType("DeoptimizeObjectsALotThread", false) != null) { + virtualConstructor.addMapping("DeoptimizeObjectsALotThread", DeoptimizeObjectsALotThread.class); + } } public Threads() { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java index bbf9d148e6643..e382914168351 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -4105,7 +4105,7 @@ static long booleanArrayAddress(boolean[] a, int index) { @ForceInline static long byteArrayAddress(byte[] a, int index) { - return (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + index; + return Unsafe.ARRAY_BYTE_BASE_OFFSET + index; } // ================================================ diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java index a217bec2dc7c6..cbb21667a154f 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -3615,7 +3615,7 @@ static long arrayAddress(double[] a, int index) { @ForceInline static long byteArrayAddress(byte[] a, int index) { - return (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + index; + return Unsafe.ARRAY_BYTE_BASE_OFFSET + index; } // ================================================ diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java index 1b2ca02e247cb..78259e7698bbd 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -3565,7 +3565,7 @@ static long arrayAddress(float[] a, int index) { @ForceInline static long byteArrayAddress(byte[] a, int index) { - return (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + index; + return Unsafe.ARRAY_BYTE_BASE_OFFSET + index; } // ================================================ diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java index eee30600bac58..d68bba1d7e25b 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java @@ -3743,7 +3743,7 @@ static long arrayAddress(int[] a, int index) { @ForceInline static long byteArrayAddress(byte[] a, int index) { - return (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + index; + return Unsafe.ARRAY_BYTE_BASE_OFFSET + index; } // ================================================ diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java index 637e9c028748b..1fa1cafac4eda 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -3678,7 +3678,7 @@ static long arrayAddress(long[] a, int index) { @ForceInline static long byteArrayAddress(byte[] a, int index) { - return (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + index; + return Unsafe.ARRAY_BYTE_BASE_OFFSET + index; } // ================================================ diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java index cf9031d613c08..19d7fa1d95e9e 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -4096,7 +4096,7 @@ static long charArrayAddress(char[] a, int index) { @ForceInline static long byteArrayAddress(byte[] a, int index) { - return (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + index; + return Unsafe.ARRAY_BYTE_BASE_OFFSET + index; } // ================================================ diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template index c7598ac40a30d..05979330ab100 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -5348,7 +5348,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { @ForceInline static long byteArrayAddress(byte[] a, int index) { - return (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + index; + return Unsafe.ARRAY_BYTE_BASE_OFFSET + index; } // ================================================ diff --git a/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/TransportService.java b/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/TransportService.java index c3889cb186ab2..6639797659ba3 100644 --- a/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/TransportService.java +++ b/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/TransportService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -64,7 +64,7 @@ * but may involve techniques such as the positive * acknowledgment with retransmission technique used in * protocols such as the Transmission Control Protocol (TCP) - * (see RFC 793 + * (see RFC 793 * ). * *A transport service can be used to initiate a connection diff --git a/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java b/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java index 043af1fc9b73d..b0a27d368ff7c 100644 --- a/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java +++ b/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2024, 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 @@ -863,7 +863,7 @@ public void freeMemory(long address) { * @deprecated Not needed when using {@link VarHandle} or {@link java.lang.foreign}. */ @Deprecated(since="23", forRemoval=true) - public static final int INVALID_FIELD_OFFSET = jdk.internal.misc.Unsafe.INVALID_FIELD_OFFSET; + public static final int INVALID_FIELD_OFFSET = (int) jdk.internal.misc.Unsafe.INVALID_FIELD_OFFSET; /** * Reports the location of a given field in the storage allocation of its @@ -994,7 +994,7 @@ public Object staticFieldBase(Field f) { @ForceInline public int arrayBaseOffset(Class> arrayClass) { beforeMemoryAccess(); - return theInternalUnsafe.arrayBaseOffset(arrayClass); + return (int) theInternalUnsafe.arrayBaseOffset(arrayClass); } /** The value of {@code arrayBaseOffset(boolean[].class)}. @@ -1002,63 +1002,63 @@ public int arrayBaseOffset(Class> arrayClass) { * @deprecated Not needed when using {@link VarHandle} or {@link java.lang.foreign}. */ @Deprecated(since="23", forRemoval=true) - public static final int ARRAY_BOOLEAN_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_BOOLEAN_BASE_OFFSET; + public static final int ARRAY_BOOLEAN_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_BOOLEAN_BASE_OFFSET; /** The value of {@code arrayBaseOffset(byte[].class)}. * * @deprecated Not needed when using {@link VarHandle} or {@link java.lang.foreign}. */ @Deprecated(since="23", forRemoval=true) - public static final int ARRAY_BYTE_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_BYTE_BASE_OFFSET; + public static final int ARRAY_BYTE_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_BYTE_BASE_OFFSET; /** The value of {@code arrayBaseOffset(short[].class)}. * * @deprecated Not needed when using {@link VarHandle} or {@link java.lang.foreign}. */ @Deprecated(since="23", forRemoval=true) - public static final int ARRAY_SHORT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_SHORT_BASE_OFFSET; + public static final int ARRAY_SHORT_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_SHORT_BASE_OFFSET; /** The value of {@code arrayBaseOffset(char[].class)}. * * @deprecated Not needed when using {@link VarHandle} or {@link java.lang.foreign}. */ @Deprecated(since="23", forRemoval=true) - public static final int ARRAY_CHAR_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_CHAR_BASE_OFFSET; + public static final int ARRAY_CHAR_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_CHAR_BASE_OFFSET; /** The value of {@code arrayBaseOffset(int[].class)}. * * @deprecated Not needed when using {@link VarHandle} or {@link java.lang.foreign}. */ @Deprecated(since="23", forRemoval=true) - public static final int ARRAY_INT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_INT_BASE_OFFSET; + public static final int ARRAY_INT_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_INT_BASE_OFFSET; /** The value of {@code arrayBaseOffset(long[].class)}. * * @deprecated Not needed when using {@link VarHandle} or {@link java.lang.foreign}. */ @Deprecated(since="23", forRemoval=true) - public static final int ARRAY_LONG_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_LONG_BASE_OFFSET; + public static final int ARRAY_LONG_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_LONG_BASE_OFFSET; /** The value of {@code arrayBaseOffset(float[].class)}. * * @deprecated Not needed when using {@link VarHandle} or {@link java.lang.foreign}. */ @Deprecated(since="23", forRemoval=true) - public static final int ARRAY_FLOAT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_FLOAT_BASE_OFFSET; + public static final int ARRAY_FLOAT_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_FLOAT_BASE_OFFSET; /** The value of {@code arrayBaseOffset(double[].class)}. * * @deprecated Not needed when using {@link VarHandle} or {@link java.lang.foreign}. */ @Deprecated(since="23", forRemoval=true) - public static final int ARRAY_DOUBLE_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_DOUBLE_BASE_OFFSET; + public static final int ARRAY_DOUBLE_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_DOUBLE_BASE_OFFSET; /** The value of {@code arrayBaseOffset(Object[].class)}. * * @deprecated Not needed when using {@link VarHandle} or {@link java.lang.foreign}. */ @Deprecated(since="23", forRemoval=true) - public static final int ARRAY_OBJECT_BASE_OFFSET = jdk.internal.misc.Unsafe.ARRAY_OBJECT_BASE_OFFSET; + public static final int ARRAY_OBJECT_BASE_OFFSET = (int) jdk.internal.misc.Unsafe.ARRAY_OBJECT_BASE_OFFSET; /** * Reports the scale factor for addressing elements in the storage diff --git a/test/docs/jdk/javadoc/doccheck/ExtLinksJdk.txt b/test/docs/jdk/javadoc/doccheck/ExtLinksJdk.txt index 704bdffb283c8..2e88186fe79f0 100644 --- a/test/docs/jdk/javadoc/doccheck/ExtLinksJdk.txt +++ b/test/docs/jdk/javadoc/doccheck/ExtLinksJdk.txt @@ -43,8 +43,8 @@ http://www.iana.org/assignments/character-sets/character-sets.xhtml http://www.iana.org/assignments/media-types/ http://www.iana.org/assignments/uri-schemes.html http://www.ietf.org/ -http://www.ietf.org/rfc/rfc0793.txt -http://www.ietf.org/rfc/rfc0822.txt +https://www.ietf.org/rfc/rfc793.txt +https://www.ietf.org/rfc/rfc822.txt http://www.ietf.org/rfc/rfc1122.txt http://www.ietf.org/rfc/rfc1123.txt http://www.ietf.org/rfc/rfc1323.txt @@ -83,8 +83,7 @@ http://www.ietf.org/rfc/rfc2440.txt http://www.ietf.org/rfc/rfc2474.txt http://www.ietf.org/rfc/rfc2609.txt http://www.ietf.org/rfc/rfc2616.txt -http://www.ietf.org/rfc/rfc2696 -http://www.ietf.org/rfc/rfc2696.txt +https://www.ietf.org/rfc/rfc2696.txt http://www.ietf.org/rfc/rfc2710.txt http://www.ietf.org/rfc/rfc2732.txt http://www.ietf.org/rfc/rfc2743.txt diff --git a/test/hotspot/gtest/nmt/test_nmt_nativecallstackstorage.cpp b/test/hotspot/gtest/nmt/test_nmt_nativecallstackstorage.cpp index 7ff18dc794ec9..b4b43c92cf18c 100644 --- a/test/hotspot/gtest/nmt/test_nmt_nativecallstackstorage.cpp +++ b/test/hotspot/gtest/nmt/test_nmt_nativecallstackstorage.cpp @@ -42,7 +42,7 @@ TEST_VM_F(NMTNativeCallStackStorageTest, DoNotStoreStackIfNotDetailed) { TEST_VM_F(NMTNativeCallStackStorageTest, CollisionsReceiveDifferentIndexes) { constexpr const int nr_of_stacks = 10; NativeCallStack ncs_arr[nr_of_stacks]; - for (int i = 0; i < nr_of_stacks; i++) { + for (size_t i = 0; i < nr_of_stacks; i++) { ncs_arr[i] = NativeCallStack((address*)(&i), 1); } @@ -52,7 +52,7 @@ TEST_VM_F(NMTNativeCallStackStorageTest, CollisionsReceiveDifferentIndexes) { si_arr[i] = ncss.push(ncs_arr[i]); } - // Every SI should be different as every sack is different + // Every SI should be different as every stack is different for (int i = 0; i < nr_of_stacks; i++) { for (int j = 0; j < nr_of_stacks; j++) { if (i == j) continue; diff --git a/test/hotspot/gtest/runtime/test_stubRoutines.cpp b/test/hotspot/gtest/runtime/test_stubRoutines.cpp index 02ab92245a6ca..6d718a8209f55 100644 --- a/test/hotspot/gtest/runtime/test_stubRoutines.cpp +++ b/test/hotspot/gtest/runtime/test_stubRoutines.cpp @@ -109,7 +109,7 @@ TEST_VM(StubRoutines, array_fill_routine) { MACOS_AARCH64_ONLY(os::current_thread_enable_wx(WXExec)); #define TEST_FILL(type) \ - if (StubRoutines::_##type##_fill != nullptr) { \ + if (StubRoutines::type##_fill() != nullptr) { \ union { \ double d; \ type body[96]; \ @@ -124,12 +124,12 @@ TEST_VM(StubRoutines, array_fill_routine) { for (int aligned = 0; aligned < 2; aligned++) { \ if (aligned) { \ if (((intptr_t)start) % HeapWordSize == 0) { \ - ((void (*)(type*, int, int))StubRoutines::_arrayof_##type##_fill)(start, v, 80); \ + ((void (*)(type*, int, int))StubRoutines::arrayof_##type##_fill())(start, v, 80); \ } else { \ continue; \ } \ } else { \ - ((void (*)(type*, int, int))StubRoutines::_##type##_fill)(start, v, 80); \ + ((void (*)(type*, int, int))StubRoutines::type##_fill())(start, v, 80); \ } \ for (int i = 0; i < 96; i++) { \ if (i < (8 + offset) || i >= (88 + offset)) { \ diff --git a/test/hotspot/gtest/utilities/test_rbtree.cpp b/test/hotspot/gtest/utilities/test_rbtree.cpp new file mode 100644 index 0000000000000..c1be34b08d64c --- /dev/null +++ b/test/hotspot/gtest/utilities/test_rbtree.cpp @@ -0,0 +1,573 @@ +/* + * 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 "memory/resourceArea.hpp" +#include "runtime/os.hpp" +#include "testutils.hpp" +#include "unittest.hpp" +#include "utilities/growableArray.hpp" +#include "utilities/rbTree.hpp" +#include "utilities/rbTree.inline.hpp" + + +class RBTreeTest : public testing::Test { +public: + struct Cmp { + static int cmp(int a, int b) { + return a - b; + } + }; + + struct CmpInverse { + static int cmp(int a, int b) { + return b - a; + } + }; + + struct FCmp { + static int cmp(float a, float b) { + if (a < b) return -1; + if (a == b) return 0; + return 1; + } + }; + +// Bump-pointer style allocator that can't free +template
+struct ArrayAllocator { + uint8_t area[AreaSize]; + size_t offset = 0; + + void* allocate(size_t sz) { + if (offset + sz > AreaSize) { + vm_exit_out_of_memory(sz, OOM_MALLOC_ERROR, + "red-black tree failed allocation"); + } + void* place = &area[offset]; + offset += sz; + return place; + } + + void free(void* ptr) { } +}; + +#ifdef ASSERT + template + void verify_it(RBTree & t) { + t.verify_self(); + } +#endif // ASSERT + +using RBTreeInt = RBTreeCHeap ; + +public: + void inserting_duplicates_results_in_one_value() { + constexpr int up_to = 10; + GrowableArrayCHeap nums_seen(up_to, up_to, 0); + RBTreeInt rbtree; + + for (int i = 0; i < up_to; i++) { + rbtree.upsert(i, i); + rbtree.upsert(i, i); + rbtree.upsert(i, i); + rbtree.upsert(i, i); + rbtree.upsert(i, i); + } + + rbtree.visit_in_order([&](RBTreeInt::RBNode* node) { + nums_seen.at(node->key())++; + }); + for (int i = 0; i < up_to; i++) { + EXPECT_EQ(1, nums_seen.at(i)); + } + } + + void rbtree_ought_not_leak() { + struct LeakCheckedAllocator { + int allocations; + + LeakCheckedAllocator() + : allocations(0) { + } + + void* allocate(size_t sz) { + void* allocation = os::malloc(sz, mtTest); + if (allocation == nullptr) { + vm_exit_out_of_memory(sz, OOM_MALLOC_ERROR, "rbtree failed allocation"); + } + ++allocations; + return allocation; + } + + void free(void* ptr) { + --allocations; + os::free(ptr); + } + }; + + constexpr int up_to = 10; + { + RBTree rbtree; + for (int i = 0; i < up_to; i++) { + rbtree.upsert(i, i); + } + EXPECT_EQ(up_to, rbtree._allocator.allocations); + for (int i = 0; i < up_to; i++) { + rbtree.remove(i); + } + EXPECT_EQ(0, rbtree._allocator.allocations); + EXPECT_EQ(nullptr, rbtree._root); + } + + { + RBTree rbtree; + for (int i = 0; i < up_to; i++) { + rbtree.upsert(i, i); + } + rbtree.remove_all(); + EXPECT_EQ(0, rbtree._allocator.allocations); + EXPECT_EQ(nullptr, rbtree._root); + } + } + + void test_find() { + struct Empty {}; + RBTreeCHeap rbtree; + using Node = RBTreeCHeap ::RBNode; + + Node* n = nullptr; + auto test = [&](float f) { + EXPECT_EQ(nullptr, rbtree.find(f)); + rbtree.upsert(f, Empty{}); + const Node* n = rbtree.find_node(f); + EXPECT_NE(nullptr, n); + EXPECT_EQ(f, n->key()); + }; + + test(1.0f); + test(5.0f); + test(0.0f); + } + + void test_visitors() { + { // Tests with 'default' ordering (ascending) + RBTreeInt rbtree; + using Node = RBTreeInt::RBNode; + + rbtree.visit_range_in_order(0, 100, [&](Node* x) { + EXPECT_TRUE(false) << "Empty rbtree has no nodes to visit"; + }); + + // Single-element set + rbtree.upsert(1, 0); + int count = 0; + rbtree.visit_range_in_order(0, 100, [&](Node* x) { + count++; + }); + EXPECT_EQ(1, count); + + count = 0; + rbtree.visit_in_order([&](Node* x) { + count++; + }); + EXPECT_EQ(1, count); + + // Add an element outside of the range that should not be visited on the right side and + // one on the left side. + rbtree.upsert(101, 0); + rbtree.upsert(-1, 0); + count = 0; + rbtree.visit_range_in_order(0, 100, [&](Node* x) { + count++; + }); + EXPECT_EQ(1, count); + + count = 0; + rbtree.visit_in_order([&](Node* x) { + count++; + }); + EXPECT_EQ(3, count); + + // Visiting empty range [0, 0) == {} + rbtree.upsert(0, 0); // This node should not be visited. + rbtree.visit_range_in_order(0, 0, [&](Node* x) { + EXPECT_TRUE(false) << "Empty visiting range should not visit any node"; + }); + + rbtree.remove_all(); + for (int i = 0; i < 11; i++) { + rbtree.upsert(i, 0); + } + + ResourceMark rm; + GrowableArray seen; + rbtree.visit_range_in_order(0, 10, [&](Node* x) { + seen.push(x->key()); + }); + EXPECT_EQ(10, seen.length()); + for (int i = 0; i < 10; i++) { + EXPECT_EQ(i, seen.at(i)); + } + + seen.clear(); + rbtree.visit_in_order([&](Node* x) { + seen.push(x->key()); + }); + EXPECT_EQ(11, seen.length()); + for (int i = 0; i < 10; i++) { + EXPECT_EQ(i, seen.at(i)); + } + + seen.clear(); + rbtree.visit_range_in_order(10, 12, [&](Node* x) { + seen.push(x->key()); + }); + EXPECT_EQ(1, seen.length()); + EXPECT_EQ(10, seen.at(0)); + } + { // Test with descending ordering + RBTreeCHeap rbtree; + using Node = RBTreeCHeap ::RBNode; + + for (int i = 0; i < 10; i++) { + rbtree.upsert(i, 0); + } + ResourceMark rm; + GrowableArray seen; + rbtree.visit_range_in_order(9, -1, [&](Node* x) { + seen.push(x->key()); + }); + EXPECT_EQ(10, seen.length()); + for (int i = 0; i < 10; i++) { + EXPECT_EQ(10-i-1, seen.at(i)); + } + seen.clear(); + + rbtree.visit_in_order([&](Node* x) { + seen.push(x->key()); + }); + EXPECT_EQ(10, seen.length()); + for (int i = 0; i < 10; i++) { + EXPECT_EQ(10 - i - 1, seen.at(i)); + } + } + } + + void test_closest_leq() { + using Node = RBTreeInt::RBNode; + { + RBTreeInt rbtree; + Node* n = rbtree.closest_leq(0); + EXPECT_EQ(nullptr, n); + + rbtree.upsert(0, 0); + n = rbtree.closest_leq(0); + EXPECT_EQ(0, n->key()); + + rbtree.upsert(-1, -1); + n = rbtree.closest_leq(0); + EXPECT_EQ(0, n->key()); + + rbtree.upsert(6, 0); + n = rbtree.closest_leq(6); + EXPECT_EQ(6, n->key()); + + n = rbtree.closest_leq(-2); + EXPECT_EQ(nullptr, n); + } + } + + void test_node_prev() { + RBTreeInt _tree; + using Node = RBTreeInt::RBNode; + constexpr int num_nodes = 100; + + for (int i = num_nodes; i > 0; i--) { + _tree.upsert(i, i); + } + + Node* node = _tree.find_node(num_nodes); + int count = num_nodes; + while (node != nullptr) { + EXPECT_EQ(count, node->val()); + node = node->prev(); + count--; + } + + EXPECT_EQ(count, 0); + } + + void test_node_next() { + RBTreeInt _tree; + using Node = RBTreeInt::RBNode; + constexpr int num_nodes = 100; + + for (int i = 0; i < num_nodes; i++) { + _tree.upsert(i, i); + } + + Node* node = _tree.find_node(0); + int count = 0; + while (node != nullptr) { + EXPECT_EQ(count, node->val()); + node = node->next(); + count++; + } + + EXPECT_EQ(count, num_nodes); + } + + void test_stable_nodes() { + using Node = RBTreeInt::RBNode; + RBTreeInt rbtree; + ResourceMark rm; + GrowableArray a(10000); + for (int i = 0; i < 10000; i++) { + rbtree.upsert(i, i); + a.push(rbtree.find_node(i)); + } + + for (int i = 0; i < 2000; i++) { + int r = os::random() % 10000; + Node* to_delete = rbtree.find_node(r); + if (to_delete != nullptr && to_delete->_left != nullptr && + to_delete->_right != nullptr) { + rbtree.remove(to_delete); + } + } + + // After deleting, nodes should have been moved around but kept their values + for (int i = 0; i < 10000; i++) { + const Node* n = rbtree.find_node(i); + if (n != nullptr) { + EXPECT_EQ(a.at(i), n); + } + } + } + + void test_stable_nodes_addresses() { + using Tree = RBTreeCHeap ; + using Node = Tree::RBNode; + Tree rbtree; + for (int i = 0; i < 10000; i++) { + rbtree.upsert(i, nullptr); + Node* inserted_node = rbtree.find_node(i); + inserted_node->val() = inserted_node; + } + + for (int i = 0; i < 2000; i++) { + int r = os::random() % 10000; + Node* to_delete = rbtree.find_node(r); + if (to_delete != nullptr && to_delete->_left != nullptr && + to_delete->_right != nullptr) { + rbtree.remove(to_delete); + } + } + + // After deleting, values should have remained consistant + rbtree.visit_in_order([&](Node* node) { + EXPECT_EQ(node, node->val()); + }); + } + +#ifdef ASSERT + void test_fill_verify() { + RBTreeInt rbtree; + + ResourceMark rm; + GrowableArray allocations; + + int size = 10000; + // Create random values + for (int i = 0; i < size; i++) { + int r = os::random() % size; + allocations.append(r); + } + + // Insert ~half of the values + for (int i = 0; i < size; i++) { + int r = os::random(); + if (r % 2 == 0) { + rbtree.upsert(allocations.at(i), allocations.at(i)); + } + if (i % 100 == 0) { + verify_it(rbtree); + } + } + + // Insert and remove randomly + for (int i = 0; i < size; i++) { + int r = os::random(); + if (r % 2 == 0) { + rbtree.upsert(allocations.at(i), allocations.at(i)); + } else { + rbtree.remove(allocations.at(i)); + } + if (i % 100 == 0) { + verify_it(rbtree); + } + } + + // Remove all elements + for (int i = 0; i < size; i++) { + rbtree.remove(allocations.at(i)); + } + + verify_it(rbtree); + EXPECT_EQ(rbtree.size(), 0UL); + } + + void test_nodes_visited_once() { + constexpr size_t memory_size = 65536; + using Tree = RBTree >; + using Node = Tree::RBNode; + + Tree tree; + + int num_nodes = memory_size / sizeof(Node); + for (int i = 0; i < num_nodes; i++) { + tree.upsert(i, i); + } + + Node* start = tree.find_node(0); + + Node* node = start; + for (int i = 0; i < num_nodes; i++) { + EXPECT_EQ(tree._expected_visited, node->_visited); + node += 1; + } + + verify_it(tree); + + node = start; + for (int i = 0; i < num_nodes; i++) { + EXPECT_EQ(tree._expected_visited, node->_visited); + node += 1; + } + + } +#endif // ASSERT + +}; + +TEST_VM_F(RBTreeTest, InsertingDuplicatesResultsInOneValue) { + this->inserting_duplicates_results_in_one_value(); +} + +TEST_VM_F(RBTreeTest, RBTreeOughtNotLeak) { + this->rbtree_ought_not_leak(); +} + +TEST_VM_F(RBTreeTest, TestFind) { + this->test_find(); +} + +TEST_VM_F(RBTreeTest, TestVisitors) { + this->test_visitors(); +} + +TEST_VM_F(RBTreeTest, TestClosestLeq) { + this->test_closest_leq(); +} + +TEST_VM_F(RBTreeTest, NodePrev) { + this->test_node_prev(); +} + +TEST_VM_F(RBTreeTest, NodeNext) { + this->test_node_next(); +} + +TEST_VM_F(RBTreeTest, NodeStableTest) { + this->test_stable_nodes(); +} + +TEST_VM_F(RBTreeTest, NodeStableAddressTest) { + this->test_stable_nodes_addresses(); +} + +#ifdef ASSERT +TEST_VM_F(RBTreeTest, FillAndVerify) { + this->test_fill_verify(); +} + +TEST_VM_F(RBTreeTest, NodesVisitedOnce) { + this->test_nodes_visited_once(); +} + +TEST_VM_F(RBTreeTest, InsertRemoveVerify) { + constexpr int num_nodes = 100; + for (int n_t1 = 0; n_t1 < num_nodes; n_t1++) { + for (int n_t2 = 0; n_t2 < n_t1; n_t2++) { + RBTreeInt tree; + for (int i = 0; i < n_t1; i++) { + tree.upsert(i, i); + } + for (int i = 0; i < n_t2; i++) { + tree.remove(i); + } + verify_it(tree); + } + } +} + +TEST_VM_F(RBTreeTest, VerifyItThroughStressTest) { + { // Repeatedly verify a tree of moderate size + RBTreeInt rbtree; + constexpr int ten_thousand = 10000; + for (int i = 0; i < ten_thousand; i++) { + int r = os::random(); + if (r % 2 == 0) { + rbtree.upsert(i, i); + } else { + rbtree.remove(i); + } + if (i % 100 == 0) { + verify_it(rbtree); + } + } + for (int i = 0; i < ten_thousand; i++) { + int r = os::random(); + if (r % 2 == 0) { + rbtree.upsert(i, i); + } else { + rbtree.remove(i); + } + if (i % 100 == 0) { + verify_it(rbtree); + } + } + } + { // Make a very large tree and verify at the end + struct Nothing {}; + RBTreeCHeap rbtree; + constexpr int one_hundred_thousand = 100000; + for (int i = 0; i < one_hundred_thousand; i++) { + rbtree.upsert(i, Nothing()); + } + verify_it(rbtree); + } +} + +#endif // ASSERT diff --git a/test/hotspot/jtreg/ProblemList-Virtual.txt b/test/hotspot/jtreg/ProblemList-Virtual.txt index 64b281ccc980e..2239a10f3e776 100644 --- a/test/hotspot/jtreg/ProblemList-Virtual.txt +++ b/test/hotspot/jtreg/ProblemList-Virtual.txt @@ -37,17 +37,8 @@ vmTestbase/nsk/jvmti/CompiledMethodUnload/compmethunload001/TestDescription.java #### ## Tests for functionality which currently is not supported for virtual threads -vmTestbase/nsk/jvmti/GetCurrentThreadCpuTime/curthrcputime001/TestDescription.java 8300708 generic-all -vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime001/TestDescription.java 8300708 generic-all -vmTestbase/nsk/jvmti/NotifyFramePop/nframepop002/TestDescription.java 8300708 generic-all -vmTestbase/nsk/jvmti/NotifyFramePop/nframepop003/TestDescription.java 8300708 generic-all -vmTestbase/nsk/jvmti/StopThread/stopthrd006/TestDescription.java 8300708 generic-all -vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t012/TestDescription.java 8300708 generic-all -vmTestbase/nsk/jvmti/SetLocalVariable/setlocal004/TestDescription.java 8300708 generic-all -vmTestbase/nsk/jvmti/SetLocalVariable/setlocal003/TestDescription.java 8300708 generic-all -vmTestbase/nsk/jvmti/SetLocalVariable/setlocal002/TestDescription.java 8300708 generic-all -vmTestbase/nsk/jvmti/SetLocalVariable/setlocal001/TestDescription.java 8300708 generic-all -vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal003/TestDescription.java 8300708 generic-all +vmTestbase/nsk/jvmti/GetCurrentThreadCpuTime/curthrcputime001/TestDescription.java 8348844 generic-all +vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime001/TestDescription.java 8348844 generic-all #### ## Test fails because it expects to find vthreads in GetAllThreads diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups index 99a34c1ef836b..c3bc2351ac85a 100644 --- a/test/hotspot/jtreg/TEST.groups +++ b/test/hotspot/jtreg/TEST.groups @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2024, 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 @@ -518,14 +518,21 @@ hotspot_aot_classlinking = \ -runtime/cds/appcds/cacheObject/ArchivedIntegerCacheTest.java \ -runtime/cds/appcds/cacheObject/ArchivedModuleCompareTest.java \ -runtime/cds/appcds/CDSandJFR.java \ + -runtime/cds/appcds/customLoader/CustomClassListDump.java \ -runtime/cds/appcds/customLoader/HelloCustom_JFR.java \ + -runtime/cds/appcds/customLoader/OldClassAndInf.java \ -runtime/cds/appcds/customLoader/ParallelTestMultiFP.java \ -runtime/cds/appcds/customLoader/ParallelTestSingleFP.java \ -runtime/cds/appcds/customLoader/SameNameInTwoLoadersTest.java \ -runtime/cds/appcds/DumpClassListWithLF.java \ -runtime/cds/appcds/dynamicArchive/ModulePath.java \ + -runtime/cds/appcds/dynamicArchive/LambdaCustomLoader.java \ + -runtime/cds/appcds/dynamicArchive/LambdaForOldInfInBaseArchive.java \ -runtime/cds/appcds/dynamicArchive/LambdaInBaseArchive.java \ -runtime/cds/appcds/dynamicArchive/LambdasInTwoArchives.java \ + -runtime/cds/appcds/dynamicArchive/OldClassAndInf.java \ + -runtime/cds/appcds/dynamicArchive/OldClassInBaseArchive.java \ + -runtime/cds/appcds/dynamicArchive/OldClassVerifierTrouble.java \ -runtime/cds/appcds/HelloExtTest.java \ -runtime/cds/appcds/javaldr/GCDuringDump.java \ -runtime/cds/appcds/javaldr/LockDuringDump.java \ @@ -545,6 +552,13 @@ hotspot_aot_classlinking = \ -runtime/cds/appcds/jvmti \ -runtime/cds/appcds/LambdaProxyClasslist.java \ -runtime/cds/appcds/loaderConstraints/LoaderConstraintsTest.java \ + -runtime/cds/appcds/NestHostOldInf.java \ + -runtime/cds/appcds/OldClassTest.java \ + -runtime/cds/appcds/OldClassWithjsr.java \ + -runtime/cds/appcds/OldInfExtendsInfDefMeth.java \ + -runtime/cds/appcds/OldSuperClass.java \ + -runtime/cds/appcds/OldSuperInfIndirect.java \ + -runtime/cds/appcds/OldSuperInf.java \ -runtime/cds/appcds/redefineClass \ -runtime/cds/appcds/resolvedConstants/AOTLinkedLambdas.java \ -runtime/cds/appcds/resolvedConstants/AOTLinkedVarHandles.java \ diff --git a/test/hotspot/jtreg/compiler/c2/Test6968348.java b/test/hotspot/jtreg/compiler/c2/Test6968348.java index 17a2d61716b0a..488bcfcac589f 100644 --- a/test/hotspot/jtreg/compiler/c2/Test6968348.java +++ b/test/hotspot/jtreg/compiler/c2/Test6968348.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -39,7 +39,7 @@ public class Test6968348 { static Unsafe unsafe = Unsafe.getUnsafe(); static final long[] buffer = new long[4096]; - static int array_long_base_offset; + static long array_long_base_offset; public static void main(String[] args) throws Exception { array_long_base_offset = unsafe.arrayBaseOffset(long[].class); diff --git a/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeCAS.java b/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeCAS.java index e0c43b055295b..64c52446c3681 100644 --- a/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeCAS.java +++ b/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeCAS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, 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 @@ -50,7 +50,7 @@ public class TestIntUnsafeCAS { private static final int UNALIGN_OFF = 5; private static final Unsafe unsafe = Unsafe.getUnsafe(); - private static final int BASE; + private static final long BASE; static { try { BASE = unsafe.arrayBaseOffset(int[].class); diff --git a/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeOrdered.java b/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeOrdered.java index b7354c88dae52..342b146a0c893 100644 --- a/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeOrdered.java +++ b/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeOrdered.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, 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 @@ -50,7 +50,7 @@ public class TestIntUnsafeOrdered { private static final int UNALIGN_OFF = 5; private static final Unsafe unsafe = Unsafe.getUnsafe(); - private static final int BASE; + private static final long BASE; static { try { BASE = unsafe.arrayBaseOffset(int[].class); diff --git a/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeVolatile.java b/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeVolatile.java index 3ff0a1323798e..3ea812a9e79ff 100644 --- a/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeVolatile.java +++ b/test/hotspot/jtreg/compiler/c2/cr8004867/TestIntUnsafeVolatile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, 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 @@ -50,7 +50,7 @@ public class TestIntUnsafeVolatile { private static final int UNALIGN_OFF = 5; private static final Unsafe unsafe = Unsafe.getUnsafe(); - private static final int BASE; + private static final long BASE; static { try { BASE = unsafe.arrayBaseOffset(int[].class); diff --git a/test/hotspot/jtreg/compiler/ciReplay/InliningBase.java b/test/hotspot/jtreg/compiler/ciReplay/InliningBase.java index e3ec752712303..fbe2e89a45d56 100644 --- a/test/hotspot/jtreg/compiler/ciReplay/InliningBase.java +++ b/test/hotspot/jtreg/compiler/ciReplay/InliningBase.java @@ -86,31 +86,31 @@ public InlineEntry(String klass, String method, String reason) { } public boolean isNormalInline() { - return reason.equals("inline (hot)"); + return reason.startsWith("inline (hot)"); } public boolean isForcedByReplay() { - return reason.equals("force inline by ciReplay"); + return reason.startsWith("force inline by ciReplay"); } public boolean isDisallowedByReplay() { - return reason.equals("failed to inline: disallowed by ciReplay"); + return reason.startsWith("failed to inline: disallowed by ciReplay"); } public boolean isUnloadedSignatureClasses() { - return reason.equals("failed to inline: unloaded signature classes"); + return reason.startsWith("failed to inline: unloaded signature classes"); } public boolean isForcedIncrementalInlineByReplay() { - return reason.equals("force (incremental) inline by ciReplay"); + return reason.startsWith("force (incremental) inline by ciReplay"); } public boolean isForcedInline() { - return reason.equals("force inline by annotation"); + return reason.startsWith("force inline by annotation"); } public boolean isTooDeep() { - return reason.equals("failed to inline: inlining too deep"); + return reason.startsWith("failed to inline: inlining too deep"); } @Override diff --git a/test/hotspot/jtreg/compiler/inlining/LateInlinePrinting.java b/test/hotspot/jtreg/compiler/inlining/LateInlinePrinting.java new file mode 100644 index 0000000000000..09ed466f2998d --- /dev/null +++ b/test/hotspot/jtreg/compiler/inlining/LateInlinePrinting.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2024, 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 8319850 + * @summary PrintInlining should print which methods are late inlines + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @requires vm.flagless + * + * @run driver compiler.inlining.LateInlinePrinting + */ + +package compiler.inlining; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public class LateInlinePrinting { + public static class TestLateInlining { + public static void main(String[] args) { + for (int i = 0; i < 20_000; i++) { + test1(); + test2(); + } + } + + private static void test1() { + test3(); + testFailInline(); + testFailInline(); + test2(); + } + + private static void test2() { + inlined1(); + inlined2(); + } + + private static void test3() {} + + private static void testFailInline() {} + + private static void inlined1() {} + + private static void inlined2() {} + } + + + public static void main(String[] args) throws Exception { + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( + "-XX:-TieredCompilation", "-XX:-UseOnStackReplacement", "-XX:-BackgroundCompilation", + "-XX:+PrintCompilation", + "-XX:CompileCommand=compileonly,compiler.inlining.LateInlinePrinting$TestLateInlining::test1", + "-XX:CompileCommand=compileonly,compiler.inlining.LateInlinePrinting$TestLateInlining::test2", + "-XX:CompileCommand=quiet", "-XX:+PrintInlining", "-XX:+AlwaysIncrementalInline", + "-XX:CompileCommand=dontinline,compiler.inlining.LateInlinePrinting$TestLateInlining::testFailInline", + TestLateInlining.class.getName() + ); + + OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); + analyzer.shouldHaveExitValue(0); + + analyzer.shouldContain(""" +compiler.inlining.LateInlinePrinting$TestLateInlining::test2 (7 bytes) + @ 0 compiler.inlining.LateInlinePrinting$TestLateInlining::inlined1 (1 bytes) inline (hot) late inline succeeded + @ 3 compiler.inlining.LateInlinePrinting$TestLateInlining::inlined2 (1 bytes) inline (hot) late inline succeeded + """); + analyzer.shouldContain(""" +compiler.inlining.LateInlinePrinting$TestLateInlining::test1 (13 bytes) + @ 0 compiler.inlining.LateInlinePrinting$TestLateInlining::test3 (1 bytes) inline (hot) late inline succeeded + @ 3 compiler.inlining.LateInlinePrinting$TestLateInlining::testFailInline (1 bytes) failed to inline: disallowed by CompileCommand + @ 6 compiler.inlining.LateInlinePrinting$TestLateInlining::testFailInline (1 bytes) failed to inline: disallowed by CompileCommand + @ 9 compiler.inlining.LateInlinePrinting$TestLateInlining::test2 (7 bytes) inline (hot) late inline succeeded + @ 0 compiler.inlining.LateInlinePrinting$TestLateInlining::inlined1 (1 bytes) inline (hot) late inline succeeded + @ 3 compiler.inlining.LateInlinePrinting$TestLateInlining::inlined2 (1 bytes) inline (hot) late inline succeeded + """); + } +} diff --git a/test/hotspot/jtreg/compiler/inlining/TestDuplicatedLateInliningOutput.java b/test/hotspot/jtreg/compiler/inlining/TestDuplicatedLateInliningOutput.java index 2b967968ea268..ebc5a827ea4c0 100644 --- a/test/hotspot/jtreg/compiler/inlining/TestDuplicatedLateInliningOutput.java +++ b/test/hotspot/jtreg/compiler/inlining/TestDuplicatedLateInliningOutput.java @@ -45,12 +45,12 @@ public class TestDuplicatedLateInliningOutput { public static void main(String[] args) throws Exception { test( NonConstantReceiverLauncher.class, - "@ (\\d+)\\s+java\\.lang\\.invoke\\.LambdaForm\\$DMH\\/0x[0-9a-f]+::invokeStatic \\(\\d+ bytes\\)\\s+force inline by annotation", + "@ (\\d+)\\s+java\\.lang\\.invoke\\.MethodHandle::invokeBasic\\(\\)V \\(\\d+ bytes\\)\\s+failed to inline: receiver not constant\\s+callee changed to\\s+java\\.lang\\.invoke\\.LambdaForm\\$DMH\\/0x[0-9a-f]+::invokeStatic \\(\\d+ bytes\\)\\s+force inline by annotation\\s+late inline succeeded \\(method handle\\)", "@ (\\d+)\\s+java\\.lang\\.invoke\\.MethodHandle::invokeBasic\\(\\)V \\(\\d+ bytes\\)\\s+failed to inline: receiver not constant"); test( VirtualCallLauncher.class, - "@ (\\d+)\\s+compiler\\.inlining\\.TestDuplicatedLateInliningOutput\\$VirtualCallLauncher\\$B::lateInlined2 \\(\\d+ bytes\\)\\s+inline \\(hot\\)", + "@ (\\d+)\\s+compiler\\.inlining\\.TestDuplicatedLateInliningOutput\\$VirtualCallLauncher\\$A::lateInlined2 \\(\\d+ bytes\\)\\s+failed to inline: virtual call\\s+callee changed to\\s+\\s+compiler\\.inlining\\.TestDuplicatedLateInliningOutput\\$VirtualCallLauncher\\$B::lateInlined2 \\(\\d+ bytes\\)\\s+inline \\(hot\\)\\s+late inline succeeded", "@ (\\d+)\\s+compiler\\.inlining\\.TestDuplicatedLateInliningOutput\\$VirtualCallLauncher\\$A::lateInlined2 \\(\\d+ bytes\\)\\s+failed to inline: virtual call" ); } @@ -75,7 +75,7 @@ private static void test(Class> launcher, String pattern1, String pattern2) th int index = IntStream.range(0, lines.size()) .filter(i -> lines.get(i).trim().matches(pattern1)) .findFirst() - .orElseThrow(() -> new Exception("No inlining found")); + .orElseThrow(() -> new Exception("No inlining found" + pattern1)); if (lines.get(index - 1).trim().matches(pattern2)) { throw new Exception("Both failure and success message found"); diff --git a/test/hotspot/jtreg/compiler/intrinsics/TestArrayGuardWithInterfaces.java b/test/hotspot/jtreg/compiler/intrinsics/TestArrayGuardWithInterfaces.java new file mode 100644 index 0000000000000..b9c26222c1604 --- /dev/null +++ b/test/hotspot/jtreg/compiler/intrinsics/TestArrayGuardWithInterfaces.java @@ -0,0 +1,63 @@ +/* + * 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.lang.reflect.Array; +import jdk.test.lib.Asserts; + +/** + * @test + * @bug 8348631 + * @summary Test folding of array guards used by intrinsics. + * @library /test/lib + * @run main/othervm -Xcomp -XX:-TieredCompilation + * -XX:CompileCommand=compileonly,TestArrayGuardWithInterfaces::test* + * TestArrayGuardWithInterfaces + */ +public class TestArrayGuardWithInterfaces { + + public static interface MyInterface { } + + public static int test1(Object obj) { + // Should be folded, arrays can never imlement 'MyInterface' + return Array.getLength((MyInterface)obj); + } + + public static int test2(Object obj) { + // Should not be folded, arrays implement 'Cloneable' + return Array.getLength((Cloneable)obj); + } + + public static void main(String[] args) { + // Warmup + Class c = MyInterface.class; + Array.getLength(args); + + try { + test1(null); + throw new RuntimeException("No exception thrown"); + } catch (Exception e) { + // Expected + } + Asserts.assertEQ(test2(new int[1]), 1); + } +} diff --git a/test/hotspot/jtreg/compiler/intrinsics/TestContinuationPinningAndEA.java b/test/hotspot/jtreg/compiler/intrinsics/TestContinuationPinningAndEA.java new file mode 100644 index 0000000000000..e2ce8312eb3cf --- /dev/null +++ b/test/hotspot/jtreg/compiler/intrinsics/TestContinuationPinningAndEA.java @@ -0,0 +1,77 @@ +/* + * 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 8347997 + * @summary Test that Continuation.pin() and unpin() intrinsics work with EA. + * @modules java.base/jdk.internal.vm + * @run main TestContinuationPinningAndEA + */ + +import jdk.internal.vm.Continuation; + +public class TestContinuationPinningAndEA { + + static class FailsEA { + final Object o; + + public FailsEA() throws Throwable { + o = new Object(); + Continuation.pin(); + Continuation.unpin(); + } + } + + static class Crashes { + final Object o; + + public Crashes() throws Throwable { + Continuation.pin(); + Continuation.unpin(); + o = new Object(); + } + } + + static void test_FailsEA() throws Throwable { + for (int i = 0; i < 10_000; ++i) { + new FailsEA(); + } + } + + static void test_Crashes() throws Throwable { + for (int i = 0; i < 10_000; ++i) { + new Crashes(); + } + } + + public static void main(String[] args) throws Throwable { + int iterations = 100; + for (int i = 0; i < iterations; ++i) { + test_FailsEA(); + } + for (int i = 0; i < iterations; ++i) { + test_Crashes(); + } + } +} diff --git a/test/hotspot/jtreg/compiler/jsr292/CallSiteDepContextTest.java b/test/hotspot/jtreg/compiler/jsr292/CallSiteDepContextTest.java index 3063c4e0f8752..2c740fa47dfb0 100644 --- a/test/hotspot/jtreg/compiler/jsr292/CallSiteDepContextTest.java +++ b/test/hotspot/jtreg/compiler/jsr292/CallSiteDepContextTest.java @@ -123,8 +123,8 @@ private static void execute(int expected, MethodHandle... mhs) throws Throwable public static void testHiddenDepField() { try { - Field f = MethodHandleHelper.MHN_CALL_SITE_CONTEXT_CLASS.getDeclaredField("vmdependencies"); - throw new AssertionError("Context.dependencies field should be hidden"); + Field f = MethodHandleHelper.JLI_CALL_SITE_CLASS.getDeclaredField("vmdependencies"); + throw new AssertionError("CallSite.dependencies field should be hidden"); } catch(NoSuchFieldException e) { /* expected */ } } diff --git a/test/hotspot/jtreg/compiler/jsr292/patches/java.base/java/lang/invoke/MethodHandleHelper.java b/test/hotspot/jtreg/compiler/jsr292/patches/java.base/java/lang/invoke/MethodHandleHelper.java index 614dc80799e2e..7e35d0c4e3d10 100644 --- a/test/hotspot/jtreg/compiler/jsr292/patches/java.base/java/lang/invoke/MethodHandleHelper.java +++ b/test/hotspot/jtreg/compiler/jsr292/patches/java.base/java/lang/invoke/MethodHandleHelper.java @@ -36,8 +36,8 @@ public class MethodHandleHelper { private MethodHandleHelper() { } public static final Lookup IMPL_LOOKUP = Lookup.IMPL_LOOKUP; - public static final Class> MHN_CALL_SITE_CONTEXT_CLASS - = MethodHandleNatives.CallSiteContext.class; + public static final Class> JLI_CALL_SITE_CLASS + = java.lang.invoke.CallSite.class; public static void customize(MethodHandle mh) { mh.customize(); diff --git a/test/hotspot/jtreg/compiler/loopopts/superword/TestMovingLoadBeforeStore.java b/test/hotspot/jtreg/compiler/loopopts/superword/TestMovingLoadBeforeStore.java index 45e3af0774193..72ca2cee3414b 100644 --- a/test/hotspot/jtreg/compiler/loopopts/superword/TestMovingLoadBeforeStore.java +++ b/test/hotspot/jtreg/compiler/loopopts/superword/TestMovingLoadBeforeStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 @@ -156,7 +156,7 @@ static void ref2(byte[] a, byte[] b) { static void test3(byte[] a) { for (int i = 51; i < 6000; i++) { - int adr = UNSAFE.ARRAY_BYTE_BASE_OFFSET + 42 + i; + long adr = UNSAFE.ARRAY_BYTE_BASE_OFFSET + 42 + i; UNSAFE.putIntUnaligned(a, adr + 0*4, UNSAFE.getIntUnaligned(a, adr + 0*4) + 1); UNSAFE.putIntUnaligned(a, adr + 1*4, UNSAFE.getIntUnaligned(a, adr + 1*4) + 1); UNSAFE.putIntUnaligned(a, adr + 2*4, UNSAFE.getIntUnaligned(a, adr + 2*4) + 1); @@ -171,7 +171,7 @@ static void test3(byte[] a) { static void ref3(byte[] a) { for (int i = 51; i < 6000; i++) { - int adr = UNSAFE.ARRAY_BYTE_BASE_OFFSET + 42 + i; + long adr = UNSAFE.ARRAY_BYTE_BASE_OFFSET + 42 + i; UNSAFE.putIntUnaligned(a, adr + 0*4, UNSAFE.getIntUnaligned(a, adr + 0*4) + 1); UNSAFE.putIntUnaligned(a, adr + 1*4, UNSAFE.getIntUnaligned(a, adr + 1*4) + 1); UNSAFE.putIntUnaligned(a, adr + 2*4, UNSAFE.getIntUnaligned(a, adr + 2*4) + 1); diff --git a/test/hotspot/jtreg/compiler/runtime/Test8010927.java b/test/hotspot/jtreg/compiler/runtime/Test8010927.java index 74aa824f2da02..3e90dc0c67cb8 100644 --- a/test/hotspot/jtreg/compiler/runtime/Test8010927.java +++ b/test/hotspot/jtreg/compiler/runtime/Test8010927.java @@ -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 @@ -74,7 +74,7 @@ public class Test8010927 { static final Test8010927 elem = new Test8010927(); static final WhiteBox wb = WhiteBox.getWhiteBox(); - static final int obj_header_size = U.ARRAY_OBJECT_BASE_OFFSET; + static final int obj_header_size = (int) U.ARRAY_OBJECT_BASE_OFFSET; static final int heap_oop_size = wb.getHeapOopSize(); static final int card_size = 512; static final int one_card = (card_size - obj_header_size) / heap_oop_size; diff --git a/test/hotspot/jtreg/compiler/stringopts/TestFluidAndNonFluid.java b/test/hotspot/jtreg/compiler/stringopts/TestFluidAndNonFluid.java deleted file mode 100644 index 34fbaa1b6edad..0000000000000 --- a/test/hotspot/jtreg/compiler/stringopts/TestFluidAndNonFluid.java +++ /dev/null @@ -1,134 +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 8341696 - * @summary Allow C2 to also optimize non-fluid string builder calls. - * @library /test/lib / - * @run driver compiler.c2.irTests.stringopts.TestFluidAndNonFluid - */ -package compiler.c2.irTests.stringopts; - -import compiler.lib.ir_framework.*; -import jdk.test.lib.Asserts; - -public class TestFluidAndNonFluid { - - public static int unknown = 1; - - public static void main(String[] args) { - // Dont inline any StringBuilder methods for this IR test to check if string opts are applied or not. - TestFramework.runWithFlags("-XX:CompileCommand=dontinline,java.lang.StringBuilder::*"); - } - - @DontInline - public static void opaque(StringBuilder builder) { - builder.append("Z"); - } - - @Run(test = {"fluid", "nonFluid", "nonFinal", "nonFluidExtraneousVariable", "nonFluidConditional", - "nonFluidOpaqueCall"}) - public void runMethod() { - Asserts.assertEQ("0ac", fluidNoParam()); - Asserts.assertEQ("ac", nonFluidNoParam()); - Asserts.assertEQ("ac", fluid("c")); - Asserts.assertEQ("ac", nonFluid("c")); - Asserts.assertEQ("ac", nonFinal("c")); - Asserts.assertEQ("ac", nonFluidExtraneousVariable("c")); - Asserts.assertEQ("ac", nonFluidConditional("c")); - Asserts.assertEQ("aZ", nonFluidOpaqueCall()); - } - - @Test - @IR(failOn = {IRNode.ALLOC_OF, "StringBuilder", IRNode.CALL_OF_METHOD, "toString", IRNode.INTRINSIC_TRAP}) - public static String fluidNoParam() { - return new StringBuilder("0").append("a").append("c").toString(); - } - - @Test - @IR(failOn = {IRNode.ALLOC_OF, "StringBuilder", IRNode.CALL_OF_METHOD, "toString", IRNode.INTRINSIC_TRAP}) - public static String nonFluidNoParam() { - final StringBuilder sb = new StringBuilder(); - sb.append("a"); - sb.append("c"); - return sb.toString(); - } - - @Test - @IR(failOn = {IRNode.ALLOC_OF, "StringBuilder", IRNode.CALL_OF_METHOD, "toString"}) - public static String fluid(String a) { - return new StringBuilder().append("a").append(a).toString(); - } - - @Test - @IR(failOn = {IRNode.ALLOC_OF, "StringBuilder", IRNode.CALL_OF_METHOD, "toString"}) - public static String nonFluid(String a) { - final StringBuilder sb = new StringBuilder(); - sb.append("a"); - sb.append(a); - return sb.toString(); - } - - @Test - @IR(failOn = {IRNode.ALLOC_OF, "StringBuilder", IRNode.CALL_OF_METHOD, "toString"}) - public static String nonFinal(String a) { - StringBuilder sb = new StringBuilder(); - sb.append("a"); - sb.append(a); - return sb.toString(); - } - - @Test - @IR(failOn = {IRNode.ALLOC_OF, "StringBuilder", IRNode.CALL_OF_METHOD, "toString"}) - public static String nonFluidExtraneousVariable(String a) { - final StringBuilder sb = new StringBuilder(); - final StringBuilder x = sb; - sb.append("a"); - x.append(a); - return sb.toString(); - } - - @Test - @IR(counts = {IRNode.ALLOC_OF, "StringBuilder", "1", IRNode.CALL_OF_METHOD, "toString", "1"}) - @IR(failOn = IRNode.INTRINSIC_TRAP) - static String nonFluidConditional(String a) { - final StringBuilder sb = new StringBuilder(); - sb.append("a"); - if (unknown == 1) { - sb.append(a); - } - return sb.toString(); - } - - @Test - @IR(counts = {IRNode.ALLOC_OF, "StringBuilder", "1", IRNode.CALL_OF_METHOD, "toString", "1"}) - @IR(failOn = IRNode.INTRINSIC_TRAP) - static String nonFluidOpaqueCall() { - final StringBuilder sb = new StringBuilder(); - sb.append("a"); - opaque(sb); - return sb.toString(); - } - -} diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java index 98f638abe2d5b..2a4015daca209 100644 --- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java +++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestBoolean { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java index e149f6bd07bb1..8b188cb7cb52e 100644 --- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java +++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestByte { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java index 62d926b66a1df..4b5b876d50720 100644 --- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java +++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestChar { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java index 2f90f0d7c7b0a..5334da98714d0 100644 --- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java +++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestDouble { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java index f0256e7815d5a..946f6d7d5dede 100644 --- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java +++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestFloat { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java index 038cd2151b1b4..93ed85805d5b6 100644 --- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java +++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestInt { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java index cffec14ad7259..7a6d2bfc033f0 100644 --- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java +++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestLong { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java index 0c74c295e2133..2fe5d7f3ae051 100644 --- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java +++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestObject { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java index 770677a98d394..47a700d9313c7 100644 --- a/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java +++ b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class JdkInternalMiscUnsafeAccessTestShort { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java index c176277d2bad2..fcb0b3fbef379 100644 --- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java +++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestBoolean { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestByte.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestByte.java index b205b1d33764a..7343463c41d88 100644 --- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestByte.java +++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestByte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestByte { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestChar.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestChar.java index 114ed7e9b5a7b..4c5e02bea2665 100644 --- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestChar.java +++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestChar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestChar { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java index d813ea73e702e..5503dcd1840f9 100644 --- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java +++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestDouble { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java index f0482c826376a..f050c5bb17b8b 100644 --- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java +++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestFloat { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestInt.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestInt.java index 9326539f4efee..85f82915e03aa 100644 --- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestInt.java +++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestInt { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestLong.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestLong.java index 30bc9551dd50c..1a73cfe308654 100644 --- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestLong.java +++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestLong { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestObject.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestObject.java index add15ff77fdd1..1aab41ddc9b6d 100644 --- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestObject.java +++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestObject { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestShort.java b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestShort.java index 4ea81f026e730..123b655220c63 100644 --- a/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestShort.java +++ b/test/hotspot/jtreg/compiler/unsafe/SunMiscUnsafeAccessTestShort.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -60,7 +60,7 @@ public class SunMiscUnsafeAccessTestShort { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/compiler/unsafe/X-UnsafeAccessTest.java.template b/test/hotspot/jtreg/compiler/unsafe/X-UnsafeAccessTest.java.template index 2fc22fa360ab9..f5eadc218e449 100644 --- a/test/hotspot/jtreg/compiler/unsafe/X-UnsafeAccessTest.java.template +++ b/test/hotspot/jtreg/compiler/unsafe/X-UnsafeAccessTest.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, 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 @@ -64,7 +64,7 @@ public class $Qualifier$UnsafeAccessTest$Type$ { static final long STATIC_V_OFFSET; - static int ARRAY_OFFSET; + static long ARRAY_OFFSET; static int ARRAY_SHIFT; diff --git a/test/hotspot/jtreg/gc/arguments/TestMaxMinHeapFreeRatioFlags.java b/test/hotspot/jtreg/gc/arguments/TestMaxMinHeapFreeRatioFlags.java index 477632e3e7783..1b8cc143fabc5 100644 --- a/test/hotspot/jtreg/gc/arguments/TestMaxMinHeapFreeRatioFlags.java +++ b/test/hotspot/jtreg/gc/arguments/TestMaxMinHeapFreeRatioFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -138,7 +138,7 @@ public static class RatioVerifier { // Size of byte array that will be allocated public static final int CHUNK_SIZE = 1024; // Length of byte array, that will be added to "garbage" list. - public static final int ARRAY_LENGTH = CHUNK_SIZE - Unsafe.ARRAY_BYTE_BASE_OFFSET; + public static final int ARRAY_LENGTH = CHUNK_SIZE - (int) Unsafe.ARRAY_BYTE_BASE_OFFSET; // Amount of tries to force heap shrinking/expansion using GC public static final int GC_TRIES = 10; diff --git a/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java b/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java index adb609f547ce5..a80b16b96a4c9 100644 --- a/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java +++ b/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2024, 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 @@ -254,7 +254,7 @@ public static class TargetSurvivorRatioVerifier { // Desired size of memory allocated at once public static final int CHUNK_SIZE = 1024; // Length of byte[] array that will have occupy CHUNK_SIZE bytes in heap - public static final int ARRAY_LENGTH = CHUNK_SIZE - Unsafe.ARRAY_BYTE_BASE_OFFSET; + public static final int ARRAY_LENGTH = CHUNK_SIZE - (int) Unsafe.ARRAY_BYTE_BASE_OFFSET; public static void main(String args[]) throws Exception { if (args.length != 1) { diff --git a/test/hotspot/jtreg/runtime/FieldLayout/BaseOffsets.java b/test/hotspot/jtreg/runtime/FieldLayout/BaseOffsets.java index e4f88b5d8d5c5..b2a6a22fb179e 100644 --- a/test/hotspot/jtreg/runtime/FieldLayout/BaseOffsets.java +++ b/test/hotspot/jtreg/runtime/FieldLayout/BaseOffsets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, 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 @@ -110,8 +110,8 @@ static class LIClass { public static final WhiteBox WB = WhiteBox.getWhiteBox(); static final long INT_OFFSET; - static final int INT_ARRAY_OFFSET; - static final int LONG_ARRAY_OFFSET; + static final long INT_ARRAY_OFFSET; + static final long LONG_ARRAY_OFFSET; static { if (!Platform.is64bit() || WB.getBooleanVMFlag("UseCompactObjectHeaders")) { INT_OFFSET = 8; @@ -151,7 +151,7 @@ static public void main(String[] args) { Asserts.assertEquals(unsafe.arrayBaseOffset(double[].class), LONG_ARRAY_OFFSET, "Misplaced double array base"); boolean narrowOops = System.getProperty("java.vm.compressedOopsMode") != null || !Platform.is64bit(); - int expected_objary_offset = narrowOops ? INT_ARRAY_OFFSET : LONG_ARRAY_OFFSET; + long expected_objary_offset = narrowOops ? INT_ARRAY_OFFSET : LONG_ARRAY_OFFSET; Asserts.assertEquals(unsafe.arrayBaseOffset(Object[].class), expected_objary_offset, "Misplaced object array base"); } } diff --git a/test/hotspot/jtreg/runtime/Safepoint/TestAbortOnVMOperationTimeout.java b/test/hotspot/jtreg/runtime/Safepoint/TestAbortOnVMOperationTimeout.java index a2c3f944db86b..d14c9627314e3 100644 --- a/test/hotspot/jtreg/runtime/Safepoint/TestAbortOnVMOperationTimeout.java +++ b/test/hotspot/jtreg/runtime/Safepoint/TestAbortOnVMOperationTimeout.java @@ -68,6 +68,7 @@ public static void testWith(int delay, boolean shouldPass) throws Exception { "-XX:+AbortVMOnVMOperationTimeout", "-XX:AbortVMOnVMOperationTimeoutDelay=" + delay, "-Xmx256m", + "-XX:NewSize=64m", "-XX:+UseSerialGC", "-XX:-CreateCoredumpOnCrash", "-Xlog:gc*=info", diff --git a/test/hotspot/jtreg/runtime/Unsafe/GetField.java b/test/hotspot/jtreg/runtime/Unsafe/GetField.java index 3772fa6e8db7f..88ac98135f1a7 100644 --- a/test/hotspot/jtreg/runtime/Unsafe/GetField.java +++ b/test/hotspot/jtreg/runtime/Unsafe/GetField.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, 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 @@ -37,11 +37,11 @@ public class GetField { public static void main(String args[]) throws Exception { Unsafe unsafe = Unsafe.getUnsafe(); - // Unsafe.INVALID_FIELD_OFFSET is a static final int field, + // Unsafe.INVALID_FIELD_OFFSET is a static final long field, // make sure getField returns the correct field Field field = Unsafe.class.getField("INVALID_FIELD_OFFSET"); assertNotEquals(field.getModifiers() & Modifier.FINAL, 0); assertNotEquals(field.getModifiers() & Modifier.STATIC, 0); - assertEquals(field.getType(), int.class); + assertEquals(field.getType(), long.class); } } diff --git a/test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java b/test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java index bc125a074eeb6..edb80bc6cebea 100644 --- a/test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java +++ b/test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -147,7 +147,7 @@ public static void test(MappedByteBuffer buffer, Unsafe unsafe, long mapAddr, lo break; case 1: // testing Unsafe.copySwapMemory, trying to access next page after truncation. - int destOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET; + long destOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET; unsafe.copySwapMemory(null, mapAddr + pageSize, new byte[4000], destOffset, 2000, 2); break; case 2: diff --git a/test/hotspot/jtreg/runtime/cds/appcds/AOTFlags.java b/test/hotspot/jtreg/runtime/cds/appcds/AOTFlags.java index 3a678eefc5b2b..98ff155abface 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/AOTFlags.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/AOTFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 @@ -59,7 +59,7 @@ static void positiveTests() throws Exception { out.shouldContain("Hello World"); out.shouldHaveExitValue(0); - // (2) Assembly Phase + // (2) Assembly Phase (AOTClassLinking unspecified -> should be enabled by default) pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:AOTMode=create", "-XX:AOTConfiguration=" + aotConfigFile, @@ -77,6 +77,7 @@ static void positiveTests() throws Exception { "-Xlog:cds", "-cp", appJar, helloClass); out = CDSTestUtils.executeAndLog(pb, "prod"); + out.shouldContain("Using AOT-linked classes: true (static archive: has aot-linked classes)"); out.shouldContain("Opened archive hello.aot."); out.shouldContain("Hello World"); out.shouldHaveExitValue(0); @@ -107,7 +108,7 @@ static void positiveTests() throws Exception { out.shouldContain("Hello World"); out.shouldHaveExitValue(0); - // (5) AOTMode=on + // (6) AOTMode=on pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:AOTCache=" + aotCacheFile, "--show-version", @@ -119,6 +120,30 @@ static void positiveTests() throws Exception { out.shouldContain("Opened archive hello.aot."); out.shouldContain("Hello World"); out.shouldHaveExitValue(0); + + // (7) Assembly Phase with -XX:-AOTClassLinking + pb = ProcessTools.createLimitedTestJavaProcessBuilder( + "-XX:AOTMode=create", + "-XX:-AOTClassLinking", + "-XX:AOTConfiguration=" + aotConfigFile, + "-XX:AOTCache=" + aotCacheFile, + "-Xlog:cds", + "-cp", appJar); + out = CDSTestUtils.executeAndLog(pb, "asm"); + out.shouldContain("Dumping shared data to file:"); + out.shouldMatch("cds.*hello[.]aot"); + out.shouldHaveExitValue(0); + + // (8) Production Run with AOTCache, which was created with -XX:-AOTClassLinking + pb = ProcessTools.createLimitedTestJavaProcessBuilder( + "-XX:AOTCache=" + aotCacheFile, + "-Xlog:cds", + "-cp", appJar, helloClass); + out = CDSTestUtils.executeAndLog(pb, "prod"); + out.shouldContain("Using AOT-linked classes: false (static archive: no aot-linked classes)"); + out.shouldContain("Opened archive hello.aot."); + out.shouldContain("Hello World"); + out.shouldHaveExitValue(0); } static void negativeTests() throws Exception { diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BadOldClassA.jasm b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BadOldClassA.jasm new file mode 100644 index 0000000000000..724d7c03584ad --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BadOldClassA.jasm @@ -0,0 +1,53 @@ +/* + * 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. + * + */ + +super public class BadOldClassA + version 49:0 +{ + + +public Method " ":"()V" + stack 1 locals 1 +{ + aload_0; + invokespecial Method java/lang/Object." ":"()V"; + return; +} + + /* + * The following method tries to return an Object as a String. + * Verifier should fail. + */ +public Method doit:"()Ljava/lang/String;" + stack 2 locals 1 +{ + new class java/lang/Object; + dup; + invokespecial Method java/lang/Object." ":"()V"; + astore_0; + aload_0; + areturn; // tries to return an Object as a String +} + +} // end Class BadOldClassA diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BadOldClassB.jasm b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BadOldClassB.jasm new file mode 100644 index 0000000000000..ce2f101a588eb --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BadOldClassB.jasm @@ -0,0 +1,53 @@ +/* + * 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. + * + */ + +super public class BadOldClassB + version 49:0 +{ + + +public Method " ":"()V" + stack 1 locals 1 +{ + aload_0; + invokespecial Method java/lang/Object." ":"()V"; + return; +} + + /* + * The following method tries to return an Object as a String. + * Verifier should fail. + */ +public Method doit:"()Ljava/lang/String;" + stack 2 locals 1 +{ + new class java/lang/Object; + dup; + invokespecial Method java/lang/Object." ":"()V"; + astore_0; + aload_0; + areturn; // tries to return an Object as a String +} + +} // end Class BadOldClassB diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java index 25361403481ee..c4648bd2eb37b 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/BulkLoaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 @@ -32,9 +32,10 @@ * @comment work around JDK-8345635 * @requires !vm.jvmci.enabled * @library /test/jdk/lib/testlibrary /test/lib - * @build InitiatingLoaderTester + * @build InitiatingLoaderTester BadOldClassA BadOldClassB * @build BulkLoaderTest * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar BulkLoaderTestApp.jar BulkLoaderTestApp MyUtil InitiatingLoaderTester + * BadOldClassA BadOldClassB * @run driver BulkLoaderTest STATIC */ @@ -44,9 +45,10 @@ * @comment work around JDK-8345635 * @requires !vm.jvmci.enabled * @library /test/jdk/lib/testlibrary /test/lib - * @build InitiatingLoaderTester + * @build InitiatingLoaderTester BadOldClassA BadOldClassB * @build jdk.test.whitebox.WhiteBox BulkLoaderTest * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar BulkLoaderTestApp.jar BulkLoaderTestApp MyUtil InitiatingLoaderTester + * BadOldClassA BadOldClassB * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. BulkLoaderTest DYNAMIC */ @@ -129,6 +131,7 @@ class BulkLoaderTestApp { public static void main(String args[]) throws Exception { checkClasses(); checkInitiatingLoader(); + checkOldClasses(); } // Check the ClassLoader/Module/Package/ProtectionDomain/CodeSource of classes that are aot-linked @@ -229,6 +232,29 @@ static void checkInitiatingLoader() throws Exception { throw new RuntimeException("Should not have succeeded"); } + + static void checkOldClasses() throws Exception { + // Resolve BadOldClassA from the constant pool without linking it. + // implNote: BadOldClassA will be excluded, so any resolved refereces + // to BadOldClassA should be removed from the archived constant pool. + Class c = BadOldClassA.class; + Object n = new Object(); + if (c.isInstance(n)) { // Note that type-testing BadOldClassA here neither links nor initializes it. + throw new RuntimeException("Must not succeed"); + } + + try { + // In dynamic dump, the VM loads BadOldClassB and then attempts to + // link it. This will leave BadOldClassB in a "failed verification" state. + // All refernces to BadOldClassB from the CP should be purged from the CDS + // archive. + c = BadOldClassB.class; + c.newInstance(); + throw new RuntimeException("Must not succeed"); + } catch (VerifyError e) { + System.out.println("Caught VerifyError for BadOldClassB: " + e); + } + } } class MyUtil { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal001.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal001.java index 757102f0c1c49..8ac20f89eaa07 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -80,6 +80,10 @@ public double meth01() { float f = 0f; double d = 0; checkPoint(); + if (currThread.isVirtual()) { + out.println("meth01: skipping results check for virtual thread"); + return d + f + 1; // SetLocal* should return OPAQUE_FRAME for a virtual thread + } if (l != 22L || f != floatVal || d != doubleVal) { out.println("meth01: l =" + l + " f = " + f + " d = " + d); result = 2; @@ -97,6 +101,10 @@ public void meth02(int step) { meth02(step - 1); } else { checkPoint(); + if (currThread.isVirtual()) { + out.println("meth02: skipping results check for virtual thread"); + return; // SetLocal* should return OPAQUE_FRAME for a virtual thread + } if (i1 != 1 || i2 != 1 || i3 != 1 || i4 != 1 || !i5) { out.println("meth02: i1 =" + i1 + " i2 = " + i2 + " i3 = " + i3 + " i4 = " + i4 + " i5 = " + i5); @@ -109,6 +117,10 @@ public static void meth03() { setlocal001 ob1 = null; int[] ob2 = null; checkPoint(); + if (currThread.isVirtual()) { + out.println("meth03: skipping results check for virtual thread"); + return; // SetLocalObject for obj1 and obj2 should return OPAQUE_FRAME for a virtual thread + } if (ob1.val != 3 || ob2[2] != 8) { out.println("meth03: ob1.val =" + ob1.val + " ob2[2] = " + ob2[2]); result = 2; @@ -118,6 +130,10 @@ public static void meth03() { public static void meth04(int i1, long l, short i2, double d, char i3, float f, byte i4, boolean b) { checkPoint(); + if (currThread.isVirtual()) { + out.println("meth04: skipping results check for virtual thread"); + return; // SetLocal* should return OPAQUE_FRAME for a virtual thread + } if (i1 != 1 || i2 != 2 || i3 != 3 || i4 != 4 || l != 22L || f != floatVal || d != doubleVal || !b) { out.println("meth04: i1 =" + i1 + " i2 = " + i2 + diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal001/setlocal001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal001/setlocal001.cpp index 8193058eba76d..9ad953e56f962 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal001/setlocal001.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal001/setlocal001.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -44,6 +44,13 @@ static jdouble doubleVal; static jobject objVal; static jobject arrVal; +static void check_error(jvmtiError err, bool is_virtual, const char* func_id) { + if (err != JVMTI_ERROR_NONE && !(is_virtual && err == JVMTI_ERROR_OPAQUE_FRAME)) { + printf("(%s) unexpected error: %s (%d)\n", func_id, TranslateError(err), err); + result = STATUS_FAILED; + } +} + void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, jmethodID method, jlocation location) { jvmtiError err; @@ -51,6 +58,7 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, jlocation loc; jint entryCount; jvmtiLocalVariableEntry *table = nullptr; + bool is_virtual = env->IsVirtualThread(thr); int i; err = jvmti_env->GetFrameLocation(thr, 1, &mid, &loc); @@ -74,27 +82,15 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, if (strcmp(table[i].name, "l") == 0) { err = jvmti_env->SetLocalLong(thr, 1, table[i].slot, longVal); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalLong) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalLong"); } else if (strcmp(table[i].name, "f") == 0) { err = jvmti_env->SetLocalFloat(thr, 1, table[i].slot, floatVal); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalFloat) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalFloat"); } else if (strcmp(table[i].name, "d") == 0) { err = jvmti_env->SetLocalDouble(thr, 1, table[i].slot, doubleVal); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalDouble) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalDouble"); } } } else if (mid == mid2) { @@ -102,43 +98,23 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, if (strcmp(table[i].name, "i1") == 0) { err = jvmti_env->SetLocalInt(thr, 1, table[i].slot, 1); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalInt#i1) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalInt#i1"); } else if (strcmp(table[i].name, "i2") == 0) { err = jvmti_env->SetLocalInt(thr, 1, table[i].slot, 1); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalInt#i2) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalInt#i2"); } else if (strcmp(table[i].name, "i3") == 0) { err = jvmti_env->SetLocalInt(thr, 1, table[i].slot, 1); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalInt#i3) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalInt#i3"); } else if (strcmp(table[i].name, "i4") == 0) { err = jvmti_env->SetLocalInt(thr, 1, table[i].slot, 1); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalInt#i4) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalInt#i4"); } else if (strcmp(table[i].name, "i5") == 0) { err = jvmti_env->SetLocalInt(thr, 1, table[i].slot, 1); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalInt#i5) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalInt#i5"); } } } else if (mid == mid3) { @@ -146,19 +122,11 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, if (strcmp(table[i].name, "ob1") == 0) { err = jvmti_env->SetLocalObject(thr, 1, table[i].slot, objVal); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalObject#ob1) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalObject#ob1"); } else if (strcmp(table[i].name, "ob2") == 0) { err = jvmti_env->SetLocalObject(thr, 1, table[i].slot, arrVal); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalObject#ob2) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalObject#ob2"); } } } else if (mid == mid4) { @@ -166,67 +134,35 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, if (strcmp(table[i].name, "i1") == 0) { err = jvmti_env->SetLocalInt(thr, 1, table[i].slot, 1); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalInt#i1,param) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalInt#i1,param"); } else if (strcmp(table[i].name, "i2") == 0) { err = jvmti_env->SetLocalInt(thr, 1, table[i].slot, 2); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalInt#i2,param) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalInt#i2,param"); } else if (strcmp(table[i].name, "i3") == 0) { err = jvmti_env->SetLocalInt(thr, 1, table[i].slot, 3); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalInt#i3,param) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalInt#i3,param"); } else if (strcmp(table[i].name, "i4") == 0) { err = jvmti_env->SetLocalInt(thr, 1, table[i].slot, 4); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalInt#i4,param) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalInt#i4,param"); } else if (strcmp(table[i].name, "b") == 0) { err = jvmti_env->SetLocalInt(thr, 1, table[i].slot, JNI_TRUE); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalInt#b,param) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalInt#b,param"); } else if (strcmp(table[i].name, "l") == 0) { err = jvmti_env->SetLocalLong(thr, 1, table[i].slot, longVal); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalLong,param) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalLong,param"); } else if (strcmp(table[i].name, "f") == 0) { err = jvmti_env->SetLocalFloat(thr, 1, table[i].slot, floatVal); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalFloat,param) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalFloat,param"); } else if (strcmp(table[i].name, "d") == 0) { err = jvmti_env->SetLocalDouble(thr, 1, table[i].slot, doubleVal); - if (err != JVMTI_ERROR_NONE) { - printf("(SetLocalDouble,param) unexpected error: %s (%d)\n", - TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, "SetLocalDouble,param"); } } } else { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal003/setlocal003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal003/setlocal003.cpp index 793f22ec40fc7..c366655a7350a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal003/setlocal003.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal003/setlocal003.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -40,6 +40,15 @@ static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; +static void check_error(jvmtiError err, bool is_virtual, char* var_name) { + if (err != JVMTI_ERROR_INVALID_SLOT && !(is_virtual && err == JVMTI_ERROR_OPAQUE_FRAME)) { + printf("(%s) ", var_name); + printf("Error expected: JVMTI_ERROR_INVALID_SLOT or JVMTI_ERROR_OPAQUE_FRAME,\n"); + printf("\t actual: %s (%d)\n", TranslateError(err), err); + result = STATUS_FAILED; + } +} + void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, jmethodID method, jlocation location) { jvmtiError err; @@ -47,6 +56,7 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, jlocation loc; jint entryCount; jvmtiLocalVariableEntry *table; + bool is_virtual = env->IsVirtualThread(thr); int i; err = jvmti_env->GetFrameLocation(thr, 1, &mid, &loc); @@ -71,51 +81,28 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, printf(">>> checking on invalid slot ...\n"); } for (i = 0; i < entryCount; i++) { + char* var_name = table[i].name; + if (strcmp(table[i].name, "o") == 0) { err = jvmti_env->SetLocalObject(thr, 1, INV_SLOT, (jobject)thr); - if (err != JVMTI_ERROR_INVALID_SLOT) { - printf("(%s) ", table[i].name); - printf("Error expected: JVMTI_ERROR_INVALID_SLOT,\n"); - printf("\t actual: %s (%d)\n", TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, var_name); } else if (strcmp(table[i].name, "i") == 0) { err = jvmti_env->SetLocalInt(thr, 1, INV_SLOT, (jint)0); - if (err != JVMTI_ERROR_INVALID_SLOT) { - printf("(%s) ", table[i].name); - printf("Error expected: JVMTI_ERROR_INVALID_SLOT,\n"); - printf("\t actual: %s (%d)\n", TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, var_name); } else if (strcmp(table[i].name, "l") == 0) { err = jvmti_env->SetLocalLong(thr, 1, INV_SLOT, (jlong)0); - if (err != JVMTI_ERROR_INVALID_SLOT) { - printf("(%s) ", table[i].name); - printf("Error expected: JVMTI_ERROR_INVALID_SLOT,\n"); - printf("\t actual: %s (%d)\n", TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, var_name); } else if (strcmp(table[i].name, "f") == 0) { err = jvmti_env->SetLocalFloat(thr, 1, INV_SLOT, (jfloat)0); - if (err != JVMTI_ERROR_INVALID_SLOT) { - printf("(%s) ", table[i].name); - printf("Error expected: JVMTI_ERROR_INVALID_SLOT,\n"); - printf("\t actual: %s (%d)\n", TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, var_name); } else if (strcmp(table[i].name, "d") == 0) { err = jvmti_env->SetLocalDouble(thr, 1, INV_SLOT, (jdouble)0); - if (err != JVMTI_ERROR_INVALID_SLOT) { - printf("(%s) ", table[i].name); - printf("Error expected: JVMTI_ERROR_INVALID_SLOT,\n"); - printf("\t actual: %s (%d)\n", TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, var_name); } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal004/setlocal004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal004/setlocal004.cpp index 37598107c455c..db10b761ca457 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal004/setlocal004.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetLocalVariable/setlocal004/setlocal004.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -40,6 +40,15 @@ static jvmtiEventCallbacks callbacks; static jint result = PASSED; static jboolean printdump = JNI_FALSE; +static void check_error(jvmtiError err, bool is_virtual, char* var_name) { + if (err != JVMTI_ERROR_TYPE_MISMATCH && !(is_virtual && err == JVMTI_ERROR_OPAQUE_FRAME)) { + printf("(%s) ", var_name); + printf("Error: expected: JVMTI_ERROR_TYPE_MISMATCH or JVMTI_ERROR_OPAQUE_FRAME,\n"); + printf("\t actual: %s (%d)\n", TranslateError(err), err); + result = STATUS_FAILED; + } +} + void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, jmethodID method, jlocation location) { jvmtiError err; @@ -47,6 +56,7 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, jlocation loc; jint entryCount; jvmtiLocalVariableEntry *table; + bool is_virtual = env->IsVirtualThread(thr); int i; err = jvmti_env->GetFrameLocation(thr, 1, &mid, &loc); @@ -72,56 +82,33 @@ void JNICALL Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, printf(">>> checking on type mismatch ...\n"); } for (i = 0; i < entryCount; i++) { + char* var_name = table[i].name; + if (strlen(table[i].name) != 1) continue; if (strcmp(table[i].name, "o") != 0) { err = jvmti_env->SetLocalObject(thr, 1, table[i].slot, (jobject)thr); - if (err != JVMTI_ERROR_TYPE_MISMATCH) { - printf("\"%s\" against SetLocalObject:\n", table[i].name); - printf(" expected: JVMTI_ERROR_TYPE_MISMATCH,"); - printf(" actual: %s (%d)\n", TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, var_name); } if (strcmp(table[i].name, "i") != 0) { err = jvmti_env->SetLocalInt(thr, 1, table[i].slot, (jint)0); - if (err != JVMTI_ERROR_TYPE_MISMATCH) { - printf("\"%s\" against SetLocalInt:\n", table[i].name); - printf(" expected: JVMTI_ERROR_TYPE_MISMATCH,"); - printf(" actual: %s (%d)\n", TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, var_name); } if (strcmp(table[i].name, "l") != 0) { err = jvmti_env->SetLocalLong(thr, 1, table[i].slot, (jlong)0); - if (err != JVMTI_ERROR_TYPE_MISMATCH) { - printf("\"%s\" against SetLocalLong:\n", table[i].name); - printf(" expected: JVMTI_ERROR_TYPE_MISMATCH,"); - printf(" actual: %s (%d)\n", TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, var_name); } if (strcmp(table[i].name, "f") != 0) { err = jvmti_env->SetLocalFloat(thr, 1, table[i].slot, (jfloat)0); - if (err != JVMTI_ERROR_TYPE_MISMATCH) { - printf("\"%s\" against SetLocalFloat:\n", table[i].name); - printf(" expected: JVMTI_ERROR_TYPE_MISMATCH,"); - printf(" actual: %s (%d)\n", TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, var_name); } if (strcmp(table[i].name, "d") != 0) { err = jvmti_env->SetLocalDouble(thr, 1, table[i].slot, (jdouble)0); - if (err != JVMTI_ERROR_TYPE_MISMATCH) { - printf("\"%s\" against SetLocalDouble:\n", table[i].name); - printf(" expected: JVMTI_ERROR_TYPE_MISMATCH,"); - printf(" actual: %s (%d)\n", TranslateError(err), err); - result = STATUS_FAILED; - } + check_error(err, is_virtual, var_name); } } diff --git a/test/jdk/java/awt/Headless/HeadlessMalfunctionAgent.java b/test/jdk/java/awt/Headless/HeadlessMalfunctionAgent.java new file mode 100644 index 0000000000000..dc422581fa993 --- /dev/null +++ b/test/jdk/java/awt/Headless/HeadlessMalfunctionAgent.java @@ -0,0 +1,71 @@ +/* + * 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. + * + * 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 jdk.internal.org.objectweb.asm.ClassReader; +import jdk.internal.org.objectweb.asm.ClassVisitor; +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; + +import java.lang.instrument.ClassFileTransformer; +import java.lang.instrument.Instrumentation; +import java.security.ProtectionDomain; + +/** + * This agent removes the isHeadless method from java.awt.GraphicsEnvironment. + */ +public class HeadlessMalfunctionAgent { + + public static void premain(String agentArgs, Instrumentation inst) { + inst.addTransformer(new ClassFileTransformer() { + + @Override + public byte[] transform(ClassLoader loader, String className, Class> classBeingRedefined, + ProtectionDomain pd, byte[] cb) { + if ("java/awt/GraphicsEnvironment".equals(className)) { + System.out.println("Transforming java.awt.GraphicsEnvironment."); + try { + final ClassReader cr = new ClassReader(cb); + final ClassWriter cw = new ClassWriter(cr, 0); + cr.accept(new ClassVisitor(Opcodes.ASM9, cw) { + + @Override + public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, + String[] exceptions) { + if ("isHeadless".equals(name) && "()Z".equals(descriptor)) { + System.out.println("isHeadless removed from java.awt.GraphicsEnvironment."); + // WHACK! Remove the isHeadless method. + return null; + } + return super.visitMethod(access, name, descriptor, signature, exceptions); + } + }, 0); + return cw.toByteArray(); + } catch (Exception e) { + e.printStackTrace(); + } + } + return null; + } + }); + } +} diff --git a/test/jdk/java/awt/Headless/HeadlessMalfunctionTest.java b/test/jdk/java/awt/Headless/HeadlessMalfunctionTest.java new file mode 100644 index 0000000000000..1d1a9c0eec01e --- /dev/null +++ b/test/jdk/java/awt/Headless/HeadlessMalfunctionTest.java @@ -0,0 +1,76 @@ +/* + * 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. + * + * 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 jdk.test.lib.JDKToolFinder; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +import java.nio.file.Files; +import java.nio.file.Path; + +/* + * @test + * @bug 8336382 + * @summary Test that in absence of isHeadless method, the JDK throws a meaningful error message. + * @library /test/lib + * @modules java.base/jdk.internal.org.objectweb.asm + * @build HeadlessMalfunctionAgent + * @run driver jdk.test.lib.helpers.ClassFileInstaller + * HeadlessMalfunctionAgent + * HeadlessMalfunctionAgent$1 + * HeadlessMalfunctionAgent$1$1 + * @run driver HeadlessMalfunctionTest + */ +public class HeadlessMalfunctionTest { + + public static void main(String[] args) throws Exception { + // Package agent + Files.writeString(Path.of("MANIFEST.MF"), "Premain-Class: HeadlessMalfunctionAgent\n"); + final ProcessBuilder pbJar = new ProcessBuilder() + .command(JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF", "agent.jar", + "HeadlessMalfunctionAgent.class", + "HeadlessMalfunctionAgent$1.class", + "HeadlessMalfunctionAgent$1$1.class"); + ProcessTools.executeProcess(pbJar).shouldHaveExitValue(0); + + // Run test + final ProcessBuilder pbJava = ProcessTools.createTestJavaProcessBuilder( + "--add-opens", + "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED", + "-javaagent:agent.jar", + "HeadlessMalfunctionTest$Runner" + ); + final OutputAnalyzer output = ProcessTools.executeProcess(pbJava); + // Unpatched JDK logs: "FATAL ERROR in native method: Could not allocate library name" + output.shouldContain("FATAL ERROR in native method: GetStaticMethodID isHeadless failed"); + output.shouldNotHaveExitValue(0); + } + + public static class Runner { + public static void main(String[] args) { + System.out.println(java.awt.GraphicsEnvironment + .getLocalGraphicsEnvironment() + .getMaximumWindowBounds()); + } + } +} diff --git a/test/jdk/java/time/test/java/time/TestZoneOffset.java b/test/jdk/java/time/test/java/time/TestZoneOffset.java index a69eedfcd6c25..b85a629aefce7 100644 --- a/test/jdk/java/time/test/java/time/TestZoneOffset.java +++ b/test/jdk/java/time/test/java/time/TestZoneOffset.java @@ -1,5 +1,6 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, Alibaba Group Holding Limited. 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 @@ -82,4 +83,19 @@ public void test_factory_ofTotalSecondsSame() { assertSame(ZoneOffset.ofTotalSeconds(0), ZoneOffset.UTC); } + @Test + public void test_quarter_cache() throws Exception { + // [-18:00, +18:00] + int quarter = 15 * 60; + int start = -18 * 3600, + end = 18 * 3600; + for (int totalSeconds = start; totalSeconds <= end; totalSeconds += quarter) { + var offset0 = ZoneOffset.ofTotalSeconds(totalSeconds); + var offset1 = ZoneOffset.ofTotalSeconds(totalSeconds); + var offset2 = ZoneOffset.ofTotalSeconds(totalSeconds); + assertSame(offset0, offset1); + assertSame(offset1, offset2); + } + } + } diff --git a/test/jdk/javax/swing/JPopupMenu/FocusablePopupDismissTest.java b/test/jdk/javax/swing/JPopupMenu/FocusablePopupDismissTest.java index 2704c9789e309..cb3811265dc12 100644 --- a/test/jdk/javax/swing/JPopupMenu/FocusablePopupDismissTest.java +++ b/test/jdk/javax/swing/JPopupMenu/FocusablePopupDismissTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 @@ -24,22 +24,28 @@ /* * @test * @key headful - * @bug 8319103 + * @bug 8319103 8342096 * @requires (os.family == "linux") - * @library /java/awt/regtesthelpers - * @build PassFailJFrame + * @library /java/awt/regtesthelpers /test/lib + * @build PassFailJFrame jtreg.SkippedException * @summary Tests if the focusable popup can be dismissed when the parent * window or the popup itself loses focus in Wayland. * @run main/manual FocusablePopupDismissTest */ +import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JTextField; import java.awt.Window; import java.util.List; +import jtreg.SkippedException; + public class FocusablePopupDismissTest { private static final String INSTRUCTIONS = """ A frame with a "Click me" button should appear next to the window @@ -47,44 +53,72 @@ public class FocusablePopupDismissTest { Click on the "Click me" button. - If the JTextField popup with "Some text" is not showing on the screen, - click Fail. + A menu should appear next to the window. If you move the cursor over + the first menu, the JTextField popup should appear on the screen. + If it doesn't, click Fail. The following steps require some focusable system window to be displayed on the screen. This could be a system settings window, file manager, etc. Click on the "Click me" button if the popup is not displayed - on the screen. + on the screen, move the mouse pointer over the menu. While the popup is displayed, click on some other window on the desktop. - If the popup has disappeared, click Pass, otherwise click Fail. + If the popup does not disappear, click Fail. + + Open the menu again, move the mouse cursor over the following: + "Focusable 1" -> "Focusable 2" -> "Editor Focusable 2" + Move the mouse to the focusable system window + (keeping the "Editor Focusable 2" JTextField open) and click on it. + + If the popup does not disappear, click Fail, otherwise click Pass. """; public static void main(String[] args) throws Exception { if (System.getenv("WAYLAND_DISPLAY") == null) { - //test is valid only when running on Wayland. - return; + throw new SkippedException("XWayland only test"); } PassFailJFrame.builder() .title("FocusablePopupDismissTest") .instructions(INSTRUCTIONS) - .rows(20) .columns(45) .testUI(FocusablePopupDismissTest::createTestUI) .build() .awaitAndCheck(); } + static JMenu getMenuWithMenuItem(boolean isSubmenuItemFocusable, String text) { + JMenu menu = new JMenu(text); + menu.add(isSubmenuItemFocusable + ? new JTextField("Editor " + text, 11) + : new JMenuItem("Menu item" + text) + ); + return menu; + } + static List createTestUI() { JFrame frame = new JFrame("FocusablePopupDismissTest"); JButton button = new JButton("Click me"); - frame.add(button); + + JPanel wrapper = new JPanel(); + wrapper.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16)); + wrapper.add(button); + + frame.add(wrapper); button.addActionListener(e -> { JPopupMenu popupMenu = new JPopupMenu(); - JTextField textField = new JTextField("Some text", 10); - popupMenu.add(textField); + + JMenu menu1 = new JMenu("Menu 1"); + menu1.add(new JTextField("Some text", 10)); + JMenu menu2 = new JMenu("Menu 2"); + menu2.add(new JTextField("Some text", 10)); + + popupMenu.add(getMenuWithMenuItem(true, "Focusable 1")); + popupMenu.add(getMenuWithMenuItem(true, "Focusable 2")); + popupMenu.add(getMenuWithMenuItem(false, "Non-Focusable 1")); + popupMenu.add(getMenuWithMenuItem(false, "Non-Focusable 2")); popupMenu.show(button, 0, button.getHeight()); }); frame.pack(); diff --git a/test/jdk/javax/swing/JPopupMenu/NestedFocusablePopupTest.java b/test/jdk/javax/swing/JPopupMenu/NestedFocusablePopupTest.java new file mode 100644 index 0000000000000..55963b081a558 --- /dev/null +++ b/test/jdk/javax/swing/JPopupMenu/NestedFocusablePopupTest.java @@ -0,0 +1,187 @@ +/* + * 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 + * @summary tests if nested menu is displayed on Wayland + * @requires (os.family == "linux") + * @key headful + * @bug 8342096 + * @library /test/lib + * @build jtreg.SkippedException + * @run main NestedFocusablePopupTest + */ + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.IllegalComponentStateException; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.FutureTask; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import jtreg.SkippedException; + +public class NestedFocusablePopupTest { + + static volatile JMenu menuWithFocusableItem; + static volatile JMenu menuWithNonFocusableItem; + static volatile JPopupMenu popupMenu; + static volatile JFrame frame; + static volatile Robot robot; + + public static void main(String[] args) throws Exception { + if (System.getenv("WAYLAND_DISPLAY") == null) { + throw new SkippedException("XWayland only test"); + } + + robot = new Robot(); + robot.setAutoDelay(50); + + try { + SwingUtilities.invokeAndWait(NestedFocusablePopupTest::initAndShowGui); + test0(); + test1(); + } finally { + SwingUtilities.invokeAndWait(frame::dispose); + } + } + + public static void waitTillShown(final Component component, long msTimeout) + throws InterruptedException, TimeoutException { + long startTime = System.currentTimeMillis(); + + while (true) { + try { + Thread.sleep(50); + component.getLocationOnScreen(); + break; + } catch (IllegalComponentStateException e) { + if (System.currentTimeMillis() - startTime > msTimeout) { + throw new TimeoutException("Component not shown within the specified timeout"); + } + } + } + } + + static Rectangle waitAndGetOnScreenBoundsOnEDT(Component component) + throws InterruptedException, TimeoutException, ExecutionException { + waitTillShown(component, 500); + robot.waitForIdle(); + + FutureTask task = new FutureTask<>(() + -> new Rectangle(component.getLocationOnScreen(), component.getSize())); + SwingUtilities.invokeLater(task); + return task.get(500, TimeUnit.MILLISECONDS); + } + + static void test0() throws Exception { + Rectangle frameBounds = waitAndGetOnScreenBoundsOnEDT(frame); + robot.mouseMove(frameBounds.x + frameBounds.width / 2, + frameBounds.y + frameBounds.height / 2); + + robot.mousePress(InputEvent.BUTTON3_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK); + + Rectangle menuBounds = waitAndGetOnScreenBoundsOnEDT(menuWithFocusableItem); + robot.mouseMove(menuBounds.x + 5, menuBounds.y + 5); + + // Give popup some time to disappear (in case of failure) + robot.waitForIdle(); + robot.delay(200); + + try { + waitTillShown(popupMenu, 500); + } catch (TimeoutException e) { + throw new RuntimeException("The popupMenu disappeared when it shouldn't have."); + } + } + + static void test1() throws Exception { + Rectangle frameBounds = waitAndGetOnScreenBoundsOnEDT(frame); + robot.mouseMove(frameBounds.x + frameBounds.width / 2, + frameBounds.y + frameBounds.height / 2); + + robot.mousePress(InputEvent.BUTTON3_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK); + + Rectangle menuBounds = waitAndGetOnScreenBoundsOnEDT(menuWithFocusableItem); + robot.mouseMove(menuBounds.x + 5, menuBounds.y + 5); + robot.waitForIdle(); + robot.delay(200); + + menuBounds = waitAndGetOnScreenBoundsOnEDT(menuWithNonFocusableItem); + robot.mouseMove(menuBounds.x + 5, menuBounds.y + 5); + + // Give popup some time to disappear (in case of failure) + robot.waitForIdle(); + robot.delay(200); + + try { + waitTillShown(popupMenu, 500); + } catch (TimeoutException e) { + throw new RuntimeException("The popupMenu disappeared when it shouldn't have."); + } + } + + static JMenu getMenuWithMenuItem(boolean isSubmenuItemFocusable, String text) { + JMenu menu = new JMenu(text); + menu.add(isSubmenuItemFocusable + ? new JButton(text) + : new JMenuItem(text) + ); + return menu; + } + + private static void initAndShowGui() { + frame = new JFrame("NestedFocusablePopupTest"); + JPanel panel = new JPanel(); + panel.setPreferredSize(new Dimension(200, 180)); + + + popupMenu = new JPopupMenu(); + menuWithFocusableItem = + getMenuWithMenuItem(true, "focusable subitem"); + menuWithNonFocusableItem = + getMenuWithMenuItem(false, "non-focusable subitem"); + + popupMenu.add(menuWithFocusableItem); + popupMenu.add(menuWithNonFocusableItem); + + panel.setComponentPopupMenu(popupMenu); + frame.add(panel); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } +} diff --git a/test/jdk/javax/swing/JProgressBar/TestProgressBarUI.java b/test/jdk/javax/swing/JProgressBar/TestProgressBarUI.java new file mode 100644 index 0000000000000..0091fe625c9bd --- /dev/null +++ b/test/jdk/javax/swing/JProgressBar/TestProgressBarUI.java @@ -0,0 +1,97 @@ +/* + * 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 8318577 + * @summary Tests JProgressBarUI renders correctly in Windows L&F + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TestProgressBarUI + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; + +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; + +public class TestProgressBarUI { + + private static final String instructionsText = """ + Two progressbar "Good" and "Bad" + will be shown with different preferred size, + If the "Bad" progressbar is rendered at the same + height as "Good" progressbar, + without any difference in padding internally + the test passes, otherwise fails. """; + + public static void main(String[] args) throws Exception { + System.setProperty("sun.java2d.uiScale", "2.0"); + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + PassFailJFrame.builder() + .title("ProgressBar Instructions") + .instructions(instructionsText) + .rows(9) + .columns(36) + .testUI(TestProgressBarUI::doTest) + .build() + .awaitAndCheck(); + } + + public static JFrame doTest() { + JFrame frame = new JFrame("JProgressBar"); + + JPanel panel = new JPanel(new FlowLayout(20, 20, FlowLayout.LEADING)); + panel.setBackground(Color.white); + + JProgressBar p1 = new JProgressBar(0, 100); + p1.setValue(50); + p1.setStringPainted(true); + p1.setString("GOOD"); + p1.setPreferredSize(new Dimension(100, 21)); + panel.add(p1); + + JProgressBar p2 = new JProgressBar(0, 100); + p2.setValue(50); + p2.setStringPainted(true); + p2.setString("BAD"); + + p2.setPreferredSize(new Dimension(100, 22)); + panel.add(p2); + + JComponent c = (JComponent) frame.getContentPane(); + c.add(panel, BorderLayout.CENTER); + + frame.pack(); + frame.setLocationByPlatform(true); + return frame; + } +} diff --git a/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java b/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java index 7ca36d40a6f90..9e9a6c79c7b60 100644 --- a/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java +++ b/test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,8 @@ public class JShellHeapDumpTest { static Process jShellProcess; static boolean doSleep = true; // By default do a short sleep when app starts up - public static void launch(String expectedMessage, List toolArgs) + // Returns false if the attempt should be retried. + public static boolean launch(String expectedMessage, List toolArgs, boolean allowRetry) throws IOException { try { @@ -81,6 +82,10 @@ public static void launch(String expectedMessage, List toolArgs) System.out.println("###### End of all output which took " + elapsedTime + "ms"); output.shouldHaveExitValue(0); } catch (Exception ex) { + if (allowRetry) { + System.out.println("Exception " + ex + " in 'launch' occured. Allow one retry."); + return false; + } throw new RuntimeException("Test ERROR " + ex, ex); } finally { if (jShellProcess.isAlive()) { @@ -91,12 +96,18 @@ public static void launch(String expectedMessage, List toolArgs) System.out.println("Jshell not alive"); } } + return true; } public static void launch(String expectedMessage, String... toolArgs) throws IOException { - launch(expectedMessage, Arrays.asList(toolArgs)); + boolean res = launch(expectedMessage, Arrays.asList(toolArgs), true); + // Allow a retry for !doSleep, because the sleep allows the debuggee to stabilize, + // making it very unlikely that jmap will fail. + if (!res && !doSleep) { + launch(expectedMessage, Arrays.asList(toolArgs), false); + } } /* Returns false if the attempt should be retried. */ diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/AllocTest.java b/test/micro/org/openjdk/bench/java/lang/foreign/AllocTest.java index a70861a0dda7e..4ae78d6d99e91 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/AllocTest.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/AllocTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 @@ -64,9 +64,9 @@ public void tearDown() { } @Benchmark - public MemorySegment alloc_confined() { + public long alloc_confined() { try (Arena arena = Arena.ofConfined()) { - return arena.allocate(size); + return arena.allocate(size).address(); } } diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/BulkOps.java b/test/micro/org/openjdk/bench/java/lang/foreign/BulkOps.java index 6a1dd05b615e5..60f36d9f1572b 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/BulkOps.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/BulkOps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,7 +69,7 @@ public class BulkOps { final int[] ints = new int[ELEM_SIZE]; final MemorySegment bytesSegment = MemorySegment.ofArray(ints); - final int UNSAFE_INT_OFFSET = unsafe.arrayBaseOffset(int[].class); + final long UNSAFE_INT_OFFSET = unsafe.arrayBaseOffset(int[].class); // large(ish) segments/buffers with same content, 0, for mismatch, non-multiple-of-8 sized static final int SIZE_WITH_TAIL = (1024 * 1024) + 7; diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/LoopOverNonConstantHeap.java b/test/micro/org/openjdk/bench/java/lang/foreign/LoopOverNonConstantHeap.java index baaa19097188b..0605db076ca71 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/LoopOverNonConstantHeap.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/LoopOverNonConstantHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,8 +57,8 @@ public class LoopOverNonConstantHeap extends JavaLayouts { static final int ELEM_SIZE = 1_000_000; static final int CARRIER_SIZE = (int)JAVA_INT.byteSize(); static final int ALLOC_SIZE = ELEM_SIZE * CARRIER_SIZE; - static final int UNSAFE_BYTE_BASE = unsafe.arrayBaseOffset(byte[].class); - static final int UNSAFE_INT_BASE = unsafe.arrayBaseOffset(int[].class); + static final long UNSAFE_BYTE_BASE = unsafe.arrayBaseOffset(byte[].class); + static final long UNSAFE_INT_BASE = unsafe.arrayBaseOffset(int[].class); MemorySegment segment, alignedSegment; byte[] base; diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayUnsafeXorOpImpl.java b/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayUnsafeXorOpImpl.java index 0b29f925c7c30..59079dc09d1a7 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayUnsafeXorOpImpl.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/xor/GetArrayUnsafeXorOpImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 @@ -42,7 +42,7 @@ public class GetArrayUnsafeXorOpImpl implements XorOp { static final Unsafe UNSAFE = Utils.unsafe; - static final int BYTE_ARR_OFFSET = Utils.unsafe.arrayBaseOffset(byte[].class); + static final long BYTE_ARR_OFFSET = Utils.unsafe.arrayBaseOffset(byte[].class); static { System.loadLibrary("jnitest"); diff --git a/test/micro/org/openjdk/bench/vm/compiler/FluidSBBench.java b/test/micro/org/openjdk/bench/vm/compiler/FluidSBBench.java deleted file mode 100644 index 794ff768678ab..0000000000000 --- a/test/micro/org/openjdk/bench/vm/compiler/FluidSBBench.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. - * 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.vm.compiler; - -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.Warmup; -import org.openjdk.jmh.annotations.State; -import org.openjdk.jmh.annotations.Scope; -import java.util.concurrent.TimeUnit; - -@Warmup(iterations = 3, time = 300, timeUnit = TimeUnit.MILLISECONDS) -@Measurement(iterations = 3, time = 300, timeUnit = TimeUnit.MILLISECONDS) -@Fork(value = 1, jvmArgsAppend = {"-XX:+UseParallelGC", "-Xmx1g", "-Xms1g"}) -@BenchmarkMode(Mode.AverageTime) -@OutputTimeUnit(TimeUnit.NANOSECONDS) -@State(Scope.Thread) -public class FluidSBBench { - static final String PREFIX = "a"; - String foo = "aaaaa aaaaa aaaaa aaaaa aaaaa"; - - @Benchmark - public String fluid() { - return new StringBuilder().append(PREFIX).append(foo).toString(); - } - - @Benchmark - public String nonFluid() { - final StringBuilder sb = new StringBuilder(); - sb.append(PREFIX); - sb.append(foo); - return sb.toString(); - } -}