natCoreInputStream.cc [plain text]
#include <config.h>
#include <gcj/cni.h>
#include <jvm.h>
#include <string.h>
#include <java/lang/NullPointerException.h>
#include <java/lang/ArrayIndexOutOfBoundsException.h>
#include <gnu/java/net/protocol/core/CoreInputStream.h>
jint
gnu::java::net::protocol::core::CoreInputStream::unsafeGetByte (jlong offset)
{
return ((char*) ptr) [offset];
}
jint
gnu::java::net::protocol::core::CoreInputStream::copyIntoByteArray (jbyteArray dest,
jint offset,
jint numBytes)
{
if (!dest)
throw new ::java::lang::NullPointerException;
jsize destSize = JvGetArrayLength (dest);
if (offset < 0 || numBytes < 0 || offset + numBytes < 0
|| offset + numBytes > destSize
|| pos + numBytes > count)
throw new ::java::lang::ArrayIndexOutOfBoundsException;
void *pcore = (void *) &((char*) ptr) [pos];
void *pdest = (void *) (elements (dest) + offset);
memcpy (pdest, pcore, numBytes);
return 0;
}