Tuesday, November 20, 2007

Dude, where's my method?

So I was creating a new method in a class. This method the same name, but different signature of an existing method, but it took in different arguments. I finished writing the method bodies, and went back to the class that called my new method.


Oddly, I got the error:

"The method getExchangeDelayPlot(ReportOptions) in the type ExchangeDelaysDAO is not applicable for the arguments (ReportRequest)".


Me: .".what are you talking about, stupid eclipse. I made the method getExchangeDelayPlot(ReportRequest), and saved it, and got no compiler errors. are you blind or something?"


Of course, my IDE was not blind. (isn't that always the case).

What I missed: Although I had added the method to the concrete class (ExchangeDelaysDAOImpl), I was trying to call the method its parent abstract class above this. I had forgotten to add the empty method signature of the new method to the abstract class.


Lesson 1: look carefully at the *type* in the error message.

Lesson 2: remember class hierarchies: remember to add method signatures to any abstract classes or interfaces you're trying to call your methods from.

No comments: