• 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

Exception parameter

 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JLS has a statement in �14.19:

Exception parameters cannot be referred to using
qualified names (�6.6), only by simple names.


What does it mean? Can someone show me a segment of code that
will violate this statement?
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A qualified name is, according to the JLS:


[a name] consisting of a sequence of identifiers separated by "." tokens


for example "this.is.my.name" is qualified, but "greg" is simple!!!
try to compile this and you will prove that the JLS is correct:
 
Nain Hwu
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Greg for the response.
I know what the qualified name is and your example explains
that. But, I still don't understand why will anyone try to use a qualified name as a parameter that way in the first place.
 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, someone might be tempted to use the Exception as a
message passing mechanism. Multiple catch blocks might
catch exceptions in the usual way, with a particular
catch block for catching a particular predefined
instance of an exception.

The second class doesn't compile under JDK 1.4, with
the compiler complaining precisely at the "." delimiter
in the qualified Exception parameter.
It's not something I'd want to do, even if it were
possible. But that's one way to visualize its use (or
abuse) if not for �14.19.
Thanks,
Joe
[This message has been edited by Cindy Glass (edited September 28, 2001).]
 
Nain Hwu
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Joe. Yes. Who would want to do that anyway?
Now, I wonder if JLS has a statement to prohibit qualified
name for a method parameter.
reply
    Bookmark Topic Watch Topic
  • New Topic