Tuesday, July 8, 2008

You don't have to answer that...

So, I had another funny interaction with Jeremiah Holly Abraham-Castlevania yesterday. This one was on the phone, but it went basically like this:

(While trying to debug an issue in her application...)
Me: Okay, I just sent you an email with a couple of configuration changes. Put those in and we'll try it again.
Jeremiah Holly Abraham-Castlevania: Okay, I got it. Do you want me to put those in?
(crickets: *chirp*chirp*chirp*)
Jeremiah Holly Abraham-Castlevania: Okay, you don't have to answer that.
Jeremiah Holly Abraham-Castlevania: Alright, they are in.
Me: Okay, now try it out.
Jeremiah Holly Abraham-Castlevania: Do you want me to run it now?
(again with the crickets: *chirp*chirp*chirp*)
Jeremiah Holly Abraham-Castlevania: You don't have to answer that either...
Me: You don't really need me here for this conversation, do you?

Tuesday, July 1, 2008

Another victim of The Wall of Erasure

Ahh, Erasure....  Today I was implementing an extension to a class that performs traversing of tree-like object structures (think UI component hierarchies).  The parent class extends another type-parameterized version of an abstract class which provides general tree traversal logic.  The problem is that I wanted to check that the current node is of a type beyond that of the type parameter provided to the parent class.  So to put that into something that might actually be understandable:

public class ParentFinder<T extends Component> extends ComponentVisitor {

private T parent = null;

public ParentFinder() {
// Set up things to travel up the tree...
...
}

public void visit(Component node) {
if(T.class.isAssignableFrom(node.getClass())
parent = (T)node;
}
}

Survey says! *BZZZZ* XXX *BZZZZ* This line is no good thanks to erasure:

  if(T.class.isAssignableFrom(node.getClass())


And, no...you cannot do "instanceof" either. The JVM couldn't tell you if it wanted to. That info is G-O-N-E, gone!

How dare you want to know what you are working with!