Skip to content

Document the cache parameter of JavaParserUtil.resolveTypeName - #8199

Merged
mernst merged 1 commit into
typetools:masterfrom
mernst:resolve-type-name-cache-javadoc
Sep 17, 2026
Merged

mernst merged 1 commit into
typetools:masterfrom
mernst:resolve-type-name-cache-javadoc

Conversation

@mernst

@mernst mernst commented Sep 17, 2026

Copy link
Copy Markdown
Member

Follow-up to #8182.

  • Document that the cache argument must permit null values (a lookup that finds no type is memoized as null), so it cannot be a ConcurrentHashMap, and that the method is not thread-safe.
  • Remove the initial-capacity argument from the HashMap that the one-argument overload creates. A capacity of 4 gives a threshold of 3 entries, but a single resolveTypeName call performs one lookup per enclosing type declaration, one per import, one for the package prefix, one for java.lang., and one for the fully-qualified name, so the map was rehashed on every call.

🤖 Generated with Claude Code

The cache must permit null values, because a lookup that finds no type is
memoized as null.  Also, don't presize the cache that the one-argument
overload creates; a single call performs more lookups than the presized
capacity holds.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 12 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

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

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: a8abd90d-4a9d-4987-b4e8-6cc0a2e62804

📥 Commits

Reviewing files that changed from the base of the PR and between ddda8cd and da3c2d5.

📒 Files selected for processing (1)
  • framework/src/main/java/org/checkerframework/framework/util/JavaParserUtil.java

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.

@mernst
mernst merged commit e5be338 into typetools:master Sep 17, 2026
14 checks passed
@mernst
mernst deleted the resolve-type-name-cache-javadoc branch September 17, 2026 03:19
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