Skip to content

Create strict number refusals and located failures without a stack trace - #683

Merged
bertysentry merged 2 commits into
mainfrom
claude/issue-679-stackless-number-format
Nov 29, 2026
Merged

bertysentry merged 2 commits into
mainfrom
claude/issue-679-stackless-number-format

Conversation

@bertysentry

@bertysentry bertysentry commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #679

Problem

A value refused by strict numbers filled two stack traces: one for the AwkNumberFormatException thrown by JRT.requireNumber(), one for the copy that AVM.atLine() ties to the source line. Any other failure, including an exception that an extension function throws without a stack trace to mean "no value", was wrapped in an AwkRuntimeException that filled one more.

Change

  • AwkNumberFormatException never fills a stack trace: it overrides fillInStackTrace(). The existing constructors still leave the cause uninitialized, so initCause() works as before. New constructor AwkNumberFormatException(int lineno, String value, Throwable cause).
  • New constructor AwkRuntimeException(int lineno, String msg, Throwable cause, boolean writableStackTrace).
  • AVM.atLine() creates the located exception without a stack trace. Its cause is the original exception, with its own stack trace when it has one, so a bug in Jawk or in an extension is still traceable through getCause().

Types, messages, line numbers and getValue() are unchanged. The command-line output is unchanged too: Cli.main prints the type, the line and the message, never a stack trace.

Not done

The optional part of the issue (set the line on an existing AwkRuntimeException instead of creating a new one): lineNumber is final, and an extension may throw the same exception instance several times, so mutating it would not be safe. The located exception is now a plain allocation, without a stack walk.

Scope

The diff of AVM.java is limited to atLine(), to avoid conflicts with the pull requests for #677, #678 and #680.

Tests and documentation

  • StrictNumbersTest: a refusal keeps its type, message, line and value, and neither the located exception nor its cause has a stack trace; the new constructors, and initCause() on the existing ones; an extension that fails is still reported as an AwkRuntimeException with the same message and line, stackless, with the original exception (and its trace) as cause; an extension that throws a stackless exception gets it back as cause, as it is.
  • java-advanced.md (Strict Numbers) and an Unreleased bullet in behavior-changes.md.
  • mvn verify: 1023 unit tests pass; checkstyle, PMD and SpotBugs report nothing; the compatibility suite fails on the same tests as main.

🤖 Generated with Claude Code

https://claude.ai/code/session_012oN69BbMXD8VrEn4aCbj5M

…ace (#679)

A value refused by strict numbers used to fill two stack traces: one for
the AwkNumberFormatException thrown by JRT.requireNumber(), one for the
copy that AVM.atLine() ties to the source line. Any other failure, an
exception thrown stackless by an extension function included, was
wrapped in an AwkRuntimeException that filled one more.

AwkNumberFormatException is now created without a stack trace, and so is
the located exception of atLine(), through the new
AwkRuntimeException(lineno, msg, cause, writableStackTrace) constructor.
Types, messages, line numbers and the refused value are unchanged, and
the cause keeps the trace of the original failure when it has one.

Claude-Session: https://claude.ai/code/session_012oN69BbMXD8VrEn4aCbj5M
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T08:25:55.347221Z e296bb1 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

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

The constructor of Throwable that disables the stack trace also marks
the cause as initialized, even when it is null, so initCause() threw an
IllegalStateException on an exception created without a cause. The
exception now stays stackless by overriding fillInStackTrace() instead,
and the constructors without a cause leave it uninitialized as before.

Claude-Session: https://claude.ai/code/session_012oN69BbMXD8VrEn4aCbj5M

Copy link
Copy Markdown
Contributor Author

@codex please review again


Generated by Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: e296bb1c58

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

@bertysentry
bertysentry merged commit 880eb49 into main Nov 29, 2026
5 checks passed
@bertysentry
bertysentry deleted the claude/issue-679-stackless-number-format branch November 29, 2026 12:10
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.

A value refused by strict numbers fills two stack traces

2 participants