• Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between RTTI and reflection  RSS feed

 
Chet Arora
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
What is the difference between RTTI methods such as "instanceof" etc as compared to reflection. I was going through Thinking in Java and it says while for RTTI the Class object is loaded at compile time, during reflection it happens at run time. Could some one please explain this ?!!
Thanks,
Chetan
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"RTTI" stands for Run-Time Type Identification, so the claim that it's something that happens at compile-time is obviously not right. "instanceof" is a runtime operation; it corresponds to a specific "instanceof" bytecode.
Someone might try to draw an artificial distinction between RTTI as "type identification", and reflection as "type investigation" but really it's a continuum; RTTI is more or less a subset of reflection.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!