This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I know Eclipse and IRAD display alot of warning. Acutally, ALOT of warnings in my code. I can't catch them programatically.
Perhaps I should take a better look at my code though. Maybe the tool is telling me something.
I don't know your tool or development environment, but I highly doubth there's a mechanism for handling warnings at compile or runtime, although I do enjoy being proven wrong (it happens fairly often).
If the warnings are produced using some logging tool (for example log4j), you might be able to register your own logger and somehow analyze the warnings.
But warnings aren't a standard mechanism in Java, so we need to know how those warnings are produced to give you more useful hints.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Also, however this third-party tool works, I'm pretty sure it won't be like catching an exception. Throwing an exception implies that the application is not going to continue processing whatever it's supposed to process; instead, execution will resume at the appropriate catch block (if there is one). However the term "warning" indicates that, although there may be a problem of some sort, the application will not stop processing, but will instead keep going. So throwing an exception would be an inappropriate response for anything which is described as a "warning". [ January 01, 2007: Message edited by: Jim Yingst ]
"I'm not back." - Bill Harding, Twister
Joined: Nov 25, 2003
Thanks for your inputs. I am trying to implement JBoss cache in my project. Warning is thrown by class file from JBoss, when it is unable to find a particular node. Though I was catching the exception, when there is some problem in deleting the node by JBOSS. it is not reaching the catch block, it just throws a warning and continues. I need some help on it.
Author and all-around good cowpoke
Joined: Mar 22, 2000
it just throws a warning and continues.
Seems to me that no "warning" object is "thrown" - a warning message is written.
Therefore the question is: WHERE is the message written and can you intercept and parse it? What do the JBoss cache docs have to say?
Bill [ January 03, 2007: Message edited by: William Brogden ]
Originally posted by Neeraj Vij: Though I was catching the exception, when there is some problem in deleting the node by JBOSS. it is not reaching the catch block, it just throws a warning and continues.
AFAIK, JBossCache uses log4j to log messages. Why would you want to rely on those warning messages? Instead there's a API in JBossCache named
It seems that the Original Poster is mis-using terms like "catch", which have a very specific meaning in Java.
However, for readers' interest, I thought I'd point out that other languages do have a programmatic mechanism for dealing with warnings. My boss was telling me about it, so it was probably in some flavours of Lisp. I believe that handling of warnings is optional and execution resumes from the same point after any handler has run. Sounds a Good Thing (TM). If anyone can tell me more, I'd be (somewhat) interested to know.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Originally posted by Peter Chase: It seems that the Original Poster is mis-using terms like "catch", which have a very specific meaning in Java.
Exactly. Not only that, the word Warning is also being misunderstood in this context. The Warning that the poster is refering to is just a level in log4j to log messages. Also relying on those messages (which can be turned off anytime using log4j configurations) for doing some business logic does not seem right. Just my thoughts.