Only the first line is an injection point, hence CDI will scan it and ensure that it can be injected. The second line is not scanned by CDI to ensure that it's injectable, because CDI isn't trying to inject into it.
SuppressWarnings
is a compile time annotation, not a runtime. It's lost in the compiled class.
You can create a Set
implementation that implements serializable and use that. It should be injected as that set impl.