PROPOSAL: Method and Field Literals

Roel Spilker r.spilker at gmail.com
Wed Mar 11 17:13:17 PDT 2009


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