You've pretty much answered your own question. How you define 'reflection' determines whether instanceof is an example of reflection. Certainly it is somewhere between normal data use and metadata use via getClass() & friends, but you can have workable definitions wither way.
–
Kilian FothSep 7 '11 at 7:26

Is the usage of return considered "structural programming"?
–
SF.Sep 7 '11 at 9:13

4 Answers
4

In computer science, reflection is the process by which a computer
program can observe (do type introspection) and modify its own
structure and behavior at runtime.

I couldn't have said it better myself and highlighted the important part for your question. That said, yes, instanceof is considered using reflection. The program observes its structure and conducts type introspection.

Can getting the type of a variable be considered 'introspection'? :) A simple if ( true ) also 'observes' the true value.
–
Steven JeurisSep 7 '11 at 7:40

3

@Steven Jeuris: The difference is that if (true) looks at a value, not at a type. That's why it's not considered reflection.
–
sleskeSep 7 '11 at 7:50

1

According to that definition of reflection, would normal polymorphism not also be a kind of reflection?
–
Bjarke Freund-HansenSep 7 '11 at 8:07

3

@bjarkef: I would say "no", as the virtual dispatch used by polymorphism is done implicitly by the language itself, rather than the application code explicitly examining the object in question to identify its characteristics.
–
Dave SherohmanSep 7 '11 at 8:31

1

@Dave Sherohman: I'd also add that most of the work (setting up jump tables, etc) is done at compile time, not run time.
–
TMNSep 7 '11 at 17:00

Theoretically, instanceof is a form of reflection, as explained in Falcon's answer.

In computer science, reflection is the process by which a computer
program can observe (do type introspection) and modify its own
structure and behavior at runtime.

However, practically, when a programmer talks about using reflection he usually refers to much more than just checking whether a variable is of a certain type. This is such a rudimentary concept, without which, polymorphism wouldn't be possible.

Do note that using instanceof often indicates a code smell, and proper polymorphism can often be used instead.