File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
src/java.base/windows/classes/java/io Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2001, 2024 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2001, 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
@@ -584,6 +584,13 @@ public File[] listRoots() {
584584 @ Override
585585 public long getSpace (File f , int t ) {
586586 if (f .exists ()) {
587+ // the value for the number of bytes of free space returned by the
588+ // native layer is not used here as it represents the number of free
589+ // bytes not considering quotas, whereas the value returned for the
590+ // number of usable bytes does respect quotas, and it is required
591+ // that free space <= total space
592+ if (t == SPACE_FREE )
593+ t = SPACE_USABLE ;
587594 return getSpace0 (f , t );
588595 }
589596 return 0 ;
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2005, 2024 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2005, 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
2323
2424/**
2525 * @test
26- * @bug 4057701 6286712 6364377 8181919
26+ * @bug 4057701 6286712 6364377 8181919 8349092
2727 * @requires (os.family == "linux" | os.family == "mac" |
2828 * os.family == "windows")
2929 * @summary Basic functionality of File.get-X-Space methods.
@@ -176,6 +176,12 @@ private static void compare(Space s) {
176176 long fs = f .getFreeSpace ();
177177 long us = f .getUsableSpace ();
178178
179+ // Verify inequalities us <= fs <= ts (JDK-8349092)
180+ if (fs > ts )
181+ throw new RuntimeException (f + " free space " + fs + " > total space " + ts );
182+ if (us > fs )
183+ throw new RuntimeException (f + " usable space " + fs + " > free space " + ts );
184+
179185 out .format ("%s (%d):%n" , s .name (), s .size ());
180186 String fmt = " %-4s total = %12d free = %12d usable = %12d%n" ;
181187 String method = Platform .isWindows () & isCDDrive (s .name ()) ? "getCDDriveSpace" : "getSpace0" ;
You can’t perform that action at this time.
0 commit comments