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

All @Inject fields/properties must be public #22

Open
kirich1409 opened this issue Mar 2, 2023 · 3 comments
Open

All @Inject fields/properties must be public #22

kirich1409 opened this issue Mar 2, 2023 · 3 comments
Labels
enhancement New feature or request priority:minor Issue with minor priority.

Comments

@kirich1409
Copy link

I use Dagger 2 and have a lot of Java fields with Inject annotation and package-private or protected access. With Yatagan isn't possible to have the same restrictions in access and I need to make all fields like this public. I found out that the restriction connected with reflection mode, but reflection API has possibility to allow modify not public fields

@Jeffset Jeffset added this to the 1.2.0 milestone Mar 2, 2023
@Jeffset Jeffset added priority:normal Issue with normal priority (default if absent) enhancement New feature or request backend:reflection Related to reflection (RT) backend labels Mar 2, 2023
@Jeffset
Copy link
Collaborator

Jeffset commented Mar 2, 2023

I'll investigate the possibility of using such API.

@Jeffset
Copy link
Collaborator

Jeffset commented Mar 15, 2023

Well, Yatagan doesn't generate any factories/injectors in the same package as Dagger does. So even if it is possible to use isAccessible = true with RT mode, the compilation will fail with generated code if the component declaration is in the different package than the class with @Inject constructor/fields being accessed. So there's no point in using this reflection API at all.
Now, what can be done, is more precise access checks instead of conservatively requiring everything to be public/internal. This is more difficult to implement, and may introduce additional performance overhead in RT. This needs more investigation. And, of course, this will not let us to use package-private/protected fields/constructors with components from another packages.

@Jeffset
Copy link
Collaborator

Jeffset commented Mar 15, 2023

As the profit of solving this is, sadly, less than we expected, I'll lower the priority.

@Jeffset Jeffset added priority:minor Issue with minor priority. and removed priority:normal Issue with normal priority (default if absent) labels Mar 15, 2023
@Jeffset Jeffset removed this from the 1.2.0 milestone Mar 27, 2023
@Jeffset Jeffset removed the backend:reflection Related to reflection (RT) backend label Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority:minor Issue with minor priority.
Projects
None yet
Development

No branches or pull requests

2 participants