• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

toString() throws UndeclaredThrowableException

 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought it might be fun to pose as a question an issue that I just resolved, so you advanced Java people can demonstrate your knowledge!
We are all familiar with the toString() method, which is declared and defined in java.lang.Object.

Notice that it is declared not to throw any checked Exceptions.
In my program, I called toString() on an Object and got an UndeclaredThrowableException. This was a surprise, as all Objects ought to have a toString() and it is not allowed to throw any checked Exceptions.
What was going on?
(As I say, I've resolved this issue, but I thought people might be interested).
[ January 31, 2003: Message edited by: Peter Chase ]
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I just went through the Java Documentation and found something.

Taken from the Java Documentation:
As of release 1.4, this exception has been retrofitted to conform to the general purpose exception-chaining mechanism. The "undeclared checked exception that was thrown by the invocation handler" that may be provided at construction time and accessed via the getUndeclaredThrowable() method is now known as the cause, and may be accessed via the Throwable.getCause() method, as well as the aforementioned "legacy method."


As it is said here you might be using reflections to invoke the member toString();
-----------------------------
Vijay.
The Hand that gives, Gathers.
[ February 03, 2003: Message edited by: Vijayakumar Arya ]
[ February 03, 2003: Message edited by: Vijayakumar Arya ]
 
Tell me how it all turns out. Here is a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic