• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Variable exception target

 
Ranch Hand
Posts: 472
Objective C Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Why? Why Java restrics me using class literal instead of class variable? I want to have code working when jnlp package available and when not. Do not tell me about work around as catch Throwable and then figure if it's UnavailableServiceException. Any elegant solution of switchable using API?
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
It seems that you are trying to play with java language feature. When catch statement is used compiler should be informed about the type of the exception so that it can check whetehr the order of catch are correct and whether it is inherited form the proper class(e.g Excpetion,RuntimeException, Throwable) by allowing class literal it will have no clue of the class type an its heirachy.

I don'tnow any elegant soln to the problem. but you can catch throwable then use reflection to check whether the exception is of expected type.
...
cath(Throwable th)
{
if (th.isAssingable(use))
{
......................
}
}
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You're using the name of an Object, where a Type is expected.
That's equivalent for writing:

The compiler doesn't even look at your 'use', but claims "can't find symbol", because it is looking for that symbol only in the list of types.
[ May 23, 2005: Message edited by: Stefan Wagner ]
 
D Rog
Ranch Hand
Posts: 472
Objective C Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I understand you. However your illustration a bit lacking. Look in avaya sahu's sugestion.
Define your parameters as Objects and then figure out an actual class.
reply
    Bookmark Topic Watch Topic
  • New Topic