-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix: consider current package when generating bean imports #10236
base: 4.3.x
Are you sure you want to change the base?
Conversation
could you add a test? |
Seems like the change broke something, so the logic is not quite correct |
dd240a3
to
3962443
Compare
3962443
to
1ce0b62
Compare
I think my change exposed a bug in core-processor/src/main/java/io/micronaut/inject/ast/utils/EnclosedElementsQuery.java which didn't filter the package private elements in case the I've noticed that the 4.3.x branch contains a major change to EnclosedElementsQuery.java and does seem to work with my change to AbstractBeanDefinitionBuilder but also doesn't consider I would like to add a test, but i'm not sure where to start since the result of the changes are a change in the generated bytecode and i'm unable to assert that the generated bean definition isn't using reflection for the package private fields. (and i was triggering the wrong shortcuts which closed and re-openend this merge request, sorry about that) |
1ce0b62
to
0c7dc01
Compare
The internal bean element implementation didn't implement the methods for the determination of the visibility of the class, which resulted in the use of reflection for the bean definitions generated for the bean import. By implementing the visibility methods the generated code for the imported bean definitions don't use reflection when the fields are visible.
The enclosed element query didn't consider the type from which the element is accessible, which made package private elements being filtered out of the result even though they where visible for the type.
0c7dc01
to
84ba934
Compare
The internal bean element implementation didn't implement the methods for the determination of the visibility of the class, which resulted in the use of reflection for the bean definitions generated for the bean import.
By implementing the visibility methods the generated code for the imported bean definitions don't use reflection when the fields are visible.
I've tried to add a test to inject-java-test/src/test/groovy/io/micronaut/inject/beanimport/BeanImportSpec.groovy but i'm unable to determine if reflection is used, this information isn't available in the BeanDefinition: