private static native long nativeWriteFileDescriptor(long nativePtr, FileDescriptor val);
private static native byte[] nativeCreateByteArray(long nativePtr);
+ private static native boolean nativeReadByteArray(long nativePtr, byte[] dest, int destLen);
private static native byte[] nativeReadBlob(long nativePtr);
@FastNative
private static native int nativeReadInt(long nativePtr);
* @param size The new number of bytes in the Parcel.
*/
public final void setDataSize(int size) {
- // STOPSHIP: Try/catch for exception is for temporary debug. Remove once bug resolved
- try {
- updateNativeSize(nativeSetDataSize(mNativePtr, size));
- } catch (IllegalArgumentException iae) {
- Log.e(TAG,"Caught Exception representing a known bug in Parcel",iae);
- Log.wtfStack(TAG, "This flow is using SetDataSize incorrectly");
- }
+ updateNativeSize(nativeSetDataSize(mNativePtr, size));
}
/**
* given byte array.
*/
public final void readByteArray(byte[] val) {
- // TODO: make this a native method to avoid the extra copy.
- byte[] ba = createByteArray();
- if (ba.length == val.length) {
- System.arraycopy(ba, 0, val, 0, ba.length);
- } else {
+ boolean valid = nativeReadByteArray(mNativePtr, val, (val != null) ? val.length : 0);
+ if (!valid) {
throw new RuntimeException("bad array lengths");
}
}