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

Annotation processor don't read field annotations with @Target(TYPE_USE) #8706

Closed
altro3 opened this issue Feb 2, 2023 · 6 comments
Closed
Assignees
Milestone

Comments

@altro3
Copy link
Contributor

altro3 commented Feb 2, 2023

Expected Behavior

Field annotations should be read correctly

Actual Behaviour

Now such annotations are ignored

Steps To Reproduce

Create class like this:

@Introspected
class HelloWorldDto {

    @org.eclipse.jdt.annotation.Nullable
    public String eclipse;

    @org.jspecify.annotations.Nullable
    public String jspecify;
}

And check field elements in annotation processsor:

element.hasStereotype("org.jspecify.annotations.Nullable")
|| element.hasStereotype("org.eclipse.jdt.annotation.Nullable")

Annotations will not be found

Environment Information

  • Win 11
  • JDK17

Example Application

No response

Version

3.8.3

altro3 added a commit to altro3/micronaut-core that referenced this issue Feb 2, 2023
@altro3 altro3 changed the title Annotation process don't read field annotations with @Target(TYPE_USE) Annotation processor don't read field annotations with @Target(TYPE_USE) Feb 3, 2023
@dstepanov
Copy link
Contributor

Type annotation aren't supported in Micronaut 3 and will be supported in Micronaut 4

@graemerocher graemerocher added this to the 4.0.0-M1 milestone Feb 23, 2023
@graemerocher
Copy link
Contributor

@dstepanov can this be closed?

@altro3
Copy link
Contributor Author

altro3 commented Jul 16, 2023

@dstepanov still doesn't work with micronaut 4.0

@dstepanov
Copy link
Contributor

Please create an example

@altro3
Copy link
Contributor Author

altro3 commented Jul 16, 2023

@dstepanov just try to run test "test build OpenAPI with eclipse and jspecify Nullable annotations" here https://github.com/micronaut-projects/micronaut-openapi/blob/905b1e98efb7d448cebd4fcc8ea1df26960e2353/openapi/src/test/groovy/io/micronaut/openapi/visitor/OpenApiNullableTypesSpec.groovy#L297C10-L297C77

And you will see that nullable is false. I mean, method isNullable() will return false, but we have annotation mappers for these annotations - SpotbugsNullableTransformer and JspecifyNullableTransformer

@dstepanov
Copy link
Contributor

@altro3 It works correctly, but in this case the nullable annotation will come on the field's type, the code needs to be adjusted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

No branches or pull requests

3 participants