You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add AI policy (so we have now rules for using AI in repositories)
document supported linux archs in README
big change: split of C++ bridge
register static method for Rust callbacks with primitive and reference types
add JavaArray, Type::parse, and direct ByteBuffer helpers on Env
breaking changes
Vm::env and Vm::attach_current_thread replace Vm::get_jni_env and Vm::detach_current_thread
AttachGuard
detaches on drop only when attach_current_thread attached the thread
find_class, define_class, and new_string now live on Env instead of Vm
Class, Object, JavaString, and Output now use the 'env lifetime, and Method and Value now take lifetime
parameters
matches on Value need the new Object, String, Class, and Array variants, and matches on Output need Class and Array
usagi_vm_attach_current_thread, usagi_class_register_method, and UsagiMethodCallback changed sigs in include/usagi.h, and usagi_test_register_add and usagi_test_register_fail no longer exist
assisted with:
model: Gemini 4 Hydrogen (gemini-4-hydrogen)
harness: Pi
kinda got busy with studying.. didn't really want to stall on progress and wanna do something, so yeah!
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
The pull request splits the C++ JNI bridge and expands its C and Rust APIs. It adds environment and reference types, array and direct-buffer operations, and callback-backed Java method registration and invocation. It also updates repository policy, platform documentation, and CI configuration.
Changes: JNI bridge and Rust API
Layer / File(s)
Summary
Native API and runtime include/usagi.h, src/ffi.rs, cpp/internal.hpp, cpp/error.cpp, cpp/vm.cpp, cpp/object.cpp, cpp/bridge.cpp, CMakeLists.txt, build.rs
The C++ bridge implementation is removed and its functionality is split across focused source files. The C API and Rust FFI declarations add VM, object, error, and JNI reference operations. Build configuration lists the new sources and recursively tracks files under the JNI source and include trees.
Java arrays and direct buffers cpp/array.cpp, cpp/bytebuffer.cpp, src/array.rs, src/env.rs, tests/phase2.rs
The APIs create and access primitive and object arrays, transfer array regions, and pin primitive elements. They also create and query direct byte buffers. Integration tests cover array behavior, thread sharing, and buffer access.
Vm::env returns an Env, and thread attachment returns an AttachGuard. Objects and strings use environment lifetimes and support conversion to GlobalRef; global references can be rebound through an environment from the same VM. Error::new is public, and FFI tests use the environment API.
Java method calls support object, class, string, and array values. Classes can register Rust callbacks as static methods. The callback bridge converts arguments and results and reports errors. Signature parsing validates field descriptors and class names. Tests cover conversions, callback replacement, exceptions, and multithreaded calls.
Repository guidance
Layer / File(s)
Summary
Contribution policy and platform status AI_POLICY.md, README.md
AI_POLICY.md adds requirements for AI-assisted bug reports and contributions. The README states that Linux on x86_64 and aarch64 are supported and other platforms are unsupported.
CI and advisory configuration
Layer / File(s)
Summary
Workflow and advisory settings .github/workflows/audit.yml, .github/workflows/ci.yml, deny.toml
The workflows update pinned versions of cargo-deny-action and cachix/install-nix-action. The advisory configuration sets unmaintained to "all".
Path filters excluded changed files. This rating applies only to the assessed changes.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "feat!: split Vm & Env, add callbacks, arrays & ByteBuffers (etc)" matches the main changes in the changeset. The diff splits the VM and environment APIs into Vm and Env (src/vm.rs, src/env.…
Description check
The description is related to the changeset. It lists the AI policy, the README Linux architecture note, the C++ bridge split, static method registration for Rust callbacks, JavaArray, Type::parse, an…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "feat!: split Vm & Env, add callbacks, arrays & ByteBuffers (etc)" matches the main changes in the changeset. The diff splits the VM and environment APIs into Vm and Env (src/vm.rs, src/env.rs), adds JNI callback registration (src/callback.rs, cpp/registry.cpp), adds primitive and object array support (src/array.rs, cpp/array.cpp), and adds direct ByteBuffer helpers (src/env.rs, cpp/bytebuffer.cpp). The title does not mention the AI policy, README status, or the C++ bridge split, which are smaller parts of the change. The "(etc)" suffix is informal but does not make the title misleading.
Full details: Description check
Explanation
The description is related to the changeset. It lists the AI policy, the README Linux architecture note, the C++ bridge split, static method registration for Rust callbacks, JavaArray, Type::parse, and direct ByteBuffer helpers on Env. Its breaking-changes section matches the Vm/Env split, the lifetime changes, and the removed test functions in the diff.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 80c4fcfb-75e5-47c0-b0b3-2af3bb6bd859
Commits
Reviewing files that changed from the base of the PR and between ea6e48f and 4c97ba7.
Files ignored due to path filters: 1
Cargo.lock is excluded by !**/*.lock
Files selected for processing: 10
.github/workflows/audit.yml
.github/workflows/ci.yml
cpp/object.cpp
cpp/registry.cpp
include/usagi.h
src/array.rs
src/ffi.rs
src/object.rs
tests/phase2.rs
tests/registration.rs
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: eefe23db-d151-4be1-aae9-3af03687f4dc
Commits
Reviewing files that changed from the base of the PR and between 4c97ba7 and 6e41ce4.
Files selected for processing: 11
cpp/internal.hpp
cpp/registry.cpp
cpp/vm.cpp
deny.toml
include/usagi.h
src/array.rs
src/callback.rs
src/ffi.rs
src/vm.rs
tests/phase2.rs
tests/registration.rs
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Review details
Context from checks skipped due to timeout: 1
GitHub Check: CodeRabbit
Additional comments: 2
src/array.rs: 1
261-262: Functional Correctness
The comment's premise fails for method-returned arrays. Array metadata comes from the runtime array class at the wrapping boundary, not from the declared return type. usagi_call_method uses the same make_object_handle path that stores java/nio/ByteBuffer for a ByteBuffer[] result. The None branch in matches_type is therefore not reached for the described ByteBuffer[] case. A separate, unestablished case where metadata is absent is not the scenario the comment raises.
cpp/registry.cpp: 1
311-311: Stability & Availability
The concern cannot be decided from the available evidence. The repository clears nativehandle during shutdown and leaves the method entry in place, which is the premise the comment relies on. Whether an active callback can then call that method and crash depends on jnivm's dispatch, which is in a dependency that is not available in this checkout. Whether the shutdown contract allows such a nested call is also unresolved.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 2994e487-deae-4bcd-a535-4a513a72aa58
Commits
Reviewing files that changed from the base of the PR and between 6e41ce4 and 38e279a.
Files selected for processing: 2
cpp/registry.cpp
tests/registration.rs
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Review details
Context from checks skipped due to timeout: 1
GitHub Check: CodeRabbit
Additional comments: 1
cpp/registry.cpp: 1
369-369: Stability & Availability
The concurrency question cannot be decided from this checkout. The pinned libjnivm submodule is absent, so its method dispatch path, and whether it reads Method::native when nativehandle is set, cannot be inspected. The unlocked write at cpp/registry.cpp:369 is in the reviewed code, but whether it races depends on that dispatch path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
JavaArray,Type::parse, and directByteBufferhelpers onEnvbreaking changes
Vm::envandVm::attach_current_threadreplaceVm::get_jni_envandVm::detach_current_threadAttachGuarddetaches on drop only when
attach_current_threadattached the threadfind_class,define_class, andnew_stringnow live onEnvinstead ofVmClass,Object,JavaString, andOutputnow use the'envlifetime, andMethodandValuenow take lifetimeparameters
Valueneed the newObject,String,Class, andArrayvariants, and matches onOutputneedClassandArrayusagi_vm_attach_current_thread,usagi_class_register_method, andUsagiMethodCallbackchanged sigs ininclude/usagi.h, andusagi_test_register_addandusagi_test_register_failno longer existassisted with: