diff options
author | Sven Gothel <[email protected]> | 2019-12-06 09:10:14 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2019-12-06 09:10:14 +0100 |
commit | 5736716ed0598c97273583717ffb9d22a60ca7a4 (patch) | |
tree | 4eae65ac5379ca1142d1d198efc3f1dc12d4da53 /src/java/com/jogamp/gluegen/JavaEmitter.java | |
parent | 50f8d56b5e7eac286e8183b162bddf2d528ffa6b (diff) |
Bug 1412 - JNI: GlueGen JavaEmitter: Check & Handle Exception after calling back into Java
The generated JNI code JVMUtil_NewDirectByteBufferCopy(..)
calls Buffers.newDirectByteBuffer(..) and potential exceptions should be checked.
Diffstat (limited to 'src/java/com/jogamp/gluegen/JavaEmitter.java')
-rw-r--r-- | src/java/com/jogamp/gluegen/JavaEmitter.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java index 02e56a4..577bca4 100644 --- a/src/java/com/jogamp/gluegen/JavaEmitter.java +++ b/src/java/com/jogamp/gluegen/JavaEmitter.java @@ -2554,6 +2554,7 @@ public class JavaEmitter implements GlueEmitter { "#define JINT_MAX_VALUE ((size_t)0x7fffffffU)\n"+ "static const char * sNewBufferImplNotCalled = \"initializeImpl() not called\";\n"+ "static const char * sNewBufferMAX_INT = \"capacity > MAX_INT\";\n"+ + "static const char * sNewBufferEXCPT = \"New direct ByteBuffer threw Exception\";\n"+ "static const char * sNewBufferNULL = \"New direct ByteBuffer is NULL\";\n"+ "\n"+ "static jobject JVMUtil_NewDirectByteBufferCopy(JNIEnv *env, void * source_address, size_t capacity) {\n"+ @@ -2571,6 +2572,12 @@ public class JavaEmitter implements GlueEmitter { " return NULL;\n"+ " }\n"+ " jbyteBuffer = (*env)->CallStaticObjectMethod(env, clazzBuffers, cstrBuffersNew, (jint)capacity);\n"+ + " if( (*env)->ExceptionCheck(env) ) {\n"+ + " (*env)->ExceptionDescribe(env);\n"+ + " (*env)->ExceptionClear(env);\n"+ + " (*env)->FatalError(env, sNewBufferEXCPT);\n"+ + " return NULL;\n"+ + " }\n"+ " if( NULL == jbyteBuffer ) {\n"+ " fprintf(stderr, \"%s %s: size %lu\\n\", sFatalError, sNewBufferNULL, (unsigned long)capacity);\n"+ " (*env)->FatalError(env, sNewBufferNULL);\n"+ |