--- old/src/java.base/share/classes/java/nio/MappedByteBuffer.java 2018-02-05 17:08:13.000000000 -0800 +++ new/src/java.base/share/classes/java/nio/MappedByteBuffer.java 2018-02-05 17:08:13.000000000 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -90,10 +90,8 @@ this.fd = null; } - private void checkMapped() { - if (fd == null) - // Can only happen if a luser explicitly casts a direct byte buffer - throw new UnsupportedOperationException(); + private boolean hasMappedFile() { + return fd != null; } // Returns the distance (in bytes) of the buffer from the page aligned address @@ -131,7 +129,9 @@ * is resident in physical memory */ public final boolean isLoaded() { - checkMapped(); + if (!hasMappedFile()) { + return true; + } if ((address == 0) || (capacity() == 0)) return true; long offset = mappingOffset(); @@ -153,7 +153,9 @@ * @return This buffer */ public final MappedByteBuffer load() { - checkMapped(); + if (!hasMappedFile()) { + return this; + } if ((address == 0) || (capacity() == 0)) return this; long offset = mappingOffset(); @@ -197,7 +199,9 @@ * @return This buffer */ public final MappedByteBuffer force() { - checkMapped(); + if (!hasMappedFile()) { + return this; + } if ((address != 0) && (capacity() != 0)) { long offset = mappingOffset(); force0(fd, mappingAddress(offset), mappingLength(offset));