Skip to content

Implement Java 5 Formatter support - #196

Merged
dlunch merged 2 commits into
mainfrom
agent/java15-formatter
Aug 9, 2026
Merged

Implement Java 5 Formatter support#196
dlunch merged 2 commits into
mainfrom
agent/java15-formatter

Conversation

@dlunch

@dlunch dlunch commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • add Java 5 Formatter, Formattable, formatting exceptions, and common conversions
  • add the supporting Appendable, Closeable, Flushable, StringBuilder, and Enum APIs
  • integrate String.format, PrintStream.format/printf, and PrintWriter.format/printf
  • match Java 5 public class hierarchy, flags, fields, constructors, and public method descriptors with manifest tests

Compatibility scope

This provides the practical Java 5 formatting subset used by typical applications. Date/time (%t/%T), hexadecimal floating point (%a/%A), arbitrary-precision number formatting, and non-English locale localization remain out of scope.

Validation

  • cargo test --workspace --quiet (524 passed, 1 pre-existing ignored)
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo fmt --all -- --check
  • git diff --check

Copilot AI review requested due to automatic review settings August 2, 2026 11:23
@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.96701% with 1752 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.41%. Comparing base (f6cab40) to head (9f05da0).

Files with missing lines Patch % Lines
...e/src/classes/java/lang/abstract_string_builder.rs 36.17% 591 Missing ⚠️
...va_runtime/src/classes/java/lang/string_builder.rs 46.84% 488 Missing ⚠️
java_runtime/src/classes/java/util/formatter.rs 79.39% 230 Missing ⚠️
...ava_runtime/src/classes/java/lang/string_buffer.rs 59.48% 205 Missing ⚠️
java_runtime/src/classes/java/io/print_writer.rs 70.28% 82 Missing ⚠️
java_runtime/src/classes/java/io/print_stream.rs 77.85% 60 Missing ⚠️
java_runtime/src/classes/java/lang/enum.rs 62.75% 54 Missing ⚠️
java_runtime/src/classes/java/lang/string.rs 61.70% 18 Missing ⚠️
...runtime/src/classes/java/util/formattable_flags.rs 78.37% 8 Missing ⚠️
java_runtime/src/classes/java/lang/byte.rs 66.66% 3 Missing ⚠️
... and 5 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #196      +/-   ##
==========================================
- Coverage   90.77%   87.41%   -3.37%     
==========================================
  Files         269      292      +23     
  Lines       33392    38301    +4909     
==========================================
+ Hits        30312    33479    +3167     
- Misses       3080     4822    +1742     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9f05da094d

ℹ️ 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".

Comment thread java_runtime/src/classes/java/io/print_stream.rs
Comment thread java_runtime/src/classes/java/util/formatter.rs
Comment thread java_runtime/src/classes/java/util/formatter.rs Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a Java 5–compatible formatting stack in RustJava, adding java.util.Formatter/Formattable plus the supporting Appendable/Closeable/Flushable/StringBuilder/Enum APIs, and wiring formatting entrypoints like String.format and PrintStream/PrintWriter format/printf. It also expands the runtime class registry and updates conformance/integration tests to validate Java 5 public API shapes and key formatting behaviors.

Changes:

  • Add java.util.Formatter + formatting exceptions and a small integration fixture under test_data/ to validate end-to-end formatting/output behavior.
  • Introduce Java 5 IO/lang support types (Appendable, Closeable, Flushable, AbstractStringBuilder, StringBuilder, Enum) and integrate them into PrintStream, PrintWriter, and String.
  • Update/extend Rust tests to assert Java 5 descriptors, access flags, bridges, and selected behavioral contracts (autoboxing valueOf, formatting IO behaviors, etc.).

Reviewed changes

