Skip to content

Add Jvm object monitor and remove rust_object_field from Object/Thread#138

Merged
dlunch merged 2 commits intomainfrom
jvm-object-monitor
Apr 5, 2026
Merged

Add Jvm object monitor and remove rust_object_field from Object/Thread#138
dlunch merged 2 commits intomainfrom
jvm-object-monitor

Conversation

@dlunch
Copy link
Copy Markdown
Owner

@dlunch dlunch commented Apr 5, 2026

Summary

  • Add object_wait, object_listen, object_notify methods to Jvm backed by a per-object Event monitor table
  • Replace Arc<Event> stored via rust_object_field in Object.waitEvent and Thread.joinEvent with Jvm-level monitor
  • Thread.join now uses object_listen + alive check pattern to avoid race condition (listen registered before condition check)
  • Thread.isAlive now returns actual alive state instead of stub true
  • Removes waitEvent: [B from Object, joinEvent: [B from Thread, adds alive: Z to Thread

This completes removal of all rust_object_field usage from java_runtime. Only java_lang_class.rs (jvm crate) remains, using byte array for class name due to circular dependency with String class.

Copilot AI review requested due to automatic review settings April 5, 2026 08:27
@dlunch dlunch force-pushed the jvm-object-monitor branch from ccb4fae to b689ca9 Compare April 5, 2026 08:29
Copy link
Copy Markdown

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

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

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

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 5, 2026

Codecov Report

❌ Patch coverage is 84.21053% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.60%. Comparing base (303f581) to head (b689ca9).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
java_runtime/src/classes/java/lang/thread.rs 64.28% 5 Missing ⚠️
java_runtime/src/classes/java/lang/object.rs 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #138      +/-   ##
==========================================
- Coverage   78.76%   78.60%   -0.17%     
==========================================
  Files         178      178              
  Lines        7286     7287       +1     
==========================================
- Hits         5739     5728      -11     
- Misses       1547     1559      +12     

☔ View full report in Codecov by Sentry.
📢 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.

@dlunch dlunch force-pushed the jvm-object-monitor branch from b689ca9 to ab975de Compare April 5, 2026 08:31
Copy link
Copy Markdown

Copilot AI left a comment

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 moves object/thread wait/notify mechanics out of rust_object_field storage and into a JVM-managed per-object monitor table, and updates java.lang.Thread/java.lang.Object to use it.

Changes:

  • Added Jvm::{object_listen, object_wait, object_notify} backed by a JVM-level monitor map.
  • Replaced Object.waitEvent / Thread.joinEvent rust-object-field storage with JVM monitors and a new Thread.alive field.
  • Updated Thread.join to register a listener before checking liveness, and implemented Thread.isAlive to reflect actual state.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
jvm/src/jvm.rs Adds JVM-level monitor storage and APIs for object wait/notify.
jvm/Cargo.toml Introduces the event-listener dependency for monitor implementation.
java_runtime/src/classes/java/lang/thread.rs Reworks Thread join/isAlive to use JVM monitors and a new alive field.
java_runtime/src/classes/java/lang/object.rs Reworks Object.wait/notify to use JVM monitors rather than per-object rust fields.
Cargo.lock Locks the new dependency.

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

@dlunch dlunch force-pushed the jvm-object-monitor branch from ab975de to 70c6193 Compare April 5, 2026 08:34
@dlunch dlunch merged commit b23f25e into main Apr 5, 2026
8 checks passed
@dlunch dlunch deleted the jvm-object-monitor branch April 5, 2026 08:35
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