aspose file tools*
The moose likes Beginning Java and the fly likes Exception parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception parameter" Watch "Exception parameter" New topic
Author

Exception parameter

Nain Hwu
Ranch Hand

Joined: Sep 16, 2001
Posts: 139
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?
greg philpott
Ranch Hand

Joined: Nov 10, 2000
Posts: 73
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

Joined: Sep 16, 2001
Posts: 139
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.
Joe Gilvary
Ranch Hand

Joined: May 11, 2001
Posts: 152
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

Joined: Sep 16, 2001
Posts: 139
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception parameter