b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * This code is free software; you can redistribute it and/or modify it
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * under the terms of the GNU General Public License version 2 only, as
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * published by the Free Software Foundation. Oracle designates this
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * particular file as subject to the "Classpath" exception as provided
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * by Oracle in the LICENSE file that accompanied this code.
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * This code is distributed in the hope that it will be useful, but WITHOUT
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * version 2 for more details (a copy is included in the LICENSE file that
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * accompanied this code).
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * You should have received a copy of the GNU General Public License version
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * 2 along with this work; if not, write to the Free Software Foundation,
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * or visit www.oracle.com if you need additional information or have any
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * questions.
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync#warn This file is preprocessed before being compiled
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync extends {#if[byte]?Mapped$Type$Buffer:$Type$Buffer}
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync // Cached unsafe-access object
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync protected static final Unsafe unsafe = Bits.unsafe();
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync // Cached array base offset
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset($type$[].class);
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync // Cached unaligned-access capability
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync protected static final boolean unaligned = Bits.unaligned();
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync // Base address, used in all indexing calculations
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync // NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync // protected long address;
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync // An object attached to this buffer. If this buffer is a view of another
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync // buffer then we use this field to keep a reference to that buffer to
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync // ensure that its memory isn't freed before we are done with it.
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync private static class Deallocator
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync private long address;
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync private long size;
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync private int capacity;
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync private Deallocator(long address, long size, int capacity) {
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync public void run() {
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync // Paranoia
#end[byte]
#if[rw]
} catch (OutOfMemoryError x) {
#else[rw]
super(cap);
#if[rw]
#if[rw]
#else[rw]
#end[byte]
int off)
#if[rw]
#end[byte]
#else[rw]
this.markValue(),
this.position(),
this.limit(),
this.capacity(),
#if[rw]
this.markValue(),
this.position(),
this.limit(),
this.capacity(),
#else[rw]
return duplicate();
#if[rw]
public long address() {
return address;
private long ix(int i) {
#if[rw]
throw new BufferUnderflowException();
#end[!byte]
#else[rw]
throw new ReadOnlyBufferException();
#if[rw]
#else[rw]
throw new ReadOnlyBufferException();
#if[rw]
#else[rw]
throw new ReadOnlyBufferException();
#if[rw]
if (src == this)
throw new IllegalArgumentException();
throw new BufferOverflowException();
#else[rw]
throw new ReadOnlyBufferException();
#if[rw]
throw new BufferOverflowException();
#end[!byte]
#else[rw]
throw new ReadOnlyBufferException();
#if[rw]
discardMark();
#else[rw]
throw new ReadOnlyBufferException();
public boolean isDirect() {
public boolean isReadOnly() {
return {#if[rw]?false:true};
throw new IndexOutOfBoundsException();
} catch (StringIndexOutOfBoundsException x) {
throw new IndexOutOfBoundsException();
throw new IndexOutOfBoundsException();
capacity(),
offset);
#end[char]
#if[boS]
#if[boU]
#end[!byte]
#if[rw]
#else[rw]
throw new ReadOnlyBufferException();
#end[byte]