If I understand it correct, it should cost nothing in addition to actual function processing (of toString/hashCode/equals), if Java could compute the functions for the object for which compile-time reflection is requested.
For the cases when objects are up/down casted the behavior is still better than pointer address as toString representation, which practically is useless.
Something like
// Returns the compile time 'ReflectionToStringBuilder.toString(foo)'
foo.tryToString()
What am I missing ?
Replying a comment I found correct words to my question.
Why do we have to hand code (/eclipse generated) toString/hash/equals which could have been done by Java compiler ?
Aucun commentaire:
Enregistrer un commentaire