Issues with generic type detection of SAM types implemented using lambdas
Oliver Gierke
ogierke at pivotal.io
Thu Jan 11 14:03:26 UTC 2018
> Am 11.01.2018 um 14:56 schrieb David Lloyd <david.lloyd at redhat.com>:
>
> On Thu, Jan 11, 2018 at 3:10 AM, Oliver Gierke <ogierke at pivotal.io> wrote:
>> Lambda based implementations of SAM types currently don't support inspecting the type for generic type parameters. This can cause unexpected surprise...
>
> Here's a non-lambda example that demonstrates that inspecting *any*
> class for generic type parameters is fragile and not a good idea:
>
> public final class Hasher<T> implements ToIntFunction<T> {
> int applyAsInt(T value) { return value.hashCode(); }
> }
>
> Oops, now all my concrete implementations have generic parameters.
I'm afraid I can't follow.
> Telling users they cannot have generic parameters on their
> implementation classes is poor API design.
Who is actually doing that?
Cheers,
Ollie
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20180111/90345a3b/signature.asc>
More information about the compiler-dev
mailing list