Skip to content

Commit b66fa8f

Browse files
committed
8253572: [windows] CDS archive may fail to open with long file names
8249943: [TESTBUG] runtime/cds/serviceability/transformRelatedClasses/TransformInterfaceAndImplementor.java Reviewed-by: ccheung, iklam
1 parent 4167540 commit b66fa8f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/hotspot/os/windows/os_windows.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4827,15 +4827,25 @@ static int stdinAvailable(int fd, long *pbytes) {
48274827
char* os::pd_map_memory(int fd, const char* file_name, size_t file_offset,
48284828
char *addr, size_t bytes, bool read_only,
48294829
bool allow_exec) {
4830+
4831+
errno_t err;
4832+
wchar_t* wide_path = wide_abs_unc_path(file_name, err);
4833+
4834+
if (wide_path == NULL) {
4835+
return NULL;
4836+
}
4837+
48304838
HANDLE hFile;
48314839
char* base;
48324840

4833-
hFile = CreateFile(file_name, GENERIC_READ, FILE_SHARE_READ, NULL,
4841+
hFile = CreateFileW(wide_path, GENERIC_READ, FILE_SHARE_READ, NULL,
48344842
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
48354843
if (hFile == INVALID_HANDLE_VALUE) {
4836-
log_info(os)("CreateFile() failed: GetLastError->%ld.", GetLastError());
4844+
log_info(os)("CreateFileW() failed: GetLastError->%ld.", GetLastError());
4845+
os::free(wide_path);
48374846
return NULL;
48384847
}
4848+
os::free(wide_path);
48394849

48404850
if (allow_exec) {
48414851
// CreateFileMapping/MapViewOfFileEx can't map executable memory

0 commit comments

Comments
 (0)