From 65b9abaa29eb9fe801b650ce787d98c31770a5dc Mon Sep 17 00:00:00 2001 From: Justin Lu Date: Mon, 16 Sep 2024 17:26:47 +0000 Subject: [PATCH] 8339769: Incorrect error message during startup if working directory does not exist Reviewed-by: naoto, dholmes, alanb --- src/java.base/unix/native/libjava/java_props_md.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/java.base/unix/native/libjava/java_props_md.c b/src/java.base/unix/native/libjava/java_props_md.c index 4766a883472..4a6d0f7f5a4 100644 --- a/src/java.base/unix/native/libjava/java_props_md.c +++ b/src/java.base/unix/native/libjava/java_props_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -521,11 +521,14 @@ GetJavaProperties(JNIEnv *env) { char buf[MAXPATHLEN]; errno = 0; - if (getcwd(buf, sizeof(buf)) == NULL) + if (getcwd(buf, sizeof(buf)) == NULL) { JNU_ThrowByName(env, "java/lang/Error", - "Properties init: Could not determine current working directory."); - else + "Properties init: Could not determine current working directory."); + return NULL; + } + else { sprops.user_dir = strdup(buf); + } } sprops.file_separator = "/";