-
Notifications
You must be signed in to change notification settings - Fork 329
Method name parsing in ExternalStubxLibraryModels class is missing a corner case
#1344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
.../jdk-integration-test/src/test/java/com/uber/nullaway/jdkannotations/JDKIntegrationTest.java
Outdated
Show resolved
Hide resolved
| methodEntry.getKey().substring(methodEntry.getKey().indexOf(" ") + 1); | ||
| while (methodNameAndSignature.contains(" ") | ||
| && methodNameAndSignature.indexOf(" ") < methodNameAndSignature.indexOf("(")) { | ||
| methodNameAndSignature = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My test case has a NonNull parameter, but passes even without this change. However, since correct parsing is needed, I just added this.
WalkthroughAdds a new test method Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (3)
🧰 Additional context used🧠 Learnings (4)📚 Learning: 2025-08-29T18:41:43.584ZApplied to files:
📚 Learning: 2025-08-14T18:50:06.159ZApplied to files:
📚 Learning: 2025-10-29T23:56:18.236ZApplied to files:
📚 Learning: 2025-08-28T04:54:20.953ZApplied to files:
🔇 Additional comments (6)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java (1)
1415-1427: Method name normalization fix looks correct; consider extracting a shared helperThe new loop that repeatedly strips leading tokens until there are no spaces before the first
'('correctly fixes the case where return types (e.g., with wildcards likeList<? super String>) introduce extra spaces before the method name. This brings the stubx-derivedmethodNameAndSignatureinto alignment with whatMethodRef.fromSymbolexpects, without changing behavior for simpler signatures.The same normalization logic is now duplicated in:
explicitlyNullableParameters(...)nonNullParameters(...)nullableReturns(...)To keep these paths consistent and easier to evolve, consider extracting a small private helper like
normalizeMethodNameAndSignature(String rawKey)that:
- Strips everything before the method name using this loop, and
- Optionally leaves comma/whitespace post-processing to the individual callers.
That would reduce repetition and the risk of future divergence between parameter and return handling.
Also applies to: 1447-1453, 1501-1507
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
jdk-annotations/jdk-integration-test/src/test/java/com/uber/nullaway/jdkannotations/JDKIntegrationTest.java(1 hunks)jdk-annotations/test-annotated/src/main/java/com/uber/nullaway/jdkannotations/ReturnAnnotation.java(2 hunks)jdk-annotations/test-unannotated/src/main/java/com/uber/nullaway/jdkannotations/ReturnAnnotation.java(2 hunks)nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java(3 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: msridhar
Repo: uber/NullAway PR: 1245
File: guava-recent-unit-tests/src/test/java/com/uber/nullaway/guava/NullAwayGuavaParametricNullnessTests.java:101-102
Timestamp: 2025-08-14T18:50:06.159Z
Learning: In NullAway JSpecify tests, when JDK version requirements exist due to bytecode annotation reading capabilities, prefer failing tests over skipping them on unsupported versions to ensure CI catches regressions and enforces proper JDK version usage for developers.
Learnt from: msridhar
Repo: uber/NullAway PR: 1248
File: nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java:847-857
Timestamp: 2025-08-28T04:54:20.953Z
Learning: In NullAway's GenericsChecks.java, NewClassTree support for explicit type argument substitution requires more extensive changes beyond just modifying the conditional in compareGenericTypeParameterNullabilityForCall. The maintainers prefer to handle NewClassTree support in a separate follow-up rather than expanding the scope of PRs focused on specific issues like super constructor calls.
📚 Learning: 2025-08-14T18:50:06.159Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1245
File: guava-recent-unit-tests/src/test/java/com/uber/nullaway/guava/NullAwayGuavaParametricNullnessTests.java:101-102
Timestamp: 2025-08-14T18:50:06.159Z
Learning: In NullAway JSpecify tests, when JDK version requirements exist due to bytecode annotation reading capabilities, prefer failing tests over skipping them on unsupported versions to ensure CI catches regressions and enforces proper JDK version usage for developers.
Applied to files:
jdk-annotations/test-annotated/src/main/java/com/uber/nullaway/jdkannotations/ReturnAnnotation.javajdk-annotations/jdk-integration-test/src/test/java/com/uber/nullaway/jdkannotations/JDKIntegrationTest.java
📚 Learning: 2025-08-29T18:41:43.584Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1259
File: jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/SwitchTests.java:318-321
Timestamp: 2025-08-29T18:41:43.584Z
Learning: Classes annotated with NullMarked are analyzed by NullAway even if they are not in packages specified by the AnnotatedPackages configuration. The NullMarked annotation guarantees NullAway analysis.
Applied to files:
jdk-annotations/test-annotated/src/main/java/com/uber/nullaway/jdkannotations/ReturnAnnotation.java
📚 Learning: 2025-10-29T23:56:18.236Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1316
File: jdk-javac-plugin/src/main/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializer.java:261-293
Timestamp: 2025-10-29T23:56:18.236Z
Learning: In NullAway's jdk-javac-plugin NullnessAnnotationSerializer, type variable bounds with annotations (e.g., `T extends Nullable Object`) are checked at their declaration sites by the typeParamHasAnnotation method for both class-level and method-level type parameters. The hasJSpecifyAnnotationDeep method is designed to check type uses (return types, parameters, etc.) and does not need a TYPEVAR case because type variable declaration bounds are already handled separately.
Applied to files:
jdk-annotations/test-annotated/src/main/java/com/uber/nullaway/jdkannotations/ReturnAnnotation.java
📚 Learning: 2025-08-28T04:54:20.953Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1248
File: nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java:847-857
Timestamp: 2025-08-28T04:54:20.953Z
Learning: In NullAway's GenericsChecks.java, NewClassTree support for explicit type argument substitution requires more extensive changes beyond just modifying the conditional in compareGenericTypeParameterNullabilityForCall. The maintainers prefer to handle NewClassTree support in a separate follow-up rather than expanding the scope of PRs focused on specific issues like super constructor calls.
Applied to files:
nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Build and test on macos-latest
- GitHub Check: Build caffeine with snapshot
- GitHub Check: Build and test on ubuntu-latest
- GitHub Check: Build and test on windows-latest
- GitHub Check: Build spring-framework with snapshot
🔇 Additional comments (2)
jdk-annotations/test-annotated/src/main/java/com/uber/nullaway/jdkannotations/ReturnAnnotation.java (1)
3-6: New annotatedgetListmethod correctly models wildcard return for testsThe added imports and
getList(@NonNull Integer, @Nullable Character)with@Nullable List<? super String>return cleanly exercise the wildcard-return modeling path without affecting production logic. Looks good as a dedicated fixture for the new integration test.Also applies to: 82-84
jdk-annotations/test-unannotated/src/main/java/com/uber/nullaway/jdkannotations/ReturnAnnotation.java (1)
3-3: UnannotatedgetListcompanion matches annotated fixture as intendedThe unannotated
getList(Integer, Character)correctly mirrors the annotated version’s signature (sans nullability) and provides the necessary target for stubx-based modeling. No issues spotted.Also applies to: 71-73
.../jdk-integration-test/src/test/java/com/uber/nullaway/jdkannotations/JDKIntegrationTest.java
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1344 +/- ##
============================================
- Coverage 88.40% 88.39% -0.02%
Complexity 2592 2592
============================================
Files 97 97
Lines 8701 8702 +1
Branches 1731 1732 +1
============================================
Hits 7692 7692
Misses 505 505
- Partials 504 505 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| return null; | ||
| } | ||
|
|
||
| public static @Nullable List<? super String> getList(@NonNull Integer i, @Nullable Character c) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this class is @NullMarked you shouldn't need the @NonNull annotation on i
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I will change.
.../jdk-integration-test/src/test/java/com/uber/nullaway/jdkannotations/JDKIntegrationTest.java
Show resolved
Hide resolved
nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java(4 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: msridhar
Repo: uber/NullAway PR: 1248
File: nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java:847-857
Timestamp: 2025-08-28T04:54:20.953Z
Learning: In NullAway's GenericsChecks.java, NewClassTree support for explicit type argument substitution requires more extensive changes beyond just modifying the conditional in compareGenericTypeParameterNullabilityForCall. The maintainers prefer to handle NewClassTree support in a separate follow-up rather than expanding the scope of PRs focused on specific issues like super constructor calls.
🔇 Additional comments (3)
nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java (3)
1420-1420: LGTM - maintainer-reviewed extraction.The use of
getMethodNameAndSignaturecorrectly handles wildcard types in method signatures. The subsequent comma-space normalization ensures consistent formatting forMethodRefconstruction.Based on past review comments
1441-1441: LGTM - consistent with parameter handling pattern.Correctly applies
getMethodNameAndSignaturewith the same whitespace normalization approach used inexplicitlyNullableParameters.
1493-1498: Clarify the need for additional stripping logic.After calling
getMethodNameAndSignature(which finds the last space before '('), this while loop continues to strip leading components if spaces remain before '('. This suggests either:
getMethodNameAndSignaturedoesn't fully handle certain edge cases, or- This is defensive/redundant code
Additionally,
nullableReturnsremoves ALL whitespace (line 1506:replaceAll("\\s", "")), while parameter methods only remove spaces after commas.Can you clarify:
- Why is the while loop necessary after
getMethodNameAndSignaturehas already extracted from the last space before '('?- Why does
nullableReturnsrequire different whitespace normalization than the parameter methods?If the while loop is defensive but not strictly necessary, consider adding a comment explaining the edge cases it handles. If it's truly redundant given the helper's logic, it could be removed for consistency with the parameter methods.
nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java(5 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: msridhar
Repo: uber/NullAway PR: 1248
File: nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java:847-857
Timestamp: 2025-08-28T04:54:20.953Z
Learning: In NullAway's GenericsChecks.java, NewClassTree support for explicit type argument substitution requires more extensive changes beyond just modifying the conditional in compareGenericTypeParameterNullabilityForCall. The maintainers prefer to handle NewClassTree support in a separate follow-up rather than expanding the scope of PRs focused on specific issues like super constructor calls.
🔇 Additional comments (3)
nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java (3)
1468-1473: LGTM: Well-implemented helper method.The helper correctly extracts the method name and signature by finding the last space before the opening parenthesis. The
Verify.verify()provides adequate defensive validation for malformed input.Based on past review comments, the maintainer has already reviewed and simplified this logic.
1421-1421: LGTM: Correct usage of the helper method.The helper is properly used to extract the method name and signature, followed by appropriate normalization to remove spaces after commas in the parameter list.
1442-1442: LGTM: Consistent implementation withexplicitlyNullableParameters().The same pattern is correctly applied here - extract method name and signature, then normalize by removing spaces after commas.
When loading external library models through the
ExternalStubxLibraryModelsclass, it previously didn't parse the method name for methods with wildcard types properly. This PR fixes the method parsing so that it will work for those cases.The unit test for this is located in
java/com/uber/nullaway/jdkannotations/JDKIntegrationTest.javaand islibraryLoadMethodParser().Summary by CodeRabbit
New Features
Tests
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.