Remove rust_object_field usage from Throwable, Class, ZipFile, InputStreamReader#137
Remove rust_object_field usage from Throwable, Class, ZipFile, InputStreamReader#137
Conversation
5529cd8 to
d811421
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #137 +/- ##
==========================================
+ Coverage 78.74% 78.79% +0.04%
==========================================
Files 178 178
Lines 7265 7286 +21
==========================================
+ Hits 5721 5741 +20
- Misses 1544 1545 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Phase 1 of removing put_rust_object_field / get_rust_object_field usage by migrating several core runtime classes to store their state in regular Java fields and reconstruct Rust-side helpers on demand, reducing reliance on embedded Rust pointers inside Java objects.
Changes:
java.lang.Class: replaces stored Rust pointer withnameBytesand resolves theClassDefinitionby name.java.util.zip.ZipFile: stores ZIP contents as a Java byte array (zipData) and rebuildsZipArchiveon each access.java.lang.Throwable+java.io.InputStreamReader: replaces Rust-object fields with Java-level representations (String[]stack traces, charset string).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
jvm/src/runtime/java_lang_class.rs |
Resolves Rust class definitions from a stored class-name byte array instead of a Rust object field. |
java_runtime/src/classes/java/lang/class.rs |
Updates java/lang/Class field layout to use nameBytes rather than raw. |
java_runtime/src/classes/java/util/zip/zip_file.rs |
Switches ZipFile state to zipData and reconstructs ZipArchive when needed. |
java_runtime/src/classes/java/lang/throwable.rs |
Stores stack traces as a Java String[] instead of a Rust-side Arc<Vec<String>>. |
java_runtime/src/classes/java/io/input_stream_reader.rs |
Stores charset name as a Java String and instantiates a decoder during reads. |
Comments suppressed due to low confidence (1)
java_runtime/src/classes/java/util/zip/zip_file.rs:146
get_input_streamhas severalunwrap()calls (zip.by_name,read_to_end, and writing into the Java byte array). Any missing entry, I/O error, or buffer write error will panic the whole JVM. Please return an appropriate Java exception (e.g.,java/lang/IllegalArgumentExceptionfor a missing entry name, orjava/io/IOException/java/util/zip/ZipExceptionfor ZIP/I/O failures) instead of panicking.
let data = {
let mut zip = Self::get_zip_archive(jvm, &this).await?;
let mut file = zip.by_name(&entry_name).unwrap();
let mut buf = Vec::new();
file.read_to_end(&mut buf).unwrap();
buf
};
// TODO do we have to use InflaterInputStream?
let mut java_buf = jvm.instantiate_array("B", data.len() as _).await?;
jvm.array_raw_buffer_mut(&mut java_buf).await?.write(0, &data).unwrap();
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5529cd8d5e
ℹ️ 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".
d811421 to
479cbb4
Compare
479cbb4 to
973379e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
java_runtime/src/classes/java/util/zip/zip_file.rs:145
get_input_streamstill usesunwrap()onzip.by_name(...),read_to_end(...), and the Java array write. If the entry name is missing/corrupt or the ZIP data can’t be read/decoded, this will panic the whole runtime instead of returning a Java-level failure (typicallynullor anIOException). Please propagate these errors throughResultand map them to an appropriate Java exception (or returnnullwhen the entry isn’t found, consistent withgetEntry).
let data = {
let mut zip = Self::get_zip_archive(jvm, &this).await?;
let mut file = zip.by_name(&entry_name).unwrap();
let mut buf = Vec::new();
file.read_to_end(&mut buf).unwrap();
buf
};
// TODO do we have to use InflaterInputStream?
let mut java_buf = jvm.instantiate_array("B", data.len() as _).await?;
jvm.array_raw_buffer_mut(&mut java_buf).await?.write(0, &data).unwrap();
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
String[]instead of serializedArc<Vec<String>>pointerClassDefinitionviajvm.resolve_class()on demand[Barray and reconstructZipArchiveon each accessDecoderperread()callPhase 1 of removing all
put_rust_object_field/get_rust_object_fieldusage. Remaining usages (Thread.joinEvent, Object.waitEvent) require JVM object monitor implementation (Phase 2).