Skip to content

Fix class initialization and bytecode edge cases - #22

Merged
Project516 merged 3 commits into
masterfrom
p516/audit-fixes
Nov 3, 2026
Merged

Project516 merged 3 commits into
masterfrom
p516/audit-fixes

Conversation

@Project516

Copy link
Copy Markdown
Owner

Classes can skip initialization of indirect superinterfaces with default methods, and two bytecode operations differ from HotSpot on edge cases. Initialize superinterfaces in JVM order, round long-to-float conversions directly, and mask values stored in boolean arrays.

The regression programs compare initialization order, float bit patterns, and generated boolean-store bytecode with HotSpot, including hot methods.

Tests: the three new programs and TypeScript typecheck passed. The full local suite was interrupted; CI runs the broader checks.

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 43 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: dcccb302-f216-4d3e-b3f8-d6767af3740c
Commits

Reviewing files that changed from the base of the PR and between af63d68 and c445a32.

Files selected for processing: 1
  • test/java/BooleanStore.java
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: c21e83ff-4030-41a0-ac5d-b59b41b2e006
Commits

Reviewing files that changed from the base of the PR and between 03bb1cd and af63d68.

Files selected for processing: 7
  • src/interp.ts
  • src/jit.ts
  • src/jvm.ts
  • src/runtime.ts
  • test/java/BooleanStore.java
  • test/java/InterfaceInitialization.java
  • test/java/LongToFloat.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Recent review details
Context from checks skipped due to timeout: 5
  • GitHub Check: CodeRabbit
  • GitHub Check: jtreg / run (1)
  • GitHub Check: jtreg / run (4)
  • GitHub Check: jtreg / run (2)
  • GitHub Check: jtreg / run (3)
Additional context used
PMD (7.28.0)
test/java/InterfaceInitialization.java

[Medium] 33-33: UnusedPrivateMethod (Best Practices): Avoid unused private methods such as 'helper()'.

(UnusedPrivateMethod (Best Practices))

Additional comments: 2
src/jvm.ts: 1

498-508: LGTM!

test/java/InterfaceInitialization.java: 1

1-44: LGTM!

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved conversion of large integer values to floating-point numbers, preserving more accurate results.
    • Corrected boolean array stores so values are stored as true or false, while byte array behavior remains unchanged.
    • Improved initialization of interfaces inherited through parent interfaces, helping ensure required interface methods are ready when needed.

The interpreter and JIT now use a shared helper for long-to-float conversion and mask boolean array stores to one bit. JVM class initialization now traverses inherited interfaces. New Java test programs exercise these conversion, store, and initialization paths.

Changes: Long-to-float conversion

Layer / File(s) Summary
Conversion helper and execution paths
src/runtime.ts, src/interp.ts, src/jit.ts, test/java/LongToFloat.java
The runtime adds longToFloat, which handles large magnitudes using a sticky bit for discarded bits. The interpreter and JIT use the helper for l2f. The Java test checks selected values, including values near a midpoint and the long limits.

Boolean array stores

Layer / File(s) Summary
Boolean store paths and test
src/interp.ts, src/jit.ts, test/java/BooleanStore.java
The interpreter and JIT store only the low bit for boolean arrays and retain direct stores for byte arrays. The Java test changes a bytecode constant and invokes the modified method repeatedly.

Interface initialization

Layer / File(s) Summary
Interface traversal and test
src/jvm.ts, test/java/InterfaceInitialization.java
initGen traverses direct interfaces and their parent interfaces, visits each once, and initializes eligible interfaces in traversal order. The Java test defines interfaces and implementing classes with marked static fields.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: Minimal · previous review af63d

No merge-blocking runtime defect was identified. Run the broader checks before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the main changes: class initialization and bytecode edge-case fixes.
Description check Passed The description directly covers all main changes, regression tests, and reported validation results.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 7 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Simplify code
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

I’m a rabbit with a careful little hop,
I test each long before I stop.
One-bit stores now land just right,
Inherited interfaces join the light.
My carrot rests; the checks are done.
I bound away beneath the sun.

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@project516-review-bot project516-review-bot 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.

The PR fixes three JVM compliance issues: (1) interface initialization now walks the full superinterface hierarchy depth-first and initializes only those with default methods, (2) long-to-float conversion uses a custom sticky-bit rounding algorithm instead of going through double, and (3) bastore (0x54) masks values with &1 when storing into boolean arrays. A test for each behavior is added. The interpreter's boolean-array store path accesses o.cls.name before null-checking, which would throw a JS TypeError instead of a Java NPE.


review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict request_changes

Comment thread src/interp.ts Resolved
Comment thread src/jvm.ts Resolved

@project516-review-bot project516-review-bot 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.

The PR fixes three JVM compliance issues: interface initialization order now follows JVM spec (parent interfaces before children, only those with default methods), long-to-float conversion uses correct round-to-nearest-even with sticky bit, and boolean array stores mask values to 0/1. Two defects from earlier reviews remain: the interpreter's bastore (0x54) reads o.cls.name before null check, and interface initialization still treats private methods as default methods.

Not approved: 2 earlier points are still open in the threads.


review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict comment

Comment thread src/interp.ts Resolved

@project516-review-bot project516-review-bot 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.

All points from the last review are settled in the threads.


review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict approve

@coderabbitai coderabbitai 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.

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread test/java/BooleanStore.java Resolved
Comment thread test/java/BooleanStore.java Resolved

@project516-review-bot project516-review-bot 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.

The PR fixes three JVM compliance issues: (1) class initialization now traverses the full superinterface hierarchy in JVM order to initialize indirect superinterfaces with default methods, (2) long-to-float conversion (l2f) uses a sticky-bit rounding algorithm matching HotSpot semantics for values above 2^53, and (3) boolean array stores (bastore) mask the stored value to its low bit. Corresponding interpreter, JIT, and runtime changes are included with regression tests. No new issues found in the diff beyond points already settled with the author.


review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict approve

@Project516
Project516 merged commit cf6854f into master Nov 3, 2026
12 checks passed
@Project516
Project516 deleted the p516/audit-fixes branch November 3, 2026 00:41
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.

1 participant

⌂ Proxy