Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Welcome to JDT
Welcome to JDT [message #442] Thu, 17 April 2003 11:39 Go to next message
Eclipse UserFriend
Originally posted by: erich_gamma.oti.com

Welcome to the JDT newsgroup. This group is for technical discussions
about the Eclipse Java Development Tools (http://www.eclipse.org/jdt/).

For implementation discussions about JDT you can subscribe
to the following mailing lists:

jdt-dev@eclipse.org - general discussion of Java tooling
jdt-core-dev@eclipse.org - JDT Core
jdt-debug-dev@eclipse.org - JDT Debug
jdt-ui-dev@eclipse.org JDT UI

--The Eclipse JDT Team
Suppressing individual Xlint warnings [message #238228 is a reply to message #442] Wed, 22 November 2006 11:09 Go to previous messageGo to next message
Eclipse UserFriend
Hello all,

please excuse if this is not the right place to ask this question...

I have problems with the Xlint warning "Exception swallowed in catch
block [Xlint:swallowedExceptionInCatchBlock]"
Basically, we want this warning enabled, but at some places,
after reviewing the situation we want to suppress the warning.

Adding an Annotation @SuppressWarnings("swallowedExceptionInCatchBlock")
didn't help. Can someone please point out what token to use in this
annotation to get it working? Is there any place, where all suppressable
warnings and tokens to use are documented (searching the eclipse help
didn't turn up any new information -- yes, ctrl-1 will suggest a quick
fix, but guess what, for this problem it doesn't)

thanks,

--
Hermann Vosseler
Baader Wertpapierhandelsbank
IT / Developement
Re: Suppressing individual Xlint warnings [message #238242 is a reply to message #238228] Wed, 22 November 2006 11:13 Go to previous messageGo to next message
Eclipse UserFriend
Hermann Voßeler a écrit :
> please excuse if this is not the right place to ask this question...
> Adding an Annotation @SuppressWarnings("swallowedExceptionInCatchBlock")
> didn't help. Can someone please point out what token to use in this
> annotation to get it working? Is there any place, where all suppressable
> warnings and tokens to use are documented (searching the eclipse help
> didn't turn up any new information -- yes, ctrl-1 will suggest a quick
> fix, but guess what, for this problem it doesn't)
Xlint is a javac option. Eclipse compiler doesn't support this name.
What compiler are you using? I have never seen this warning option.
--
Olivier
Re: Suppressing individual Xlint warnings [message #238256 is a reply to message #238242] Wed, 22 November 2006 13:06 Go to previous messageGo to next message
Eclipse UserFriend
> Hermann Voßeler a écrit :
> > Adding an Annotation @SuppressWarnings("swallowedExceptionInCatchBlock")
> > didn't help.

> Am Mittwoch, den 22.11.2006, 11:13 -0500 schrieb Olivier Thomann:
> Xlint is a javac option. Eclipse compiler doesn't support this name.
> What compiler are you using? I have never seen this warning option.

We are using the Eclipse compiler (3.2). In the compiler prefereences,
you can configure a lot of warnings and errors. Of course, we can
disable the warning globally there (which is the default). But
actually we want this warning, as it hints at bad style.
Not in all cases, of course, and this is the problem...

Hermann
Re: Suppressing individual Xlint warnings [message #238262 is a reply to message #238256] Wed, 22 November 2006 13:53 Go to previous messageGo to next message
Eclipse UserFriend
Hermann Voßeler a écrit :
> We are using the Eclipse compiler (3.2). In the compiler prefereences,
> you can configure a lot of warnings and errors. Of course, we can
> disable the warning globally there (which is the default). But
> actually we want this warning, as it hints at bad style.
> Not in all cases, of course, and this is the problem...
Open a feature request against JDT/Core to get it added in the list of
warnings that can be removed using SuppressWarnings.

In this case why don't you simply fix it?
--
Olivier
Re: Suppressing individual Xlint warnings [message #238271 is a reply to message #238262] Wed, 22 November 2006 14:39 Go to previous messageGo to next message
Eclipse UserFriend
Am Mittwoch, den 22.11.2006, 13:53 -0500 schrieb Olivier Thomann:
> Open a feature request against JDT/Core to get it added in the list of
> warnings that can be removed using SuppressWarnings.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=165512

Thanks for the infos.
Hermann


>
> In this case why don't you simply fix it?
Do you mean the code that produces the warning?
Typical example you normally won't fix:

try{
Thread.sleep(....);
} catch (InterruptedException ie) {}

if ( ..check some condition anyway...)
Re: Suppressing individual Xlint warnings [message #238277 is a reply to message #238271] Wed, 22 November 2006 15:08 Go to previous messageGo to next message
Eclipse UserFriend
Hermann Voßeler wrote:
> Typical example you normally won't fix:
> try{
> Thread.sleep(....);
> } catch (InterruptedException ie) {}

Well, if you want to have robust coding, you should probably fix
this case of throwing away significant information. More at:
http://www-128.ibm.com/developerworks/java/library/j-jtp0523 6.html
Re: Suppressing individual Xlint warnings [message #238282 is a reply to message #238277] Wed, 22 November 2006 16:13 Go to previous messageGo to next message
Eclipse UserFriend
Am Mittwoch, den 22.11.2006, 21:08 +0100 schrieb Johnnie Hougaard
Nielsen:
> > Thread.sleep(....);
> > } catch (InterruptedException ie) {}
>
> Well, if you want to have robust coding, you should probably fix
> this case of throwing away significant information. More at:
> http://www-128.ibm.com/developerworks/java/library/j-jtp0523 6.html

Thanks for pointing this out, indeed, there are a lot of progammers
"out there" who think they are especially brilliant and need
not bother...


But you didn't get my point: There /are/ cases where you just
swallow and it's OK. E.g if your thread is just about to exit
anyway or if you are just writing a small test or a single threaded
console app doing no long-lasting activities.

That's the whole point with warnings: there /may/ be a problem and
it needs your attention -- and it doesn't get your attention for sure
if your log is spamed by lots of false alarms and you don't have a legal
option to silence them!

Hermann
Re: Suppressing individual Xlint warnings [message #238292 is a reply to message #238282] Wed, 22 November 2006 17:57 Go to previous messageGo to next message
Eclipse UserFriend
Hermann Voßeler a écrit :
> But you didn't get my point: There /are/ cases where you just
> swallow and it's OK. E.g if your thread is just about to exit
> anyway or if you are just writing a small test or a single threaded
> console app doing no long-lasting activities.
I don't get it. We don't have warnings for this inside Eclipse. The only
warning we might have is the fact that empty block should be documented.
And this is a general rule. By adding a small comment like /*ignore*/,
you make sure that this case is under control.
--
Olivier
Re: Suppressing individual Xlint warnings [message #238298 is a reply to message #238282] Wed, 22 November 2006 18:11 Go to previous messageGo to next message
Eclipse UserFriend
Hermann Voßeler wrote:
> But you didn't get my point: There /are/ cases where you just
> swallow and it's OK. E.g if your thread is just about to exit
> anyway or if you are just writing a small test or a single threaded
> console app doing no long-lasting activities.

Thats why I started with "/if/ you want to have robust coding" ;-)

I can understand reasons for not writing robust coding - OTOH, the
temporary solutions often get to be rather permanent, and subjected
to copy/paste reuse. When a reasonable (and harmless) catch block has
just one line of coding - why disable the warning?

More generally, I agree that there can be a very few rare cases when
swallowing an exception can be OK - I've even done it myself :-D
Re: Suppressing individual Xlint warnings [message #238307 is a reply to message #238292] Wed, 22 November 2006 20:49 Go to previous messageGo to next message
Eclipse UserFriend
> Hermann Voßeler a écrit :
>> But you didn't get my point: There /are/ cases where you just
>> swallow and it's OK.

Olivier Thomann schrieb:
> I don't get it. We don't have warnings for this inside Eclipse.
> The only warning we might have is the fact that empty block should be documented.

just to make it clear: the warning in question is about exeption swallowed in
catch blocks, not about an empty block. You can't silence it with a comment.

But more generally, my request applies to all this Xlint warnings which can
be enabled via the Eclipse GUI. Btw, we all agree that we dont want to
"silence" the warnings, rather we want to see the warnings to fix some
possible problems.

And if -- for some good (or bad but at least definite) reason a warning
can be considered false alarm, then I prefere a whell defined Annotation
like @SuppressWarning or @SuppressAjWarning (for AspectJ). So let's
see what happenes with my enhancement request!

Cheers,
Hermann Vosseler
Re: Suppressing individual Xlint warnings [message #238312 is a reply to message #238307] Wed, 22 November 2006 21:11 Go to previous message
Eclipse UserFriend
Ichthyostega wrote:
> just to make it clear: the warning in question is about exeption swallowed in
> catch blocks, not about an empty block. You can't silence it with a comment.

Are you sure that the warning is from Eclipse? To me, it sounds like one of those
several code analysis tools which can be added as plugins, and which report
warnings in very much the same way as Eclipse itself. They tend to be visible
in the properties dialog, and varying other places.
Previous Topic:get keywords from ModifierFlag
Next Topic:Builders: Storing output resources from a builder for further processing.
Goto Forum:
  


Current Time: Thu May 08 14:48:15 EDT 2025

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

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

Back to the top