Issues with generic type detection of SAM types implemented using lambdas
David Lloyd
david.lloyd at redhat.com
Thu Jan 11 13:56:50 UTC 2018
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.
Telling users they cannot have generic parameters on their
implementation classes is poor API design.
--
- DML
More information about the compiler-dev
mailing list