Skip to content

Add Java primitive wrapper classes - #176

Merged
dlunch merged 2 commits into
mainfrom
boxing-classes
Jul 16, 2026
Merged

Add Java primitive wrapper classes#176
dlunch merged 2 commits into
mainfrom
boxing-classes

Conversation

@dlunch

@dlunch dlunch commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • add Number and the missing primitive wrapper classes with Java 1.2-compatible APIs
  • expand Integer and add primitive Class objects used by wrapper TYPE fields
  • cover parsing, comparisons, character classification, and runtime type integration

Validation

  • cargo fmt --all -- --check
  • cargo test --workspace
  • cargo clippy --workspace --all-targets -- -D warnings

Copilot AI review requested due to automatic review settings July 16, 2026 08:08
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.01869% with 267 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.35%. Comparing base (fe5d116) to head (366ea34).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
java_runtime/src/classes/java/lang/long.rs 83.37% 62 Missing ⚠️
java_runtime/src/classes/java/lang/integer.rs 84.51% 57 Missing ⚠️
java_runtime/src/classes/java/lang/character.rs 93.26% 47 Missing ⚠️
java_runtime/src/classes/java/lang/short.rs 81.53% 36 Missing ⚠️
java_runtime/src/classes/java/lang/byte.rs 86.63% 27 Missing ⚠️
java_runtime/src/classes/java/lang/double.rs 94.39% 18 Missing ⚠️
java_runtime/src/classes/java/lang/float.rs 94.46% 18 Missing ⚠️
java_runtime/src/classes/java/lang/boolean.rs 99.08% 1 Missing ⚠️
jvm/src/runtime/java_lang_class.rs 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #176      +/-   ##
==========================================
+ Coverage   83.89%   85.35%   +1.46%     
==========================================
  Files         173      181       +8     
  Lines       12939    15569    +2630     
==========================================
+ Hits        10855    13289    +2434     
- Misses       2084     2280     +196     

☔ 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.

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 extends RustJava’s Java runtime library to include Java 1.2-compatible primitive wrapper classes (plus Number) and integrates primitive Class objects used by wrapper TYPE fields, with a broad set of runtime tests validating parsing, formatting, comparisons, and reflection behavior.

Changes:

  • Add java/lang/Number and implement missing primitive wrapper classes (Boolean, Byte, Short, Long, Float, Double, Character) plus major expansion of Integer.
  • Add primitive Class construction and primitive-aware logic for Class.getName, Class.isPrimitive, and Class.isAssignableFrom.
  • Add comprehensive async integration tests covering wrapper APIs, boundaries, errors, GC stability of TYPE, and Number/Comparable metadata.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
