PROPOSAL: Method and Field Literals (original) (raw)
Roel Spilker r.spilker at gmail.com
Wed Mar 11 17:13:17 PDT 2009
- Previous message: PROPOSAL: Method and Field Literals
- Next message: PROPOSAL: Method and Field Literals
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Previous message: PROPOSAL: Method and Field Literals
- Next message: PROPOSAL: Method and Field Literals
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]