Como converter Array para HashMap usando o Java 8 Stream

Estou escrevendo uma função para converter matriz em mapa usando o Java 8 Stream.

Aqui está o que eu queria

public static <K, V> Map<K, V> toMap(Object... entries) {
    // Requirements:
    // entries must be K1, V1, K2, V2, .... ( even length )
    if (entries.length % 2 == 1) {
        throw new IllegalArgumentException("Invalid entries");
    }

    // TODO
    Arrays.stream(entries).????
}

Usos válidos

Map<String, Integer> map1 = toMap("k1", 1, "k2", 2);

Map<String, String> map2 = toMap("k1", "v1", "k2", "v2", "k3", "v3");

Usos inválidos

Map<String, Integer> map1 = toMap("k1", 1, "k2", 2, "k3");

Alguma ajuda?

Obrigado!

questionAnswers(5)

yourAnswerToTheQuestion