/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#if[rw]
#else[rw]
implements DirectBuffer
{
#if[rw]
// Cached unsafe-access object
// Cached array base offset
// Cached unaligned-access capability
// Base address, used in all indexing calculations
// NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress
// protected long address;
// An object attached to this buffer. If this buffer is a view of another
// buffer then we use this field to keep a reference to that buffer to
// ensure that its memory isn't freed before we are done with it.
public Object attachment() {
return att;
}
#if[byte]
private static class Deallocator
implements Runnable
{
private long address;
private long size;
private int capacity;
assert (address != 0);
}
public void run() {
if (address == 0) {
// Paranoia
return;
}
address = 0;
}
}
#else[byte]
#end[byte]
#if[byte]
// Primary constructor
//
#if[rw]
long base = 0;
try {
} catch (OutOfMemoryError x) {
throw x;
}
// Round up to page boundary
} else {
}
#else[rw]
super(cap);
}
#if[rw]
// Invoked to construct a direct ByteBuffer referring to the block of
// memory. A given arbitrary object may also be attached to the buffer.
//
}
// Invoked only by JNI: NewDirectByteBuffer(void*, long)
//
}
// For memory-mapped buffers -- invoked by FileChannelImpl via reflection
//
{
#if[rw]
#else[rw]
}
#end[byte]
// For duplicates and slices
//
int off)
{
#if[rw]
#if[byte]
#end[byte]
#else[rw]
}
assert (off >= 0);
}
this.markValue(),
this.position(),
this.limit(),
this.capacity(),
0);
}
#if[rw]
this.markValue(),
this.position(),
this.limit(),
this.capacity(),
0);
#else[rw]
return duplicate();
}
#if[rw]
public long address() {
return address;
}
private long ix(int i) {
return address + (i << $LG_BYTES_PER_VALUE$);
}
}
}
#if[rw]
throw new BufferUnderflowException();
#if[!byte]
offset << $LG_BYTES_PER_VALUE$,
length << $LG_BYTES_PER_VALUE$);
else
#end[!byte]
offset << $LG_BYTES_PER_VALUE$,
length << $LG_BYTES_PER_VALUE$);
} else {
}
return this;
#else[rw]
throw new ReadOnlyBufferException();
}
#if[rw]
return this;
#else[rw]
throw new ReadOnlyBufferException();
}
#if[rw]
return this;
#else[rw]
throw new ReadOnlyBufferException();
}
#if[rw]
if (src == this)
throw new IllegalArgumentException();
throw new BufferOverflowException();
} else {
}
return this;
#else[rw]
throw new ReadOnlyBufferException();
}
#if[rw]
throw new BufferOverflowException();
#if[!byte]
else
#end[!byte]
} else {
}
return this;
#else[rw]
throw new ReadOnlyBufferException();
}
#if[rw]
discardMark();
return this;
#else[rw]
throw new ReadOnlyBufferException();
}
public boolean isDirect() {
return true;
}
public boolean isReadOnly() {
return {#if[rw]?false:true};
}
#if[char]
throw new IndexOutOfBoundsException();
try {
} catch (StringIndexOutOfBoundsException x) {
throw new IndexOutOfBoundsException();
}
}
// --- Methods to support CharSequence ---
throw new IndexOutOfBoundsException();
-1,
capacity(),
offset);
}
#end[char]
#if[!byte]
#if[boS]
#if[boU]
}
#end[!byte]
#if[byte]
byte _get(int i) { // package-private
}
void _put(int i, byte b) { // package-private
#if[rw]
#else[rw]
throw new ReadOnlyBufferException();
}
// #BIN
//
// Binary-data access methods for short, char, int, long, float,
// and double will be inserted here
#end[byte]
}