Using SonarLint Plugin 5.1.0.34721 for IntelliJ gives a hint based on S1612 for line with mapToObj:
Replace this lambda with method reference ‘char.class::cast’.
public static void main(String[] args) {
final List<Character> characters = "abc"
.chars()
.mapToObj(i -> (char) i)
.collect(Collectors.toList());
characters.forEach(c->System.out.println("char: "+c));
}
After changing the code it produces a ClassCastException at runtime:
Cannot cast java.lang.Integer to char