Wow, I ran some tests, and instanceof really is lightning fast.
I made new Test[10000000] containing 50% Test1 and 50% Test2 objects, then iterated over all of them, calling getValue() on each. This took about 1350 ms.
I made another loop, doing instanceof on each object, testing against both Test1 and Test2, setting the value to what the object call would return. This ran in about 700 ms
Out of curiosity, I also made a loop that did getType() and compared it against a static final int (basically a manual version of instanceof), and this ran in 1350 ms.
instanceof is still bad, imo, as in order to add new code, you have to find all the places you use instanceof and insert code there, instead of having it all encapsulated in one place… but if you have a tight inner loop that you want to get rid of a costly method call in, instanceof actually seems like a good idea, as it’s almost twice as fast (in my very naive test).