Review of javacutil package#1708
Conversation
| if (method.getParameters().isEmpty() | ||
| && method.getSimpleName().contentEquals("iterator")) { | ||
| iteratorMethod = (Symbol.MethodSymbol) method; | ||
| // See buildCloseMethodAccess for why we use members().getSymbolsByName rather than |
There was a problem hiding this comment.
@copilot This same pattern is used four times in this file. Extract it out into a new helper method findMethodByName or something like that. It will take the Element and the Name as parameters and return the MethodSymbol.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR refactors parts of javacutil to reduce allocations and avoid certain javac symbol-completion failures, while also adjusting collection semantics and adding caching for repeated lookups.
Changes:
- Replace
elements.getAllMembersmember lookups with javac symbol-table traversal for iterator/close/hasNext/next method resolution. - Reduce list-allocation churn by switching from
List.appendtoListBufferin hot loops. - Update annotation collection/map behaviors (including
addAll,keySet()caching, and lookup logic) and add small caches inAnnotationBuilder.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
javacutil/src/main/java/org/checkerframework/javacutil/trees/TreeBuilder.java |
Use members().getSymbolsByName + supertype closure to find methods, avoiding costly member completion. |
javacutil/src/main/java/org/checkerframework/javacutil/TypeAnnotationUtils.java |
Use ListBuffer to avoid repeated persistent-list appends in loops. |
javacutil/src/main/java/org/checkerframework/javacutil/TreePathUtil.java |
Replace one-element EnumSet calls with simple loops / shared constant set. |
javacutil/src/main/java/org/checkerframework/javacutil/Resolver.java |
Cache reflective handles and reduce per-call reflection/list allocations. |
javacutil/src/main/java/org/checkerframework/javacutil/AnnotationUtils.java |
Change areSame(Collection, Collection) comparison strategy. |
javacutil/src/main/java/org/checkerframework/javacutil/AnnotationMirrorSet.java |
Align addAll with Set contract; adjust hash-code caching behavior. |
javacutil/src/main/java/org/checkerframework/javacutil/AnnotationMirrorMap.java |
Rely on TreeMap comparator for O(log n) lookups; add cached keySet() snapshot. |
javacutil/src/main/java/org/checkerframework/javacutil/AnnotationBuilder.java |
Cache annotation methods list and unmodifiable element-values map wrapper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * is a separate class rather than a view over the backing map's keys, we approximate with a | ||
| * cached snapshot rebuilt only when the map mutates. | ||
| */ | ||
| private @Nullable AnnotationMirrorSet keySetCache; |
Agent-Logs-Url: https://github.com/eisop/checker-framework/sessions/4bd568d4-df3f-499b-9d83-a192d395233b Co-authored-by: wmdietl <6699136+wmdietl@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot Re-review the whole PR again. |
Agent-Logs-Url: https://github.com/eisop/checker-framework/sessions/22df9c4c-5ba5-4d0b-9783-b90527678796 Co-authored-by: wmdietl <6699136+wmdietl@users.noreply.github.com>
Re-reviewed the PR and pushed follow-up fixes in 0c779d2. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
No description provided.