1
1
/*
2
- * Copyright (c) 2000, 2013 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2000, 2024 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
24
24
/* @test
25
25
* @bug 4563125
26
26
* @summary Test size method of FileChannel
27
+ * @library /test/lib
27
28
* @run main/othervm Size
28
29
* @key randomness
29
30
*/
30
31
31
32
import java .io .*;
32
33
import java .nio .MappedByteBuffer ;
33
34
import java .nio .channels .*;
35
+ import java .nio .file .FileStore ;
36
+ import java .nio .file .Path ;
34
37
import java .util .Random ;
35
-
38
+ import jtreg . SkippedException ;
36
39
37
40
/**
38
41
* Testing FileChannel's size method.
@@ -65,6 +68,8 @@ private static void testSmallFile() throws Exception {
65
68
// Test for bug 4563125
66
69
private static void testLargeFile () throws Exception {
67
70
File largeFile = new File ("largeFileTest" );
71
+ largeFile .deleteOnExit ();
72
+
68
73
long testSize = ((long )Integer .MAX_VALUE ) * 2 ;
69
74
initTestFile (largeFile , 10 );
70
75
try (FileChannel fc = new RandomAccessFile (largeFile , "rw" ).getChannel ()) {
@@ -75,8 +80,15 @@ private static void testLargeFile() throws Exception {
75
80
+ "Expect size " + (testSize + 10 )
76
81
+ ", actual size " + fc .size ());
77
82
}
83
+ } catch (IOException ioe ) {
84
+ if ("File too large" .equals (ioe .getMessage ())) {
85
+ Path p = largeFile .toPath ();
86
+ FileStore store = p .getFileSystem ().provider ().getFileStore (p );
87
+ if ("msdos" .equals (store .type ()))
88
+ throw new SkippedException ("file too big for FAT32" );
89
+ }
90
+ throw ioe ;
78
91
}
79
- largeFile .deleteOnExit ();
80
92
}
81
93
82
94
/**
0 commit comments