diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2016-08-30 09:58:48 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2016-09-08 18:53:00 +0800 |
commit | 4eb7cd5b36da74ce2bcb3c05459dee39d56a1c0b (patch) | |
tree | 4f7aee141f0bfad8976f201097f86aa1f1181c77 /platform | |
parent | 9c1db67e6cc05c06bcdd4571b8344e1923ea123f (diff) | |
download | mupdf-4eb7cd5b36da74ce2bcb3c05459dee39d56a1c0b.tar.xz |
JNI: Make exceptions unchecked.
Previously all exceptions thrown by the library would be converted
into checked exceptions, but there was no sensible response to
expect from a client.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/java/mupdf_native.c | 8 | ||||
-rw-r--r-- | platform/java/mupdf_native.h | 2 | ||||
-rw-r--r-- | platform/java/src/com/artifex/mupdf/fitz/TryLaterException.java | 2 |
3 files changed, 7 insertions, 5 deletions
diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c index 2fe37054..13b15e11 100644 --- a/platform/java/mupdf_native.c +++ b/platform/java/mupdf_native.c @@ -57,7 +57,6 @@ static jclass cls_Device; static jclass cls_DisplayList; static jclass cls_Document; static jclass cls_DocumentWriter; -static jclass cls_Exception; static jclass cls_Font; static jclass cls_Image; static jclass cls_IllegalArgumentException; @@ -77,6 +76,7 @@ static jclass cls_PDFObject; static jclass cls_Pixmap; static jclass cls_Point; static jclass cls_Rect; +static jclass cls_RuntimeException; static jclass cls_Shade; static jclass cls_StrokeState; static jclass cls_StructuredText; @@ -200,7 +200,7 @@ static void jni_throw(JNIEnv *env, int type, const char *mess) if (type == FZ_ERROR_TRYLATER) (*env)->ThrowNew(env, cls_TryLaterException, mess); else - (*env)->ThrowNew(env, cls_Exception, mess); + (*env)->ThrowNew(env, cls_RuntimeException, mess); } static void jni_rethrow(JNIEnv *env, fz_context *ctx) @@ -501,9 +501,9 @@ static int find_fids(JNIEnv *env) cls_Object = get_class(&err, env, "java/lang/Object"); mid_Object_toString = get_method(&err, env, "toString", "()Ljava/lang/String;"); - cls_Exception = get_class(&err, env, "java/lang/Exception"); cls_IndexOutOfBoundsException = get_class(&err, env, "java/lang/IndexOutOfBoundsException"); cls_IllegalArgumentException = get_class(&err, env, "java/lang/IllegalArgumentException"); + cls_RuntimeException = get_class(&err, env, "java/lang/RuntimeException"); cls_OutOfMemoryError = get_class(&err, env, "java/lang/OutOfMemoryError"); @@ -520,7 +520,6 @@ static void lose_fids(JNIEnv *env) (*env)->DeleteGlobalRef(env, cls_DisplayList); (*env)->DeleteGlobalRef(env, cls_Document); (*env)->DeleteGlobalRef(env, cls_DocumentWriter); - (*env)->DeleteGlobalRef(env, cls_Exception); (*env)->DeleteGlobalRef(env, cls_Font); (*env)->DeleteGlobalRef(env, cls_Image); (*env)->DeleteGlobalRef(env, cls_IndexOutOfBoundsException); @@ -540,6 +539,7 @@ static void lose_fids(JNIEnv *env) (*env)->DeleteGlobalRef(env, cls_Pixmap); (*env)->DeleteGlobalRef(env, cls_Point); (*env)->DeleteGlobalRef(env, cls_Rect); + (*env)->DeleteGlobalRef(env, cls_RuntimeException); (*env)->DeleteGlobalRef(env, cls_Shade); (*env)->DeleteGlobalRef(env, cls_StrokeState); (*env)->DeleteGlobalRef(env, cls_StructuredText); diff --git a/platform/java/mupdf_native.h b/platform/java/mupdf_native.h index c01e10a0..d43f1526 100644 --- a/platform/java/mupdf_native.h +++ b/platform/java/mupdf_native.h @@ -2737,6 +2737,8 @@ extern "C" { #define com_artifex_mupdf_fitz_TryLaterException_serialVersionUID -3042686055658047285LL #undef com_artifex_mupdf_fitz_TryLaterException_serialVersionUID #define com_artifex_mupdf_fitz_TryLaterException_serialVersionUID -3387516993124229948LL +#undef com_artifex_mupdf_fitz_TryLaterException_serialVersionUID +#define com_artifex_mupdf_fitz_TryLaterException_serialVersionUID -7034897190745766939LL #ifdef __cplusplus } #endif diff --git a/platform/java/src/com/artifex/mupdf/fitz/TryLaterException.java b/platform/java/src/com/artifex/mupdf/fitz/TryLaterException.java index e2d1b88e..e6f34ba4 100644 --- a/platform/java/src/com/artifex/mupdf/fitz/TryLaterException.java +++ b/platform/java/src/com/artifex/mupdf/fitz/TryLaterException.java @@ -1,6 +1,6 @@ package com.artifex.mupdf.fitz; -public class TryLaterException extends Exception +public class TryLaterException extends RuntimeException { TryLaterException(String message) { super(message); |