Esempio n. 1
0
        public FastJavaByteArray(int length, bool readOnly = true)
        {
            if (length <= 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            IsReadOnly = readOnly;

            IntPtr arrayHandle = JniEnvEx.NewByteArray(length);

            if (arrayHandle == IntPtr.Zero)
            {
                throw new OutOfMemoryException();
            }

            SetHandle(arrayHandle, JniHandleOwnership.DoNotTransfer);
            Count = length;
            bool isCopy = false;

            unsafe
            {
                Raw = JniEnvEx.GetByteArrayElements(arrayHandle, ref isCopy);
            }
        }
Esempio n. 2
0
        public FastJavaByteArray(IntPtr handle, bool readOnly = true) : base(handle, JniHandleOwnership.DoNotTransfer)
        {
            if (handle == IntPtr.Zero)
            {
                throw new ArgumentNullException("handle");
            }

            IsReadOnly = readOnly;

            Count = JNIEnv.GetArrayLength(handle);
            bool isCopy = false;

            unsafe
            {
                Raw = JniEnvEx.GetByteArrayElements(handle, ref isCopy);
            }
        }