You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Antonio Gallardo <ag...@agsoftware.dnsalias.com> on 2003/10/26 11:06:31 UTC

Declared exceptions not thrown - Can be removed?

I was reviewing the cocoon code and found some declared exceptions that
are not thrown by the methods declared by it.

Sample: o.a.c.webapps.authentication.components.DefaultAuthenticationManager

There is a function:

   public void configure(SitemapConfigurationHolder holder)
    throws ConfigurationException {
        this.holder = holder;
    }

But this function does not trows any Exception. We can write:

   public void configure(SitemapConfigurationHolder holder)
   {
        this.holder = holder;
   }

This also works in Cocoon. Can we remove it? I ask because there are other
similars elsewhere.

Best Regards,

Antonio Gallardo.




RE: Declared exceptions not thrown - Can be removed?

Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Carsten Ziegeler dijo:
>> From: Antonio Gallardo [mailto:agallardo@agsoftware.dnsalias.com]
>>
>> I was reviewing the cocoon code and found some declared exceptions
>> that are not thrown by the methods declared by it.
>>
>> Sample:
>> o.a.c.webapps.authentication.components.DefaultAuthenticationManager
>>
>> There is a function:
>>
>>    public void configure(SitemapConfigurationHolder holder)
>>     throws ConfigurationException {
>>         this.holder = holder;
>>     }
>>
>> But this function does not trows any Exception. We can write:
>>
>>    public void configure(SitemapConfigurationHolder holder)
>>    {
>>         this.holder = holder;
>>    }
>>
>> This also works in Cocoon. Can we remove it? I ask because there are
>> other similars elsewhere.
>>
> These are methods defined by interfaces, like in the case above the
> Configurable interface. The method declared in that interface
> has the "throws" clause in its signature.
> You could remove them, but as soon as you start inheriting from such a
> class you can't overwrite the method anymore because of signature
> problems.
> So we should leave the throws clause if it belongs to an interface. In
> other cases, we could remove them.

Thanks for the answer.

Antonio Gallardo.





RE: Declared exceptions not thrown - Can be removed?

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
> From: Antonio Gallardo [mailto:agallardo@agsoftware.dnsalias.com]
>
> I was reviewing the cocoon code and found some declared exceptions that
> are not thrown by the methods declared by it.
>
> Sample:
> o.a.c.webapps.authentication.components.DefaultAuthenticationManager
>
> There is a function:
>
>    public void configure(SitemapConfigurationHolder holder)
>     throws ConfigurationException {
>         this.holder = holder;
>     }
>
> But this function does not trows any Exception. We can write:
>
>    public void configure(SitemapConfigurationHolder holder)
>    {
>         this.holder = holder;
>    }
>
> This also works in Cocoon. Can we remove it? I ask because there are other
> similars elsewhere.
>
These are methods defined by interfaces, like in the case above the
Configurable interface. The method declared in that interface
has the "throws" clause in its signature.
You could remove them, but as soon as you start inheriting from such
a class you can't overwrite the method anymore because of signature
problems.
So we should leave the throws clause if it belongs to an interface.
In other cases, we could remove them.

Carsten