Conversation
Wraps oxbitnet directly via the `jni` crate (same pattern as oxbitnet-python with PyO3). Provides BitNet.loadSync(), generate(), chat() with TokenCallback streaming, and AutoCloseable support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
oxbitnet-javacrate with JNI native methods wrappingoxbitnetdirectly (same pattern asoxbitnet-pythonwith PyO3)BitNet.loadSync(),generate(),chat()withTokenCallbackstreaming,AutoCloseablesupportio.github.m96chan.oxbitnetpackage), Gradle build stub,Chat.javaexample, and crate READMECloses #5
Details
Rust side (
src/lib.rs):JavaBitNetstruct ownsOption<BitNet>+tokio::Runtime(same as Python)nativeLoad,nativeGenerate,nativeChat,nativeFreeGlobalRef+JavaVM::attach_current_threadboolean onToken(String)— returnfalseto stop earlyOxBitNetExceptionviaenv.throw_new()Java side (7 files):
BitNet— main class,AutoCloseable, storeslong nativeHandleChatMessage— record(role, content)GenerateOptions— builder pattern (maxTokens, temperature, topK, repeatPenalty, repeatLastN)TokenCallback—@FunctionalInterfaceLoadOptions— progress callback + cache dirLoadProgress— record for progress infoOxBitNetException— RuntimeException subclassTest plan
cargo build -p oxbitnet-javacompiles to.socargo clippy -p oxbitnet-java -- -D warningspasses cleanChat.javaexample with a GGUF model🤖 Generated with Claude Code