/// <summary>
        /// Creates a new FastJavaByteArray with the given number of bytes reserved.
        /// </summary>
        /// <param name="length">Number of bytes to reserve</param>
        public FastJavaByteArray(int length)
        {
            if (length <= 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            JniObjectReference localRef = JniEnvironment.Arrays.NewByteArray(length);

            if (!localRef.IsValid)
            {
                throw new OutOfMemoryException();
            }

            // Retain a global reference to the byte array.
            _javaRef = localRef.NewGlobalRef();
            Count    = length;

            bool isCopy = false;

            unsafe
            {
                // Get the pointer to the byte array using the global Handle
                Raw = (byte *)JniEnvironment.Arrays.GetByteArrayElements(_javaRef, &isCopy);
            }
        }
Пример #2
0
 public JavaMethodBase(JniPeerMembers members, JniObjectReference method)
 {
     this.members  = members;
     PeerReference = method.NewGlobalRef();
 }