Type safety with Java 8

98 views
Skip to first unread message

Mark Hobson

unread,
May 24, 2015, 10:22:37 AM5/24/15
to hamcre...@googlegroups.com
Hi there,

Using Hamcrest under Java 8 appears to relax type safety in matcher expressions. For example, the following fails to compile under Java 7 but is fine in Java 8:

    assertThat(singletonList("x"), contains(123));

This is due to Java 8's generalized target-type inference. Is anyone aware of a way to improve Hamcrest's generics to reinstate the previous stricter behaviour?

Thanks,

Mark

Thierry Monney

unread,
Sep 24, 2015, 8:53:23 AM9/24/15
to Hamcrest Java Users
Hi Mark,

Any news on this topic? I could not find much info and this group seems to be really quiet...

Cheers
Thierry

Mark Hobson

unread,
Sep 24, 2015, 6:09:02 PM9/24/15
to hamcre...@googlegroups.com
Hi Thierry,

I'm afraid there hasn't been any discussion about this. The list is
pretty quiet so perhaps raising an issue would be better.

Cheers,

Mark
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Hamcrest Java Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/hamcrest-java/oZcgPZPZ3YY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> hamcrest-jav...@googlegroups.com.
> To post to this group, send email to hamcre...@googlegroups.com.
> Visit this group at http://groups.google.com/group/hamcrest-java.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages