All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.java.rules.java.S4968.html Maven / Gradle / Ivy

There is a newer version: 8.6.0.37351
Show newest version

Why is this an issue?

When a type variable or a wildcard declares an upper bound that is final, the parametrization is not generic at all because it accepts one and only one type at runtime: the one that is final. Instead of using Generics, it’s simpler to directly use the concrete final class.

Noncompliant code example

public static <T extends String> T getMyString() { // Noncompliant; String is a "final" class and so can't be extended
 [...]
}

Compliant solution

public static String getMyString() { // Compliant
  [...]
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy