From 00ff3f0a7880b8b487382320d8807d55a7cc15e8 Mon Sep 17 00:00:00 2001 From: Stefan Bratanov Date: Tue, 20 Dec 2022 18:34:29 +0200 Subject: [PATCH] [Java binding] return NULL instead of 0 for jbyteArray methods --- bindings/java/c_kzg_4844_jni.c | 8 ++++---- .../testFixtures/java/ethereum/ckzg4844/TestUtils.java | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bindings/java/c_kzg_4844_jni.c b/bindings/java/c_kzg_4844_jni.c index 12062e6..4890066 100644 --- a/bindings/java/c_kzg_4844_jni.c +++ b/bindings/java/c_kzg_4844_jni.c @@ -55,7 +55,7 @@ JNIEXPORT void JNICALL Java_ethereum_ckzg4844_CKZG4844JNI_loadTrustedSetup__Ljav settings = malloc(sizeof(KZGSettings)); if (settings == NULL) { - throw_exception(env, "Failed to allocate memory for the trusted setup."); + throw_exception(env, "Failed to allocate memory for the Trusted Setup."); return; } @@ -95,7 +95,7 @@ JNIEXPORT void JNICALL Java_ethereum_ckzg4844_CKZG4844JNI_loadTrustedSetup___3BJ settings = malloc(sizeof(KZGSettings)); if (settings == NULL) { - throw_exception(env, "Failed to allocate memory for the trusted setup."); + throw_exception(env, "Failed to allocate memory for the Trusted Setup."); return; } @@ -138,7 +138,7 @@ JNIEXPORT jbyteArray JNICALL Java_ethereum_ckzg4844_CKZG4844JNI_computeAggregate if (blobs_size != expected_blobs_size) { throw_invalid_size_exception(env, "Invalid blobs size.", blobs_size, expected_blobs_size); - return 0; + return NULL; } jbyte *blobs_native = (*env)->GetByteArrayElements(env, blobs, NULL); @@ -248,7 +248,7 @@ JNIEXPORT jbyteArray JNICALL Java_ethereum_ckzg4844_CKZG4844JNI_blobToKzgCommitm if (blob_size != BYTES_PER_BLOB) { throw_invalid_size_exception(env, "Invalid blob size.", blob_size, BYTES_PER_BLOB); - return 0; + return NULL; } jbyte *blob_native = (*env)->GetByteArrayElements(env, blob, NULL); diff --git a/bindings/java/src/testFixtures/java/ethereum/ckzg4844/TestUtils.java b/bindings/java/src/testFixtures/java/ethereum/ckzg4844/TestUtils.java index 8e55d69..d0dd7e5 100644 --- a/bindings/java/src/testFixtures/java/ethereum/ckzg4844/TestUtils.java +++ b/bindings/java/src/testFixtures/java/ethereum/ckzg4844/TestUtils.java @@ -75,7 +75,8 @@ public class TestUtils { */ public static List getVerifyKzgProofTestVectors() { final JsonNode jsonNode; - try (InputStream testVectors = readResource("test-vectors/public_verify_kzg_proof.json")) { + try (final InputStream testVectors = readResource( + "test-vectors/public_verify_kzg_proof.json")) { jsonNode = OBJECT_MAPPER.readTree(testVectors); } catch (final IOException ex) { throw new UncheckedIOException(ex);