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 ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.