From 4eb7cd5b36da74ce2bcb3c05459dee39d56a1c0b Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Tue, 30 Aug 2016 09:58:48 +0800 Subject: 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. --- platform/java/mupdf_native.c | 8 ++++---- platform/java/mupdf_native.h | 2 ++ platform/java/src/com/artifex/mupdf/fitz/TryLaterException.java | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'platform') 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); -- cgit v1.2.3