Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

RTTI vs. Reflection

637 views
Skip to first unread message

Michael Maretzke

unread,
Jun 6, 2001, 6:54:58 AM6/6/01
to
Hello !

I'm a little bit confused using RTTI and Reflection ...

RTTI means:
* Know the class to use and the interface at compiletime
* Usage of instanceof
* Usage of Class

Reflection means:
* No knowledge about the class to use at compiletime -> usage of
java.lang.reflection.*
* Usage of Class

Main difference is the knowledge / missing knowledge of the class to use or
its internal
structure. Am I right ?

Thx, Michael.


Chris Smith

unread,
Jun 6, 2001, 1:37:08 PM6/6/01
to
"Michael Maretzke" <michael....@conrad.com> wrote ...

> I'm a little bit confused using RTTI and Reflection ...
>

Don't be. They are essentially the same. RTTI is a term from C++ heritage,
and Reflection from the "pure" OO heritage. Typically, reflection implies a
greater level of control than RTTI. Java's implementation falls somewhere
between the capabilities of RTTI and Reflection, but has been given the name
reflection by Sun.

Historically, Java did not have all of its reflection abilities that it
currently does until version 1.1 -- so book authors describing the 1.0
abilities (which were far more limited and not yet named) applied the term
RTTI to refer to them. Some people still try to make a distinction between
1.0 compatible type information and "reflection", but it makes more sense to
consider the whole thing (including Class and even the instanceof operator)
to be reflection.

Chris Smith

Michael Maretzke

unread,
Jun 7, 2001, 3:53:58 AM6/7/01
to
Hey, Chris !

Thank you for your answer. I felt that RTTI and reflection are basically the
same.
But Bruce Eckel in his book "Thinking in java" didn't make it as clear.

Your answer brought me the light ;-)))

RU,
Michael.

"Chris Smith" <cds...@twu.net> schrieb im Newsbeitrag
news:9flpp0$uv8$0...@pita.alt.net...

0 new messages