M
mark
This is a shameless plug to try to get votes for a recent bug I've
filed:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6356762
For a long time, it's bothered me that there is no way other than
reflection to obtain Method and Field objects to identify components of
classes. It should be possible to write something like
MyClass::nameOfMyField to obtain the FIeld object directly. With the
current reflection-only method, one has to obtain these by looking up
their String names. So:
-there's no way for the compiler to detect syntax errors at compile
time
-no real way to obfuscate this code
-debugging is more difficult because you are working indirectly through
strings
-it's inelegant to use Strings to perform at runtime what the compiler
should be able to do at compile time
One of the most immediate uses for this could be with classes
conforming to the Beans pattern. Instead of specifying String names
directly when firing property change events (whilch always risks a typo
cauing a hard to trace error), you could obtain the coresponding Field
object and call getName() on it.
If something like this could be provided in Mustang, I would be in
seventh heaven. Please vote for the bug, or let me know what you think
about this.
filed:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6356762
For a long time, it's bothered me that there is no way other than
reflection to obtain Method and Field objects to identify components of
classes. It should be possible to write something like
MyClass::nameOfMyField to obtain the FIeld object directly. With the
current reflection-only method, one has to obtain these by looking up
their String names. So:
-there's no way for the compiler to detect syntax errors at compile
time
-no real way to obfuscate this code
-debugging is more difficult because you are working indirectly through
strings
-it's inelegant to use Strings to perform at runtime what the compiler
should be able to do at compile time
One of the most immediate uses for this could be with classes
conforming to the Beans pattern. Instead of specifying String names
directly when firing property change events (whilch always risks a typo
cauing a hard to trace error), you could obtain the coresponding Field
object and call getName() on it.
If something like this could be provided in Mustang, I would be in
seventh heaven. Please vote for the bug, or let me know what you think
about this.