Recently in read thinking in Java this book. When I read the type information, I started to mix up the Rtti and reflections in the book, and I don't know what the connection is, what the similarities and differences are. So on the Internet and find some content auxiliary understanding, this chapter again read again, to the above questions have their own answer, think of Rtti and reflection, the mind has its own outline.
They both have the same purpose:
At run time, information about objects and classes is recognized.
Same point:
The same purpose;
Functions are implemented through class classes.
Different points:
RTTI: (primarily in polymorphic, such as parameter passing) it assumes that we already know all types at compile time and will open and inspect all. class files. For example: in polymorphic parameter passing, the base class and the derived class are opened and checked.
Reflection:. Class is not available at compile time, so the. class file is opened and checked at run time.
Noun Explanation:
Rtti:runtime type identification, run-time types identification.
Class: Classes of classes; class type; For example, an object dog dog, [Dog.class,dog.getclass (), Class.forName (dog)] are objects of class type. Role: One is how the type information of an object is represented at run time and is a special object through class.
Understanding of Java's Rtti and reflection