Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Compiler Setting: Unnecessary Exception Declaration
Compiler Setting: Unnecessary Exception Declaration [message #269310] Mon, 30 August 2004 19:31 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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!
>
>
>
Previous Topic:Lost my syntax highlighting
Next Topic:[3.0.1] Was there any change on Ant?
Goto Forum:
  


Current Time: Thu Apr 25 21:20:35 GMT 2024

Powered by FUDForum. Page generated in 0.02965 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top