Private field is never assigned....... but it is!!

Hi,
with intellij idea community
I have a class where I do define:

@Inject @Any private Event<BootstrapData> bootstrapDataEvent;

and I use it.
But at the definition line the variable is marked as never assigned "Private field bootstrapDataEvent is never assigned".

I notice that the same happens with other @Inject variables.

How can I make those variables marked as used, please?

TIA,
bye
Nicola

2 comments

nikolaus wrote:
How can I make those variables marked as used, please?


With your cursor on the field name (i.e. bootstrapDataEvent), type Alt + Enter (Windows) or   (Mac)  . From the popup, select the "Suppress for fields annotated by 'package.name.Inject'".

If that option does not show, arrow down to the "Create Setter" option and hit the right arrow. On the side menu select "Edit inspection profile setting". That will open the Inspections Configuration dialog, with the "Unused  symbol" inspection selected. Click the "Configure annotations..." button and add your annotation.

6

This works but it seems like something that IntelliJ should do automatically for things like CDI and JPA.

2

Please sign in to leave a comment.