Skip to content

Commit 8ab3c9d

Browse files
committed
Merge master HEAD into openj9-staging
Signed-off-by: J9 Build <[email protected]>
2 parents b2aa212 + 4f70490 commit 8ab3c9d

File tree

43 files changed

+1693
-329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1693
-329
lines changed

src/java.base/share/classes/java/io/PipedOutputStream.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -129,16 +129,17 @@ public void write(int b) throws IOException {
129129
/**
130130
* Writes {@code len} bytes from the specified byte array
131131
* starting at offset {@code off} to this piped output stream.
132-
* This method blocks until all the bytes are written to the output
133-
* stream.
132+
* If {@code len} is not zero, this method blocks until all the
133+
* bytes are written to the output stream.
134134
*
135135
* @param b {@inheritDoc}
136136
* @param off {@inheritDoc}
137137
* @param len {@inheritDoc}
138+
* @throws IndexOutOfBoundsException {@inheritDoc}
138139
* @throws IOException if the pipe is <a href=#BROKEN> broken</a>,
139140
* {@link #connect(java.io.PipedInputStream) unconnected},
140-
* closed, or if an I/O error occurs.
141-
* @throws IndexOutOfBoundsException {@inheritDoc}
141+
* closed and {@code len} is greater than zero,
142+
* or if an I/O error occurs.
142143
*/
143144
@Override
144145
public void write(byte[] b, int off, int len) throws IOException {

src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,27 @@
6464
* Values should be annotated with the feature's {@code JEP}.
6565
*/
6666
public enum Feature {
67-
// while building the interim javac, the ClassReader will produce a warning when loading a class
68-
// keeping the constant of a feature that has been integrated or dropped, serves the purpose of muting such warnings.
67+
// The JDK build process involves creating an interim javac which is then
68+
// used to compile the rest of the JDK. The jdk.internal.javac.PreviewFeature
69+
// annotation from the current sources is used when compiling interim javac.
70+
// That's because the javac APIs of the current sources may be annotated with
71+
// this annotation and they may be using the enum constants of the current sources.
72+
// Furthermore, when compiling interim javac, the class files from the bootstrap JDK get
73+
// used and those may also contain the PreviewFeature annotation. However, they may be
74+
// using the enum constants of the bootstrap JDK's PreviewFeature annotation.
75+
// If javac sees an annotation with an unknown enum constant, it produces a warning,
76+
// and that in turn fails the build.
77+
// So, in the current sources, we need to preserve the PreviewFeature enum constants
78+
// for as long as the interim javac build needs it. As a result, we retain PreviewFeature
79+
// enum constants for preview features that are present in the bootstrap JDK.
80+
// Older constants can be removed.
81+
//
82+
// For example, Class-File API became final in JDK 24. As soon as JDK 23 was dropped as
83+
// the bootstrap JDK, the CLASSFILE_API enum constant became eligible for removal.
6984

7085
//---
71-
IMPLICIT_CLASSES, //to be removed when boot JDK is 25
72-
SCOPED_VALUES,
7386
@JEP(number=505, title="Structured Concurrency", status="Fifth Preview")
7487
STRUCTURED_CONCURRENCY,
75-
CLASSFILE_API,
76-
STREAM_GATHERERS,
77-
MODULE_IMPORTS, //remove when the boot JDK is JDK 25
78-
KEY_DERIVATION, //remove when the boot JDK is JDK 25
7988
@JEP(number = 502, title = "Stable Values", status = "Preview")
8089
STABLE_VALUES,
8190
@JEP(number=470, title="PEM Encodings of Cryptographic Objects", status="Preview")

src/java.base/windows/classes/java/io/WinNTFileSystem.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -482,27 +482,12 @@ public String canonicalize(String path) throws IOException {
482482
return path;
483483
return "" + ((char) (c-32)) + ':' + '\\';
484484
}
485-
String canonicalPath = canonicalize0(path);
486-
String finalPath = null;
487-
try {
488-
finalPath = getFinalPath(canonicalPath);
489-
} catch (IOException ignored) {
490-
finalPath = canonicalPath;
491-
}
492-
return finalPath;
485+
return canonicalize0(path);
493486
}
494487

495488
private native String canonicalize0(String path)
496489
throws IOException;
497490

498-
private String getFinalPath(String path) throws IOException {
499-
return getFinalPath0(path);
500-
}
501-
502-
private native String getFinalPath0(String path)
503-
throws IOException;
504-
505-
506491
/* -- Attribute accessors -- */
507492

508493
@Override

src/java.base/windows/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -116,22 +116,18 @@ public class HostLocaleProviderAdapterImpl {
116116
private static final String nativeDisplayLanguage;
117117
static {
118118
Set<Locale> tmpSet = new HashSet<>();
119-
if (initialize()) {
120-
// Assuming the default locales do not include any extensions, so
121-
// no stripping is needed here.
122-
Control c = Control.getNoFallbackControl(Control.FORMAT_DEFAULT);
123-
String displayLocale = getDefaultLocale(CAT_DISPLAY);
124-
Locale l = Locale.forLanguageTag(displayLocale.replace('_', '-'));
119+
// Assuming the default locales do not include any extensions, so
120+
// no stripping is needed here.
121+
Control c = Control.getNoFallbackControl(Control.FORMAT_DEFAULT);
122+
String displayLocale = getDefaultLocale(CAT_DISPLAY);
123+
Locale l = Locale.forLanguageTag(displayLocale.replace('_', '-'));
124+
tmpSet.addAll(c.getCandidateLocales("", l));
125+
nativeDisplayLanguage = l.getLanguage();
126+
127+
String formatLocale = getDefaultLocale(CAT_FORMAT);
128+
if (!formatLocale.equals(displayLocale)) {
129+
l = Locale.forLanguageTag(formatLocale.replace('_', '-'));
125130
tmpSet.addAll(c.getCandidateLocales("", l));
126-
nativeDisplayLanguage = l.getLanguage();
127-
128-
String formatLocale = getDefaultLocale(CAT_FORMAT);
129-
if (!formatLocale.equals(displayLocale)) {
130-
l = Locale.forLanguageTag(formatLocale.replace('_', '-'));
131-
tmpSet.addAll(c.getCandidateLocales("", l));
132-
}
133-
} else {
134-
nativeDisplayLanguage = "";
135131
}
136132
supportedLocaleSet = Collections.unmodifiableSet(tmpSet);
137133
}
@@ -850,7 +846,6 @@ private static Locale getNumberLocale(Locale src) {
850846
// native methods
851847

852848
// initialize
853-
private static native boolean initialize();
854849
private static native String getDefaultLocale(int cat);
855850

856851
// For DateFormatProvider

src/java.base/windows/native/libjava/HostLocaleProviderAdapter_md.c

Lines changed: 15 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -39,15 +39,6 @@
3939
#define CALENDAR_STYLE_SHORT_MASK 0x00000001 // Calendar.SHORT
4040
#define CALENDAR_STYLE_STANDALONE_MASK 0x00008000 // Calendar.STANDALONE
4141

42-
// global variables
43-
typedef int (WINAPI *PGLIE)(const jchar *, LCTYPE, LPWSTR, int);
44-
typedef int (WINAPI *PGCIE)(const jchar *, CALID, LPCWSTR, CALTYPE, LPWSTR, int, LPDWORD);
45-
typedef int (WINAPI *PECIEE)(CALINFO_ENUMPROCEXEX, const jchar *, CALID, LPCWSTR, CALTYPE, LPARAM);
46-
PGLIE pGetLocaleInfoEx;
47-
PGCIE pGetCalendarInfoEx;
48-
PECIEE pEnumCalendarInfoExEx;
49-
BOOL initialized = FALSE;
50-
5142
// prototypes
5243
int getLocaleInfoWrapper(const jchar *langtag, LCTYPE type, LPWSTR data, int buflen);
5344
int getCalendarInfoWrapper(const jchar *langtag, CALID id, LPCWSTR reserved, CALTYPE type, LPWSTR data, int buflen, LPDWORD val);
@@ -178,31 +169,6 @@ WCHAR * fixes[2][2][3][16] =
178169
}
179170
};
180171

181-
/*
182-
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl
183-
* Method: initialize
184-
* Signature: ()Z
185-
*/
186-
JNIEXPORT jboolean JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_initialize
187-
(JNIEnv *env, jclass cls) {
188-
if (!initialized) {
189-
pGetLocaleInfoEx = (PGLIE)GetProcAddress(
190-
GetModuleHandle("kernel32.dll"),
191-
"GetLocaleInfoEx");
192-
pGetCalendarInfoEx = (PGCIE)GetProcAddress(
193-
GetModuleHandle("kernel32.dll"),
194-
"GetCalendarInfoEx");
195-
pEnumCalendarInfoExEx = (PECIEE)GetProcAddress(
196-
GetModuleHandle("kernel32.dll"),
197-
"EnumCalendarInfoExEx");
198-
initialized =TRUE;
199-
}
200-
201-
return pGetLocaleInfoEx != NULL &&
202-
pGetCalendarInfoEx != NULL &&
203-
pEnumCalendarInfoExEx != NULL;
204-
}
205-
206172
/*
207173
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl
208174
* Method: getDefaultLocale
@@ -768,34 +734,20 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte
768734
}
769735

770736
int getLocaleInfoWrapper(const jchar *langtag, LCTYPE type, LPWSTR data, int buflen) {
771-
if (pGetLocaleInfoEx) {
772-
if (wcscmp(L"und", (LPWSTR)langtag) == 0) {
773-
// defaults to "en"
774-
return pGetLocaleInfoEx(L"en", type, data, buflen);
775-
} else {
776-
return pGetLocaleInfoEx((LPWSTR)langtag, type, data, buflen);
777-
}
737+
if (wcscmp(L"und", (LPWSTR)langtag) == 0) {
738+
// defaults to "en"
739+
return GetLocaleInfoEx(L"en", type, data, buflen);
778740
} else {
779-
// If we ever wanted to support WinXP, we will need extra module from
780-
// MS...
781-
// return GetLocaleInfo(DownlevelLocaleNameToLCID(langtag, 0), type, data, buflen);
782-
return 0;
741+
return GetLocaleInfoEx((LPWSTR)langtag, type, data, buflen);
783742
}
784743
}
785744

786745
int getCalendarInfoWrapper(const jchar *langtag, CALID id, LPCWSTR reserved, CALTYPE type, LPWSTR data, int buflen, LPDWORD val) {
787-
if (pGetCalendarInfoEx) {
788-
if (wcscmp(L"und", (LPWSTR)langtag) == 0) {
789-
// defaults to "en"
790-
return pGetCalendarInfoEx(L"en", id, reserved, type, data, buflen, val);
791-
} else {
792-
return pGetCalendarInfoEx((LPWSTR)langtag, id, reserved, type, data, buflen, val);
793-
}
746+
if (wcscmp(L"und", (LPWSTR)langtag) == 0) {
747+
// defaults to "en"
748+
return GetCalendarInfoEx(L"en", id, reserved, type, data, buflen, val);
794749
} else {
795-
// If we ever wanted to support WinXP, we will need extra module from
796-
// MS...
797-
// return GetCalendarInfo(DownlevelLocaleNameToLCID(langtag, 0), ...);
798-
return 0;
750+
return GetCalendarInfoEx((LPWSTR)langtag, id, reserved, type, data, buflen, val);
799751
}
800752
}
801753

@@ -1000,17 +952,13 @@ void getFixPart(const jchar * langtag, const jint numberStyle, BOOL positive, BO
1000952
}
1001953

1002954
int enumCalendarInfoWrapper(const jchar *langtag, CALID calid, CALTYPE type, LPWSTR buf, int buflen) {
1003-
if (pEnumCalendarInfoExEx) {
1004-
if (wcscmp(L"und", (LPWSTR)langtag) == 0) {
1005-
// defaults to "en"
1006-
return pEnumCalendarInfoExEx(&EnumCalendarInfoProc, L"en",
1007-
calid, NULL, type, (LPARAM)buf);
1008-
} else {
1009-
return pEnumCalendarInfoExEx(&EnumCalendarInfoProc, langtag,
1010-
calid, NULL, type, (LPARAM)buf);
1011-
}
955+
if (wcscmp(L"und", (LPWSTR)langtag) == 0) {
956+
// defaults to "en"
957+
return EnumCalendarInfoExEx(&EnumCalendarInfoProc, L"en",
958+
calid, NULL, type, (LPARAM)buf);
1012959
} else {
1013-
return 0;
960+
return EnumCalendarInfoExEx(&EnumCalendarInfoProc, langtag,
961+
calid, NULL, type, (LPARAM)buf);
1014962
}
1015963
}
1016964

src/java.base/windows/native/libjava/WinNTFileSystem_md.c

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Java_java_io_WinNTFileSystem_initIDs(JNIEnv *env, jclass cls)
5959

6060
/* -- Path operations -- */
6161

62-
extern int wcanonicalize(const WCHAR *path, WCHAR *out, int len);
62+
extern WCHAR* wcanonicalize(const WCHAR *path, WCHAR *out, int len);
6363

6464
/**
6565
* Retrieves the fully resolved (final) path for the given path or NULL
@@ -274,18 +274,23 @@ Java_java_io_WinNTFileSystem_canonicalize0(JNIEnv *env, jobject this,
274274
*/
275275
int len = (int)wcslen(path);
276276
len += currentDirLength(path, len);
277+
WCHAR* fp;
277278
if (len > MAX_PATH_LENGTH - 1) {
278279
WCHAR *cp = (WCHAR*)malloc(len * sizeof(WCHAR));
279280
if (cp != NULL) {
280-
if (wcanonicalize(path, cp, len) >= 0) {
281-
rv = (*env)->NewString(env, cp, (jsize)wcslen(cp));
281+
if ((fp = wcanonicalize(path, cp, len)) != NULL) {
282+
rv = (*env)->NewString(env, fp, (jsize)wcslen(fp));
283+
if (fp != cp)
284+
free(fp);
282285
}
283286
free(cp);
284287
} else {
285288
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
286289
}
287-
} else if (wcanonicalize(path, canonicalPath, MAX_PATH_LENGTH) >= 0) {
288-
rv = (*env)->NewString(env, canonicalPath, (jsize)wcslen(canonicalPath));
290+
} else if ((fp = wcanonicalize(path, canonicalPath, MAX_PATH_LENGTH)) != NULL) {
291+
rv = (*env)->NewString(env, fp, (jsize)wcslen(fp));
292+
if (fp != canonicalPath)
293+
free(fp);
289294
}
290295
} END_UNICODE_STRING(env, path);
291296
if (rv == NULL && !(*env)->ExceptionCheck(env)) {
@@ -294,26 +299,6 @@ Java_java_io_WinNTFileSystem_canonicalize0(JNIEnv *env, jobject this,
294299
return rv;
295300
}
296301

297-
298-
JNIEXPORT jstring JNICALL
299-
Java_java_io_WinNTFileSystem_getFinalPath0(JNIEnv* env, jobject this, jstring pathname) {
300-
jstring rv = NULL;
301-
302-
WITH_UNICODE_STRING(env, pathname, path) {
303-
WCHAR* finalPath = getFinalPath(env, path);
304-
if (finalPath != NULL) {
305-
rv = (*env)->NewString(env, finalPath, (jsize)wcslen(finalPath));
306-
free(finalPath);
307-
}
308-
} END_UNICODE_STRING(env, path);
309-
310-
if (rv == NULL && !(*env)->ExceptionCheck(env)) {
311-
JNU_ThrowIOExceptionWithLastError(env, "Bad pathname");
312-
}
313-
314-
return rv;
315-
}
316-
317302
/* -- Attribute accessors -- */
318303

319304
/* Check whether or not the file name in "path" is a Windows reserved

0 commit comments

Comments
 (0)