Skip to content

Commit 40fcb90

Browse files
committed
8339769: Incorrect error message during startup if working directory does not exist
Backport-of: 65b9abaa29eb9fe801b650ce787d98c31770a5dc
1 parent e3a7b10 commit 40fcb90

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/java.base/unix/native/libjava/java_props_md.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2024, 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
@@ -521,11 +521,14 @@ GetJavaProperties(JNIEnv *env)
521521
{
522522
char buf[MAXPATHLEN];
523523
errno = 0;
524-
if (getcwd(buf, sizeof(buf)) == NULL)
524+
if (getcwd(buf, sizeof(buf)) == NULL) {
525525
JNU_ThrowByName(env, "java/lang/Error",
526-
"Properties init: Could not determine current working directory.");
527-
else
526+
"Properties init: Could not determine current working directory.");
527+
return NULL;
528+
}
529+
else {
528530
sprops.user_dir = strdup(buf);
531+
}
529532
}
530533

531534
sprops.file_separator = "/";

0 commit comments

Comments
 (0)