Copilot reviewed 53 out of 57 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test_data/src/FormatterIntegration.java New Java integration program exercising Formatter, Formattable, Appendable, and stream/writer formatting.
test_data/FormatterIntegration.txt Expected output for the new formatter integration fixture.
java_runtime/tests/classes/java/util/mod.rs Registers the new test_formatter module in util test suite.
java_runtime/tests/classes/java/util/test_formatter.rs Adds API-shape and behavior tests for Formatter, formatting exceptions, Enum, and IO type bridges.
java_runtime/tests/classes/java/lang/mod.rs Registers new test_string_builder module in lang test suite.
java_runtime/tests/classes/java/lang/test_string_builder.rs New tests for Appendable and Java 5 StringBuilder hierarchy/bridges and UTF-16 behavior.
java_runtime/tests/classes/java/lang/test_string_buffer.rs Updates expectations for StringBuffer hierarchy and method flags/descriptors.
java_runtime/tests/classes/java/lang/test_character.rs Updates Character.valueOf(char) expectation for Java 5.
java_runtime/tests/classes/java/lang/test_boolean.rs Updates Boolean.valueOf(boolean) expectation for Java 5 interning semantics.
java_runtime/tests/classes/java/io/test_print_writer.rs Extends PrintWriter API surface checks (constructors + format/printf + append bridges + setError).
java_runtime/tests/classes/java/io/test_print_stream.rs Extends PrintStream API surface checks and adds an autoFlush + format flush behavior assertion.
java_runtime/tests/classes/java/io/test_file_reader_writer.rs Adds a regression test ensuring Formatter file constructors truncate before writing.
java_runtime/src/loader.rs Registers new runtime class protos for formatter-related and supporting Java 5 classes.
java_runtime/src/classes/java/util.rs Adds modules/exports for Formatter, exceptions, Formattable, and related types.
java_runtime/src/classes/java/util/formatter.rs Core java.util.Formatter implementation and formatting engine.
java_runtime/src/classes/java/util/formattable.rs Adds the java.util.Formattable interface proto.
java_runtime/src/classes/java/util/formattable_flags.rs Adds java.util.FormattableFlags constants holder.
java_runtime/src/classes/java/util/formatter_closed_exception.rs Adds FormatterClosedException.
java_runtime/src/classes/java/util/formatter_big_decimal_layout_form.rs Adds Formatter$BigDecimalLayoutForm enum support for signature compatibility.
java_runtime/src/classes/java/util/illegal_format_exception.rs Adds base IllegalFormatException.
java_runtime/src/classes/java/util/duplicate_format_flags_exception.rs Adds DuplicateFormatFlagsException.
java_runtime/src/classes/java/util/illegal_format_flags_exception.rs Adds IllegalFormatFlagsException.
java_runtime/src/classes/java/util/format_flags_conversion_mismatch_exception.rs Adds FormatFlagsConversionMismatchException.
java_runtime/src/classes/java/util/illegal_format_conversion_exception.rs Adds IllegalFormatConversionException.
java_runtime/src/classes/java/util/illegal_format_code_point_exception.rs Adds IllegalFormatCodePointException.
java_runtime/src/classes/java/util/illegal_format_precision_exception.rs Adds IllegalFormatPrecisionException.
java_runtime/src/classes/java/util/illegal_format_width_exception.rs Adds IllegalFormatWidthException.
java_runtime/src/classes/java/util/missing_format_argument_exception.rs Adds MissingFormatArgumentException.
java_runtime/src/classes/java/util/missing_format_width_exception.rs Adds MissingFormatWidthException.
java_runtime/src/classes/java/util/unknown_format_conversion_exception.rs Adds UnknownFormatConversionException.
java_runtime/src/classes/java/util/unknown_format_flags_exception.rs Adds UnknownFormatFlagsException.
java_runtime/src/classes/java/lang.rs Wires new Java 5 lang modules into the runtime (Appendable, AbstractStringBuilder, Enum, StringBuilder).
java_runtime/src/classes/java/lang/appendable.rs Adds the java.lang.Appendable interface proto.
java_runtime/src/classes/java/lang/abstract_string_builder.rs Adds AbstractStringBuilder implementation used by both StringBuffer and StringBuilder.
java_runtime/src/classes/java/lang/string_builder.rs Adds StringBuilder implementation and bridge methods.
java_runtime/src/classes/java/lang/string_buffer.rs Refactors StringBuffer to extend AbstractStringBuilder and adds Java 5 overloads/bridges.
java_runtime/src/classes/java/lang/enum.rs Adds java.lang.Enum base implementation and Enum.valueOf.
java_runtime/src/classes/java/lang/string.rs Adds String.format(...) overloads backed by Formatter.
java_runtime/src/classes/java/lang/boolean.rs Adds Boolean.valueOf(boolean) returning interned constants.
java_runtime/src/classes/java/lang/byte.rs Adds Byte.valueOf(byte).
java_runtime/src/classes/java/lang/character.rs Adds Character.valueOf(char).
java_runtime/src/classes/java/lang/double.rs Adds Double.valueOf(double).
java_runtime/src/classes/java/lang/float.rs Adds Float.valueOf(float).
java_runtime/src/classes/java/lang/long.rs Adds Long.valueOf(long).
java_runtime/src/classes/java/lang/short.rs Adds Short.valueOf(short).
java_runtime/src/classes/java/io.rs Exposes Closeable and Flushable in the java.io module exports.
java_runtime/src/classes/java/io/closeable.rs Adds the java.io.Closeable interface proto.
java_runtime/src/classes/java/io/flushable.rs Adds the java.io.Flushable interface proto.
java_runtime/src/classes/java/io/output_stream.rs Updates OutputStream to implement Closeable/Flushable and fixes public/abstract method flags.
java_runtime/src/classes/java/io/writer.rs Updates Writer to implement Appendable/Closeable/Flushable and adds append(...) methods + bridges.
java_runtime/src/classes/java/io/output_stream_writer.rs Refactors encoding validation and reuse across new constructors/callers.
java_runtime/src/classes/java/io/print_stream.rs Adds PrintStream.format/printf, Appendable bridges, and new constructors.
java_runtime/src/classes/java/io/print_writer.rs Adds PrintWriter.format/printf, Appendable bridges, and new constructors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread java_runtime/src/classes/java/io/print_stream.rs
Comment thread java_runtime/src/classes/java/lang/string_buffer.rs
Comment thread java_runtime/src/classes/java/lang/string_buffer.rs
@dlunch
dlunch merged commit c92a32a into main Aug 9, 2026
12 checks passed
@dlunch
dlunch deleted the agent/java15-formatter branch August 9, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants