11/*
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.
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
2424/* @test
2525 * @bug 4563125
2626 * @summary Test size method of FileChannel
27+ * @library /test/lib
2728 * @run main/othervm Size
2829 * @key randomness
2930 */
3031
3132import java .io .*;
3233import java .nio .MappedByteBuffer ;
3334import java .nio .channels .*;
35+ import java .nio .file .FileStore ;
36+ import java .nio .file .Path ;
3437import java .util .Random ;
35-
38+ import jtreg . SkippedException ;
3639
3740/**
3841 * Testing FileChannel's size method.
@@ -65,6 +68,8 @@ private static void testSmallFile() throws Exception {
6568 // Test for bug 4563125
6669 private static void testLargeFile () throws Exception {
6770 File largeFile = new File ("largeFileTest" );
71+ largeFile .deleteOnExit ();
72+
6873 long testSize = ((long )Integer .MAX_VALUE ) * 2 ;
6974 initTestFile (largeFile , 10 );
7075 try (FileChannel fc = new RandomAccessFile (largeFile , "rw" ).getChannel ()) {
@@ -75,8 +80,15 @@ private static void testLargeFile() throws Exception {
7580 + "Expect size " + (testSize + 10 )
7681 + ", actual size " + fc .size ());
7782 }
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 ;
7891 }
79- largeFile .deleteOnExit ();
8092 }
8193
8294 /**
0 commit comments