@@ -46,6 +46,11 @@ void aws_jni_throw_runtime_exception(JNIEnv *env, const char *msg, ...);
4646 ******************************************************************************/
4747void aws_jni_throw_null_pointer_exception (JNIEnv * env , const char * msg , ...);
4848
49+ /*******************************************************************************
50+ * Throws java OutOfMemoryError
51+ ******************************************************************************/
52+ void aws_jni_throw_out_of_memory_exception (JNIEnv * env , const char * msg , ...);
53+
4954/*******************************************************************************
5055 * Throws java IllegalArgumentException
5156 ******************************************************************************/
@@ -172,19 +177,40 @@ void aws_jni_byte_cursor_from_jstring_release(JNIEnv *env, jstring str, struct a
172177/*******************************************************************************
173178 * aws_jni_byte_cursor_from_jbyteArray_acquire - Creates an aws_byte_cursor from the
174179 * bytes extracted from the supplied jbyteArray.
175- * The aws_byte_cursor MUST be given to aws_jni_byte_cursor_from jstring_release () when
180+ * The aws_byte_cursor MUST be given to aws_jni_byte_cursor_from_jbyteArray_release () when
176181 * it's no longer needed, or it will leak.
177182 *
178183 * If there is an error, the returned aws_byte_cursor.ptr will be NULL and
179184 * and a java exception is being thrown.
180185 ******************************************************************************/
181186struct aws_byte_cursor aws_jni_byte_cursor_from_jbyteArray_acquire (JNIEnv * env , jbyteArray str );
182187
188+ /*******************************************************************************
189+ * aws_jni_byte_cursor_from_jbyteArray_critical_acquire - Creates an aws_byte_cursor from the
190+ * bytes extracted from the supplied jbyteArray.
191+ * The aws_byte_cursor MUST be given to aws_jni_byte_cursor_from_jbyteArray_critical_release() when
192+ * it's no longer needed, or it will leak.
193+ *
194+ * If there is an error, the returned aws_byte_cursor.ptr will be NULL and
195+ * and a java exception is being thrown.
196+ * **** WARNING: Here be dragons ****
197+ * This function uses critical jvm functions to access memory, which is faster, but comes
198+ * with a litany of limitations, so use at your own risk.
199+ * Spending too much time in a critical section will stall gc and mem functionality, so under
200+ * no conditions use jni functions while in critical section on current thread (ok, on other threads).
201+ ******************************************************************************/
202+ struct aws_byte_cursor aws_jni_byte_cursor_from_jbyteArray_critical_acquire (JNIEnv * env , jbyteArray str );
203+
183204/********************************************************************************
184205 * aws_jni_byte_cursor_from_jbyteArray_release - Releases the array back to the JVM
185206 ********************************************************************************/
186207void aws_jni_byte_cursor_from_jbyteArray_release (JNIEnv * env , jbyteArray str , struct aws_byte_cursor cur );
187208
209+ /********************************************************************************
210+ * aws_jni_byte_cursor_from_jbyteArray_critical_release - Releases critical array access back to JVM
211+ ********************************************************************************/
212+ void aws_jni_byte_cursor_from_jbyteArray_critical_release (JNIEnv * env , jbyteArray str , struct aws_byte_cursor cur );
213+
188214/*******************************************************************************
189215 * aws_jni_byte_cursor_from_direct_byte_buffer - Creates an aws_byte_cursor from the
190216 * direct byte buffer. Note that the buffer is not reference pinned, so the cursor
0 commit comments