diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 index 42bac4f79ede..3db3e505508a 100644 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -95,6 +95,13 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_OPEN_OR_CUSTOM], AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS], [ + # Should we build a JDK with/without sound ? + UTIL_ARG_ENABLE(NAME: jsound, DEFAULT: true, + RESULT: ENABLE_JSOUND, + DESC: [build with sound support], + CHECKING_MSG: [if we should build with sound support]) + AC_SUBST(ENABLE_JSOUND) + # Should we build a JDK without a graphical UI? UTIL_ARG_ENABLE(NAME: headless-only, DEFAULT: false, RESULT: ENABLE_HEADLESS_ONLY, diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in index a7d39d2c9556..19e3300df49f 100644 --- a/make/autoconf/spec.gmk.in +++ b/make/autoconf/spec.gmk.in @@ -328,6 +328,8 @@ HOTSPOT_OVERRIDE_LIBPATH := @HOTSPOT_OVERRIDE_LIBPATH@ # Control use of precompiled header in hotspot libjvm build USE_PRECOMPILED_HEADER := @USE_PRECOMPILED_HEADER@ +ENABLE_JSOUND := @ENABLE_JSOUND@ + # Only build headless support or not ENABLE_HEADLESS_ONLY := @ENABLE_HEADLESS_ONLY@ diff --git a/make/modules/java.desktop/Lib.gmk b/make/modules/java.desktop/Lib.gmk index be1ac3f1fb8a..faf279fcb7da 100644 --- a/make/modules/java.desktop/Lib.gmk +++ b/make/modules/java.desktop/Lib.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -40,44 +40,45 @@ include lib/Awt2dLibraries.gmk ################################################################################ # Create the libjsound library -ifeq ($(call isTargetOs, aix), false) - - LIBJSOUND_CFLAGS := \ - $(ALSA_CFLAGS) \ - -DX_PLATFORM=X_$(OPENJDK_TARGET_OS_UPPERCASE) \ - -DUSE_PORTS=TRUE \ - -DUSE_DAUDIO=TRUE \ - -DUSE_PLATFORM_MIDI_OUT=TRUE \ - -DUSE_PLATFORM_MIDI_IN=TRUE \ - # - - ifeq ($(call isTargetOs, macosx), true) - LIBJSOUND_TOOLCHAIN := TOOLCHAIN_LINK_CXX +ifeq ($(ENABLE_JSOUND), true) + ifeq ($(call isTargetOs, aix), false) + + LIBJSOUND_CFLAGS := \ + $(ALSA_CFLAGS) \ + -DX_PLATFORM=X_$(OPENJDK_TARGET_OS_UPPERCASE) \ + -DUSE_PORTS=TRUE \ + -DUSE_DAUDIO=TRUE \ + -DUSE_PLATFORM_MIDI_OUT=TRUE \ + -DUSE_PLATFORM_MIDI_IN=TRUE \ + # + + ifeq ($(call isTargetOs, macosx), true) + LIBJSOUND_TOOLCHAIN := TOOLCHAIN_LINK_CXX + endif + + $(eval $(call SetupJdkLibrary, BUILD_LIBJSOUND, \ + NAME := jsound, \ + TOOLCHAIN := $(LIBJSOUND_TOOLCHAIN), \ + OPTIMIZATION := LOW, \ + CFLAGS := $(CFLAGS_JDKLIB) \ + $(LIBJSOUND_CFLAGS), \ + CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBJSOUND_CFLAGS), \ + DISABLED_WARNINGS_gcc := undef, \ + DISABLED_WARNINGS_clang := undef, \ + LDFLAGS := $(LDFLAGS_JDKLIB) \ + $(call SET_SHARED_LIBRARY_ORIGIN), \ + LIBS_unix := -ljava -ljvm, \ + LIBS_linux := $(ALSA_LIBS), \ + LIBS_macosx := -framework CoreAudio -framework CoreFoundation \ + -framework CoreServices -framework AudioUnit \ + -framework CoreMIDI -framework AudioToolbox $(LIBCXX), \ + LIBS_windows := $(WIN_JAVA_LIB) advapi32.lib dsound.lib winmm.lib user32.lib ole32.lib, \ + )) + + $(BUILD_LIBJSOUND): $(call FindLib, java.base, java) + + TARGETS += $(BUILD_LIBJSOUND) endif - - $(eval $(call SetupJdkLibrary, BUILD_LIBJSOUND, \ - NAME := jsound, \ - TOOLCHAIN := $(LIBJSOUND_TOOLCHAIN), \ - OPTIMIZATION := LOW, \ - CFLAGS := $(CFLAGS_JDKLIB) \ - $(LIBJSOUND_CFLAGS), \ - CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBJSOUND_CFLAGS), \ - DISABLED_WARNINGS_gcc := undef, \ - DISABLED_WARNINGS_clang := undef, \ - LDFLAGS := $(LDFLAGS_JDKLIB) \ - $(call SET_SHARED_LIBRARY_ORIGIN), \ - LIBS_unix := -ljava -ljvm, \ - LIBS_linux := $(ALSA_LIBS), \ - LIBS_macosx := -framework CoreAudio -framework CoreFoundation \ - -framework CoreServices -framework AudioUnit \ - -framework CoreMIDI -framework AudioToolbox $(LIBCXX), \ - LIBS_windows := $(WIN_JAVA_LIB) advapi32.lib dsound.lib winmm.lib user32.lib ole32.lib, \ - )) - - $(BUILD_LIBJSOUND): $(call FindLib, java.base, java) - - TARGETS += $(BUILD_LIBJSOUND) - endif ################################################################################ diff --git a/src/hotspot/cpu/arm/frame_arm.hpp b/src/hotspot/cpu/arm/frame_arm.hpp index 7ef941ad0ff7..90eaac4745b4 100644 --- a/src/hotspot/cpu/arm/frame_arm.hpp +++ b/src/hotspot/cpu/arm/frame_arm.hpp @@ -61,6 +61,7 @@ // between a callee frame and its stack arguments, where it is part // of the caller/callee overlap metadata_words_at_top = 0, + // in bytes frame_alignment = 16, // size, in words, of maximum shift in frame position due to alignment align_wiggle = 1 diff --git a/src/hotspot/cpu/ppc/frame_ppc.hpp b/src/hotspot/cpu/ppc/frame_ppc.hpp index e2e2b9d015dd..bd0a348cd011 100644 --- a/src/hotspot/cpu/ppc/frame_ppc.hpp +++ b/src/hotspot/cpu/ppc/frame_ppc.hpp @@ -444,8 +444,7 @@ // between a callee frame and its stack arguments, where it is part // of the caller/callee overlap metadata_words_at_top = sizeof(java_abi) >> LogBytesPerWord, - // size, in words, of frame metadata at the frame top that needs - // to be reserved for callee functions in the runtime + // in bytes frame_alignment = 16, frame_alignment_in_words = frame_alignment >> LogBytesPerWord, // size, in words, of maximum shift in frame position due to alignment diff --git a/src/hotspot/cpu/x86/frame_x86.hpp b/src/hotspot/cpu/x86/frame_x86.hpp index 3658fa234675..595432d8ea9a 100644 --- a/src/hotspot/cpu/x86/frame_x86.hpp +++ b/src/hotspot/cpu/x86/frame_x86.hpp @@ -105,8 +105,7 @@ // between a callee frame and its stack arguments, where it is part // of the caller/callee overlap metadata_words_at_top = 0, - // size, in words, of frame metadata at the frame top that needs - // to be reserved for callee functions in the runtime + // in bytes frame_alignment = 16, // size, in words, of maximum shift in frame position due to alignment align_wiggle = 1 diff --git a/src/hotspot/cpu/zero/frame_zero.hpp b/src/hotspot/cpu/zero/frame_zero.hpp index 87511ab212e1..83923cd0cbf8 100644 --- a/src/hotspot/cpu/zero/frame_zero.hpp +++ b/src/hotspot/cpu/zero/frame_zero.hpp @@ -39,6 +39,7 @@ // between a callee frame and its stack arguments, where it is part // of the caller/callee overlap metadata_words_at_top = 0, + // in bytes frame_alignment = 16, // size, in words, of maximum shift in frame position due to alignment align_wiggle = 1 diff --git a/src/java.base/share/classes/java/lang/StringLatin1.java b/src/java.base/share/classes/java/lang/StringLatin1.java index 7f901e4717c4..ac26dee05633 100644 --- a/src/java.base/share/classes/java/lang/StringLatin1.java +++ b/src/java.base/share/classes/java/lang/StringLatin1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/src/java.base/share/classes/java/lang/invoke/VarHandles.java b/src/java.base/share/classes/java/lang/invoke/VarHandles.java index fa1c6470ec10..8f57211a48f9 100644 --- a/src/java.base/share/classes/java/lang/invoke/VarHandles.java +++ b/src/java.base/share/classes/java/lang/invoke/VarHandles.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -196,7 +196,7 @@ static VarHandle makeArrayElementHandle(Class> arrayClass) { Class> componentType = arrayClass.getComponentType(); - int aoffset = UNSAFE.arrayBaseOffset(arrayClass); + int aoffset = (int) UNSAFE.arrayBaseOffset(arrayClass); int ascale = UNSAFE.arrayIndexScale(arrayClass); int ashift = 31 - Integer.numberOfLeadingZeros(ascale); diff --git a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java index 024390f26d90..2fa6b56650f4 100644 --- a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java +++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java @@ -6366,7 +6366,7 @@ public final void compute() { = U.objectFieldOffset(ConcurrentHashMap.class, "cellsBusy"); private static final long CELLVALUE = U.objectFieldOffset(CounterCell.class, "value"); - private static final int ABASE = U.arrayBaseOffset(Node[].class); + private static final long ABASE = U.arrayBaseOffset(Node[].class); private static final int ASHIFT; static { diff --git a/src/java.base/share/classes/java/util/zip/CRC32C.java b/src/java.base/share/classes/java/util/zip/CRC32C.java index b60c564e6832..36d37f3fe267 100644 --- a/src/java.base/share/classes/java/util/zip/CRC32C.java +++ b/src/java.base/share/classes/java/util/zip/CRC32C.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -222,9 +222,9 @@ private static int updateBytes(int crc, byte[] b, int off, int end) { if (end - off >= 8 && Unsafe.ARRAY_BYTE_INDEX_SCALE == 1) { // align on 8 bytes - int alignLength + long alignLength = (8 - ((Unsafe.ARRAY_BYTE_BASE_OFFSET + off) & 0x7)) & 0x7; - for (int alignEnd = off + alignLength; off < alignEnd; off++) { + for (long alignEnd = off + alignLength; off < alignEnd; off++) { crc = (crc >>> 8) ^ byteTable[(crc ^ b[off]) & 0xFF]; } @@ -238,11 +238,11 @@ private static int updateBytes(int crc, byte[] b, int off, int end) { int secondHalf; if (Unsafe.ADDRESS_SIZE == 4) { // On 32 bit platforms read two ints instead of a single 64bit long - firstHalf = UNSAFE.getInt(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off); - secondHalf = UNSAFE.getInt(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off + firstHalf = UNSAFE.getInt(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off); + secondHalf = UNSAFE.getInt(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off + Integer.BYTES); } else { - long value = UNSAFE.getLong(b, (long)Unsafe.ARRAY_BYTE_BASE_OFFSET + off); + long value = UNSAFE.getLong(b, Unsafe.ARRAY_BYTE_BASE_OFFSET + off); if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) { firstHalf = (int) value; secondHalf = (int) (value >>> 32); diff --git a/src/java.base/share/classes/java/util/zip/ZipUtils.java b/src/java.base/share/classes/java/util/zip/ZipUtils.java index 0cbc2e28795d..1d66a546f848 100644 --- a/src/java.base/share/classes/java/util/zip/ZipUtils.java +++ b/src/java.base/share/classes/java/util/zip/ZipUtils.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 diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/RawBytecodeHelper.java b/src/java.base/share/classes/jdk/internal/classfile/impl/RawBytecodeHelper.java index 223f04d59182..2150bee65a6e 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/RawBytecodeHelper.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/RawBytecodeHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java b/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java index 3906d07e775c..5654093e4368 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java +++ b/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java @@ -716,19 +716,19 @@ public static long mismatch(MemorySegment srcSegment, long srcFromOffset, long s private static long getBaseAndScale(Class> arrayType) { if (arrayType.equals(byte[].class)) { - return (long) Unsafe.ARRAY_BYTE_BASE_OFFSET | ((long)Unsafe.ARRAY_BYTE_INDEX_SCALE << 32); + return Unsafe.ARRAY_BYTE_BASE_OFFSET | ((long)Unsafe.ARRAY_BYTE_INDEX_SCALE << 32); } else if (arrayType.equals(char[].class)) { - return (long) Unsafe.ARRAY_CHAR_BASE_OFFSET | ((long)Unsafe.ARRAY_CHAR_INDEX_SCALE << 32); + return Unsafe.ARRAY_CHAR_BASE_OFFSET | ((long)Unsafe.ARRAY_CHAR_INDEX_SCALE << 32); } else if (arrayType.equals(short[].class)) { - return (long)Unsafe.ARRAY_SHORT_BASE_OFFSET | ((long)Unsafe.ARRAY_SHORT_INDEX_SCALE << 32); + return Unsafe.ARRAY_SHORT_BASE_OFFSET | ((long)Unsafe.ARRAY_SHORT_INDEX_SCALE << 32); } else if (arrayType.equals(int[].class)) { - return (long)Unsafe.ARRAY_INT_BASE_OFFSET | ((long) Unsafe.ARRAY_INT_INDEX_SCALE << 32); + return Unsafe.ARRAY_INT_BASE_OFFSET | ((long)Unsafe.ARRAY_INT_INDEX_SCALE << 32); } else if (arrayType.equals(float[].class)) { - return (long)Unsafe.ARRAY_FLOAT_BASE_OFFSET | ((long)Unsafe.ARRAY_FLOAT_INDEX_SCALE << 32); + return Unsafe.ARRAY_FLOAT_BASE_OFFSET | ((long)Unsafe.ARRAY_FLOAT_INDEX_SCALE << 32); } else if (arrayType.equals(long[].class)) { - return (long)Unsafe.ARRAY_LONG_BASE_OFFSET | ((long)Unsafe.ARRAY_LONG_INDEX_SCALE << 32); + return Unsafe.ARRAY_LONG_BASE_OFFSET | ((long)Unsafe.ARRAY_LONG_INDEX_SCALE << 32); } else if (arrayType.equals(double[].class)) { - return (long)Unsafe.ARRAY_DOUBLE_BASE_OFFSET | ((long)Unsafe.ARRAY_DOUBLE_INDEX_SCALE << 32); + return Unsafe.ARRAY_DOUBLE_BASE_OFFSET | ((long)Unsafe.ARRAY_DOUBLE_INDEX_SCALE << 32); } else { throw new IllegalArgumentException("Not a supported array class: " + arrayType.getSimpleName()); } diff --git a/src/java.base/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java b/src/java.base/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java index e6b0ab7ab8de..e87ada0d7ac7 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java +++ b/src/java.base/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java @@ -51,7 +51,7 @@ public abstract sealed class HeapMemorySegmentImpl extends AbstractMemorySegmentImpl { private static final Unsafe UNSAFE = Unsafe.getUnsafe(); - private static final int BYTE_ARR_BASE = UNSAFE.arrayBaseOffset(byte[].class); + private static final long BYTE_ARR_BASE = UNSAFE.arrayBaseOffset(byte[].class); private static final long MAX_ALIGN_1 = ValueLayout.JAVA_BYTE.byteAlignment(); private static final long MAX_ALIGN_2 = ValueLayout.JAVA_SHORT.byteAlignment(); @@ -89,7 +89,7 @@ ByteBuffer makeByteBuffer() { throw new UnsupportedOperationException("Not an address to an heap-allocated byte array"); } JavaNioAccess nioAccess = SharedSecrets.getJavaNioAccess(); - return nioAccess.newHeapByteBuffer(baseByte, (int)offset - BYTE_ARR_BASE, (int) byteSize(), null); + return nioAccess.newHeapByteBuffer(baseByte, (int)(offset - BYTE_ARR_BASE), (int) byteSize(), null); } // factories diff --git a/src/java.base/share/classes/jdk/internal/misc/Unsafe.java b/src/java.base/share/classes/jdk/internal/misc/Unsafe.java index 47e8bf80c50e..2ac8553e334c 100644 --- a/src/java.base/share/classes/jdk/internal/misc/Unsafe.java +++ b/src/java.base/share/classes/jdk/internal/misc/Unsafe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1037,8 +1037,11 @@ private void checkWritebackEnabled() { * This constant differs from all results that will ever be returned from * {@link #staticFieldOffset}, {@link #objectFieldOffset}, * or {@link #arrayBaseOffset}. + *
+ * 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 @@ -1166,11 +1169,15 @@ public void ensureClassInitialized(Class> c) { * for the same class, you may use that scale factor, together with this * base offset, to form new offsets to access elements of arrays of the * given class. + *
+ * 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(); } @@ -1180,39 +1187,39 @@ public int arrayBaseOffset(Class> arrayClass) { /** The value of {@code arrayBaseOffset(boolean[].class)} */ - public static final int ARRAY_BOOLEAN_BASE_OFFSET + public static final long ARRAY_BOOLEAN_BASE_OFFSET = theUnsafe.arrayBaseOffset(boolean[].class); /** The value of {@code arrayBaseOffset(byte[].class)} */ - public static final int ARRAY_BYTE_BASE_OFFSET + public static final long ARRAY_BYTE_BASE_OFFSET = theUnsafe.arrayBaseOffset(byte[].class); /** The value of {@code arrayBaseOffset(short[].class)} */ - public static final int ARRAY_SHORT_BASE_OFFSET + public static final long ARRAY_SHORT_BASE_OFFSET = theUnsafe.arrayBaseOffset(short[].class); /** The value of {@code arrayBaseOffset(char[].class)} */ - public static final int ARRAY_CHAR_BASE_OFFSET + public static final long ARRAY_CHAR_BASE_OFFSET = theUnsafe.arrayBaseOffset(char[].class); /** The value of {@code arrayBaseOffset(int[].class)} */ - public static final int ARRAY_INT_BASE_OFFSET + public static final long ARRAY_INT_BASE_OFFSET = theUnsafe.arrayBaseOffset(int[].class); /** The value of {@code arrayBaseOffset(long[].class)} */ - public static final int ARRAY_LONG_BASE_OFFSET + public static final long ARRAY_LONG_BASE_OFFSET = theUnsafe.arrayBaseOffset(long[].class); /** The value of {@code arrayBaseOffset(float[].class)} */ - public static final int ARRAY_FLOAT_BASE_OFFSET + public static final long ARRAY_FLOAT_BASE_OFFSET = theUnsafe.arrayBaseOffset(float[].class); /** The value of {@code arrayBaseOffset(double[].class)} */ - public static final int ARRAY_DOUBLE_BASE_OFFSET + public static final long ARRAY_DOUBLE_BASE_OFFSET = theUnsafe.arrayBaseOffset(double[].class); /** The value of {@code arrayBaseOffset(Object[].class)} */ - public static final int ARRAY_OBJECT_BASE_OFFSET + public static final long ARRAY_OBJECT_BASE_OFFSET = theUnsafe.arrayBaseOffset(Object[].class); /** @@ -1221,6 +1228,9 @@ public int arrayBaseOffset(Class> arrayClass) { * will generally not work properly with accessors like {@link * #getByte(Object, long)}, so the scale factor for such classes is reported * as zero. + *
+ * The computation of the actual memory offset should always use {@code + * long} arithmetic to avoid overflows. * * @see #arrayBaseOffset * @see #getInt(Object, long) @@ -3833,7 +3843,7 @@ private void putShortParts(Object o, long offset, byte i0, byte i1) { private native Object staticFieldBase0(Field f); private native boolean shouldBeInitialized0(Class> c); private native void ensureClassInitialized0(Class> c); - private native int arrayBaseOffset0(Class> arrayClass); + private native int arrayBaseOffset0(Class> arrayClass); // public version returns long to promote correct arithmetic private native int arrayIndexScale0(Class> arrayClass); private native int getLoadAverage0(double[] loadavg, int nelems); 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 98ce4a5d63a7..92c769ba964a 100644 --- a/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java +++ b/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java @@ -295,8 +295,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, @@ -388,8 +388,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, diff --git a/src/java.base/share/classes/sun/security/ssl/DHasKEM.java b/src/java.base/share/classes/sun/security/ssl/DHasKEM.java index ef5c5b82f060..9f860af101e0 100644 --- a/src/java.base/share/classes/sun/security/ssl/DHasKEM.java +++ b/src/java.base/share/classes/sun/security/ssl/DHasKEM.java @@ -268,17 +268,17 @@ private SecretKey DH(String alg, PrivateKey skE, PublicKey pkR) // RFC 8446 section 7.4.2: checks for all-zero // X25519/X448 shared secret. - if (kaAlgorithm.equals("X25519") || - kaAlgorithm.equals("X448")) { + if (this == X25519 || this == X448) { byte[] s = secret.getEncoded(); + byte data = 0; for (byte b : s) { - if (b != 0) { - return secret; - } + data |= b; + } + if (data == 0) { + // Trigger ILLEGAL_PARAMETER alert + throw new IllegalArgumentException( + "All-zero shared secret"); } - // Trigger ILLEGAL_PARAMETER alert - throw new IllegalArgumentException( - "All-zero shared secret"); } return secret; diff --git a/src/java.base/share/classes/sun/security/ssl/Hybrid.java b/src/java.base/share/classes/sun/security/ssl/Hybrid.java index e3e2cfa0b238..43634ce2f346 100644 --- a/src/java.base/share/classes/sun/security/ssl/Hybrid.java +++ b/src/java.base/share/classes/sun/security/ssl/Hybrid.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -355,7 +355,7 @@ public SecretKey engineDecapsulate(byte[] encapsulation, int from, int to, String algorithm) throws DecapsulateException { int expectedEncSize = engineEncapsulationSize(); if (encapsulation.length != expectedEncSize) { - throw new IllegalArgumentException( + throw new DecapsulateException( "Invalid key encapsulation message length: " + encapsulation.length + ", expected = " + expectedEncSize); diff --git a/src/java.base/share/legal/zlib.md b/src/java.base/share/legal/zlib.md index c729c4248d48..d346a4d0c986 100644 --- a/src/java.base/share/legal/zlib.md +++ b/src/java.base/share/legal/zlib.md @@ -1,4 +1,4 @@ -## zlib v1.3.2 +## zlib v1.4 ### zlib License
diff --git a/src/java.base/share/native/libzip/zlib/ChangeLog b/src/java.base/share/native/libzip/zlib/ChangeLog
index 312753edadef..228a03afa1d7 100644
--- a/src/java.base/share/native/libzip/zlib/ChangeLog
+++ b/src/java.base/share/native/libzip/zlib/ChangeLog
@@ -1,6 +1,37 @@
ChangeLog file for zlib
+Changes in 1.4 (4 Nov 2026)
+- Change CMake library names on MSVC
+- Return z_off_t default to long for portability
+- Fail gzopen() with "x" if O_EXCL not available
+- Deliver all gzip data before reporting error
+- Fix gzwrite() buffer overflow (CVE-2026-85091)
+- Fix inflateGetDictionary() write past buffer on invalid window size
+- Fix window write overrun after inflateSync()
+- Fix read before provided data after repeated inflatePrime()'s
+- Fix write past pending buffer after repeated deflatePrime()'s
+- Fix copy of uninitialized memory by inflateBack() on invalid data
+- Fix copy of uninitialized memory after gzseek() as first write action
+- Fix read outside window after a deflateResetKeep() mid-stream
+- Avoid out-of-bounds pointer arithmetic in infback9() (CVE-2026-4738)
+- Fix several vulnerabilities in contrib/minizip
+- Fix truncated stream detection in gzread()
+- Fix pending skip handling in gzread()
+- Fix loss of zero fill on repeated gzseek()'s when writing
+- Fix inaccurate total_in after Z_NEED_DICT returned
+- Detect and report bad deflateSetDictionary() calls
+- Avoid undefined behaviors in C language usage
+- Fix minizip extra field overflows when almost full and need Zip64
+- Don't assume NULL is defined in compress.c and uncompr.c
+- Use the generated zconf.h when building test programs out of tree
+- Improve portability and functionality of CMake builds
+- Provide 64-bit file offsets on Windows with #defines as on Linux
+- Improve portability to Android, AIX, PowerPC, s390x, and Windows
+- Use a PCG random number generator instead of rand() in minizip
+- Clarify documentation
+- (See https://github.com/madler/zlib for all 195 commits)
+
Changes in 1.3.2 (17 Feb 2026)
- Continued rewrite of CMake build [Vollstrecker]
- Various portability improvements
diff --git a/src/java.base/share/native/libzip/zlib/README b/src/java.base/share/native/libzip/zlib/README
index 2b1e6f36fe3e..265c8b47d316 100644
--- a/src/java.base/share/native/libzip/zlib/README
+++ b/src/java.base/share/native/libzip/zlib/README
@@ -1,6 +1,6 @@
ZLIB DATA COMPRESSION LIBRARY
-zlib 1.3.2 is a general purpose data compression library. All the code is
+zlib 1.4 is a general purpose data compression library. All the code is
thread safe (though see the FAQ for caveats). The data format used by the zlib
library is described by RFCs (Request for Comments) 1950 to 1952 at
https://datatracker.ietf.org/doc/html/rfc1950 (zlib format), rfc1951 (deflate
@@ -31,7 +31,7 @@ Mark Nelson wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available at
https://zlib.net/nelson/ .
-The changes made in version 1.3.2 are documented in the file ChangeLog.
+The changes made in version 1.4 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory contrib/ .
diff --git a/src/java.base/share/native/libzip/zlib/compress.c b/src/java.base/share/native/libzip/zlib/compress.c
index 54346ad2a2f1..832788e9248f 100644
--- a/src/java.base/share/native/libzip/zlib/compress.c
+++ b/src/java.base/share/native/libzip/zlib/compress.c
@@ -52,8 +52,8 @@ int ZEXPORT compress2_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
const uInt max = (uInt)-1;
z_size_t left;
- if ((sourceLen > 0 && source == NULL) ||
- destLen == NULL || (*destLen > 0 && dest == NULL))
+ if ((sourceLen > 0 && source == Z_NULL) ||
+ destLen == Z_NULL || (*destLen > 0 && dest == Z_NULL))
return Z_STREAM_ERROR;
left = *destLen;
diff --git a/src/java.base/share/native/libzip/zlib/deflate.c b/src/java.base/share/native/libzip/zlib/deflate.c
index 0ec56ec5691f..5918d8cb00b4 100644
--- a/src/java.base/share/native/libzip/zlib/deflate.c
+++ b/src/java.base/share/native/libzip/zlib/deflate.c
@@ -76,7 +76,7 @@
#include "deflate.h"
const char deflate_copyright[] =
- " deflate 1.3.2 Copyright 1995-2026 Jean-loup Gailly and Mark Adler ";
+ " deflate 1.4 Copyright 1995-2026 Jean-loup Gailly and Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -469,7 +469,6 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
s->status = INIT_STATE; /* to pass state test in deflateReset() */
s->wrap = wrap;
- s->gzhead = Z_NULL;
s->w_bits = (uInt)windowBits;
s->w_size = 1 << s->w_bits;
s->w_mask = s->w_size - 1;
@@ -592,7 +591,8 @@ int ZEXPORT deflateSetDictionary(z_streamp strm, const Bytef *dictionary,
return Z_STREAM_ERROR;
s = strm->state;
wrap = s->wrap;
- if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
+ if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead ||
+ (wrap == 0 && (long)s->strstart != s->block_start))
return Z_STREAM_ERROR;
/* when using zlib wrappers, compute Adler-32 for provided dictionary */
@@ -695,7 +695,20 @@ int ZEXPORT deflateResetKeep(z_streamp strm) {
adler32(0L, Z_NULL, 0);
s->last_flush = -2;
- _tr_init(s);
+ s->gzhead = Z_NULL;
+
+ {
+ /* Retain the hash work done for level 0. */
+ uInt matches = s->level == 0 ? s->matches : 0;
+ _tr_init(s);
+ s->matches = matches;
+ }
+
+ /* Keep the window and the hash, but drop what was left unfinished */
+ s->block_start = (long)s->strstart;
+ s->lookahead = 0;
+ s->match_length = s->prev_length = MIN_MATCH-1;
+ s->match_available = 0;
return Z_OK;
}
@@ -707,6 +720,7 @@ local void lm_init(deflate_state *s) {
s->window_size = (ulg)2L*s->w_size;
CLEAR_HASH(s);
+ s->matches = 0; /* the hash is clear */
/* Set the default configuration parameters:
*/
@@ -769,18 +783,23 @@ int ZEXPORT deflateUsed(z_streamp strm, int *bits) {
int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) {
deflate_state *s;
int put;
+ int need;
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
s = strm->state;
-#ifdef LIT_MEM
- if (bits < 0 || bits > 16 ||
- (uchf *)s->d_buf < s->pending_out + ((Buf_size + 7) >> 3))
+ if (bits < 0 || bits > 16)
return Z_BUF_ERROR;
-#else
- if (bits < 0 || bits > 16 ||
- s->sym_buf < s->pending_out + ((Buf_size + 7) >> 3))
+ if (s->pending_out != s->pending_buf) {
+ /* move partially flushed pending output to buffer start */
+ Bytef *to = s->pending_buf, *from = s->pending_out;
+ ulg n = s->pending;
+ while (n--)
+ *to++ = *from++;
+ s->pending_out = s->pending_buf;
+ }
+ need = (s->bi_valid + bits) >> 3;
+ if (s->pending_buf_size - s->pending < (ulg)need)
return Z_BUF_ERROR;
-#endif
do {
put = Buf_size - s->bi_valid;
if (put > bits)
@@ -1340,39 +1359,49 @@ int ZEXPORT deflateEnd(z_streamp strm) {
*/
int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
#ifdef MAXSEG_64K
- (void)dest;
(void)source;
+ if (dest != Z_NULL)
+ dest->state = Z_NULL;
return Z_STREAM_ERROR;
#else
deflate_state *ds;
deflate_state *ss;
-
- if (deflateStateCheck(source) || dest == Z_NULL) {
+ if (dest == Z_NULL)
+ return Z_STREAM_ERROR;
+ if (deflateStateCheck(source)) {
+ dest->state = Z_NULL;
return Z_STREAM_ERROR;
}
ss = source->state;
- zmemcpy(dest, source, sizeof(z_stream));
-
- ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
- if (ds == Z_NULL) return Z_MEM_ERROR;
- zmemzero(ds, sizeof(deflate_state));
- dest->state = (struct internal_state FAR *) ds;
+ ds = (deflate_state *) ZALLOC(source, 1, sizeof(deflate_state));
+ if (ds == Z_NULL) {
+ dest->state = Z_NULL;
+ return Z_MEM_ERROR;
+ }
zmemcpy(ds, ss, sizeof(deflate_state));
- ds->strm = dest;
-
- ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
- ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
- ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
- ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, LIT_BUFS);
-
+ ds->window = (Bytef *) ZALLOC(source, ds->w_size, 2*sizeof(Byte));
+ ds->prev = (Posf *) ZALLOC(source, ds->w_size, sizeof(Pos));
+ ds->head = (Posf *) ZALLOC(source, ds->hash_size, sizeof(Pos));
+ ds->pending_buf = (uchf *) ZALLOC(source, ds->lit_bufsize, LIT_BUFS);
if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
ds->pending_buf == Z_NULL) {
- deflateEnd (dest);
+ TRY_FREE(source, ds->pending_buf);
+ TRY_FREE(source, ds->head);
+ TRY_FREE(source, ds->prev);
+ TRY_FREE(source, ds->window);
+ ZFREE(source, ds);
+ dest->state = Z_NULL;
return Z_MEM_ERROR;
}
+
+ /* copy the stream and attach the new state */
+ zmemcpy(dest, source, sizeof(z_stream));
+ dest->state = (struct internal_state FAR *) ds;
+ ds->strm = dest;
+
/* following zmemcpy's do not work for 16-bit MSDOS */
zmemcpy(ds->window, ss->window, ss->high_water);
zmemcpy(ds->prev, ss->prev,
@@ -1665,7 +1694,10 @@ local void check_match(deflate_state *s, IPos start, IPos match, int length) {
/* Same but force premature exit if necessary. */
#define FLUSH_BLOCK(s, last) { \
FLUSH_BLOCK_ONLY(s, last); \
- if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
+ if (s->strm->avail_out == 0) { \
+ if (!(last)) return need_more; \
+ if (s->pending != 0 || s->wrap != 0) return finish_started; \
+ } \
}
/* Maximum stored block length in deflate format (not including header). */
@@ -1700,7 +1732,7 @@ local block_state deflate_stored(deflate_state *s, int flush) {
* possible. If flushing, copy the remaining available input to next_out as
* stored blocks, if there is enough space.
*/
- int last = 0;
+ int last = 0, all;
unsigned len, left, have;
unsigned used = s->strm->avail_in;
do {
@@ -1715,11 +1747,14 @@ local block_state deflate_stored(deflate_state *s, int flush) {
/* maximum stored block length that will fit in avail_out: */
have = s->strm->avail_out - have;
left = (unsigned)(s->strstart - s->block_start); /* window bytes */
- if (len > (ulg)left + s->strm->avail_in)
+ if (left < len && s->strm->avail_in < len - left)
len = left + s->strm->avail_in; /* limit len to the input */
if (len > have)
len = have; /* limit len to the output */
+ /* all is true if len is all of the available input */
+ all = len >= left && len - left == s->strm->avail_in;
+
/* If the stored block would be less than min_block in length, or if
* unable to copy all of the available input when flushing, then try
* copying to the window and the pending buffer instead. Also don't
@@ -1727,13 +1762,13 @@ local block_state deflate_stored(deflate_state *s, int flush) {
*/
if (len < min_block && ((len == 0 && flush != Z_FINISH) ||
flush == Z_NO_FLUSH ||
- len != left + s->strm->avail_in))
+ !all))
break;
/* Make a dummy stored block in pending to get the header bytes,
* including any pending bits. This also updates the debugging counts.
*/
- last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0;
+ last = flush == Z_FINISH && all ? 1 : 0;
_tr_stored_block(s, (char *)0, 0L, last);
/* Replace the lengths in the dummy stored block with len. */
@@ -2038,7 +2073,8 @@ local block_state deflate_slow(deflate_state *s, int flush) {
uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
/* Do not insert strings in hash table beyond this. */
- check_match(s, s->strstart - 1, s->prev_match, (int)s->prev_length);
+ check_match(s, s->strstart - 1, s->prev_match,
+ (int)s->prev_length);
_tr_tally_dist(s, s->strstart - 1 - s->prev_match,
s->prev_length - MIN_MATCH, bflush);
diff --git a/src/java.base/share/native/libzip/zlib/gzguts.h b/src/java.base/share/native/libzip/zlib/gzguts.h
index 0be646016ed8..70ca11af0bc3 100644
--- a/src/java.base/share/native/libzip/zlib/gzguts.h
+++ b/src/java.base/share/native/libzip/zlib/gzguts.h
@@ -116,8 +116,10 @@
# define vsnprintf _vsnprintf
# endif
# endif
-# elif !defined(__STDC_VERSION__) || __STDC_VERSION__-0 < 199901L
-/* Otherwise if C89/90, assume no C99 snprintf() or vsnprintf() */
+# elif (!defined(__STDC_VERSION__) || __STDC_VERSION__-0 < 199901L) && \
+ (!defined(__cplusplus) || __cplusplus < 201103L)
+/* Otherwise if C89/90 (and not C++11 or later), assume no C99 snprintf() or
+ vsnprintf() */
# ifndef NO_snprintf
# define NO_snprintf
# endif
@@ -152,14 +154,28 @@
# include
# define zstrerror() gz_strwinerror((DWORD)GetLastError())
#else
+# include
# ifndef NO_STRERROR
-# include
# define zstrerror() strerror(errno)
# else
# define zstrerror() "stdio error (consult errno)"
# endif
#endif
+#ifdef EAGAIN
+# ifdef EWOULDBLOCK
+# define BLOCKED(e) ((e) == EAGAIN || (e) == EWOULDBLOCK)
+# else
+# define BLOCKED(e) ((e) == EAGAIN)
+# endif
+#else
+# ifdef EWOULDBLOCK
+# define BLOCKED(e) ((e) == EWOULDBLOCK)
+# else
+# define BLOCKED(e) (0)
+# endif
+#endif
+
/* provide prototypes for these when building zlib without LFS */
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
@@ -238,3 +254,10 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error);
(possible z_off64_t types off_t, off64_t, and long are all signed) */
unsigned ZLIB_INTERNAL gz_intmax(void);
#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
+
+/* largest value representable in z_off64_t */
+#ifndef CHAR_BIT
+# define CHAR_BIT 8
+#endif
+#define GZ_OFF_MAX \
+ ((((z_off64_t)1 << (sizeof(z_off64_t) * CHAR_BIT - 2)) - 1) * 2 + 1)
diff --git a/src/java.base/share/native/libzip/zlib/gzlib.c b/src/java.base/share/native/libzip/zlib/gzlib.c
index 9489bcc1f12e..c62db8580075 100644
--- a/src/java.base/share/native/libzip/zlib/gzlib.c
+++ b/src/java.base/share/native/libzip/zlib/gzlib.c
@@ -92,9 +92,9 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
/* Reset gzip file state */
local void gz_reset(gz_statep state) {
state->x.have = 0; /* no output data available */
+ state->past = 0; /* have not read past end yet */
if (state->mode == GZ_READ) { /* for reading ... */
state->eof = 0; /* not at end of file */
- state->past = 0; /* have not read past end yet */
state->how = LOOK; /* look for gzip header */
state->junk = -1; /* mark first member */
}
@@ -112,9 +112,7 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
gz_statep state;
z_size_t len;
int oflag = 0;
-#ifdef O_EXCL
int exclusive = 0;
-#endif
/* check input */
if (path == NULL || mode == NULL)
@@ -160,11 +158,9 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
oflag |= O_CLOEXEC;
break;
#endif
-#ifdef O_EXCL
case 'x':
exclusive = 1;
break;
-#endif
case 'f':
state->strategy = Z_FILTERED;
break;
@@ -220,10 +216,21 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
/* if reading, direct == 1 for auto-detect, -1 for gzip only; if writing or
appending, direct == 0 for gzip, 1 for transparent (copy in to out) */
+#ifndef O_EXCL
+ if (exclusive && state->mode != GZ_READ && fd < 0) {
+ /* exclusive creation request can't be honored -- fail out */
+ free(state);
+ return NULL;
+ }
+#endif
+
/* save the path name for error messages */
#ifdef WIDECHAR
- if (fd == -2)
+ if (fd == -2) {
len = wcstombs(NULL, path, 0);
+ if (len == (z_size_t)-1)
+ len = 0; /* not representable in the current locale */
+ }
else
#endif
len = strlen((const char *)path);
@@ -234,9 +241,7 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
}
#ifdef WIDECHAR
if (fd == -2) {
- if (len)
- wcstombs(state->path, path, len + 1);
- else
+ if (len == 0 || wcstombs(state->path, path, len + 1) != len)
*(state->path) = 0;
}
else
@@ -245,7 +250,7 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
(void)snprintf(state->path, len + 1, "%s", (const char *)path);
#else
- strcpy(state->path, path);
+ strcpy(state->path, (const char *)path);
#endif
}
@@ -279,9 +284,9 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
if (oflag & O_NONBLOCK)
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
#endif
-#ifdef O_CLOEXEC
+#if defined(O_CLOEXEC) && defined(FD_CLOEXEC)
if (oflag & O_CLOEXEC)
- fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | O_CLOEXEC);
+ fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
#endif
state->fd = fd;
}
@@ -323,7 +328,7 @@ gzFile ZEXPORT gzdopen(int fd, const char *mode) {
char *path; /* identifier for error messages */
gzFile gz;
- if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL)
+ if (fd < 0 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL)
return NULL;
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
(void)snprintf(path, 7 + 3 * sizeof(int), "", fd);
@@ -390,7 +395,7 @@ int ZEXPORT gzrewind(gzFile file) {
/* -- see zlib.h -- */
z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
unsigned n;
- z_off64_t ret;
+ z_off64_t ret, pos;
gz_statep state;
/* get internal structure and check integrity */
@@ -408,18 +413,19 @@ z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
if (whence != SEEK_SET && whence != SEEK_CUR)
return -1;
- /* normalize offset to a SEEK_CUR specification */
- if (whence == SEEK_SET)
- offset -= state->x.pos;
- else {
- offset += state->past ? 0 : state->skip;
- state->skip = 0;
- }
+ /* compute the absolute position */
+ pos = whence == SEEK_SET ? 0 :
+ state->x.pos + (state->past ? 0 : state->skip);
+ if (offset > GZ_OFF_MAX - pos)
+ return -1; /* would overflow z_off64_t */
+ if (offset < -pos)
+ return -1; /* before start of file */
+ pos += offset;
/* if within raw area while reading, just go there */
- if (state->mode == GZ_READ && state->how == COPY &&
- state->x.pos + offset >= 0) {
- ret = LSEEK(state->fd, offset - (z_off64_t)state->x.have, SEEK_CUR);
+ if (state->mode == GZ_READ && state->how == COPY) {
+ ret = LSEEK(state->fd, pos - state->x.pos - (z_off64_t)state->x.have,
+ SEEK_CUR);
if (ret == -1)
return -1;
state->x.have = 0;
@@ -428,20 +434,18 @@ z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
state->skip = 0;
gz_error(state, Z_OK, NULL);
state->strm.avail_in = 0;
- state->x.pos += offset;
- return state->x.pos;
+ state->x.pos = pos;
+ return pos;
}
- /* calculate skip amount, rewinding if needed for back seek when reading */
- if (offset < 0) {
+ /* rewind if needed for back seek when reading */
+ if (pos < state->x.pos) {
if (state->mode != GZ_READ) /* writing -- can't go backwards */
return -1;
- offset += state->x.pos;
- if (offset < 0) /* before start of file! */
- return -1;
- if (gzrewind(file) == -1) /* rewind, then skip to offset */
+ if (gzrewind(file) == -1) /* rewind, then skip to pos */
return -1;
}
+ offset = pos - state->x.pos;
/* if reading, skip what's in output buffer (one less gzgetc() check) */
if (state->mode == GZ_READ) {
@@ -455,7 +459,7 @@ z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
/* request skip (if not zero) */
state->skip = offset;
- return state->x.pos + offset;
+ return pos;
}
/* -- see zlib.h -- */
@@ -584,10 +588,6 @@ void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
state->msg = NULL;
}
- /* if fatal, set state->x.have to 0 so that the gzgetc() macro fails */
- if (err != Z_OK && err != Z_BUF_ERROR && !state->again)
- state->x.have = 0;
-
/* set error code, and if no message, then done */
state->err = err;
if (msg == NULL)
diff --git a/src/java.base/share/native/libzip/zlib/gzread.c b/src/java.base/share/native/libzip/zlib/gzread.c
index 89144d2e56fe..ce7da3d0c999 100644
--- a/src/java.base/share/native/libzip/zlib/gzread.c
+++ b/src/java.base/share/native/libzip/zlib/gzread.c
@@ -57,7 +57,7 @@ local int gz_load(gz_statep state, unsigned char *buf, unsigned len,
*have += (unsigned)ret;
} while (*have < len);
if (ret < 0) {
- if (errno == EAGAIN || errno == EWOULDBLOCK) {
+ if (BLOCKED(errno)) {
state->again = 1;
if (*have != 0)
return 0;
@@ -149,6 +149,13 @@ local int gz_look(gz_statep state) {
if we're looking for a gzip member after the first one, which is not at
the start, then proceed directly to look for a gzip member next */
if (state->direct == -1 || state->junk == 0) {
+ /* wait for input before committing to another gzip member */
+ if (state->junk == 0 && strm->avail_in == 0) {
+ if (gz_avail(state) == -1)
+ return -1;
+ if (strm->avail_in == 0)
+ return 0;
+ }
inflateReset(strm);
state->how = GZIP;
state->junk = state->junk != -1;
@@ -177,7 +184,7 @@ local int gz_look(gz_statep state) {
strm->next_in[2] == 8 && strm->next_in[3] < 32) {
inflateReset(strm);
state->how = GZIP;
- state->junk = 1;
+ state->junk = 0;
state->direct = 0;
return 0;
}
@@ -272,6 +279,11 @@ local int gz_decomp(gz_statep state) {
local int gz_fetch(gz_statep state) {
z_streamp strm = &(state->strm);
+ /* after a serious error, only what is already in the output buffer is
+ delivered -- don't try to decompress any more */
+ if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
+ return -1;
+
do {
switch(state->how) {
case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */
@@ -300,32 +312,46 @@ local int gz_fetch(gz_statep state) {
return 0;
}
+/* Apply as much of a pending skip request as the output already available in
+ state->x allows. */
+local void gz_skip_have(gz_statep state) {
+ unsigned n;
+
+ n = GT_OFF(state->x.have) ||
+ (z_off64_t)state->x.have > state->skip ?
+ (unsigned)state->skip : state->x.have;
+ state->x.have -= n;
+ state->x.next += n;
+ state->x.pos += n;
+ state->skip -= n;
+}
+
/* Skip state->skip (> 0) uncompressed bytes of output. Return -1 on error, 0
on success. */
local int gz_skip(gz_statep state) {
- unsigned n;
-
/* skip over len bytes or reach end-of-file, whichever comes first */
do {
/* skip over whatever is in output buffer */
- if (state->x.have) {
- n = GT_OFF(state->x.have) ||
- (z_off64_t)state->x.have > state->skip ?
- (unsigned)state->skip : state->x.have;
- state->x.have -= n;
- state->x.next += n;
- state->x.pos += n;
- state->skip -= n;
- }
+ if (state->x.have)
+ gz_skip_have(state);
/* output buffer empty -- return if we're at the end of the input */
- else if (state->eof && state->strm.avail_in == 0)
+ else if (state->eof && state->strm.avail_in == 0) {
+ if (state->how == GZIP && state->err == Z_OK)
+ gz_error(state, Z_BUF_ERROR, "unexpected end of file");
+ state->skip = 0;
+ state->past = 1;
break;
+ }
/* need more data to skip -- load up output buffer */
else {
- /* get more output, looking for header if required */
- if (gz_fetch(state) == -1)
+ /* get more output, looking for header if required. If the fetch
+ stalled but provided some output, consume it before returning
+ so that x.have > 0 always implies the data is at the current
+ logical position (x.pos), as assumed by the gzgetc() fast path
+ in zlib.h and gzread.c */
+ if (gz_fetch(state) == -1 && state->x.have == 0)
return -1;
}
} while (state->skip);
@@ -373,8 +399,11 @@ local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) {
}
/* output buffer empty -- return if we're at the end of the input */
- else if (state->eof && state->strm.avail_in == 0)
+ else if (state->eof && state->strm.avail_in == 0) {
+ if (state->how == GZIP && state->err == Z_OK)
+ gz_error(state, Z_BUF_ERROR, "unexpected end of file");
break;
+ }
/* need output data -- for small len or new stream load up our output
buffer, so that gzgetc() can be fast */
@@ -427,15 +456,21 @@ int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) {
if (state->mode != GZ_READ)
return -1;
- /* check that there was no (serious) error */
- if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
+ /* check that there was no (serious) error -- if there was, deliver any
+ data read before the error until it is exhausted, and only then return
+ the error */
+ if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again &&
+ state->x.have == 0)
return -1;
- gz_error(state, Z_OK, NULL);
+ if (state->again)
+ gz_error(state, Z_OK, NULL);
/* since an int is returned, make sure len fits in one, otherwise return
- with an error (this avoids a flaw in the interface) */
+ with an error (this avoids a flaw in the interface) -- keep a pending
+ serious error, which is the one the caller needs to see */
if ((int)len < 0) {
- gz_error(state, Z_STREAM_ERROR, "request does not fit in an int");
+ if (state->err == Z_OK || state->err == Z_BUF_ERROR)
+ gz_error(state, Z_STREAM_ERROR, "request does not fit in an int");
return -1;
}
@@ -472,15 +507,22 @@ z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems,
if (state->mode != GZ_READ)
return 0;
- /* check that there was no (serious) error */
- if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
+ /* check that there was no (serious) error -- if there was, deliver any
+ data read before the error until it is exhausted, and only then return
+ the error */
+ if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again &&
+ state->x.have == 0)
return 0;
- gz_error(state, Z_OK, NULL);
+ if (state->again)
+ gz_error(state, Z_OK, NULL);
- /* compute bytes to read -- error on overflow */
+ /* compute bytes to read -- error on overflow, keeping a pending serious
+ error, which is the one the caller needs to see */
len = nitems * size;
if (size && len / size != nitems) {
- gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
+ if (state->err == Z_OK || state->err == Z_BUF_ERROR)
+ gz_error(state, Z_STREAM_ERROR,
+ "request does not fit in a size_t");
return 0;
}
@@ -505,10 +547,14 @@ int ZEXPORT gzgetc(gzFile file) {
if (state->mode != GZ_READ)
return -1;
- /* check that there was no (serious) error */
- if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
+ /* check that there was no (serious) error -- if there was, deliver any
+ data read before the error until it is exhausted, and only then return
+ the error, as the gzgetc() macro does */
+ if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again &&
+ state->x.have == 0)
return -1;
- gz_error(state, Z_OK, NULL);
+ if (state->again)
+ gz_error(state, Z_OK, NULL);
/* try output buffer (no need to check for skip request) */
if (state->x.have) {
@@ -540,10 +586,15 @@ int ZEXPORT gzungetc(int c, gzFile file) {
if (state->how == LOOK && state->x.have == 0)
(void)gz_look(state);
- /* check that there was no (serious) error */
- if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
+ /* check that there was no (serious) error -- a character can still be
+ pushed back after one, since it is data that was read before the
+ error, and it will be returned before the error is signaled -- but only
+ if there is an output buffer to put it in */
+ if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again &&
+ state->size == 0)
return -1;
- gz_error(state, Z_OK, NULL);
+ if (state->again)
+ gz_error(state, Z_OK, NULL);
/* process a skip request */
if (state->skip && gz_skip(state) == -1)
@@ -565,7 +616,8 @@ int ZEXPORT gzungetc(int c, gzFile file) {
/* if no room, give up (must have already done a gzungetc()) */
if (state->x.have == (state->size << 1)) {
- gz_error(state, Z_DATA_ERROR, "out of room to push characters");
+ if (state->err == Z_OK || state->err == Z_BUF_ERROR)
+ gz_error(state, Z_DATA_ERROR, "out of room to push characters");
return -1;
}
@@ -601,10 +653,14 @@ char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
if (state->mode != GZ_READ)
return NULL;
- /* check that there was no (serious) error */
- if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
+ /* check that there was no (serious) error -- if there was, deliver any
+ data read before the error until it is exhausted, and only then return
+ the error */
+ if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again &&
+ state->x.have == 0)
return NULL;
- gz_error(state, Z_OK, NULL);
+ if (state->again)
+ gz_error(state, Z_OK, NULL);
/* process a skip request */
if (state->skip && gz_skip(state) == -1)
@@ -616,8 +672,9 @@ char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
left = (unsigned)len - 1;
if (left) do {
/* assure that something is in the output buffer */
- if (state->x.have == 0 && gz_fetch(state) == -1)
- break; /* error */
+ if (state->x.have == 0 && gz_fetch(state) == -1 &&
+ state->x.have == 0)
+ break; /* error, and nothing left to return */
if (state->x.have == 0) { /* end of file */
state->past = 1; /* read past end */
break; /* return what we have */
@@ -641,7 +698,7 @@ char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
/* append a terminating zero to the string (we don't check for a zero in
the contents, let the user worry about that) -- return the terminated
string, or if nothing was read, NULL */
- if (buf == str)
+ if (buf == str && len > 1)
return NULL;
buf[0] = 0;
return str;
@@ -658,8 +715,10 @@ int ZEXPORT gzdirect(gzFile file) {
/* if the state is not known, but we can find out, then do so (this is
mainly for right after a gzopen() or gzdopen()) */
- if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
+ if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0) {
(void)gz_look(state);
+ gz_skip_have(state); /* apply skip to current buffer */
+ }
/* return 1 if transparent, 0 if processing a gzip stream */
return state->direct == 1;
diff --git a/src/java.base/share/native/libzip/zlib/gzwrite.c b/src/java.base/share/native/libzip/zlib/gzwrite.c
index b11c318d5432..cf933bef87b8 100644
--- a/src/java.base/share/native/libzip/zlib/gzwrite.c
+++ b/src/java.base/share/native/libzip/zlib/gzwrite.c
@@ -65,8 +65,8 @@ local int gz_init(gz_statep state) {
gz_error(state, Z_MEM_ERROR, "out of memory");
return -1;
}
- strm->next_in = NULL;
}
+ strm->next_in = NULL;
/* mark state as initialized */
state->size = state->want;
@@ -103,7 +103,7 @@ local int gz_comp(gz_statep state, int flush) {
put = strm->avail_in > max ? max : strm->avail_in;
writ = (int)write(state->fd, strm->next_in, put);
if (writ < 0) {
- if (errno == EAGAIN || errno == EWOULDBLOCK)
+ if (BLOCKED(errno))
state->again = 1;
gz_error(state, Z_ERRNO, zstrerror());
return -1;
@@ -138,7 +138,7 @@ local int gz_comp(gz_statep state, int flush) {
(unsigned)(strm->next_out - state->x.next);
writ = (int)write(state->fd, state->x.next, put);
if (writ < 0) {
- if (errno == EAGAIN || errno == EWOULDBLOCK)
+ if (BLOCKED(errno))
state->again = 1;
gz_error(state, Z_ERRNO, zstrerror());
return -1;
@@ -180,6 +180,11 @@ local int gz_zero(gz_statep state) {
unsigned n;
z_streamp strm = &(state->strm);
+ /* allocate memory if this is the first time through -- the input buffer
+ must exist before it is zeroed below */
+ if (state->size == 0 && gz_init(state) == -1)
+ return -1;
+
/* consume whatever's left in the input buffer */
if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
return -1;
@@ -199,8 +204,14 @@ local int gz_zero(gz_statep state) {
n -= strm->avail_in;
state->x.pos += n;
state->skip -= n;
- if (ret == -1)
+ if (ret == -1) {
+ /* discard any unconsumed zero fill -- it was not yet accounted
+ for in state->skip, so it will be generated again when the
+ operation is retried */
+ strm->avail_in = 0;
+ strm->next_in = state->in;
return -1;
+ }
} while (state->skip);
return 0;
}
@@ -266,9 +277,13 @@ local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
n -= state->strm.avail_in;
state->x.pos += n;
len -= n;
- if (ret == -1)
+ if (ret == -1) {
+ state->strm.avail_in = 0;
+ state->strm.next_in = state->in;
return state->again ? put - len : 0;
+ }
} while (len);
+ state->strm.next_in = state->in;
}
/* input was all buffered or compressed */
@@ -395,9 +410,10 @@ int ZEXPORT gzputs(gzFile file, const char *s) {
return len && put == 0 ? -1 : (int)put;
}
-#if (((!defined(STDC) && !defined(Z_HAVE_STDARG_H)) || !defined(NO_vsnprintf)) && \
- (defined(STDC) || defined(Z_HAVE_STDARG_H) || !defined(NO_snprintf))) || \
- defined(ZLIB_INSECURE)
+#if (((!defined(STDC) && !defined(Z_HAVE_STDARG_H)) || \
+ !defined(NO_vsnprintf)) && \
+ (defined(STDC) || defined(Z_HAVE_STDARG_H) || \
+ !defined(NO_snprintf))) || defined(ZLIB_INSECURE)
/* If the second half of the input buffer is occupied, write out the contents.
If there is any input remaining due to a non-blocking stall on write, move
it to the start of the buffer. Return true if this did not open up the
@@ -407,7 +423,8 @@ local int gz_vacate(gz_statep state) {
z_streamp strm;
strm = &(state->strm);
- if (strm->next_in + strm->avail_in <= state->in + state->size)
+ if (strm->next_in == NULL ||
+ strm->next_in + strm->avail_in <= state->in + state->size)
return 0;
(void)gz_comp(state, Z_NO_FLUSH);
if (strm->avail_in == 0) {
@@ -467,6 +484,7 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
a Z_BUF_ERROR to let the application know that this gzprintf()
needs to be retried. */
gz_error(state, Z_BUF_ERROR, "stalled write on gzprintf");
+ return state->err;
}
if (!state->again)
return state->err;
@@ -502,6 +520,14 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
/* write out buffer if more than half is occupied */
ret = gz_vacate(state);
+ if (ret) {
+ /* discard unwritten formatted output */
+ strm->avail_in -= (unsigned)len;
+ state->x.pos -= len;
+ if (state->again)
+ gz_error(state, Z_BUF_ERROR, "stalled write on gzprintf");
+ return state->err;
+ }
if (state->err && !state->again)
return state->err;
return len;
@@ -575,6 +601,7 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3,
a Z_BUF_ERROR to let the application know that this gzprintf()
needs to be retried. */
gz_error(state, Z_BUF_ERROR, "stalled write on gzprintf");
+ return state->err;
}
if (!state->again)
return state->err;
@@ -615,6 +642,14 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3,
/* write out buffer if more than half is occupied */
ret = gz_vacate(state);
+ if (ret) {
+ /* discard unwritten formatted output */
+ strm->avail_in -= (unsigned)len;
+ state->x.pos -= len;
+ if (state->again)
+ gz_error(state, Z_BUF_ERROR, "stalled write on gzprintf");
+ return state->err;
+ }
if (state->err && !state->again)
return state->err;
return (int)len;
diff --git a/src/java.base/share/native/libzip/zlib/infback.c b/src/java.base/share/native/libzip/zlib/infback.c
index 0becbb9eb4f6..c2286bd20699 100644
--- a/src/java.base/share/native/libzip/zlib/infback.c
+++ b/src/java.base/share/native/libzip/zlib/infback.c
@@ -447,8 +447,6 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
/* use inflate_fast() if we have enough input and output */
if (have >= 6 && left >= 258) {
RESTORE();
- if (state->whave < state->wsize)
- state->whave = state->wsize - left;
inflate_fast(strm, state->wsize);
LOAD();
break;
diff --git a/src/java.base/share/native/libzip/zlib/inflate.c b/src/java.base/share/native/libzip/zlib/inflate.c
index c548f98f6de3..16bc832948e3 100644
--- a/src/java.base/share/native/libzip/zlib/inflate.c
+++ b/src/java.base/share/native/libzip/zlib/inflate.c
@@ -151,6 +151,14 @@ int ZEXPORT inflateReset(z_streamp strm) {
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
+ if (state->wbits != state->reqbits) {
+ if (state->window != Z_NULL) {
+ ZFREE(strm, state->window);
+ state->window = Z_NULL;
+ }
+ state->wbits = state->reqbits;
+ }
+ state->wrap = state->reqwrap;
state->wsize = 0;
state->whave = 0;
state->wnext = 0;
@@ -189,8 +197,8 @@ int ZEXPORT inflateReset2(z_streamp strm, int windowBits) {
}
/* update state and reset the rest of it */
- state->wrap = wrap;
- state->wbits = (unsigned)windowBits;
+ state->reqwrap = state->wrap = wrap;
+ state->reqbits = state->wbits = (unsigned)windowBits;
return inflateReset(strm);
}
@@ -561,13 +569,13 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
}
DROPBITS(4);
len = BITS(4) + 8;
- if (state->wbits == 0)
- state->wbits = len;
- if (len > 15 || len > state->wbits) {
+ if (len > 15 || (state->wbits != 0 && len > state->wbits)) {
strm->msg = (z_const char *)"invalid window size";
state->mode = BAD;
break;
}
+ if (state->wbits == 0)
+ state->wbits = len;
state->dmax = 1U << len;
state->flags = 0; /* indicate zlib header */
Tracev((stderr, "inflate: zlib header ok\n"));
@@ -724,6 +732,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
case DICT:
if (state->havedict == 0) {
RESTORE();
+ strm->total_in += in - strm->avail_in;
return Z_NEED_DICT;
}
strm->adler = state->check = adler32(0L, Z_NULL, 0);
@@ -936,7 +945,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
state->mode = LEN;
/* fallthrough */
case LEN:
- if (have >= 6 && left >= 258) {
+ if (have >= 6 && left >= 258 && bits < 8) {
RESTORE();
inflate_fast(strm, out);
LOAD();
@@ -1215,7 +1224,8 @@ int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary,
int ret;
/* check state */
- if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm) || dictionary == Z_NULL)
+ return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
if (state->wrap != 0 && state->mode != DICT)
return Z_STREAM_ERROR;
@@ -1320,15 +1330,23 @@ int ZEXPORT inflateSync(z_streamp strm) {
/* return no joy or set up to restart inflate() on a new block */
if (state->have != 4) return Z_DATA_ERROR;
- if (state->flags == -1)
- state->wrap = 0; /* if no header yet, treat as raw */
- else
- state->wrap &= ~4; /* no point in computing a check value now */
flags = state->flags;
in = strm->total_in; out = strm->total_out;
inflateReset(strm);
strm->total_in = in; strm->total_out = out;
state->flags = flags;
+ if (flags == -1)
+ state->wrap = 0; /* if no header yet, treat as raw */
+ else
+ state->wrap &= ~4; /* no point in computing a check value now */
+ if (state->wbits == 0) {
+ /* we never got to see a header for the window size -- set to max */
+ if (state->window != Z_NULL) {
+ ZFREE(strm, state->window);
+ state->window = Z_NULL;
+ }
+ state->wbits = 15;
+ }
state->mode = TYPE;
return Z_OK;
}
@@ -1355,14 +1373,21 @@ int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
unsigned char FAR *window;
/* check input */
- if (inflateStateCheck(source) || dest == Z_NULL)
+ if (dest == Z_NULL)
return Z_STREAM_ERROR;
+ if (inflateStateCheck(source)) {
+ dest->state = Z_NULL;
+ return Z_STREAM_ERROR;
+ }
state = (struct inflate_state FAR *)source->state;
/* allocate space */
copy = (struct inflate_state FAR *)
ZALLOC(source, 1, sizeof(struct inflate_state));
- if (copy == Z_NULL) return Z_MEM_ERROR;
+ if (copy == Z_NULL) {
+ dest->state = Z_NULL;
+ return Z_MEM_ERROR;
+ }
zmemzero(copy, sizeof(struct inflate_state));
window = Z_NULL;
if (state->window != Z_NULL) {
@@ -1370,6 +1395,7 @@ int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
if (window == Z_NULL) {
ZFREE(source, copy);
+ dest->state = Z_NULL;
return Z_MEM_ERROR;
}
}
@@ -1415,6 +1441,10 @@ int ZEXPORT inflateValidate(z_streamp strm, int check) {
state->wrap |= 4;
else
state->wrap &= ~4;
+ if (check && state->reqwrap)
+ state->reqwrap |= 4;
+ else
+ state->reqwrap &= ~4;
return Z_OK;
}
diff --git a/src/java.base/share/native/libzip/zlib/inflate.h b/src/java.base/share/native/libzip/zlib/inflate.h
index 7828fb5db38e..1f2783e58cf8 100644
--- a/src/java.base/share/native/libzip/zlib/inflate.h
+++ b/src/java.base/share/native/libzip/zlib/inflate.h
@@ -109,6 +109,7 @@ struct inflate_state {
int last; /* true if processing last block */
int wrap; /* bit 0 true for zlib, bit 1 true for gzip,
bit 2 true to validate check value */
+ int reqwrap; /* requested wrap */
int havedict; /* true if dictionary provided */
int flags; /* gzip header method and flags, 0 if zlib, or
-1 if raw or no header yet */
@@ -117,7 +118,8 @@ struct inflate_state {
unsigned long total; /* protected copy of output count */
gz_headerp head; /* where to save gzip header information */
/* sliding window */
- unsigned wbits; /* log base 2 of requested window size */
+ unsigned reqbits; /* requested log base 2 of window size */
+ unsigned wbits; /* current log base 2 of window size */
unsigned wsize; /* window size or zero if not using window */
unsigned whave; /* valid bytes in the window */
unsigned wnext; /* window write index */
diff --git a/src/java.base/share/native/libzip/zlib/inftrees.c b/src/java.base/share/native/libzip/zlib/inftrees.c
index 5f5d6b4baef2..7486efef8ee9 100644
--- a/src/java.base/share/native/libzip/zlib/inftrees.c
+++ b/src/java.base/share/native/libzip/zlib/inftrees.c
@@ -47,7 +47,7 @@
#define MAXBITS 15
const char inflate_copyright[] =
- " inflate 1.3.2 Copyright 1995-2026 Mark Adler ";
+ " inflate 1.4 Copyright 1995-2026 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -95,7 +95,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
- 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 75};
+ 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 71, 77};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
diff --git a/src/java.base/share/native/libzip/zlib/inftrees.h b/src/java.base/share/native/libzip/zlib/inftrees.h
index b9b4fc2fb2bc..51f67b68c65b 100644
--- a/src/java.base/share/native/libzip/zlib/inftrees.h
+++ b/src/java.base/share/native/libzip/zlib/inftrees.h
@@ -70,8 +70,14 @@ typedef struct {
inflate_table() calls in inflate.c and infback.c. If the root table size is
changed, then these maximum sizes would be need to be recalculated and
updated. */
-#define ENOUGH_LENS 852
-#define ENOUGH_DISTS 592
+#ifndef PKZIP_BUG_WORKAROUND
+# define ENOUGH_LENS 852
+# define ENOUGH_DISTS 592
+#else
+/* That workaround permits 288 literal/length codes and 32 distance codes. */
+# define ENOUGH_LENS 854
+# define ENOUGH_DISTS 594
+#endif
#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
/* Type of code to build for inflate_table() */
diff --git a/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java b/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java
index dfde58f0122d..46affe2cd5e2 100644
--- a/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java
+++ b/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java
@@ -1,6 +1,6 @@
-Changes in JDK's in-tree zlib compared to upstream zlib 1.3.2
+Changes in JDK's in-tree zlib compared to upstream zlib 1.4
-(1) renamed adler32.c -> zadler32.c, crc32c -> zcrc32.c
+(1) renamed adler32.c -> zadler32.c, crc32.c -> zcrc32.c
diff --git a/src/java.base/share/native/libzip/zlib/trees.c b/src/java.base/share/native/libzip/zlib/trees.c
index cc7b136bcf68..bf5c1b24149e 100644
--- a/src/java.base/share/native/libzip/zlib/trees.c
+++ b/src/java.base/share/native/libzip/zlib/trees.c
@@ -251,7 +251,7 @@ local void gen_codes(ct_data *tree, int max_code, ushf *bl_count) {
tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
- n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1));
+ n, (isgraph(n & 0xff) ? n : ' '), len, tree[n].Code, next_code[len] - 1));
}
}
diff --git a/src/java.base/share/native/libzip/zlib/uncompr.c b/src/java.base/share/native/libzip/zlib/uncompr.c
index 25da59461c37..d55a4f2d66ca 100644
--- a/src/java.base/share/native/libzip/zlib/uncompr.c
+++ b/src/java.base/share/native/libzip/zlib/uncompr.c
@@ -57,8 +57,8 @@ int ZEXPORT uncompress2_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
const uInt max = (uInt)-1;
z_size_t len, left;
- if (sourceLen == NULL || (*sourceLen > 0 && source == NULL) ||
- destLen == NULL || (*destLen > 0 && dest == NULL))
+ if (sourceLen == Z_NULL || (*sourceLen > 0 && source == Z_NULL) ||
+ destLen == Z_NULL || (*destLen > 0 && dest == Z_NULL))
return Z_STREAM_ERROR;
len = *sourceLen;
diff --git a/src/java.base/share/native/libzip/zlib/zconf.h b/src/java.base/share/native/libzip/zlib/zconf.h
index d4589739a0ae..542e462ac177 100644
--- a/src/java.base/share/native/libzip/zlib/zconf.h
+++ b/src/java.base/share/native/libzip/zlib/zconf.h
@@ -523,6 +523,10 @@ typedef uLong FAR uLongf;
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
# define Z_LFS64
+#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) && \
+ !defined(UNDER_CE) && (defined(__MINGW32__) || !defined(__GNUC__))
+# define Z_LFS64 /* native Windows has 64-bit file offsets */
+# define Z_WINLFS
#endif
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
@@ -540,7 +544,7 @@ typedef uLong FAR uLongf;
#endif
#ifndef z_off_t
-# define z_off_t long long
+# define z_off_t long
#endif
#if !defined(_WIN32) && defined(Z_LARGE64)
@@ -555,6 +559,11 @@ typedef uLong FAR uLongf;
# define z_off64_t z_off_t
#endif
+#if defined(Z_WINLFS) && defined(Z_WANT64) && !defined(Z_SOLO)
+# undef z_off_t
+# define z_off_t z_off64_t
+#endif
+
/* MVS linker does not support external names larger than 8 bytes */
#if defined(__MVS__)
#pragma map(deflateInit_,"DEIN")
diff --git a/src/java.base/share/native/libzip/zlib/zcrc32.c b/src/java.base/share/native/libzip/zlib/zcrc32.c
index 133cbe158aa4..0161f1ee20e8 100644
--- a/src/java.base/share/native/libzip/zlib/zcrc32.c
+++ b/src/java.base/share/native/libzip/zlib/zcrc32.c
@@ -710,7 +710,7 @@ uLong ZEXPORT crc32_z(uLong crc, const unsigned char FAR *buf, z_size_t len) {
#endif
/* Initialize the CRC for each braid. */
- crc0 = crc;
+ crc0 = (z_crc_t)crc;
#if N > 1
crc1 = 0;
#if N > 2
diff --git a/src/java.base/share/native/libzip/zlib/zlib.h b/src/java.base/share/native/libzip/zlib/zlib.h
index 90230f4f23fb..15b6b927a10c 100644
--- a/src/java.base/share/native/libzip/zlib/zlib.h
+++ b/src/java.base/share/native/libzip/zlib/zlib.h
@@ -23,7 +23,7 @@
*/
/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.3.2, February 17th, 2026
+ version 1.4, November 4th, 2026
Copyright (C) 1995-2026 Jean-loup Gailly and Mark Adler
@@ -65,11 +65,11 @@
extern "C" {
#endif
-#define ZLIB_VERSION "1.3.2"
-#define ZLIB_VERNUM 0x1320
+#define ZLIB_VERSION "1.4"
+#define ZLIB_VERNUM 0x1400
#define ZLIB_VER_MAJOR 1
-#define ZLIB_VER_MINOR 3
-#define ZLIB_VER_REVISION 2
+#define ZLIB_VER_MINOR 4
+#define ZLIB_VER_REVISION 0
#define ZLIB_VER_SUBREVISION 0
/*
@@ -720,7 +720,9 @@ ZEXTERN int ZEXPORT deflateCopy(z_streamp dest,
deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
(such as zalloc being Z_NULL). msg is left unchanged in both source and
- destination.
+ destination. If deflateCopy fails and dest is not Z_NULL, then dest->state
+ is set to Z_NULL with dest otherwise unchanged, so that deflateEnd(dest) can
+ be called safely, though dest is not a usable stream.
*/
ZEXTERN int ZEXPORT deflateReset(z_streamp strm);
@@ -793,17 +795,17 @@ ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen);
ZEXTERN z_size_t ZEXPORT deflateBound_z(z_streamp strm, z_size_t sourceLen);
/*
deflateBound() returns an upper bound on the compressed size after
- deflation of sourceLen bytes. It must be called after deflateInit() or
- deflateInit2(), and after deflateSetHeader(), if used. This would be used
- to allocate an output buffer for deflation in a single pass, and so would be
- called before deflate(). If that first deflate() call is provided the
- sourceLen input bytes, an output buffer allocated to the size returned by
- deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed
- to return Z_STREAM_END. Note that it is possible for the compressed size to
- be larger than the value returned by deflateBound() if flush options other
- than Z_FINISH or Z_NO_FLUSH are used.
-
- delfateBound_z() is the same, but takes and returns a size_t length. Note
+ deflation of sourceLen bytes. It must be called after deflateInit() or
+ deflateInit2(), and after deflateSetHeader() or deflateSetDictionary(), if
+ used. This would be used to allocate an output buffer for deflation in a
+ single pass, and so would be called before deflate(). If that first
+ deflate() call is provided the sourceLen input bytes, an output buffer
+ allocated to the size returned by deflateBound(), and the flush value
+ Z_FINISH, then deflate() is guaranteed to return Z_STREAM_END. Note that it
+ is possible for the compressed size to be larger than the value returned by
+ deflateBound() if flush options other than Z_FINISH or Z_NO_FLUSH are used.
+
+ deflateBound_z() is the same, but takes and returns a size_t length. Note
that a long is 32 bits on Windows.
*/
@@ -813,7 +815,7 @@ ZEXTERN int ZEXPORT deflatePending(z_streamp strm,
/*
deflatePending() returns the number of bytes and bits of output that have
been generated, but not yet provided in the available output. The bytes not
- provided would be due to the available output space having being consumed.
+ provided would be due to the available output space having been consumed.
The number of bits of output not provided are between 0 and 7, where they
await more bits to join them in order to fill out a full byte. If pending
or bits are Z_NULL, then those values are not set.
@@ -893,8 +895,7 @@ ZEXTERN int ZEXPORT inflateInit2(z_streamp strm,
instead. windowBits must be greater than or equal to the windowBits value
provided to deflateInit2() while compressing, or it must be equal to 15 if
deflateInit2() was not used. If a compressed stream with a larger window
- size is given as input, inflate() will return with the error code
- Z_DATA_ERROR instead of trying to allocate a larger window.
+ size is given as input, inflate() may return with a Z_DATA_ERROR.
windowBits can also be zero to request that inflate use the window size in
the zlib header of the compressed stream.
@@ -1004,7 +1005,9 @@ ZEXTERN int ZEXPORT inflateCopy(z_streamp dest,
inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
(such as zalloc being Z_NULL). msg is left unchanged in both source and
- destination.
+ destination. If inflateCopy fails and dest is not Z_NULL, then dest->state
+ is set to Z_NULL with dest otherwise unchanged, so that inflateEnd(dest) can
+ be called safely, though dest is not a usable stream.
*/
ZEXTERN int ZEXPORT inflateReset(z_streamp strm);
@@ -1119,9 +1122,10 @@ ZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm,
a terminating zero. If any of extra, name, or comment are not present in
the header, then that field's pointer is set to Z_NULL. This allows the use
of deflateSetHeader() with the returned structure to duplicate the header.
- Note that if those fields initially pointed to allocated memory, then the
- application will need to save them elsewhere so that they can be eventually
- freed.
+ Though take care that none of the fields were truncated before so using it,
+ lest havoc ensue. Note that if those fields initially pointed to allocated
+ memory, then the application will need to save them elsewhere so that they
+ can be eventually freed.
If inflateGetHeader is not used, then the header information is simply
discarded. The header is always checked for validity, including the header
@@ -1418,8 +1422,8 @@ ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode);
errno can be checked to determine if the reason gzopen failed was that the
file could not be opened. Note that if 'N' is in mode for non-blocking, the
open() itself can fail in order to not block. In that case gzopen() will
- return NULL and errno will be EAGAIN or ENONBLOCK. The call to gzopen() can
- then be re-tried. If the application would like to block on opening the
+ return NULL and errno will be EAGAIN or EWOULDBLOCK. The call to gzopen()
+ can then be re-tried. If the application would like to block on opening the
file, then it can use open() without O_NONBLOCK, and then gzdopen() with the
resulting file descriptor and 'N' in the mode, which will set it to non-
blocking.
@@ -1525,9 +1529,12 @@ ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems,
gzfread() returns the number of full items read of size size, or zero if
the end of the file was reached and a full item could not be read, or if
there was an error. gzerror() must be consulted if zero is returned in
- order to determine if there was an error. If the multiplication of size and
- nitems overflows, i.e. the product does not fit in a z_size_t, then nothing
- is read, zero is returned, and the error state is set to Z_STREAM_ERROR.
+ order to determine if there was an error. If some data was read before an
+ error, then that data is returned until exhausted, after which the next call
+ will return zero and gzerror() will report the error. If the multiplication
+ of size and nitems overflows, i.e. the product does not fit in a z_size_t,
+ then nothing is read, zero is returned, and the error state is set to
+ Z_STREAM_ERROR.
In the event that the end of file is reached and only a partial item is
available at the end, i.e. the remaining uncompressed data length is not a
@@ -1593,7 +1600,7 @@ ZEXTERN int ZEXPORTVA gzprintf();
these possibilities can be determined using zlibCompileFlags().
If a Z_BUF_ERROR is returned, then nothing was written due to a stall on
- the non-blocking write destination.
+ the non-blocking write destination. The operation can be retried.
*/
ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s);
@@ -1701,7 +1708,9 @@ ZEXTERN z_off_t ZEXPORT gzseek(gzFile file,
gzseek returns the resulting offset location as measured in bytes from
the beginning of the uncompressed stream, or -1 in case of error, in
particular if the file is opened for writing and the new starting position
- would be before the current position.
+ would be before the current position, or if the resulting position would
+ not be representable in the offset type. If gzseek returns -1, the stream
+ position is unchanged.
*/
ZEXTERN int ZEXPORT gzrewind(gzFile file);
@@ -1802,7 +1811,8 @@ ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum);
If errnum is not NULL, *errnum is set to zlib error number. If an error
occurred in the file system and not in the compression library, *errnum is
set to Z_ERRNO and the application may consult errno to get the exact error
- code.
+ code. The error is reported by gzerror() as soon as it is detected, which
+ may be before all of the data read prior to the error has been returned.
The application must not modify the returned string. Future calls to
this function may invalidate the previously returned string. If file is
@@ -1996,7 +2006,8 @@ ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */
* change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
* both are true, the application gets the *64 functions, and the regular
* functions are changed to 64 bits) -- in case these are set on systems
- * without large file support, _LFS64_LARGEFILE must also be true
+ * without large file support, _LFS64_LARGEFILE must also be true, except on
+ * native Windows, where 64-bit offsets are always available
*/
#ifdef Z_LARGE64
ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
@@ -2053,7 +2064,7 @@ ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */
#endif /* !Z_SOLO */
-/* undocumented functions */
+/* undocumented functions (not part of the zlib API) */
ZEXTERN const char * ZEXPORT zError(int);
ZEXTERN int ZEXPORT inflateSyncPoint(z_streamp);
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table(void);
diff --git a/src/java.base/share/native/libzip/zlib/zutil.c b/src/java.base/share/native/libzip/zlib/zutil.c
index c57c162ffde8..ae5e85102786 100644
--- a/src/java.base/share/native/libzip/zlib/zutil.c
+++ b/src/java.base/share/native/libzip/zlib/zutil.c
@@ -195,7 +195,6 @@ int ZLIB_INTERNAL zmemcmp(const void FAR *s1, const void FAR *s2, z_size_t n) {
void ZLIB_INTERNAL zmemzero(void FAR *b, z_size_t len) {
uchf *p = b;
- if (len == 0) return;
while (len) {
*p++ = 0;
len--;
@@ -252,7 +251,11 @@ voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) {
} else {
buf = farmalloc(bsize + 16L);
}
- if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
+ if (buf == NULL) return NULL;
+ if (next_ptr >= MAX_PTR) {
+ farfree(buf);
+ return NULL;
+ }
table[next_ptr].org_ptr = buf;
/* Normalize the pointer to seg:0 */
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 41528a55e376..394af890723b 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, 2022, 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
@@ -194,7 +194,7 @@ public int read(String name, ByteBuffer dst) throws IOException {
int n = read(name, address, rem);
// copy from buffer into backing array
- int off = dst.arrayOffset() + pos + 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);
@@ -257,7 +257,7 @@ public int write(String name, ByteBuffer src) throws IOException {
if (src.hasArray()) {
// copy from backing array into buffer
- int off = src.arrayOffset() + pos + 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.base/windows/native/libjava/TimeZone_md.c b/src/java.base/windows/native/libjava/TimeZone_md.c
index fc9e29f01ac5..f10dd1ad225d 100644
--- a/src/java.base/windows/native/libjava/TimeZone_md.c
+++ b/src/java.base/windows/native/libjava/TimeZone_md.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -330,6 +330,7 @@ static int getWinTimeZone(char *winZoneName, size_t winZoneNameBufSize)
if (ret != ERROR_SUCCESS) {
goto err;
}
+ RegCloseKey(hSubKey);
break;
}
@@ -366,6 +367,7 @@ static int getWinTimeZone(char *winZoneName, size_t winZoneNameBufSize)
* found matched record, terminate search
*/
strcpy(winZoneName, subKeyName);
+ RegCloseKey(hSubKey);
break;
}
out:
diff --git a/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp b/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp
index 7b00215ccded..a9ee121991b1 100644
--- a/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp
+++ b/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp
@@ -4301,7 +4301,19 @@ static BOOL SetPrinterDevice(LPTSTR pszDeviceName, HGLOBAL* p_hDevMode,
// Allocate a global handle big enough to hold DEVNAMES.
HGLOBAL hDevNames = ::GlobalAlloc(GHND, devNameSize);
+ if (hDevNames == NULL) {
+ ::GlobalFree(hDevMode);
+ ::GlobalFree(p2);
+ return FALSE;
+ }
+
DEVNAMES* pDevNames = (DEVNAMES*)::GlobalLock(hDevNames);
+ if (pDevNames == NULL) {
+ ::GlobalFree(hDevNames);
+ ::GlobalFree(hDevMode);
+ ::GlobalFree(p2);
+ return FALSE;
+ }
// Copy the DEVNAMES information from PRINTER_INFO_2 structure.
pDevNames->wDriverOffset = sizeof(DEVNAMES)/sizeof(TCHAR);
diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/common/Utils.java b/src/java.net.http/share/classes/jdk/internal/net/http/common/Utils.java
index 052402cbf844..98dfa1d59918 100644
--- a/src/java.net.http/share/classes/jdk/internal/net/http/common/Utils.java
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/common/Utils.java
@@ -634,6 +634,8 @@ public static SSLParameters copySSLParameters(SSLParameters p) {
p1.setServerNames(p.getServerNames());
p1.setUseCipherSuitesOrder(p.getUseCipherSuitesOrder());
p1.setWantClientAuth(p.getWantClientAuth());
+ p1.setSignatureSchemes(p.getSignatureSchemes());
+ p1.setNamedGroups(p.getNamedGroups());
return p1;
}
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java
index c9ffca89ec70..72861d9c30da 100644
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -1005,56 +1005,56 @@ protected void writePrimitiveArray(TypeArray array) throws IOException {
private void writeBooleanArray(TypeArray array, int length) throws IOException {
for (int index = 0; index < length; index++) {
- long offset = BOOLEAN_BASE_OFFSET + index * BOOLEAN_SIZE;
+ long offset = (long) BOOLEAN_BASE_OFFSET + index * BOOLEAN_SIZE;
out.writeBoolean(array.getHandle().getJBooleanAt(offset));
}
}
private void writeByteArray(TypeArray array, int length) throws IOException {
for (int index = 0; index < length; index++) {
- long offset = BYTE_BASE_OFFSET + index * BYTE_SIZE;
+ long offset = (long) BYTE_BASE_OFFSET + index * BYTE_SIZE;
out.writeByte(array.getHandle().getJByteAt(offset));
}
}
private void writeShortArray(TypeArray array, int length) throws IOException {
for (int index = 0; index < length; index++) {
- long offset = SHORT_BASE_OFFSET + index * SHORT_SIZE;
+ long offset = (long) SHORT_BASE_OFFSET + index * SHORT_SIZE;
out.writeShort(array.getHandle().getJShortAt(offset));
}
}
private void writeIntArray(TypeArray array, int length) throws IOException {
for (int index = 0; index < length; index++) {
- long offset = INT_BASE_OFFSET + index * INT_SIZE;
+ long offset = (long) INT_BASE_OFFSET + index * INT_SIZE;
out.writeInt(array.getHandle().getJIntAt(offset));
}
}
private void writeLongArray(TypeArray array, int length) throws IOException {
for (int index = 0; index < length; index++) {
- long offset = LONG_BASE_OFFSET + index * LONG_SIZE;
+ long offset = (long) LONG_BASE_OFFSET + index * LONG_SIZE;
out.writeLong(array.getHandle().getJLongAt(offset));
}
}
private void writeCharArray(TypeArray array, int length) throws IOException {
for (int index = 0; index < length; index++) {
- long offset = CHAR_BASE_OFFSET + index * CHAR_SIZE;
+ long offset = (long) CHAR_BASE_OFFSET + index * CHAR_SIZE;
out.writeChar(array.getHandle().getJCharAt(offset));
}
}
private void writeFloatArray(TypeArray array, int length) throws IOException {
for (int index = 0; index < length; index++) {
- long offset = FLOAT_BASE_OFFSET + index * FLOAT_SIZE;
+ long offset = (long) FLOAT_BASE_OFFSET + index * FLOAT_SIZE;
out.writeFloat(array.getHandle().getJFloatAt(offset));
}
}
private void writeDoubleArray(TypeArray array, int length) throws IOException {
for (int index = 0; index < length; index++) {
- long offset = DOUBLE_BASE_OFFSET + index * DOUBLE_SIZE;
+ long offset = (long) DOUBLE_BASE_OFFSET + index * DOUBLE_SIZE;
out.writeDouble(array.getHandle().getJDoubleAt(offset));
}
}
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 4db53b189d66..5388687a5466 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
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 b8607febaefb..7b41fcf1944f 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
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 439917011360..bbfd4cac34a5 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
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 03a38497334b..5ba3ca549983 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
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 da414574dfc6..9e5dfec5c361 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
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 dfec9cc7a674..b224b579ddc4 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
diff --git a/src/jdk.security.auth/windows/native/libjaas/nt.c b/src/jdk.security.auth/windows/native/libjaas/nt.c
index e41386c87ac1..b5f80715aec4 100644
--- a/src/jdk.security.auth/windows/native/libjaas/nt.c
+++ b/src/jdk.security.auth/windows/native/libjaas/nt.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -106,21 +106,21 @@ Java_com_sun_security_auth_module_NTSystem_getCurrent
}
if (getUser
(tokenHandle, &userName, &domainName, &userSid, &domainSid) == FALSE) {
- return;
+ goto cleanup;
}
if (debug) {
printf("getting primary group\n");
}
if (getPrimaryGroup(tokenHandle, &primaryGroup) == FALSE) {
- return;
+ goto cleanup;
}
if (debug) {
printf("getting supplementary groups\n");
}
if (getGroups(tokenHandle, &numGroups, &groups) == FALSE) {
- return;
+ goto cleanup;
}
// then set values into NTSystem
@@ -578,6 +578,7 @@ BOOL getImpersonationToken(PHANDLE impersonationToken) {
GetLastError());
DisplayErrorText(GetLastError());
}
+ CloseHandle(dupToken);
return FALSE;
}
CloseHandle(dupToken);
diff --git a/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java b/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java
index 2f8d397c6c99..d980d67ecfd7 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, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -615,7 +615,7 @@ public void freeMemory(long address) {
* {@link #staticFieldOffset}, {@link #objectFieldOffset},
* or {@link #arrayBaseOffset}.
*/
- 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
@@ -775,35 +775,35 @@ public void ensureClassInitialized(Class> c) {
*/
@ForceInline
public int arrayBaseOffset(Class> arrayClass) {
- return theInternalUnsafe.arrayBaseOffset(arrayClass);
+ return (int) theInternalUnsafe.arrayBaseOffset(arrayClass);
}
/** The value of {@code arrayBaseOffset(boolean[].class)} */
- 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)} */
- 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)} */
- 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)} */
- 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)} */
- 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)} */
- 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)} */
- 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)} */
- 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)} */
- 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/hotspot/jtreg/compiler/c2/Test6968348.java b/test/hotspot/jtreg/compiler/c2/Test6968348.java
index 17a2d61716b0..488bcfcac589 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 e0c43b055295..64c52446c368 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 b7354c88dae5..342b146a0c89 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 3ff0a1323798..3ea812a9e79f 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/loopopts/superword/TestMovingLoadBeforeStore.java b/test/hotspot/jtreg/compiler/loopopts/superword/TestMovingLoadBeforeStore.java
index a8c0750c6564..4ab48c13cf61 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, 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
@@ -157,7 +157,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);
@@ -172,7 +172,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 74aa824f2da0..3e90dc0c67cb 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/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java b/test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java
index 98f638abe2d5..2a4015daca20 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 e149f6bd07bb..8b188cb7cb52 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 62d926b66a1d..4b5b876d5072 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 2f90f0d7c7b0..5334da98714d 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 f0256e7815d5..946f6d7d5ded 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 038cd2151b1b..93ed85805d5b 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 cffec14ad725..7a6d2bfc033f 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 0c74c295e213..2fe5d7f3ae05 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 770677a98d39..47a700d9313c 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 c176277d2bad..fcb0b3fbef37 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 b205b1d33764..7343463c41d8 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 114ed7e9b5a7..4c5e02bea266 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 d813ea73e702..5503dcd1840f 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 f0482c826376..f050c5bb17b8 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 9326539f4efe..85f82915e03a 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 30bc9551dd50..1a73cfe30865 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 add15ff77fdd..1aab41ddc9b6 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 4ea81f026e73..123b655220c6 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 2fc22fa360ab..f5eadc218e44 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 11729aa58273..1b8cc143fabc 100644
--- a/test/hotspot/jtreg/gc/arguments/TestMaxMinHeapFreeRatioFlags.java
+++ b/test/hotspot/jtreg/gc/arguments/TestMaxMinHeapFreeRatioFlags.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2023, 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 afe424896b56..a80b16b96a4c 100644
--- a/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java
+++ b/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -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/Unsafe/GetField.java b/test/hotspot/jtreg/runtime/Unsafe/GetField.java
index 3772fa6e8db7..88ac98135f1a 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 57599cffd625..92fcb215b256 100644
--- a/test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java
+++ b/test/hotspot/jtreg/runtime/Unsafe/InternalErrorTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, 2022, 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
@@ -143,8 +143,9 @@ public static void test(MappedByteBuffer buffer, Unsafe unsafe, long mapAddr, lo
buffer.get(new byte[8]);
break;
case 1:
- // testing Unsafe.copySwapMemory, trying to access next page after truncation.
- unsafe.copySwapMemory(null, mapAddr + pageSize, new byte[4000], 16, 2000, 2);
+ // testing Unsafe.copySwapMemory, trying to access next page after truncation.
+ long destOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET;
+ unsafe.copySwapMemory(null, mapAddr + pageSize, new byte[4000], destOffset, 2000, 2);
break;
case 2:
// testing Unsafe.copySwapMemory, trying to access next page after truncation.
diff --git a/test/jdk/java/net/httpclient/HttpClientBuilderTest.java b/test/jdk/java/net/httpclient/HttpClientBuilderTest.java
index 781ac1183009..1887e46fc622 100644
--- a/test/jdk/java/net/httpclient/HttpClientBuilderTest.java
+++ b/test/jdk/java/net/httpclient/HttpClientBuilderTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2023, 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
@@ -57,7 +57,7 @@
/*
* @test
- * @bug 8209137
+ * @bug 8209137 8367112
* @summary HttpClient[.Builder] API and behaviour checks
* @library /test/lib
* @build jdk.test.lib.net.SimpleSSLContext
@@ -271,6 +271,20 @@ public void testSSLParameters() {
try (var closer = closeable(builder)) {
assertTrue(closer.build().sslParameters().getProtocols()[0].equals("C"));
}
+ SSLParameters d = new SSLParameters();
+ d.setSignatureSchemes(new String[] { "C" });
+ builder.sslParameters(d);
+ d.setSignatureSchemes(new String[] { "D" });
+ try (var closer = closeable(builder)) {
+ assertTrue(closer.build().sslParameters().getSignatureSchemes()[0].equals("C"));
+ }
+ SSLParameters e = new SSLParameters();
+ e.setNamedGroups(new String[] { "C" });
+ builder.sslParameters(e);
+ e.setNamedGroups(new String[] { "D" });
+ try (var closer = closeable(builder)) {
+ assertTrue(closer.build().sslParameters().getNamedGroups()[0].equals("C"));
+ }
}
@Test
diff --git a/test/jdk/sun/security/ssl/HybridKeyExchange/TestHybrid.java b/test/jdk/sun/security/ssl/HybridKeyExchange/TestHybrid.java
new file mode 100644
index 000000000000..82314c31dcf2
--- /dev/null
+++ b/test/jdk/sun/security/ssl/HybridKeyExchange/TestHybrid.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8379433
+ * @summary Test expected DecapsulateException thrown by Hybrid KEM implementation
+ * @modules java.base/sun.security.ssl
+ * @run main/othervm TestHybrid
+*/
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.Provider;
+import java.util.Arrays;
+import javax.crypto.DecapsulateException;
+import javax.crypto.KEM;
+
+public class TestHybrid {
+
+ public static void main(String[] args) throws Exception {
+
+ Class> clazz = Class.forName("sun.security.ssl.HybridProvider");
+ Provider p = (Provider) clazz.getField("PROVIDER").get(null);
+
+ String alg = "X25519MLKEM768";
+ KeyPairGenerator kpg = KeyPairGenerator.getInstance(alg, p);
+ KeyPair kp = kpg.generateKeyPair();
+
+ KEM kem = KEM.getInstance(alg, p);
+ KEM.Encapsulator e = kem.newEncapsulator(kp.getPublic());
+ KEM.Decapsulator d = kem.newDecapsulator(kp.getPrivate());
+
+ int secretSize = e.secretSize();
+ KEM.Encapsulated enc = e.encapsulate();
+ byte[] ciphertext = enc.encapsulation();
+
+ byte[] badCiphertext = Arrays.copyOf(ciphertext,
+ ciphertext.length - 1);
+ try {
+ d.decapsulate(badCiphertext, 0, secretSize, "Generic");
+ throw new RuntimeException(
+ "Expected DecapsulateException not thrown");
+ } catch (DecapsulateException expected) {
+ System.out.println("Expected DecapsulateException thrown");
+ }
+ }
+}
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 9f67332c2cc8..95250a1c2647 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, 2022, 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 876fa3aafb3f..a18cbb267b4c 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, 2022, 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;