Skip to content

[java] Expose symbol annotations#4243

Merged
oowekyala merged 44 commits into
pmd:pmd/7.0.xfrom
jsotuyod:cle-typeres-annotations
Nov 29, 2022
Merged

[java] Expose symbol annotations#4243
oowekyala merged 44 commits into
pmd:pmd/7.0.xfrom
jsotuyod:cle-typeres-annotations

Conversation

@jsotuyod

@jsotuyod jsotuyod commented Nov 29, 2022

Copy link
Copy Markdown
Member

Describe the PR

This PR takes on @oowekyala's work on symbol annotations (see #4241) and expands on it to finalize it with a few minor improvements along the way.

Notice this PR focuses solely on symbolic annotations, that is, those that Java reflection will retrieve through AnnotatedElement.getDeclaredAnnotations(), which excludes both those with Target ElementType.TYPE_USE and ElementType.TYPE_PARAMETER, as those are actually impacting on the types (and in the reflection API obtainable only through getAnnotated*Type() family of methods. Targeting those are a next step, but both, independent, and massive enough to be worth a separate PR.

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

@jsotuyod jsotuyod added the in:type-resolution Affects the type resolution code label Nov 29, 2022
@jsotuyod jsotuyod added this to the 7.0.0 milestone Nov 29, 2022
@jsotuyod jsotuyod requested a review from oowekyala November 29, 2022 05:27
@jsotuyod jsotuyod mentioned this pull request Nov 29, 2022
4 tasks

@oowekyala oowekyala left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks fine to me, thanks! I have a couple of minor comments.

I implemented type annotation recovery from ASM in this branch. This does no interfere with your effort I think, but that may be a candidate for the next PR, to avoid diverging

jsotuyod and others added 4 commits November 29, 2022 09:58
…nternal/ast/AbstractAstExecSymbol.java

Co-authored-by: Clément Fournier <clement.fournier@tu-dresden.de>
…nternal/ast/AstClassSym.java

Co-authored-by: Clément Fournier <clement.fournier@tu-dresden.de>
…nternal/ast/AbstractAstVariableSym.java

Co-authored-by: Clément Fournier <clement.fournier@tu-dresden.de>
@ghost

ghost commented Nov 29, 2022

Copy link
Copy Markdown
2 Messages
📖 Compared to pmd/7.0.x:
This changeset changes 24 violations,
introduces 19 new violations, 0 new errors and 0 new configuration errors,
removes 14 violations, 0 errors and 0 configuration errors.
Full report
📖 Compared to master:
This changeset changes 50509 violations,
introduces 34666 new violations, 9 new errors and 0 new configuration errors,
removes 138300 violations, 4 errors and 7 configuration errors.
Full report
Compared to pmd/7.0.x:
This changeset changes 32 violations,
introduces 28 new violations, 0 new errors and 0 new configuration errors,
removes 20 violations, 0 errors and 0 configuration errors.
Full report
Compared to master:
This changeset changes 50508 violations,
introduces 34670 new violations, 9 new errors and 0 new configuration errors,
removes 138301 violations, 4 errors and 7 configuration errors.
Full report

Generated by 🚫 Danger

@jsotuyod

Copy link
Copy Markdown
Member Author

This should be ready now!

@oowekyala, as for how to let type annotations flow through type inference, keeping equality and what not… I've been thinking, maybe an option here is to do something similar to what Java'a reflection API actually does. Have the "annotated" types be wrappers on the standard types, and expose both (ie: Method.getReturnType() vs Method.getAnnotatedReturnType()). Equality can always be delegated to the not annotated one, and using a decorator can help minimize the number of classes we need to cope with.

I'm yet to take a look into what you did with https://github.com/oowekyala/pmd/tree/clem.type-annotations-support, but hope this helps. Let me know if I can assist you in any way with this.

@oowekyala oowekyala added the in:symbol-table Affects the symbol table code label Nov 29, 2022
@oowekyala oowekyala merged commit 5848e51 into pmd:pmd/7.0.x Nov 29, 2022
@jsotuyod jsotuyod deleted the cle-typeres-annotations branch November 29, 2022 20:43
@adangel adangel mentioned this pull request Jan 23, 2023
55 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:symbol-table Affects the symbol table code in:type-resolution Affects the type resolution code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants