ZeroMap.java revision 2362
656N/A/*
656N/A * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
656N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
656N/A *
656N/A * This code is free software; you can redistribute it and/or modify it
656N/A * under the terms of the GNU General Public License version 2 only, as
656N/A * published by the Free Software Foundation.
656N/A *
656N/A * This code is distributed in the hope that it will be useful, but WITHOUT
656N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
656N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
656N/A * version 2 for more details (a copy is included in the LICENSE file that
656N/A * accompanied this code).
656N/A *
656N/A * You should have received a copy of the GNU General Public License version
656N/A * 2 along with this work; if not, write to the Free Software Foundation,
656N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
656N/A *
656N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
656N/A * or visit www.oracle.com if you need additional information or have any
656N/A * questions.
656N/A */
656N/A
656N/A/* @test
656N/A * @bug 4802340
656N/A * @summary Testing force(), load() isLoaded() of zero len MBB
656N/A */
656N/A
656N/Aimport java.io.*;
656N/Aimport java.nio.*;
656N/Aimport java.util.*;
656N/Aimport java.nio.channels.*;
656N/A
656N/Apublic class ZeroMap {
656N/A public static void main(String[] args) throws Exception {
656N/A Random random = new Random();
656N/A long filesize = random.nextInt(1024*1024);
656N/A int cut = random.nextInt((int)filesize);
656N/A File file = new File("Blah");
656N/A RandomAccessFile raf = new RandomAccessFile(file, "rw");
656N/A raf.setLength(filesize);
656N/A FileChannel fc = raf.getChannel();
656N/A MappedByteBuffer buf1 = fc.map(
656N/A FileChannel.MapMode.READ_WRITE, cut, 0);
656N/A buf1.force();
656N/A buf1.load();
656N/A buf1.isLoaded();
656N/A fc.close();
656N/A raf.close();
656N/A }
656N/A}
656N/A