Skip to content
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

Refactor PreservedAnnotationTreeVisitor #955

Merged
merged 4 commits into from
May 14, 2024

Conversation

msridhar
Copy link
Collaborator

We extract some code from visitParameterizedType into a proper visitAnnotatedType method. This will be useful for an upcoming PR that handles AnnotatedTypeTrees in new array expressions. The change introduces some complexity due to API changes in JDK 21, which we work around through further use of MethodHandles.

Copy link

codecov bot commented May 13, 2024

Codecov Report

Attention: Patch coverage is 87.75510% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 86.06%. Comparing base (c26ae17) to head (0a2d4d5).

Files Patch % Lines
...laway/generics/PreservedAnnotationTreeVisitor.java 87.75% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #955      +/-   ##
============================================
- Coverage     86.11%   86.06%   -0.06%     
+ Complexity     2030     2027       -3     
============================================
  Files            81       81              
  Lines          6662     6679      +17     
  Branches       1291     1287       -4     
============================================
+ Hits           5737     5748      +11     
- Misses          512      518       +6     
  Partials        413      413              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@msridhar msridhar marked this pull request as ready for review May 13, 2024 22:42
Copy link
Collaborator

@lazaroclapp lazaroclapp left a comment

Choose a reason for hiding this comment

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

LGTM. Particularly since all existing tests pass after the refactor.

@@ -156,6 +160,32 @@ private static MethodHandle createHandle() {
}
}

private static MethodHandle createGetMetadataHandle() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remind me, all of these methods with reflection trickery are to avoid having a compile-time dep on JDK21, correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A bunch of (internal) javac APIs changed between JDK 17 and 21 related to these TypeMetadata objects. On JDK 21+ we use reflection to operate on them since I expect that is used less for compiling than JDK 17 and before. Unfortunately I think we can only drop this reflection approach once we drop support for building on JDK 17. This is hacky, but the alternative that doesn't rely on internal APIs would require building up our own type data structures from scratch, like Checker Framework, which would be a lot more code.

@msridhar msridhar enabled auto-merge (squash) May 14, 2024 02:49
@msridhar msridhar merged commit e0d5c6b into uber:master May 14, 2024
12 checks passed
@msridhar msridhar deleted the refactor-preserved-annotations branch May 14, 2024 02:56
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