logging-log4j2 icon indicating copy to clipboard operation
logging-log4j2 copied to clipboard

Type parameters used only in the return type

Open ppkarwasz opened this issue 2 years ago • 3 comments

As described in TypeParameterUnusedInFormals, these methods provide developers a false sense of type safety, whereas in reality they can cause ClassCastExceptions at runtime:

Changing/removing these methods is a binary compatible, but source incompatible change, hence this must be done in a major release.

ppkarwasz avatar Nov 14 '23 07:11 ppkarwasz

This is related to #1850.

ppkarwasz avatar Nov 14 '23 08:11 ppkarwasz

Also a few new places in the DI system (some of which is difficult to express within the limitations of the Java type system).

jvz avatar Dec 01 '23 17:12 jvz

In fact, there are numerous places in the DI system abusing this. I'd be open to cleaning that up as it might also allow for the Key<T> class to be turned into a Key record class instead as only the Type reference is needed.

jvz avatar Jan 19 '24 20:01 jvz