square / dagger

A fast dependency injector for Android and Java.

Home Page:https://square.github.io/dagger/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consider constructor auto-generation to allow private field injection.

vackosar opened this issue · comments

For example in class A { @Inject private B b; } field b cannot be injected because it is private field.

Can you please consider to automatically generate constructor into class A upon compilation to avoid having to make b more accessible or writing constructor manually?

Annotation processing cannot modify existing classes. This cannot be done
for that reason alone, among others.

On Mon, Feb 15, 2016, 3:37 PM Vaclav Kosar notifications@github.com wrote:

For example in class A { @Inject private B b; } field b cannot be
injected because it is private field.

Can you please consider to automatically generate constructor into class A
upon compilation to avoid having to make b more accessible or writing
constructor manually?


Reply to this email directly or view it on GitHub
#518.

Well AspectJ does code generation at compile time, so it can be done, no?

Byte code rewriting is a very different thing than annotation processing,
though. And Dagger has no way of interacting with code at the bytecode
level.

On Mon, Feb 15, 2016 at 5:13 PM Vaclav Kosar notifications@github.com
wrote:

Well AspectJ does code generation at compile time, so it can be done, no?


Reply to this email directly or view it on GitHub
#518 (comment).