PROPOSAL: Method and Field Literals

Neal Gafter neal at
Wed Mar 11 17:23:24 PDT 2009

This was the best we could do given the generic type system.  I don't
think there is anything to be done about it now, particularly not in
the context of this proposal.

On Wed, Mar 11, 2009 at 5:13 PM, Roel Spilker <r.spilker at> wrote:
> Another possible problem about the generified Field and Method literals is
> that there is no good support for the built-in types.
> class Foo {
>    int bar;
>    Field<Integer> barField = Foo#bar;
> }
> This seems a bit strange, even though it seems barField.set(foo,
> Integer.valueOf(1)) would work just fine, just as int value =
> barField.get(foo);
> However barField.set(foo, null) does not give a compiler error, but would
> fail. Currently, the javadoc suggests it would throw an
> IllegalArgumentException instead of a NPE. The only way to distinguish an
> Integer field from an int field is to check barField.getType() and compare
> it to int.class.

More information about the coin-dev mailing list