8354189: Remove JLI_ReportErrorMessageSys on Windows

Reviewed-by: alanb, mdoerr
This commit is contained in:
Matthias Baesken 2025-04-11 11:32:42 +00:00
parent efb5a80e52
commit b5d2e25478
3 changed files with 7 additions and 76 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -125,10 +125,6 @@ void CreateExecutionEnvironment(int *argc, char ***argv,
JNIEXPORT void JNICALL
JLI_ReportErrorMessage(const char * message, ...);
/* Reports a system error message to stderr or a window */
JNIEXPORT void JNICALL
JLI_ReportErrorMessageSys(const char * message, ...);
/* Reports an error message only to stderr. */
JNIEXPORT void JNICALL
JLI_ReportMessage(const char * message, ...);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -59,6 +59,10 @@ static jboolean GetJVMPath(const char *jdkroot, const char *jvmtype,
char *jvmpath, jint jvmpathsize);
static jboolean GetJDKInstallRoot(char *path, jint pathsize, jboolean speculative);
/* Reports a system error message to stderr, including errno */
JNIEXPORT void JNICALL
JLI_ReportErrorMessageSys(const char * message, ...);
#if defined(_AIX)
jboolean GetApplicationHomeFromLibpath(char *buf, jint bufsize);
#include "java_md_aix.h"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -570,75 +570,6 @@ JLI_ReportErrorMessage(const char* fmt, ...) {
va_end(vl);
}
/*
* Just like JLI_ReportErrorMessage, except that it concatenates the system
* error message if any, it's up to the calling routine to correctly
* format the separation of the messages.
*/
JNIEXPORT void JNICALL
JLI_ReportErrorMessageSys(const char *fmt, ...)
{
va_list vl;
int save_errno = errno;
DWORD errval;
jboolean freeit = JNI_FALSE;
char *errtext = NULL;
va_start(vl, fmt);
if ((errval = GetLastError()) != 0) { /* Platform SDK / DOS Error */
int n = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|
FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_ALLOCATE_BUFFER,
NULL, errval, 0, (LPTSTR)&errtext, 0, NULL);
if (errtext == NULL || n == 0) { /* Paranoia check */
errtext = "";
n = 0;
} else {
freeit = JNI_TRUE;
if (n > 2) { /* Drop final CR, LF */
if (errtext[n - 1] == '\n') n--;
if (errtext[n - 1] == '\r') n--;
errtext[n] = '\0';
}
}
} else { /* C runtime error that has no corresponding DOS error code */
errtext = strerror(save_errno);
}
if (IsJavaw()) {
char *message;
int mlen;
/* get the length of the string we need */
int len = mlen = _vscprintf(fmt, vl) + 1;
if (freeit) {
mlen += (int)JLI_StrLen(errtext);
}
message = (char *)JLI_MemAlloc(mlen);
_vsnprintf(message, len, fmt, vl);
message[len]='\0';
if (freeit) {
JLI_StrCat(message, errtext);
}
MessageBox(NULL, message, "Java Virtual Machine Launcher",
(MB_OK|MB_ICONSTOP|MB_APPLMODAL));
JLI_MemFree(message);
} else {
vfprintf(stderr, fmt, vl);
if (freeit) {
fprintf(stderr, "%s", errtext);
}
}
if (freeit) {
(void)LocalFree((HLOCAL)errtext);
}
va_end(vl);
}
JNIEXPORT void JNICALL
JLI_ReportExceptionDescription(JNIEnv * env) {
if (IsJavaw()) {