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

Invalid code generated when annotating private fields with @Inject #113

Closed
gunnarmorling opened this Issue Nov 17, 2012 · 3 comments

Comments

3 participants
@gunnarmorling

gunnarmorling commented Nov 17, 2012

When annotating a private field with visibility with @Inject, the annotation processor still generates code which directly accesses that field and thus can't be compiled. I think the annotation processor should better create an error clearly indicating the issue. On the other hand injecting private field works when using the reflective plug-in, so maybe the processor could also generate code which accesses the field reflectively in such cases.

@swankjesse

This comment has been minimized.

Show comment
Hide comment
@swankjesse

swankjesse Nov 17, 2012

Member

We should just report an error in either case. We don't want to rely on reflection.

Member

swankjesse commented Nov 17, 2012

We should just report an error in either case. We don't want to rely on reflection.

@gunnarmorling

This comment has been minimized.

Show comment
Hide comment
@gunnarmorling

gunnarmorling Nov 17, 2012

Or maybe invoke a setter method (if there is one)?

gunnarmorling commented Nov 17, 2012

Or maybe invoke a setter method (if there is one)?

@swankjesse

This comment has been minimized.

Show comment
Hide comment
@swankjesse

swankjesse Nov 17, 2012

Member

If application code wants private or final, it should use constructor injection.

Member

swankjesse commented Nov 17, 2012

If application code wants private or final, it should use constructor injection.

JakeWharton added a commit that referenced this issue Mar 26, 2013

JakeWharton added a commit that referenced this issue Mar 26, 2013

JakeWharton added a commit that referenced this issue Mar 26, 2013

JakeWharton added a commit that referenced this issue Mar 26, 2013

JakeWharton added a commit that referenced this issue Mar 26, 2013

JakeWharton added a commit that referenced this issue Mar 26, 2013

JakeWharton added a commit that referenced this issue Mar 26, 2013

JakeWharton added a commit that referenced this issue Mar 26, 2013

JakeWharton added a commit that referenced this issue Mar 27, 2013

Add restrictions around injectable targets.
 * Private fields are not supported.
 * Private constructors are not supported.
 * Methods are not supported.

Closes #181. Closes #113. Closes #112.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment