Marshall Schor wrote:
Thilo Goetz wrote:
Marshall Schor wrote:
Running Findbugs, etc., will report on throws / catches that are
never used because the code in the try doesn't throw what is being
caught or propagated up.
It might be good to clean these up. Typically, they are not changed,
because that kind of a change in an API breaks user code. I'm
wondering if we could clean these up and have the migration utility
fix the user code?
Opinions?
-Marshall
Can you give examples? I wonder if Findbugs finds more than the
corresponding Eclipse compiler warning?
Actually, it's just Eclipse which picks up these warnings. Here's the
set from yesterday's build of uimaj-core; other projects also have these
warnings:
The declared exception AnalysisEngineProcessException is not actually
thrown by the method newCasProduced(CAS, String) from type CasFlow_ImplBase
<snip>
When you use Eclipse to generate method templates from interfaces,
Eclipse will add all the throws declarations inherited from the
interface for you. That's why we then get these warnings for exceptions
that we don't throw. Operationally, however, declaring the exception at
the implementation even if it isn't thrown makes no difference. Users
programming against the interface must try/catch the exception, no
matter what. Not declaring exceptions you don't throw on the
implementation is no more than documenting that your implementation
doesn't actually throw the exception declared in the interface (I have a
lurking suspicion that there is one too many negations in that sentence ;-).
I personally remove such throws declarations when I happen upon them,
but I'm not going out of my way to hunt them down. I have no strong
preferences either way.
--Thilo