Add CDC text formatting APIs - #183
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@## main #183 +/- ##
==========================================
- Coverage 87.09% 86.50% -0.59%
==========================================
Files 199 207 +8 Lines 17962 20224 +2262 ==========================================
+ Hits 15644 17495 +1851 - Misses 2318 2729 +411 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds a minimal java.text formatting/parsing stack to java_runtime to improve CDC application compatibility, including core Format/DateFormat/NumberFormat hierarchies, supporting position/exception types, and the Calendar behaviors needed for date formatting.
Changes:
- Introduces
java.textruntime classes:Format,DateFormat/SimpleDateFormat,NumberFormat/DecimalFormat, plusFieldPosition,ParsePosition, andParseException. - Registers the new runtime classes and extends
java.util.Calendarwith timezone + leniency behavior needed by the formatters. - Adds standard-library tests covering factories, formatting/parsing, patterns/quoting, cloning, and error/field positions.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| java_runtime/tests/classes/java/text/test_number_format.rs | Adds NumberFormat/DecimalFormat factory/format/parse and position tests. |
| java_runtime/tests/classes/java/text/test_format.rs | Adds tests for common text hierarchy, positions, ParseException, and polymorphic Format methods. |
| java_runtime/tests/classes/java/text/test_date_format.rs | Adds DateFormat/SimpleDateFormat formatting/parsing/timezone/clone tests. |
| java_runtime/tests/classes/java/text/mod.rs | Wires new java.text test modules. |
| java_runtime/tests/classes/java/mod.rs | Enables text tests from the Java test module root. |
| java_runtime/src/loader.rs | Registers new java/text/* runtime class protos. |
| java_runtime/src/classes/java/util/calendar.rs | Adds setTimeZone, isLenient, setLenient, and leniency participation in equals/hashCode. |
| java_runtime/src/classes/java/text/simple_date_format.rs | Implements pattern tokenization plus formatting/parsing for a scoped set of SimpleDateFormat tokens. |
| java_runtime/src/classes/java/text/parse_position.rs | Implements ParsePosition fields/accessors/equality/hash/toString. |
| java_runtime/src/classes/java/text/parse_exception.rs | Implements ParseException with error offset storage. |
| java_runtime/src/classes/java/text/number_format.rs | Implements NumberFormat factories, formatting dispatch, parsing helpers, and digit/grouping configuration. |
| java_runtime/src/classes/java/text/format.rs | Implements base Format behavior: format(Object), parseObject(String), and clone. |
| java_runtime/src/classes/java/text/field_position.rs | Implements FieldPosition fields/accessors/equality/hash/toString. |
| java_runtime/src/classes/java/text/decimal_format.rs | Implements DecimalFormat pattern parsing, formatting, parsing, and multiplier support. |
| java_runtime/src/classes/java/text/date_format.rs | Implements DateFormat factories, calendar/numberFormat plumbing, parsing/format helpers, and deep-ish clone behavior. |
| java_runtime/src/classes/java/text.rs | Adds the java::text module and re-exports new classes. |
| java_runtime/src/classes/java.rs | Exposes pub mod text from classes::java. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:0bdf8ff24d
ℹ️ 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".
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
* Bump bytemuck from 1.25.0 to 1.25.1 (dlunch#173) Bumps [bytemuck](https://github.com/Lokathor/bytemuck) from 1.25.0 to 1.25.1. - [Changelog](https://github.com/Lokathor/bytemuck/blob/main/changelog.md) - [Commits](Lokathor/bytemuck@v1.25.0...v1.25.1) --- updated-dependencies: - dependency-name: bytemuck dependency-version: 1.25.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Replace runtime panics with the matching Java exceptions (dlunch#174) * Replace runtime panics with the matching Java exceptions An unwrap audit found panics reachable from ordinary Java code: - File.length() returns 0 for a missing file; isDirectory/isFile lose their guard-then-unwrap shape - FileImpl (native runtime) maps open/read/write/seek failures to IOError instead of panicking, so FileInputStream and RandomAccessFile guards actually produce FileNotFoundException; FileOutputStream gains the same guard - File I/O operations (read/write/seek/available/length/setLength) throw java.io.IOException on failure via a shared helper - Class.forName resolves the class and throws ClassNotFoundException (new runtime class) instead of panicking on any not-yet-loaded name - StringBuffer.append(char)/append(char[]) keep exact UTF-16 units so unpaired surrogates no longer panic and pairs built char by char survive; String.valueOf(char) builds through [C for the same reason - PrintStream.println(char) replaces an unpaired surrogate with '?' like the JDK charset encoder - ZipFile validates the archive in its constructor and throws java.util.zip.ZipException (new runtime class) for a malformed archive; getInputStream returns null for a missing entry Expected outputs for the new fixtures are generated by a real JVM. Remaining unwraps are invariants (interpreter stack discipline, thread attach), guarded lookups, or documented gaps (lenient calendar normalization, ClassFormatError plumbing). * Inline the IOException conversion at each I/O call site * Return the same Thread object from Thread.currentThread() (dlunch#175) Every attached thread now owns its java/lang/Thread instance: attach takes the instance for threads started via Thread.start (so currentThread() inside run() is the started Thread object) and creates one otherwise (bootstrap, external attachers). currentThread() returns the stored instance, and the GC roots it per thread. Also parse unrecognized classfile attributes as an opaque Unknown variant instead of failing — JVMS 4.7.1 requires silently ignoring them, and the anonymous-class fixture carries EnclosingMethod and Signature attributes the parser rejected. Expected output for the fixture is generated by a real JVM. * Add Java primitive wrapper classes (dlunch#176) * Add Java primitive wrapper classes * Use Character digit semantics for numeric parsing * Bump tokio from 1.52.3 to 1.52.4 (dlunch#179) Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.52.3 to 1.52.4. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](tokio-rs/tokio@tokio-1.52.3...tokio-1.52.4) --- updated-dependencies: - dependency-name: tokio dependency-version: 1.52.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add CLDC 1.1 core API compatibility (dlunch#177) * Add CLDC 1.1 core API compatibility * Fix CI lint and improve CLDC coverage * Fix array assignability and reader progress * Harden JVM runtime correctness (dlunch#180) * Harden JVM runtime correctness * Address classfile review findings * Move class initialization tests to Java fixture * Separate classfile validation from JVM verification * Remove ClassFileError re-export * Bump tokio from 1.52.4 to 1.53.0 (dlunch#181) Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.52.4 to 1.53.0. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](tokio-rs/tokio@tokio-1.52.4...tokio-1.53.0) --- updated-dependencies: - dependency-name: tokio dependency-version: 1.53.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Hide classfile errors behind class definition errors * Delegate null-parent class loading to bootstrap * Remove duplicate array instance methods * Add JNI-style global references (dlunch#182) * Generalize monitor instance arguments * Add CDC text formatting APIs (dlunch#183) * Add CDC text formatting APIs * Add integer number format factories * Fix text format position handling * Add CLI classpath options (dlunch#184) * Add CLI classpath options * Simplify URL classpath lookup * Fix platform classpath handling * Use File path separator for class loading * Separate RustJar class loading * [rustjava-upstream-sync-s4] test: widen test_timer_periodic margin 500ms->2000ms (upstream 3296139 slowed TimerThread) * [rustjava-upstream-sync-s4] docs: record S4 landing (cut 3296139, conflicts 20->2) + S3 landing sha * [rustjava-upstream-sync-s4] docs: correct the timer finding - chronic boundary test, not a cut regression The prior wording compared a standalone run on origin/main against parallel full-suite runs on upstream and called the gap a regression. Matched-condition alternating runs show no difference (standalone x10: pre 3.5 mean / post 3.5 mean; full-suite x8: no difference). Upstream widened this same margin in 895d67d (2025-08) and ad8b477 (2025-10), both already ancestors of main, 11 months before e557673 (2026-07) which the prior wording blamed. sleep 2000 and both conflict resolutions are untouched. Comment-only in .rs; no code change. * [rustjava-upstream-sync-s4] docs: retarget follow-up (4) - no timer perf regression exists; the open axis is our test's wall-clock dependence REPORT.md line 27 already said the 'imported upstream regression' framing was wrong, but the follow-up list 20 lines below still carried it verbatim - and that list is what the next round tickets from. Retargeted to the axis that does exist (our test design, no upstream sending). --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Inseok Lee <git@dlun.ch> Co-authored-by: jun0 <junyoung.choi.a@miraeasset.com>
Summary
java.textcore hierarchy:Format,DateFormat,SimpleDateFormat,NumberFormat, andDecimalFormat.FieldPosition,ParsePosition, andParseException, plus runtime class registration.Calendarwith timezone and leniency behavior needed by date formatting.Compatibility scope
This targets practical CDC application compatibility with English/US symbols and GMT or raw-offset time zones. Localized symbol resource classes, localized patterns, scientific notation, a full timezone database, and full lenient date normalization remain out of scope.
Validation
cargo fmt --all -- --checkcargo clippy -p java_runtime --tests -- -D warningscargo test -p java_runtime(187 passed)cargo test --workspace(229 passed, 1 ignored)git diff --check