Merge branch 'rubicon' of https://github.com/4jcraft/4jcraft into rubicon

This commit is contained in:
Tropical
2026-03-30 20:14:03 -05:00
413 changed files with 2410 additions and 2722 deletions

View File

@@ -36,7 +36,7 @@ ByteBuffer::~ByteBuffer() {
// Wraps a byte array into a buffer.
// The new buffer will be backed by the given uint8_t array; that is,
// modifications to the buffer will cause the array to be modified and vice
// versa. The new buffer's capacity and limit will be array.length, its position
// versa. The new buffer's capacity and limit will be array.size(), its position
// will be zero, and its mark will be undefined. Its backing array will be the
// given array, and its array offset will be zero.
//
@@ -44,8 +44,8 @@ ByteBuffer::~ByteBuffer() {
// array - The array that will back this buffer
// Returns:
// The new byte buffer
ByteBuffer* ByteBuffer::wrap(byteArray& b) {
return new ByteBuffer(b.length, b.data);
ByteBuffer* ByteBuffer::wrap(std::vector<uint8_t>& b) {
return new ByteBuffer(b.size(), b.data());
}
// Allocates a new byte buffer.
@@ -211,13 +211,13 @@ short ByteBuffer::getShort() {
return value;
}
void ByteBuffer::getShortArray(shortArray& s) {
void ByteBuffer::getShortArray(std::vector<short>& s) {
// TODO 4J Stu - Should this function be writing from the start of the
// buffer, or from position? And should it update position?
assert(s.length >= m_limit / 2);
assert(s.size() >= m_limit / 2);
// 4J Stu - Assumes big endian
memcpy(s.data, buffer, (m_limit - m_position));
memcpy(s.data(), buffer, (m_limit - m_position));
}
// Absolute put method (optional operation).
@@ -320,13 +320,13 @@ ByteBuffer* ByteBuffer::putShort(short value) {
return this;
}
ByteBuffer* ByteBuffer::putShortArray(shortArray& s) {
ByteBuffer* ByteBuffer::putShortArray(std::vector<short>& s) {
// TODO 4J Stu - Should this function be writing from the start of the
// buffer, or from position? And should it update position?
assert(s.length * 2 <= m_limit);
assert(s.size() * 2 <= m_limit);
// 4J Stu - Assumes big endian
memcpy(buffer, s.data, s.length * 2);
memcpy(buffer, s.data(), s.size() * 2);
return this;
}
@@ -371,22 +371,22 @@ ByteBuffer* ByteBuffer::putLong(int64_t value) {
// this buffer. An invocation of this method of the form dst.put(a) behaves in
// exactly the same way as the invocation
//
// dst.put(a, 0, a.length)
// dst.put(a, 0, a.size())
// Returns:
// This buffer
ByteBuffer* ByteBuffer::put(byteArray inputArray) {
if (inputArray.length > remaining())
ByteBuffer* ByteBuffer::put(std::vector<uint8_t>& inputArray) {
if (inputArray.size() > remaining())
assert(false); // TODO 4J Stu - Some kind of exception?
std::copy(inputArray.data, inputArray.data + inputArray.length,
std::copy(inputArray.data(), inputArray.data() + inputArray.size(),
buffer + m_position);
m_position += inputArray.length;
m_position += inputArray.size();
return this;
}
byteArray ByteBuffer::array() { return byteArray(buffer, m_capacity); }
std::vector<uint8_t> ByteBuffer::array() { return std::vector<uint8_t>(buffer, buffer + m_capacity); }
// Creates a view of this byte buffer as an int buffer.
// The content of the new buffer will start at this buffer's current position.

View File

@@ -51,11 +51,11 @@ FloatBuffer* FloatBuffer::put(float f) {
// array. An invocation of this method of the form src.get(a) behaves in exactly
// the same way as the invocation
//
// src.get(a, 0, a.length)
// src.get(a, 0, a.size())
// Returns:
// This buffer
void FloatBuffer::get(floatArray* dst) {
assert(dst->length <= m_capacity);
void FloatBuffer::get(std::vector<float>* dst) {
assert(dst->size() <= m_capacity);
for (unsigned int i = 0; i < dst->length; i++) dst->data[i] = buffer[i];
for (unsigned int i = 0; i < dst->size(); i++) (*dst)[i] = buffer[i];
}

View File

@@ -5,7 +5,7 @@
// the underlying output stream. size - the buffer size.
BufferedOutputStream::BufferedOutputStream(OutputStream* out, int size) {
stream = out;
buf = byteArray(size);
buf = std::vector<uint8_t>(size);
count = 0;
}
@@ -14,7 +14,6 @@ BufferedOutputStream::~BufferedOutputStream() {
// TODO: ArrayWithLength.h doesnt have a destructor.
// this wouldnt need to be done manually.
// but for some reason the destructor is commented out in the source code?
delete[] buf.data;
}
// Flushes this buffered output stream. This forces any buffered output bytes to
@@ -61,11 +60,11 @@ void BufferedOutputStream::close() {
// b - the data.
// off - the start offset in the data.
// len - the number of bytes to write.
void BufferedOutputStream::write(byteArray b, unsigned int offset,
void BufferedOutputStream::write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) {
// Over the length of what we can store in our buffer - just flush the
// buffer and output directly
if (length >= buf.length) {
if (length >= buf.size()) {
flush();
stream->write(b, offset, length);
} else {
@@ -75,13 +74,13 @@ void BufferedOutputStream::write(byteArray b, unsigned int offset,
}
}
// Writes b.length bytes to this output stream.
// Writes b.size() bytes to this output stream.
// The write method of FilterOutputStream calls its write method of three
// arguments with the arguments b, 0, and b.length.
// arguments with the arguments b, 0, and b.size().
//
// Note that this method does not call the one-argument write method of its
// underlying stream with the single argument b.
void BufferedOutputStream::write(byteArray b) { write(b, 0, b.length); }
void BufferedOutputStream::write(const std::vector<uint8_t>& b) { write(b, 0, b.size()); }
// Writes the specified byte to this buffered output stream.
// Overrides:
@@ -90,7 +89,7 @@ void BufferedOutputStream::write(byteArray b) { write(b, 0, b.length); }
// b - the byte to be written.
void BufferedOutputStream::write(unsigned int b) {
buf[count++] = (uint8_t)b;
if (count == buf.length) {
if (count == buf.size()) {
flush();
}
}

View File

@@ -2,21 +2,21 @@
// Creates ByteArrayInputStream that uses buf as its buffer array. The initial
// value of pos is offset and the initial value of count is the minimum of
// offset+length and buf.length. The buffer array is not copied. The buffer's
// offset+length and buf.size(). The buffer array is not copied. The buffer's
// mark is set to the specified offset. Parameters: buf - the input buffer.
// offset - the offset in the buffer of the first byte to read.
// length - the maximum number of bytes to read from the buffer.
ByteArrayInputStream::ByteArrayInputStream(byteArray buf, unsigned int offset,
ByteArrayInputStream::ByteArrayInputStream(std::vector<uint8_t>& buf, unsigned int offset,
unsigned int length)
: pos(offset), count(std::min(offset + length, buf.length)), mark(offset) {
: pos(offset), count(std::min(offset + length, (unsigned int)buf.size())), mark(offset) {
this->buf = buf;
}
// Creates a ByteArrayInputStream so that it uses buf as its buffer array. The
// buffer array is not copied. The initial value of pos is 0 and the initial
// value of count is the length of buf. Parameters: buf - the input buffer.
ByteArrayInputStream::ByteArrayInputStream(byteArray buf)
: pos(0), count(buf.length), mark(0) {
ByteArrayInputStream::ByteArrayInputStream(std::vector<uint8_t>& buf)
: pos(0), count(buf.size()), mark(0) {
this->buf = buf;
}
@@ -43,17 +43,17 @@ int ByteArrayInputStream::read() {
// The first byte read is stored into element b[0], the next one into b[1], and
// so on. The number of bytes read is, at most, equal to the length of b. Let k
// be the number of bytes actually read; these bytes will be stored in elements
// b[0] through b[k-1], leaving elements b[k] through b[b.length-1] unaffected.
// b[0] through b[k-1], leaving elements b[k] through b[b.size()-1] unaffected.
//
// The read(b) method for class InputStream has the same effect as:
//
// read(b, 0, b.length)
// read(b, 0, b.size())
// Parameters:
// b - the buffer into which the data is read.
// Returns:
// the total number of bytes read into the buffer, or -1 is there is no more
// data because the end of the stream has been reached.
int ByteArrayInputStream::read(byteArray b) { return read(b, 0, b.length); }
int ByteArrayInputStream::read(std::vector<uint8_t>& b) { return read(b, 0, b.size()); }
// Reads up to len bytes of data into an array of bytes from this input stream.
// If pos equals count, then -1 is returned to indicate end of file. Otherwise,
@@ -68,7 +68,7 @@ int ByteArrayInputStream::read(byteArray b) { return read(b, 0, b.length); }
// Returns:
// the total number of bytes read into the buffer, or -1 if there is no more
// data because the end of the stream has been reached.
int ByteArrayInputStream::read(byteArray b, unsigned int offset,
int ByteArrayInputStream::read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) {
if (pos == count) return -1;
@@ -105,5 +105,4 @@ int64_t ByteArrayInputStream::skip(int64_t n) {
}
ByteArrayInputStream::~ByteArrayInputStream() {
if (buf.data != nullptr) delete[] buf.data;
}

View File

@@ -4,18 +4,17 @@
// bytes, though its size increases if necessary.
ByteArrayOutputStream::ByteArrayOutputStream() {
count = 0;
buf = byteArray(32);
buf = std::vector<uint8_t>(32);
}
// Creates a new byte array output stream, with a buffer capacity of the
// specified size, in bytes. Parameters: size - the initial size.
ByteArrayOutputStream::ByteArrayOutputStream(unsigned int size) {
count = 0;
buf = byteArray(size);
buf = std::vector<uint8_t>(size);
}
ByteArrayOutputStream::~ByteArrayOutputStream() {
if (buf.data != nullptr) delete[] buf.data;
}
// Writes the specified byte to this byte array output stream.
@@ -23,27 +22,27 @@ ByteArrayOutputStream::~ByteArrayOutputStream() {
// b - the byte to be written.
void ByteArrayOutputStream::write(unsigned int b) {
// If we will fill the buffer we need to make it bigger
if (count + 1 >= buf.length) buf.resize(buf.length * 2);
if (count + 1 >= buf.size()) buf.resize(buf.size() * 2);
buf[count] = (uint8_t)b;
count++;
}
// Writes b.length bytes from the specified byte array to this output stream.
// Writes b.size() bytes from the specified byte array to this output stream.
// The general contract for write(b) is that it should have exactly the same
// effect as the call write(b, 0, b.length).
void ByteArrayOutputStream::write(byteArray b) { write(b, 0, b.length); }
// effect as the call write(b, 0, b.size()).
void ByteArrayOutputStream::write(const std::vector<uint8_t>& b) { write(b, 0, b.size()); }
// Writes len bytes from the specified byte array starting at offset off to this
// byte array output stream. Parameters: b - the data. off - the start offset in
// the data. len - the number of bytes to write.
void ByteArrayOutputStream::write(byteArray b, unsigned int offset,
void ByteArrayOutputStream::write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) {
assert(b.length >= offset + length);
assert(b.size() >= offset + length);
// If we will fill the buffer we need to make it bigger
if (count + length >= buf.length)
buf.resize(std::max(count + length + 1, buf.length * 2));
if (count + length >= buf.size())
buf.resize(std::max(count + length + 1, (unsigned int)(buf.size() * 2)));
std::memcpy(&buf[count], &b[offset], length);
// std::copy( b->data+offset, b->data+offset+length, buf->data + count ); //
@@ -61,8 +60,8 @@ void ByteArrayOutputStream::close() {}
// output stream and the valid contents of the buffer have been copied into it.
// Returns:
// the current contents of this output stream, as a byte array.
byteArray ByteArrayOutputStream::toByteArray() {
byteArray out(count);
memcpy(out.data, buf.data, count);
std::vector<uint8_t> ByteArrayOutputStream::toByteArray() {
std::vector<uint8_t> out(count);
memcpy(out.data(), buf.data(), count);
return out;
}

View File

@@ -36,11 +36,11 @@ int DataInputStream::read() {
// The first byte read is stored into element b[0], the next one into b[1], and
// so on. The number of bytes read is, at most, equal to the length of b. Let k
// be the number of bytes actually read; these bytes will be stored in elements
// b[0] through b[k-1], leaving elements b[k] through b[b.length-1] unaffected.
// b[0] through b[k-1], leaving elements b[k] through b[b.size()-1] unaffected.
//
// The read(b) method has the same effect as:
//
// read(b, 0, b.length)
// read(b, 0, b.size())
//
// Overrides:
// read in class FilterInputStream
@@ -49,14 +49,14 @@ int DataInputStream::read() {
// Returns:
// the total number of bytes read into the buffer, or -1 if there is no more
// data because the end of the stream has been reached.
int DataInputStream::read(byteArray b) {
int DataInputStream::read(std::vector<uint8_t>& b) {
if (stream == nullptr) {
fprintf(stderr,
"DataInputStream::read(byteArray) called but underlying stream is "
"DataInputStream::read(std::vector<uint8_t>) called but underlying stream is "
"nullptr\n");
return -1;
}
return read(b, 0, b.length);
return read(b, 0, b.size());
}
// Reads up to len bytes of data from the contained input stream into an array
@@ -77,7 +77,7 @@ int DataInputStream::read(byteArray b) {
// b[off+len-1] unaffected.
//
// In every case, elements b[0] through b[off] and elements b[off+len] through
// b[b.length-1] are unaffected.
// b[b.size()-1] are unaffected.
//
// Overrides:
// read in class FilterInputStream
@@ -88,11 +88,11 @@ int DataInputStream::read(byteArray b) {
// Returns:
// the total number of bytes read into the buffer, or -1 if there is no more
// data because the end of the stream has been reached.
int DataInputStream::read(byteArray b, unsigned int offset,
int DataInputStream::read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) {
if (stream == nullptr) {
fprintf(stderr,
"DataInputStream::read(byteArray,offset,length) called but "
"DataInputStream::read(std::vector<uint8_t>,offset,length) called but "
"underlying stream is nullptr\n");
return -1;
}
@@ -168,10 +168,10 @@ wchar_t DataInputStream::readChar() {
// b. The number of bytes read is equal to the length of b. This method blocks
// until one of the following conditions occurs:
//
// b.length bytes of input data are available, in which case a normal return is
// b.size() bytes of input data are available, in which case a normal return is
// made. End of file is detected, in which case an EOFException is thrown. An
// I/O error occurs, in which case an IOException other than EOFException is
// thrown. If b is null, a NullPointerException is thrown. If b.length is zero,
// thrown. If b is null, a NullPointerException is thrown. If b.size() is zero,
// then no bytes are read. Otherwise, the first byte read is stored into element
// b[0], the next one into b[1], and so on. If an exception is thrown from this
// method, then it may be that some but not all bytes of b have been updated
@@ -179,18 +179,18 @@ wchar_t DataInputStream::readChar() {
//
// Parameters:
// b - the buffer into which the data is read.
bool DataInputStream::readFully(byteArray b) {
bool DataInputStream::readFully(std::vector<uint8_t>& b) {
// TODO 4J Stu - I am not entirely sure if this matches the implementation
// of the Java library
// TODO 4J Stu - Need to handle exceptions here is we throw them in other
// InputStreams
if (stream == nullptr) {
fprintf(stderr,
"DataInputStream::readFully(byteArray) but underlying stream is "
"DataInputStream::readFully(std::vector<uint8_t>) but underlying stream is "
"nullptr\n");
return false;
}
for (unsigned int i = 0; i < b.length; i++) {
for (unsigned int i = 0; i < b.size(); i++) {
int byteRead = stream->read();
if (byteRead == -1) {
return false;
@@ -201,18 +201,18 @@ bool DataInputStream::readFully(byteArray b) {
return true;
}
bool DataInputStream::readFully(charArray b) {
bool DataInputStream::readFully(std::vector<char>& b) {
// TODO 4J Stu - I am not entirely sure if this matches the implementation
// of the Java library
// TODO 4J Stu - Need to handle exceptions here is we throw them in other
// InputStreams
if (stream == nullptr) {
fprintf(stderr,
"DataInputStream::readFully(charArray) but underlying stream is "
"DataInputStream::readFully(std::vector<char>) but underlying stream is "
"nullptr\n");
return false;
}
for (unsigned int i = 0; i < b.length; i++) {
for (unsigned int i = 0; i < b.size(); i++) {
int byteRead = stream->read();
if (byteRead == -1) {
return false;

View File

@@ -40,20 +40,20 @@ void DataOutputStream::flush() {
stream->flush();
}
// Writes b.length bytes from the specified byte array to this output stream.
// Writes b.size() bytes from the specified byte array to this output stream.
// The general contract for write(b) is that it should have exactly the same
// effect as the call write(b, 0, b.length). Parameters: b - the data.
void DataOutputStream::write(byteArray b) { write(b, 0, b.length); }
// effect as the call write(b, 0, b.size()). Parameters: b - the data.
void DataOutputStream::write(const std::vector<uint8_t>& b) { write(b, 0, b.size()); }
// Writes len bytes from the specified byte array starting at offset off to the
// underlying output stream. If no exception is thrown, the counter written is
// incremented by len. Parameters: b - the data. off - the start offset in the
// data. len - the number of bytes to write.
void DataOutputStream::write(byteArray b, unsigned int offset,
void DataOutputStream::write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) {
if (stream == nullptr) {
fprintf(stderr,
"DataOutputStream::write(byteArray,...) called but underlying "
"DataOutputStream::write(std::vector<uint8_t>,...) called but underlying "
"stream is nullptr\n");
return;
}
@@ -224,7 +224,7 @@ void DataOutputStream::writeUTF(const std::wstring& str) {
// throw new UTFDataFormatException(
// "encoded string too long: " + utflen + " bytes");
byteArray bytearr(utflen + 2);
std::vector<uint8_t> bytearr(utflen + 2);
bytearr[count++] = (uint8_t)((utflen >> 8) & 0xFF);
bytearr[count++] = (uint8_t)((utflen >> 0) & 0xFF);
@@ -251,7 +251,6 @@ void DataOutputStream::writeUTF(const std::wstring& str) {
}
}
write(bytearr, 0, utflen + 2);
delete[] bytearr.data;
}
// 4J Added

View File

@@ -80,18 +80,18 @@ int FileInputStream::read() {
return static_cast<int>(byteRead);
}
// Reads up to b.length bytes of data from this input stream into an array of
// Reads up to b.size() bytes of data from this input stream into an array of
// bytes. This method blocks until some input is available. Parameters: b - the
// buffer into which the data is read. Returns: the total number of bytes read
// into the buffer, or -1 if there is no more data because the end of the file
// has been reached.
int FileInputStream::read(byteArray b) {
int FileInputStream::read(std::vector<uint8_t>& b) {
if (m_fileHandle == nullptr) {
return -1;
}
const size_t numberOfBytesRead =
std::fread(b.data, 1, b.length, m_fileHandle);
std::fread(b.data(), 1, b.size(), m_fileHandle);
if (std::ferror(m_fileHandle) != 0) {
assert(0);
@@ -110,10 +110,10 @@ int FileInputStream::read(byteArray b) {
// b len - the maximum number of bytes read. Returns: the total number of bytes
// read into the buffer, or -1 if there is no more data because the end of the
// file has been reached.
int FileInputStream::read(byteArray b, unsigned int offset,
int FileInputStream::read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) {
// 4J Stu - We don't want to read any more than the array buffer can hold
assert(length <= (b.length - offset));
assert(length <= (b.size() - offset));
if (m_fileHandle == nullptr) {
return -1;

View File

@@ -56,20 +56,20 @@ void FileOutputStream::write(unsigned int b) {
}
}
// Writes b.length bytes from the specified byte array to this file output
// Writes b.size() bytes from the specified byte array to this file output
// stream. Parameters: b - the data.
void FileOutputStream::write(byteArray b) {
void FileOutputStream::write(const std::vector<uint8_t>& b) {
if (m_fileHandle == nullptr) {
return;
}
const size_t numberOfBytesWritten =
std::fwrite(b.data, 1, b.length, m_fileHandle);
std::fwrite(b.data(), 1, b.size(), m_fileHandle);
const int result = std::ferror(m_fileHandle);
if (result != 0) {
// TODO 4J Stu - Some kind of error handling
} else if (numberOfBytesWritten == 0 || numberOfBytesWritten != b.length) {
} else if (numberOfBytesWritten == 0 || numberOfBytesWritten != b.size()) {
// File pointer is past the end of the file
}
}
@@ -77,10 +77,10 @@ void FileOutputStream::write(byteArray b) {
// Writes len bytes from the specified byte array starting at offset off to this
// file output stream. Parameters: b - the data. off - the start offset in the
// data. len - the number of bytes to write.
void FileOutputStream::write(byteArray b, unsigned int offset,
void FileOutputStream::write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) {
// 4J Stu - We don't want to write any more than the array buffer holds
assert(length <= (b.length - offset));
assert(length <= (b.size() - offset));
if (m_fileHandle == nullptr) {
return;

View File

@@ -64,14 +64,14 @@ int IntBuffer::get(unsigned int index) {
// except that it first checks that there is sufficient space in this buffer and
// it is potentially much more efficient. Parameters: src - The array from which
// ints are to be read offset - The offset within the array of the first int to
// be read; must be non-negative and no larger than array.length length - The
// be read; must be non-negative and no larger than array.size() length - The
// number of ints to be read from the given array; must be non-negative and no
// larger than array.length - offset Returns: This buffer
IntBuffer* IntBuffer::put(intArray* inputArray, unsigned int offset,
// larger than array.size() - offset Returns: This buffer
IntBuffer* IntBuffer::put(std::vector<int>* inputArray, unsigned int offset,
unsigned int length) {
assert(offset + length < inputArray->length);
assert(offset + length < inputArray->size());
std::copy(inputArray->data + offset, inputArray->data + offset + length,
std::copy(inputArray->data() + offset, inputArray->data() + offset + length,
buffer + m_position);
m_position += length;
@@ -79,14 +79,14 @@ IntBuffer* IntBuffer::put(intArray* inputArray, unsigned int offset,
return this;
}
IntBuffer* IntBuffer::put(intArray inputArray) {
if (inputArray.length > remaining())
IntBuffer* IntBuffer::put(std::vector<int>& inputArray) {
if (inputArray.size() > remaining())
assert(false); // TODO 4J Stu - Some kind of exception?
std::copy(inputArray.data, inputArray.data + inputArray.length,
std::copy(inputArray.data(), inputArray.data() + inputArray.size(),
buffer + m_position);
m_position += inputArray.length;
m_position += inputArray.size();
return this;
}

View File

@@ -7,37 +7,37 @@
#include "java/System.h"
template <class T>
void System::arraycopy(arrayWithLength<T> src, unsigned int srcPos,
arrayWithLength<T>* dst, unsigned int dstPos,
void System::arraycopy(const std::vector<T>& src, unsigned int srcPos,
std::vector<T>* dst, unsigned int dstPos,
unsigned int length) {
assert(srcPos >= 0 && srcPos <= src.length);
assert(srcPos + length <= src.length);
assert(dstPos + length <= dst->length);
assert(srcPos >= 0 && srcPos <= src.size());
assert(srcPos + length <= src.size());
assert(dstPos + length <= dst->size());
std::copy(src.data + srcPos, src.data + srcPos + length,
dst->data + dstPos);
std::copy(src.data() + srcPos, src.data() + srcPos + length,
dst->data() + dstPos);
}
ArrayCopyFunctionDefinition(Node*) ArrayCopyFunctionDefinition(Biome*)
void System::arraycopy(arrayWithLength<uint8_t> src, unsigned int srcPos,
arrayWithLength<uint8_t>* dst, unsigned int dstPos,
void System::arraycopy(const std::vector<uint8_t>& src, unsigned int srcPos,
std::vector<uint8_t>* dst, unsigned int dstPos,
unsigned int length) {
assert(srcPos >= 0 && srcPos <= src.length);
assert(srcPos + length <= src.length);
assert(dstPos + length <= dst->length);
assert(srcPos >= 0 && srcPos <= src.size());
assert(srcPos + length <= src.size());
assert(dstPos + length <= dst->size());
memcpy(dst->data + dstPos, src.data + srcPos, length);
memcpy(dst->data() + dstPos, src.data() + srcPos, length);
}
void System::arraycopy(arrayWithLength<int> src, unsigned int srcPos,
arrayWithLength<int>* dst, unsigned int dstPos,
void System::arraycopy(const std::vector<int>& src, unsigned int srcPos,
std::vector<int>* dst, unsigned int dstPos,
unsigned int length) {
assert(srcPos >= 0 && srcPos <= src.length);
assert(srcPos + length <= src.length);
assert(dstPos + length <= dst->length);
assert(srcPos >= 0 && srcPos <= src.size());
assert(srcPos + length <= src.size());
assert(dstPos + length <= dst->size());
memcpy(dst->data + dstPos, src.data + srcPos, length * sizeof(int));
memcpy(dst->data() + dstPos, src.data() + srcPos, length * sizeof(int));
}
// TODO 4J Stu - These time functions may suffer from accuracy and we might have