Skip to content

Fix incompatible (int) cast on boxed Double in Quick Start code#82

Merged
edburns merged 2 commits intomainfrom
copilot/fix-github-actions-workflow
Apr 20, 2026
Merged

Fix incompatible (int) cast on boxed Double in Quick Start code#82
edburns merged 2 commits intomainfrom
copilot/fix-github-actions-workflow

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 20, 2026

The smoke test CI job (JDK 25) was failing because the Quick Start code casts Double (boxed) return values from SessionUsageInfoEventData using (int), which only works for primitive double.

[ERROR] incompatible types: java.lang.Double cannot be converted to int

Changes

  • README.md / jbang-example.java: Replace illegal (int) casts with .intValue() on the three SessionUsageInfoEventData accessors (currentTokens(), tokenLimit(), messagesLength()):
// Before (compile error with boxed Double)
System.out.println("Current tokens: " + (int) data.currentTokens());

// After
System.out.println("Current tokens: " + data.currentTokens().intValue());

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • mvn spotless:apply has been run to format the code
  • mvn clean verify passes locally

Does this introduce a breaking change?

  • Yes
  • No

Copilot AI changed the title [WIP] Fix failing GitHub Actions workflow for smoke test Fix incompatible (int) cast on boxed Double in Quick Start code Apr 20, 2026
Copilot AI requested a review from edburns April 20, 2026 13:10
@edburns edburns marked this pull request as ready for review April 20, 2026 13:49
Copilot AI review requested due to automatic review settings April 20, 2026 13:49
@edburns edburns merged commit 9697a1d into main Apr 20, 2026
5 checks passed
@edburns edburns deleted the copilot/fix-github-actions-workflow branch April 20, 2026 13:50
Copy link
Copy Markdown
Contributor

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

Fixes a JDK 25 compilation failure in the repository’s Quick Start examples by updating how usage metrics (boxed Double values) are converted to integers for display.

Changes:

  • Replace illegal (int) casts on Double values with .intValue() for currentTokens(), tokenLimit(), and messagesLength() in example code.
  • Apply the same fix consistently in both the README Quick Start snippet and the JBang example.
Show a summary per file
File Description
jbang-example.java Updates usage-metrics printing to use Double.intValue() instead of an invalid cast.
README.md Updates the Quick Start snippet to use Double.intValue() for usage metrics, fixing compilation on newer JDKs.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

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.

3 participants