Compiler Setting: Unnecessary Exception Declaration [message #269310] |
Mon, 30 August 2004 19:31 |
Eclipse User |
|
|
|
Originally posted by: jay.kurant.com
Not sure if this is the correct newsgroup, so please correct me if it is
not.
Given the following classes:
public class A {
public void doSomething() throws IOException {
// nothing to do here
}
}
public class B extends A {
public void doSomething() throws IOException {
throw new IOException("I'm not doing anything!");
}
}
I enabled the compiler setting (Java | Compiler | Unused Code |
Unnecessary declaration of thrown checked exceptions) to be a warning. I
then get that A.doSomething() unnecessarily throws an IOException, as
expected. I then checked the box under the above compiler option, "Check
overriding and implementing methods". I expected the above warning to go
away, but it didn't.
I checked the archives and bug database about this, but I can only find
where the checkbox was added since having the functionality to check
overridding classes as the default could be costly (if I understand the
checkbox functionality correctly). I also could not find any documentation
in the help about this setting or the checkbox.
Any help on straighten me out on the purpose of this checkbox or why I am
still getting the warning would be greatly appreciated!
Platform: Eclipse 3.0
JDK: Sun, 1.4.2_02-b03
|
|
|
Re: Compiler Setting: Unnecessary Exception Declaration [message #269433 is a reply to message #269310] |
Tue, 31 August 2004 08:21 |
Eclipse User |
|
|
|
Originally posted by: daniel.megert.gmx.net
Jay Rutten wrote:
>Not sure if this is the correct newsgroup, so please correct me if it is
>not.
>
>
The correct one is eclipse.tools.jdt.
>Given the following classes:
>
>public class A {
> public void doSomething() throws IOException {
> // nothing to do here
> }
>}
>
>public class B extends A {
> public void doSomething() throws IOException {
> throw new IOException("I'm not doing anything!");
> }
>}
>
>I enabled the compiler setting (Java | Compiler | Unused Code |
>Unnecessary declaration of thrown checked exceptions) to be a warning. I
>then get that A.doSomething() unnecessarily throws an IOException, as
>expected. I then checked the box under the above compiler option, "Check
>overriding and implementing methods". I expected the above warning to go
>away, but it didn't.
>
>
It's the other way around: the checkbox affects B not A.
Dani
>I checked the archives and bug database about this, but I can only find
>where the checkbox was added since having the functionality to check
>overridding classes as the default could be costly (if I understand the
>checkbox functionality correctly). I also could not find any documentation
>in the help about this setting or the checkbox.
>
>Any help on straighten me out on the purpose of this checkbox or why I am
>still getting the warning would be greatly appreciated!
>
>Platform: Eclipse 3.0
>JDK: Sun, 1.4.2_02-b03
>
>
>
|
|
|
Re: Compiler Setting: Unnecessary Exception Declaration [message #269587 is a reply to message #269433] |
Tue, 31 August 2004 18:32 |
Eclipse User |
|
|
|
Originally posted by: jay.kurant.com
Daniel Megert wrote:
> Jay Rutten wrote:
> >Given the following classes:
> >
> >public class A {
> > public void doSomething() throws IOException {
> > // nothing to do here
> > }
> >}
> >
> >public class B extends A {
> > public void doSomething() throws IOException {
> > throw new IOException("I'm not doing anything!");
> > }
> >}
> >
> >I enabled the compiler setting (Java | Compiler | Unused Code |
> >Unnecessary declaration of thrown checked exceptions) to be a warning. I
> >then get that A.doSomething() unnecessarily throws an IOException, as
> >expected. I then checked the box under the above compiler option, "Check
> >overriding and implementing methods". I expected the above warning to go
> >away, but it didn't.
> >
> >
> It's the other way around: the checkbox affects B not A.
Ok, so if B.doSomething() above did nothing and I uncheck the box, I only
get the warning for A.doSomething(). If I check the box, I get both
warnings. But wouldn't B get checked with the the original setting since
the concept would be the same if checking A or B? Why is B immune from the
check since it is simply overriding the method? It doesn't call the parent
nor does it throw an exception!
So to linger on this topic, I am just trying to understand. Also, there
seems to be no way to get rid of the warning for class A (due to having to
check all derived classes), correct?
Thanks for your help!
|
|
|
Re: Compiler Setting: Unnecessary Exception Declaration [message #270016 is a reply to message #269587] |
Fri, 03 September 2004 13:43 |
Eclipse User |
|
|
|
Originally posted by: daniel.megert.gmx.net
Jay Rutten wrote:
>Daniel Megert wrote:
>
>
>
>>Jay Rutten wrote:
>>
>>
>
>
>
>>>Given the following classes:
>>>
>>>public class A {
>>> public void doSomething() throws IOException {
>>> // nothing to do here
>>> }
>>>}
>>>
>>>public class B extends A {
>>> public void doSomething() throws IOException {
>>> throw new IOException("I'm not doing anything!");
>>> }
>>>}
>>>
>>>I enabled the compiler setting (Java | Compiler | Unused Code |
>>>Unnecessary declaration of thrown checked exceptions) to be a warning. I
>>>then get that A.doSomething() unnecessarily throws an IOException, as
>>>expected. I then checked the box under the above compiler option, "Check
>>>overriding and implementing methods". I expected the above warning to go
>>>away, but it didn't.
>>>
>>>
>>>
>>>
>>It's the other way around: the checkbox affects B not A.
>>
>>
>
>Ok, so if B.doSomething() above did nothing and I uncheck the box, I only
>get the warning for A.doSomething(). If I check the box, I get both
>warnings. But wouldn't B get checked with the the original setting since
>the concept would be the same if checking A or B? Why is B immune from the
>check since it is simply overriding the method? It doesn't call the parent
>nor does it throw an exception!
>
>So to linger on this topic, I am just trying to understand. Also, there
>seems to be no way to get rid of the warning for class A (due to having to
>check all derived classes), correct?
>
>
It's not about checking derived classes but yes, you can't get rid of
that warning. That's the reason why we set this setting to 'ignore'. I
just filed a feature request to improve this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=73244
Dani
>Thanks for your help!
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.04299 seconds