Skip to content

Commit b5d2e25

Browse files
committed
8354189: Remove JLI_ReportErrorMessageSys on Windows
Reviewed-by: alanb, mdoerr
1 parent efb5a80 commit b5d2e25

File tree

3 files changed

+7
-76
lines changed

3 files changed

+7
-76
lines changed

src/java.base/share/native/libjli/java.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 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
@@ -125,10 +125,6 @@ void CreateExecutionEnvironment(int *argc, char ***argv,
125125
JNIEXPORT void JNICALL
126126
JLI_ReportErrorMessage(const char * message, ...);
127127

128-
/* Reports a system error message to stderr or a window */
129-
JNIEXPORT void JNICALL
130-
JLI_ReportErrorMessageSys(const char * message, ...);
131-
132128
/* Reports an error message only to stderr. */
133129
JNIEXPORT void JNICALL
134130
JLI_ReportMessage(const char * message, ...);

src/java.base/unix/native/libjli/java_md.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 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
@@ -59,6 +59,10 @@ static jboolean GetJVMPath(const char *jdkroot, const char *jvmtype,
5959
char *jvmpath, jint jvmpathsize);
6060
static jboolean GetJDKInstallRoot(char *path, jint pathsize, jboolean speculative);
6161

62+
/* Reports a system error message to stderr, including errno */
63+
JNIEXPORT void JNICALL
64+
JLI_ReportErrorMessageSys(const char * message, ...);
65+
6266
#if defined(_AIX)
6367
jboolean GetApplicationHomeFromLibpath(char *buf, jint bufsize);
6468
#include "java_md_aix.h"

src/java.base/windows/native/libjli/java_md.c

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 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
@@ -570,75 +570,6 @@ JLI_ReportErrorMessage(const char* fmt, ...) {
570570
va_end(vl);
571571
}
572572

573-
/*
574-
* Just like JLI_ReportErrorMessage, except that it concatenates the system
575-
* error message if any, it's up to the calling routine to correctly
576-
* format the separation of the messages.
577-
*/
578-
JNIEXPORT void JNICALL
579-
JLI_ReportErrorMessageSys(const char *fmt, ...)
580-
{
581-
va_list vl;
582-
583-
int save_errno = errno;
584-
DWORD errval;
585-
jboolean freeit = JNI_FALSE;
586-
char *errtext = NULL;
587-
588-
va_start(vl, fmt);
589-
590-
if ((errval = GetLastError()) != 0) { /* Platform SDK / DOS Error */
591-
int n = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|
592-
FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_ALLOCATE_BUFFER,
593-
NULL, errval, 0, (LPTSTR)&errtext, 0, NULL);
594-
if (errtext == NULL || n == 0) { /* Paranoia check */
595-
errtext = "";
596-
n = 0;
597-
} else {
598-
freeit = JNI_TRUE;
599-
if (n > 2) { /* Drop final CR, LF */
600-
if (errtext[n - 1] == '\n') n--;
601-
if (errtext[n - 1] == '\r') n--;
602-
errtext[n] = '\0';
603-
}
604-
}
605-
} else { /* C runtime error that has no corresponding DOS error code */
606-
errtext = strerror(save_errno);
607-
}
608-
609-
if (IsJavaw()) {
610-
char *message;
611-
int mlen;
612-
/* get the length of the string we need */
613-
int len = mlen = _vscprintf(fmt, vl) + 1;
614-
if (freeit) {
615-
mlen += (int)JLI_StrLen(errtext);
616-
}
617-
618-
message = (char *)JLI_MemAlloc(mlen);
619-
_vsnprintf(message, len, fmt, vl);
620-
message[len]='\0';
621-
622-
if (freeit) {
623-
JLI_StrCat(message, errtext);
624-
}
625-
626-
MessageBox(NULL, message, "Java Virtual Machine Launcher",
627-
(MB_OK|MB_ICONSTOP|MB_APPLMODAL));
628-
629-
JLI_MemFree(message);
630-
} else {
631-
vfprintf(stderr, fmt, vl);
632-
if (freeit) {
633-
fprintf(stderr, "%s", errtext);
634-
}
635-
}
636-
if (freeit) {
637-
(void)LocalFree((HLOCAL)errtext);
638-
}
639-
va_end(vl);
640-
}
641-
642573
JNIEXPORT void JNICALL
643574
JLI_ReportExceptionDescription(JNIEnv * env) {
644575
if (IsJavaw()) {

0 commit comments

Comments
 (0)