Add FileDescriptorId abstraction for serializable file descriptors#136
Add FileDescriptorId abstraction for serializable file descriptors#136
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: faac185209
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
There was a problem hiding this comment.
Pull request overview
This PR replaces storing raw Rust object pointers in java.io.FileDescriptor with a FileDescriptorId newtype, enabling file descriptor values to be represented as plain integers (and thus more amenable to serialization) while allowing runtimes to map IDs back to File objects.
Changes:
- Introduces
FileDescriptorId(usize)and re-exports it fromjava_runtime. - Updates the
Runtimetrait:stdin/stdout/stderr/opennow returnFileDescriptorId, plus a newget_file(fd)method for lookup. - Adds fd tables (
Arc<Mutex<BTreeMap<..>>>) toRuntimeImplandTestRuntime, and updates Java I/O classes to use the new fd-based flow.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
java_runtime/src/runtime/io.rs |
Adds the FileDescriptorId newtype used as the runtime-facing FD handle. |
java_runtime/src/runtime.rs |
Updates the Runtime trait to return FileDescriptorId and adds get_file. |
java_runtime/src/lib.rs |
Re-exports FileDescriptorId from the java_runtime crate API. |
src/runtime.rs |
Implements an fd table in RuntimeImpl and adapts stdio/open to return ids and support lookup. |
test_utils/src/lib.rs |
Updates TestRuntime to use an fd table and the new Runtime interface. |
java_runtime/src/classes/java/io/file_descriptor.rs |
Changes Java FileDescriptor storage from raw pointer bytes to an int fd and resolves via Runtime::get_file. |
java_runtime/src/classes/java/io/random_access_file.rs |
Switches to creating FileDescriptor from a FileDescriptorId and passes runtime context for lookup. |
java_runtime/src/classes/java/io/file_input_stream.rs |
Switches open/init and read paths to fd-based lookup via Runtime::get_file. |
java_runtime/src/classes/java/io/file_output_stream.rs |
Switches open/init and write paths to fd-based lookup via Runtime::get_file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
FileDescriptorIdnewtype wrappingusizeto replace raw Rust object pointer storage inFileDescriptor, making it serializableRuntimetrait sostdin/stdout/stderr/openreturnFileDescriptorIdinstead ofBox<dyn File>, with a newget_file(fd)method for retrievalArc<Mutex<BTreeMap>>) toRuntimeImplandTestRuntimefor fd → file mapping management