Skip to content

Null type safety warnings occur in method references that take primitive values as arguments #2716

Open
@mazeneko

Description

@mazeneko

When such code is written, a warning occurs.
But I expected no warning here.

Is this behavior reasonable?

package example;

import java.math.BigInteger;
import java.util.List;
import java.util.Optional;

public class App {
    public static void main(String[] args) {
        List.of(1, 2, 3)
                .stream()
                .map(BigInteger::valueOf)
                .forEach(System.out::println);

        Optional.of(1)
                .map(Math::incrementExact)
                .ifPresent(System.out::println);
    }
}

image

Environment
  • Operating System: Windows10
  • JDK version: JDK17
  • Visual Studio Code version: 1.71.2
  • Java extension version: 1.11.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions