From 19cb01055b46643a8b7228135fd368e7982e6728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=8C=E4=B9=90?= Date: Thu, 24 Jun 2021 11:36:23 +0800 Subject: [PATCH 1/2] fix calling array() on non array based Buffer core by rethrowing the exception --- src/main/java/org/bytedeco/javacpp/tools/Generator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/bytedeco/javacpp/tools/Generator.java b/src/main/java/org/bytedeco/javacpp/tools/Generator.java index 32d3186ad..e7997fedf 100644 --- a/src/main/java/org/bytedeco/javacpp/tools/Generator.java +++ b/src/main/java/org/bytedeco/javacpp/tools/Generator.java @@ -2237,7 +2237,7 @@ void parametersBefore(MethodInformation methodInfo) { out.println(" arr" + j + " = (j" + paramNameLowerCase + "Array)env->CallObjectMethod(arg" + j + ", JavaCPP_arrayMID);"); out.println(" offset" + j + " = env->CallIntMethod(arg" + j + ", JavaCPP_arrayOffsetMID);"); out.println(" if (env->ExceptionOccurred() != NULL) {"); - out.println(" env->ExceptionClear();"); + out.println(" return" + (methodInfo.returnType == void.class ? ";" : " 0;")); out.println(" } else {"); if (methodInfo.criticalRegion) { out.println(" ptr" + j + " = arr" + j + " == NULL ? NULL : (" + typeName[0] + typeName[1] From 5a6b3fd35f5ecd5db0bb08ee19d628951887313f Mon Sep 17 00:00:00 2001 From: Samuel Audet Date: Fri, 25 Jun 2021 10:19:08 +0900 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 094204600..878a8e366 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ + * Prevent `Generator` from swallowing exceptions caught on `Buffer.array()` ([pull #504](https://github.com/bytedeco/javacpp/pull/504)) * Add `enum` classes missing from config files required by GraalVM Native Image * Let `Parser` annotate `&&` parameters with new `@ByRef(true)` value used by `Generator` to call `std::move()` * Fix `Parser` overlooking anonymous `class`, `struct` or `union` with comments after `}` ([issue #501](https://github.com/bytedeco/javacpp/issues/501))