PROPOSAL: Method and Field Literals (original) (raw)
Neal Gafter neal at gafter.com
Wed Mar 11 17:23:24 PDT 2009
- Previous message: PROPOSAL: Method and Field Literals
- Next message: PROPOSAL: Method and Field Literals
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 gmail.com> 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 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.
- Previous message: PROPOSAL: Method and Field Literals
- Next message: PROPOSAL: Method and Field Literals
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]