Skip to content

Fix crash on unsolved argument to JDK constructor - #469

Merged
kelloggm merged 8 commits into
mainfrom
jdkctorunsolvedarg
Jul 21, 2026
Merged

Fix crash on unsolved argument to JDK constructor#469
kelloggm merged 8 commits into
mainfrom
jdkctorunsolvedarg

Conversation

@kelloggm

Copy link
Copy Markdown
Collaborator

Fixes the crash in #405. The actual test case for #405 still doesn't compile, but I think that's a separate problem. I've manually confirmed that the test case fails with the appropriate crash without the fix commit.

This PR is a further experiment in AI-assisted software engineering. All of the code in this PR was initially authored by Claude, but I've reviewed it and it seems reasonable to me. Here is its change summary:

In UnsolvedSymbolGenerator.java, a constructor call to a fully-known class (e.g. a JDK type like IllegalStateException) whose argument type was unsolvable was being routed down the "synthetic constructor" path. That path assumes the constructor's declaring type is one of Specimin's synthetic symbols, so it looked up a scope that doesn't exist and crashed with Scope not created when it should've been.

Two guards were added in the unresolvable-args branch:

  1. isKnownConstructorDeclaringType(node) — if the constructor's declaring type resolves (JDK/known class), there is no synthetic constructor to generate, so return EMPTY.
  2. If the synthetic constructor's alternates can't be located (because argument types were refined after the constructor was first generated), return EMPTY gracefully instead of throwing.

The new test (JdkCtorUnsolvedArgTest + jdkctorunsolvedarg/)

A minimal reproduction distilled from the real crash: a target method that throws new IllegalStateException("bad value: " + field) where field has an unsolvable type. This exercises exactly the fixed path.

@kelloggm
kelloggm requested a review from theron-wang July 21, 2026 17:37
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kelloggm, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a10ac09e-1641-4c59-b78b-d9ce94c23aa9

📥 Commits

Reviewing files that changed from the base of the PR and between 2ead702 and 1f172fe.

📒 Files selected for processing (1)
  • src/main/java/org/checkerframework/specimin/unsolved/UnsolvedSymbolGenerator.java
📝 Walkthrough

Walkthrough

UnsolvedSymbolGenerator now detects resolvable constructor declaring types, skips synthetic constructor generation when appropriate, and returns an empty result when no synthetic constructor alternate exists. A regression test and input/expected sources cover an unsolvable argument passed to a known JDK constructor. Javadoc for isProbablyAConstant now documents its parameter and return value.

Possibly related PRs

Suggested reviewers: theron-wang

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jdkctorunsolvedarg

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

Comment @coderabbitai help to get the list of available commands.

@theron-wang theron-wang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kelloggm
kelloggm enabled auto-merge (squash) July 21, 2026 17:52

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/org/checkerframework/specimin/unsolved/UnsolvedSymbolGenerator.java (1)

3869-3888: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Keep the Javadocs attached to the methods they describe.

The new helper was inserted between the existing getFQNsForUnsolvableConstructor Javadoc and its method, leaving that comment orphaned and creating duplicate documentation. Move or remove the original block, and fix the "constuctor" typo in the replacement comment.

Also applies to: 3889-3897

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/org/checkerframework/specimin/unsolved/UnsolvedSymbolGenerator.java`
around lines 3869 - 3888, Move the existing Javadoc for
getFQNsForUnsolvableConstructor so it remains directly above that method,
removing any orphaned or duplicate documentation. Keep the new
isKnownConstructorDeclaringType Javadoc attached to its helper and correct
“constuctor” to “constructor” in the replacement comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@src/main/java/org/checkerframework/specimin/unsolved/UnsolvedSymbolGenerator.java`:
- Around line 3869-3888: Move the existing Javadoc for
getFQNsForUnsolvableConstructor so it remains directly above that method,
removing any orphaned or duplicate documentation. Keep the new
isKnownConstructorDeclaringType Javadoc attached to its helper and correct
“constuctor” to “constructor” in the replacement comment.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 317a79e9-8b32-44a3-be0e-1392393cd936

📥 Commits

Reviewing files that changed from the base of the PR and between a7787bf and 2ead702.

📒 Files selected for processing (2)
  • src/main/java/org/checkerframework/specimin/JavaParserUtil.java
  • src/main/java/org/checkerframework/specimin/unsolved/UnsolvedSymbolGenerator.java

@kelloggm
kelloggm disabled auto-merge July 21, 2026 19:24
@kelloggm
kelloggm enabled auto-merge (squash) July 21, 2026 19:25
@kelloggm
kelloggm merged commit ed4b56f into main Jul 21, 2026
3 checks passed
@kelloggm
kelloggm deleted the jdkctorunsolvedarg branch July 21, 2026 19: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.

2 participants