Add missing native functions, and make naming consistent - #3
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. 💤 Files selected but had no reviewable changes (1)
⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe JNI wrapper was updated for the Java SDK build, expanded node and collection option marshalling, boxed signing overrides, boolean document encryption flags, a corrected block-signature symbol, and previously missing transaction-native operations. ChangesJava JNI bridge
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant DefraTransaction
participant nativewrapper.c
participant Cbindings
participant JavaResult
DefraTransaction->>nativewrapper.c: invoke transaction native operation
nativewrapper.c->>Cbindings: call transaction-handle operation
Cbindings-->>nativewrapper.c: return native Result
nativewrapper.c-->>JavaResult: convert Result to Java result object
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/c/nativewrapper.c (1)
1602-1738: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftConsider extracting shared logic to reduce DefraNode/DefraTransaction duplication.
The 9 newly-added
DefraTransactionnatives are byte-for-byte duplicates of theirDefraNodecounterparts (same body, same underlying C-function calls), as the comment above line 1602 acknowledges. This mirrors dozens of other duplicated pairs already in the file (ACP, P2P, Document, Index methods). Since JNI requires one exported symbol per Java native method, consider factoring each duplicated body into astatichelper (e.g.ACPAddDACPolicyImpl(...)) called by bothJava_..._DefraNode_XNativeandJava_..._DefraTransaction_XNativewrappers, to cut duplication without breaking the JNI export surface.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/c/nativewrapper.c` around lines 1602 - 1738, Extract the shared implementations for the nine newly added DefraTransaction natives into static C helpers, then have both the corresponding Java_source_defra_DefraNode_*Native and Java_source_defra_DefraTransaction_*Native JNI wrappers delegate to them. Preserve each existing signature, argument conversion and release behavior, underlying cbindings call, and JNI export symbol while removing the duplicated method bodies.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/main/c/nativewrapper.c`:
- Around line 1602-1738: Extract the shared implementations for the nine newly
added DefraTransaction natives into static C helpers, then have both the
corresponding Java_source_defra_DefraNode_*Native and
Java_source_defra_DefraTransaction_*Native JNI wrappers delegate to them.
Preserve each existing signature, argument conversion and release behavior,
underlying cbindings call, and JNI export symbol while removing the duplicated
method bodies.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: facdf9bb-e631-4955-80d2-aac11b0c4213
📒 Files selected for processing (5)
src/main/c/nativewrapper.csrc/main/java/source/defra/DefraCollection.javasrc/main/java/source/defra/DefraCollectionOptions.javasrc/main/java/source/defra/DefraNode.javasrc/main/java/source/defra/DefraTransaction.java
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: Build Android Library and Test
🔇 Additional comments (7)
src/main/c/nativewrapper.c (3)
1-24: LGTM!Also applies to: 29-95, 96-107, 117-270, 285-364, 365-1155, 1157-1601, 1740-1920
108-116: 🩺 Stability & AvailabilityNo change needed.
DefraNodeInitOptions()initializesdbPath,listeningAddresses,replicatorRetryIntervals, andpeersto"", so theseGetStringUTFCharscalls are not reaching aNULLjstring in the JNI entry point.
271-284: 🎯 Functional CorrectnessVerify
CollectionOptions.enableSigningtri-state contract in DefraDBThis Java mapping uses
null→0,true→1, andfalse→-1; make suredefra_exports.hand the Go/C consumer enforce the same0/1/-1semantics for signing overrides.src/main/java/source/defra/DefraCollectionOptions.java (1)
9-11: LGTM!src/main/java/source/defra/DefraNode.java (1)
41-41: LGTM!Also applies to: 456-464
src/main/java/source/defra/DefraCollection.java (1)
10-10: LGTM!Also applies to: 59-67
src/main/java/source/defra/DefraTransaction.java (1)
36-36: LGTM!Also applies to: 349-357
This PR adds the following missing methods:
Java_source_defra_DefraTransaction_VerifyBlockSignatureNativeJava_source_defra_DefraTransaction_ListLensesNativeJava_source_defra_DefraTransaction_AddLensNativeJava_source_defra_DefraTransaction_SetLensNativeJava_source_defra_DefraTransaction_DeleteEncryptedIndexNativeJava_source_defra_DefraTransaction_ListEncryptedIndexesNativeJava_source_defra_DefraTransaction_NewEncryptedIndexNativeJava_source_defra_DefraTransaction_TruncateCollectionNativeJava_source_defra_DefraTransaction_DescribeCollectionNativeThis PR also renames
BlockVerifySignaturetoVerifyBlockSignatureto be consistent with our Go codebase.This PR also makes
isEncrypteda boolean, whereas before it was an integer.