jvm/src/runtime/java_lang_class.rs Adds primitive Class construction and stricter name decoding used by runtime java/lang/Class.
java_runtime/src/loader.rs Registers new runtime class prototypes so wrappers/Number resolve at runtime.
java_runtime/src/classes/java/lang.rs Wires new wrapper modules into the java.lang runtime module exports.
java_runtime/src/classes/java/lang/number.rs Adds abstract Number base class with concrete byteValue/shortValue and abstract numeric conversions.
java_runtime/src/classes/java/lang/integer.rs Expands Integer to a Java-1.2-like API surface (parsing, decode, getInteger, formatting, comparisons, TYPE/MIN/MAX).
java_runtime/src/classes/java/lang/boolean.rs Implements Boolean wrapper (TRUE/FALSE/TYPE, parsing/valueOf, getBoolean).
java_runtime/src/classes/java/lang/byte.rs Implements Byte wrapper APIs including parsing/decoding, constants, comparisons, and TYPE.
java_runtime/src/classes/java/lang/short.rs Implements Short wrapper APIs including parsing/decoding, constants, comparisons, and TYPE.
java_runtime/src/classes/java/lang/long.rs Implements Long wrapper APIs including parse/decode/getLong, formatting helpers, comparisons, and TYPE.
java_runtime/src/classes/java/lang/float.rs Implements Float wrapper APIs including parse/valueOf, bit conversions, constants, comparisons, and TYPE.
java_runtime/src/classes/java/lang/double.rs Implements Double wrapper APIs including parse/valueOf, bit conversions, constants, comparisons, and TYPE.
java_runtime/src/classes/java/lang/character.rs Implements Character wrapper APIs including classification, case mapping, digit/numeric helpers, constants, comparisons, and TYPE.
java_runtime/src/classes/java/lang/comparable.rs Defines Comparable.compareTo(Object) as an abstract method and corrects interface access flags.
java_runtime/src/classes/java/lang/class.rs Adds Class.isPrimitive, primitive-aware isAssignableFrom, and null-check for forName; uses JavaLangClass::name.
java_runtime/tests/classes/java/lang/mod.rs Includes new wrapper/Number test modules in the test suite.
java_runtime/tests/classes/java/lang/test_class.rs Adds tests for primitive Class objects, primitive rejection in forName, assignability rules, and GC stability of TYPE.
java_runtime/tests/classes/java/lang/test_number.rs Verifies Number is abstract and wrappers implement Number/Comparable/Serializable as expected.
java_runtime/tests/classes/java/lang/test_integer.rs Expands coverage for Integer APIs (radix parsing, decode, formatting, compareTo errors, getInteger defaults, TYPE stability).
java_runtime/tests/classes/java/lang/test_boolean.rs Adds coverage for Boolean parsing, constants, getBoolean, and Java 1.2 API exclusions.
java_runtime/tests/classes/java/lang/test_byte.rs Adds coverage for Byte parsing/decoding, overflow errors, comparisons, and TYPE.
java_runtime/tests/classes/java/lang/test_short.rs Adds coverage for Short parsing/decoding, overflow errors, comparisons, and TYPE.
java_runtime/tests/classes/java/lang/test_long.rs Adds coverage for Long parsing/decoding/getLong, formatting, overflow errors, comparisons, and TYPE.
java_runtime/tests/classes/java/lang/test_float.rs Adds coverage for Float parsing, formatting, NaN/Infinity, bits conversions, comparisons, constants, and TYPE.
java_runtime/tests/classes/java/lang/test_double.rs Adds coverage for Double parsing, formatting, NaN/Infinity, bits conversions, comparisons, constants, and TYPE.
java_runtime/tests/classes/java/lang/test_character.rs Adds coverage for Character constants, classification, radix helpers, surrogate handling, and compareTo error behavior.

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

Comment thread java_runtime/src/classes/java/lang/integer.rs
Comment thread java_runtime/src/classes/java/lang/integer.rs
Comment thread java_runtime/src/classes/java/lang/byte.rs
Comment thread java_runtime/src/classes/java/lang/byte.rs
Comment thread java_runtime/src/classes/java/lang/short.rs
Comment thread java_runtime/src/classes/java/lang/float.rs
Comment thread java_runtime/src/classes/java/lang/double.rs
Comment thread java_runtime/src/classes/java/lang/double.rs
Comment thread java_runtime/src/classes/java/lang/character.rs
Comment thread java_runtime/src/classes/java/lang/character.rs

@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: d80e4cc9fe

ℹ️ 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/lang/integer.rs Outdated
@dlunch
dlunch merged commit 7f6b1a9 into main Jul 16, 2026
10 checks passed
@dlunch
dlunch deleted the boxing-classes branch July 16, 2026 09:21
Jun025 added a commit to Jun025/RustJava that referenced this pull request Jul 31, 2026
Judged the two remaining remote branches on the fork:

- dependabot/cargo/tracing-attributes-0.1.31: deleted. PR #4 (fa92ef9)
  removed the tracing-attributes direct dependency outright, so the
  branch patches a Cargo.toml line that no longer exists.
- wie-ktf-hardening: preserved. 8 of its 12 commits are already in
  upstream/main via squash merges (dlunch#174 dlunch#175 dlunch#176 dlunch#177 dlunch#180 dlunch#182);
  git cherry missed this because origin/main trails upstream/main by
  20 commits. 4 commits carry residual value.

No code changes.

Co-authored-by: jun0 <junyoung.choi.a@miraeasset.com>
Co-authored-by: Claude <noreply@anthropic.com>
Jun025 added a commit to Jun025/RustJava that referenced this pull request Aug 17, 2026
…am-sync-s1-tracing-cut-1f356ae]

* 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>

* [rustjava-upstream-sync-s1-tracing-cut-1f356ae] docs: record S1 landing (conflicts 2, setProperty descriptor breakage)

---------

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>
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