apache / logging-log4j2

Apache Log4j 2 is a versatile, feature-rich, efficient logging API and backend for Java.
https://logging.apache.org/log4j/2.x/
Apache License 2.0
3.39k stars 1.61k forks source link

Type parameters used only in the return type #1967

Open ppkarwasz opened 11 months ago

ppkarwasz commented 11 months ago

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 commented 11 months ago

This is related to #1850.

jvz commented 11 months ago

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 commented 9 months ago

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.