Repository navigation
Fix runtime null handling and standard stream initialization - #226
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #226 +/- ##
==========================================
+ Coverage 87.31% 87.78% +0.46%
==========================================
Files 311 311
Lines 46772 47092 +320
==========================================
+ Hits 40841 41338 +497
+ Misses 5931 5754 -177 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🔵 Needs a closer look
The change spans ~40 files and alters cross-cutting runtime semantics (standard stream initialization and multiple Java exception contracts), which warrants final human review despite the added test coverage.
No open issues 🎉
What changed in this PR
This PR hardens the RustJava runtime so Java null contracts are enforced with proper Java exceptions instead of Rust panics, and reworks standard-stream initialization. Across java.lang, java.io, java.net, java.text, java.util, and org.rustjava classes, nullable references are now validated and converted into NullPointerException (or MalformedURLException) before any dereference. FileDescriptor.<clinit> now always publishes non-null in/out/err descriptors (leaving fd=0 when the host stream is unavailable, which surfaces as IOException on use), so System.<clinit> no longer needs to guard stdin. It also corrects Integer/Long.decode(null) to throw NullPointerException (not NumberFormatException), makes calendar/date-format setters tolerate null and fail safely on later use, and adds extensive regression tests.
Changes:
- Add explicit null validation to runtime APIs (String, arraycopy, I/O streams, URL/handler/class-loader, ZIP/JAR, numeric decode) that previously risked panics.
- Keep standard file descriptors non-null when host streams are missing and report
IOExceptiononly on actual use; allow nullable calendar/number-format state with safe downstream failure. - Add integration tests covering rejected nulls, permitted empty operations, and recovery from nullable state.
| File | Description |
|---|---|
io/file_descriptor.rs |
Always creates non-null in/out/err descriptors (fd=0 when host stream unavailable). |
lang/system.rs |
Drops stdin null guard (now always non-null); adds arraycopy null check. |
util/calendar.rs, util/gregorian_calendar.rs |
Nullable setTimeZone; identity/null-tz handling in equals; NPE in get/hashCode/compute on null tz. |
text/simple_date_format.rs |
Adds DateParseError enum and null-numberFormat NPE path; NPE on null calendar/timeZone/numberFormat. |
text/date_format.rs |
Setters accept null; get/set/isLenient/clone throw NPE when backing state is null. |
lang/string.rs |
Null checks for byte/char/String/StringBuffer constructors, concat, getChars. |
lang/integer.rs, lang/long.rs |
decode(null) now throws NullPointerException. |
lang/class_loader.rs, lang/throwable.rs |
Null checks for loadClass/getResource and printStackTrace. |
net/url.rs, net/url_stream_handler.rs, net/url_class_loader.rs, net/jar_url_connection.rs |
Reject null spec/url/array/name with appropriate exceptions. |
io/filter_input_stream.rs, io/filter_output_stream.rs, io/data_input_stream.rs, io/data_output_stream.rs |
Guard null underlying stream and null/empty arguments; preserve valid empty ops. |
io/file.rs, io/file_input_stream.rs, io/file_output_stream.rs, io/random_access_file.rs, io/reader.rs, io/writer.rs, io/input_stream_reader.rs, io/output_stream_writer.rs, io/buffered_output_stream.rs |
Null checks on constructor/read/write arguments. |
util/zip/zip_file.rs, util/zip/zip_entry.rs, org/rustjava/lang/rust_jar_class_loader.rs, org/rustjava/net/file_url_handler.rs, org/rustjava/net/url_path.rs |
Reject null file/entry/name/url/path. |
tests/classes/** (io, lang, net, text, util, org) |
New regression tests for null rejection, empty-op acceptance, and recovery. |
Review effort: Balanced
Changes
Verification
Wasm execution was not tested.